From 8160a1bfaf6046ae0eef692a7a5c0cc7cf004235 Mon Sep 17 00:00:00 2001 From: Raalzz Date: Tue, 31 Jan 2023 13:08:46 +0530 Subject: [PATCH 1/5] fix: includes util function to map defined values and upated Radio component --- docs/docs/components/radio.mdx | 4 ++-- packages/lib/src/components/Radio/Radio.tsx | 17 +++++++++-------- .../components/Radio/RadioGroup/RadioGroup.tsx | 9 ++------- .../src/components/Radio/radio.styles.css.ts | 1 + .../lib/src/components/Radio/radio.types.ts | 7 +++---- .../access-defined-values.ts | 11 +++++++++++ packages/lib/src/utils/index.ts | 2 ++ 7 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 packages/lib/src/utils/access-defined-values/access-defined-values.ts create mode 100644 packages/lib/src/utils/index.ts diff --git a/docs/docs/components/radio.mdx b/docs/docs/components/radio.mdx index b0b04cb..b7ca75b 100644 --- a/docs/docs/components/radio.mdx +++ b/docs/docs/components/radio.mdx @@ -144,8 +144,8 @@ const Demo = () => { | Key | type | Optional? | | :------------- | :-----------------------------: | --------: | -| value | `string;` | No | -| name | `string;` | No | +| value | `string;` | Yes | +| name | `string;` | Yes | | radioSize | `xs` `sm` `md` `lg` `xl` string | Yes | | isDisabled | `boolean` | Yes | | baseStyles | `baseStyles object` | Yes | diff --git a/packages/lib/src/components/Radio/Radio.tsx b/packages/lib/src/components/Radio/Radio.tsx index 8b15ed1..5c52f28 100644 --- a/packages/lib/src/components/Radio/Radio.tsx +++ b/packages/lib/src/components/Radio/Radio.tsx @@ -9,8 +9,8 @@ import { } from "./radio.styles.css"; import "./radio.global.styles.css"; import { assignInlineVars } from "@vanilla-extract/dynamic"; -import { eliminateUndefinedKeys } from "../../utils/object-utils"; import { SvgDot } from "../_internal/Icons/SvgDot"; +import { accessDefinedValues, eliminateUndefinedKeys } from "../../utils"; const Radio: ForwardRefRenderFunction = ( { @@ -19,20 +19,21 @@ const Radio: ForwardRefRenderFunction = ( value, name, checked, - radioSize = "xs", - isDisabled = false, + radioSize, baseStyles, disabledStyles, selectedStyles, + isDisabled = false, ...nativeProps }, ref ) => { const assignVariables = assignInlineVars( eliminateUndefinedKeys({ - [radioThemeVars.radioStyleSize]: radioSizes[radioSize] - ? radioSizes[radioSize] - : undefined, + [radioThemeVars.radioStyleSize]: accessDefinedValues( + radioSize, + radioSizes + ), [radioThemeVars.baseStyles.backgroundColor]: baseStyles?.backgroundColor, [radioThemeVars.baseStyles.borderColor]: baseStyles?.borderColor, [radioThemeVars.selectedStyles.backgroundColor]: @@ -51,8 +52,8 @@ const Radio: ForwardRefRenderFunction = ( style={{ ...assignVariables, ...(style || {}) }} > = ( />