Skip to content

Commit

Permalink
fix: cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Nov 12, 2023
1 parent d442e82 commit b3291a2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/kit/src/components/CheckBox/CheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends PolymorphicProps<"label">>(props: T) {
export function createFieldLabelProps<TValidComponent extends ValidComponent = "label">(
props: PolymorphicProps<TValidComponent>,
) {
return mergeProps(props, {
get class() {
return mergeClasses(props.class, label);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends PolymorphicProps<"div">>(props: T) {
return mergeProps(props, {
export function createFieldMessageProps<TComponent extends ValidComponent = "div">(
props: PolymorphicProps<TComponent>,
) {
const [local] = splitProps(props, []);
return mergeProps(local, {
get class() {
return mergeClasses(props.class, description);
},
Expand Down
5 changes: 1 addition & 4 deletions packages/kit/src/components/Link/Link.css.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/components/RadioList/RadioList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <RadioGroup.Label {...fieldLabelProps} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function Select<T>(props: ParentProps<SelectProps<T>>) {
["options", "value"],
);
const baseFieldProps = createBaseFieldProps(props);
const labelProps = createFieldLabelProps({});
const labelProps = createFieldLabelProps<"span">({});
const descriptionProps = createFieldMessageProps({});
const errorProps = createFieldErrorMessageProps(props);

Expand Down

0 comments on commit b3291a2

Please sign in to comment.