From b3291a22cafacb902f372fadffca86b67d5cd660 Mon Sep 17 00:00:00 2001 From: Riccardo Perra Date: Sun, 12 Nov 2023 15:23:46 +0100 Subject: [PATCH] fix: cleanup code --- packages/kit/src/components/CheckBox/CheckBox.tsx | 2 +- .../components/Field/FieldLabel/createFieldLabelProps.ts | 6 ++++-- .../Field/FieldMessage/createFieldMessageProps.ts | 9 ++++++--- packages/kit/src/components/Link/Link.css.ts | 5 +---- packages/kit/src/components/RadioList/RadioList.tsx | 2 +- packages/kit/src/components/Select/Select.tsx | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/kit/src/components/CheckBox/CheckBox.tsx b/packages/kit/src/components/CheckBox/CheckBox.tsx index 9ab56f1..3625844 100644 --- a/packages/kit/src/components/CheckBox/CheckBox.tsx +++ b/packages/kit/src/components/CheckBox/CheckBox.tsx @@ -34,7 +34,7 @@ export function Checkbox(props: CheckBoxProps) { ]); const errorMessageProps = createFieldErrorMessageProps(props); - const fieldLabelProps = createFieldMessageProps(props); + const fieldLabelProps = createFieldMessageProps({}); const inputClasses = () => mergeClasses(styles.input, local.slotClasses?.input); diff --git a/packages/kit/src/components/Field/FieldLabel/createFieldLabelProps.ts b/packages/kit/src/components/Field/FieldLabel/createFieldLabelProps.ts index d92f098..2c4bcb9 100644 --- a/packages/kit/src/components/Field/FieldLabel/createFieldLabelProps.ts +++ b/packages/kit/src/components/Field/FieldLabel/createFieldLabelProps.ts @@ -1,9 +1,11 @@ import { label } from "./FieldLabel.css"; -import { mergeProps } from "solid-js"; +import { mergeProps, ValidComponent } from "solid-js"; import { mergeClasses } from "../../../utils/css"; import { PolymorphicProps } from "@kobalte/core"; -export function createFieldLabelProps>(props: T) { +export function createFieldLabelProps( + props: PolymorphicProps, +) { return mergeProps(props, { get class() { return mergeClasses(props.class, label); diff --git a/packages/kit/src/components/Field/FieldMessage/createFieldMessageProps.ts b/packages/kit/src/components/Field/FieldMessage/createFieldMessageProps.ts index 1601a46..345e2c4 100644 --- a/packages/kit/src/components/Field/FieldMessage/createFieldMessageProps.ts +++ b/packages/kit/src/components/Field/FieldMessage/createFieldMessageProps.ts @@ -1,10 +1,13 @@ import { description } from "./FieldMessage.css"; -import { mergeProps } from "solid-js"; +import { mergeProps, splitProps, ValidComponent } from "solid-js"; import { mergeClasses } from "../../../utils/css"; import { PolymorphicProps } from "@kobalte/core"; -export function createFieldMessageProps>(props: T) { - return mergeProps(props, { +export function createFieldMessageProps( + props: PolymorphicProps, +) { + const [local] = splitProps(props, []); + return mergeProps(local, { get class() { return mergeClasses(props.class, description); }, diff --git a/packages/kit/src/components/Link/Link.css.ts b/packages/kit/src/components/Link/Link.css.ts index 6b621d3..2f0dd9b 100644 --- a/packages/kit/src/components/Link/Link.css.ts +++ b/packages/kit/src/components/Link/Link.css.ts @@ -1,10 +1,7 @@ import { createTheme } from "@vanilla-extract/css"; import { recipe, RecipeVariants } from "@vanilla-extract/recipes"; -import { themeTokens } from "../../foundation/themes.css"; -const [linkTheme, linkVars] = createTheme({ - blockBorderRadius: themeTokens.radii.sm, -}); +const [linkTheme] = createTheme({}); export const link = recipe({ base: [ diff --git a/packages/kit/src/components/RadioList/RadioList.tsx b/packages/kit/src/components/RadioList/RadioList.tsx index 717ddb6..ae1dc7a 100644 --- a/packages/kit/src/components/RadioList/RadioList.tsx +++ b/packages/kit/src/components/RadioList/RadioList.tsx @@ -16,7 +16,7 @@ export type RadioListProps = RadioGroup.RadioGroupRootProps & FieldWithErrorMessageSupport & { label?: JSXElement; description?: string }; function RadioGroupLabel(props: RadioGroup.RadioGroupLabelProps) { - const fieldLabelProps = createFieldLabelProps(props); + const fieldLabelProps = createFieldLabelProps<"span">(props); return ; } diff --git a/packages/kit/src/components/Select/Select.tsx b/packages/kit/src/components/Select/Select.tsx index 1adbd73..ea4ad28 100644 --- a/packages/kit/src/components/Select/Select.tsx +++ b/packages/kit/src/components/Select/Select.tsx @@ -62,7 +62,7 @@ export function Select(props: ParentProps>) { ["options", "value"], ); const baseFieldProps = createBaseFieldProps(props); - const labelProps = createFieldLabelProps({}); + const labelProps = createFieldLabelProps<"span">({}); const descriptionProps = createFieldMessageProps({}); const errorProps = createFieldErrorMessageProps(props);