From a0092b691eaaf149de1fab0acc0f59f3429382d1 Mon Sep 17 00:00:00 2001 From: bhenique Date: Sun, 9 Jun 2024 23:23:36 +0200 Subject: [PATCH] fix: change size to sizing into Select component --- apps/web/src/examples.ts | 2 +- .../[theme-rtl]/select/04-sizes/index@examples.tsx | 6 +++--- packages/lib/src/components/Select/Select.tsx | 8 ++++---- .../components/Select/composables/use-select-classes.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/web/src/examples.ts b/apps/web/src/examples.ts index 0762365f..ac7a7aeb 100644 --- a/apps/web/src/examples.ts +++ b/apps/web/src/examples.ts @@ -887,7 +887,7 @@ export const examples: Record = { description: 'Get started with the small, default, and large sizes for the select component from the example below.', url: '/examples/[theme-rtl]/select/04-sizes', content: - 'import { component$, useSignal } from \'@builder.io/qwik\'\nimport { Select } from \'flowbite-qwik\'\n\nexport default component$(() => {\n const selected = useSignal(\'\')\n const countries = [\n { value: \'us\', name: \'United States\' },\n { value: \'ca\', name: \'Canada\' },\n { value: \'fr\', name: \'France\' },\n ]\n\n return (\n <>\n
\n \n \n \n
\n \n )\n})', height: '200', }, { diff --git a/apps/web/src/routes/examples/[theme-rtl]/select/04-sizes/index@examples.tsx b/apps/web/src/routes/examples/[theme-rtl]/select/04-sizes/index@examples.tsx index 5caefa4d..3f0a6275 100644 --- a/apps/web/src/routes/examples/[theme-rtl]/select/04-sizes/index@examples.tsx +++ b/apps/web/src/routes/examples/[theme-rtl]/select/04-sizes/index@examples.tsx @@ -19,9 +19,9 @@ export default component$(() => { return ( <>
- - +
) diff --git a/packages/lib/src/components/Select/Select.tsx b/packages/lib/src/components/Select/Select.tsx index 7d5757c2..d59ca307 100644 --- a/packages/lib/src/components/Select/Select.tsx +++ b/packages/lib/src/components/Select/Select.tsx @@ -11,20 +11,20 @@ type SelectProps = PropsOf<'select'> & { placeholder?: string disabled?: boolean underline?: boolean - size?: InputSize + sizing?: InputSize validationStatus?: ValidationStatus validationMessage?: JSXOutput helper?: JSXOutput } -export const Select = component$(({ label, options, class: classNames, ...props }) => { +export const Select = component$(({ label, options, sizing = 'md', ...props }) => { const validationStatus = useComputed$(() => props.validationStatus) - const size = useComputed$(() => props.size ?? ('md' as InputSize)) + const sizingComputed = useComputed$(() => sizing as InputSize) const disabled = useComputed$(() => props.disabled ?? false) const underline = useComputed$(() => props.underline ?? false) const { labelClasses, selectClasses, validationWrapperClasses } = useSelectClasses({ - size, + sizing: sizingComputed, disabled, underline, validationStatus, diff --git a/packages/lib/src/components/Select/composables/use-select-classes.ts b/packages/lib/src/components/Select/composables/use-select-classes.ts index d70ccf1d..2cb7c01d 100644 --- a/packages/lib/src/components/Select/composables/use-select-classes.ts +++ b/packages/lib/src/components/Select/composables/use-select-classes.ts @@ -23,7 +23,7 @@ const errorInputClasses = 'bg-red-50 border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 focus:border-red-500 dark:text-red-500 dark:placeholder-red-500 dark:border-red-500' export type UseSelectClassesProps = { - size: Signal + sizing: Signal disabled: Signal underline: Signal validationStatus: Signal @@ -45,7 +45,7 @@ export function useSelectClasses(props: UseSelectClassesProps): { return twMerge( defaultSelectClasses, classByStatus, - selectSizeClasses[props.size.value], + selectSizeClasses[props.sizing.value], props.disabled.value && disabledSelectClasses, props.underline.value ? underlineSelectClasses : 'border border-gray-300 rounded-lg', props.underline.value && underlineByStatus,