import { type ComponentProps, type ValidComponent, createMemo, mergeProps, splitProps, Show, } from "solid-js"; import { Dynamic } from "solid-js/web"; import { type Prettify, } from "@/components/types/Prettify"; import { type WithExtendedComponentProps } from "@/components/types/ExtendedComponentProps"; import { type VariantProps, } from "tailwind-variants"; import { useThemeContext, } from "@/components/ThemeProvider/"; import cn from "@/components/utils/cn"; import dividerDefaultStyles from "./style"; type DividerVariants = VariantProps; type DividerSlotProps = Prettify<{ divider?: Prettify & WithExtendedComponentProps>; }>; export type DividerProps = { align?: DividerVariants["align"]; as?: T; class?: string; orientation?: DividerVariants["orientation"]; slotProps?: DividerSlotProps; } & ComponentProps; const Divider = ( props: DividerProps, ) => { const merged = mergeProps({ align: "center" as const, orientation: "horizontal" as const, }, props); const [local, rest] = splitProps(merged, [ "align", "as", "class", "children", "orientation", "slotProps", ]); const themeContextValue = useThemeContext(); const hasChildren = createMemo(() => !!local.children); const classes = createMemo(() => { const state = { align: local.align, hasChildren: hasChildren(), orientation: local.orientation, }; if (themeContextValue) { return themeContextValue.componentsTV.divider(state); } return dividerDefaultStyles(state); }); return ( {local.children} ); }; export default Divider;