diff --git a/apps/docs/src/config/docs.ts b/apps/docs/src/config/docs.ts index c5e427e8..a6ede2b1 100644 --- a/apps/docs/src/config/docs.ts +++ b/apps/docs/src/config/docs.ts @@ -84,6 +84,10 @@ export const docsConfig: Config = { title: "Checkbox", href: "/docs/components/checkbox" }, + { + title: "Collapsible", + href: "/docs/components/collapsible" + }, { title: "Dropdown Menu", href: "/docs/components/dropdown-menu" diff --git a/apps/docs/src/registry/__index__.tsx b/apps/docs/src/registry/__index__.tsx index ba1a190a..bddec368 100644 --- a/apps/docs/src/registry/__index__.tsx +++ b/apps/docs/src/registry/__index__.tsx @@ -212,6 +212,20 @@ export const Index: Record = { categories: undefined, meta: undefined }, + "collapsible": { + name: "collapsible", + description: "", + type: "registry:ui", + registryDependencies: undefined, + component: lazy(() => import("~/registry/ui/collapsible.tsx")), + files: [{ + path: "registry/ui/collapsible.tsx", + type: "registry:ui", + target: "" + }], + categories: undefined, + meta: undefined, + }, "dropdown-menu": { name: "dropdown-menu", description: "", @@ -1028,6 +1042,20 @@ export const Index: Record = { categories: undefined, meta: undefined }, + "collapsible-demo": { + name: "collapsible-demo", + description: "", + type: "registry:example", + registryDependencies: ["collapsible","button"], + component: lazy(() => import("~/registry/examples/collapsible-demo.tsx")), + files: [{ + path: "registry/examples/collapsible-demo.tsx", + type: "registry:example", + target: "" + }], + categories: undefined, + meta: undefined, + }, "dropdown-menu-demo": { name: "dropdown-menu-demo", description: "", diff --git a/apps/docs/src/registry/examples/_registry.ts b/apps/docs/src/registry/examples/_registry.ts index 6433cc34..fd90119d 100644 --- a/apps/docs/src/registry/examples/_registry.ts +++ b/apps/docs/src/registry/examples/_registry.ts @@ -464,6 +464,17 @@ export const examples: Registry["items"] = [ } ] }, + { + name: "collapsible-demo", + type: "registry:example", + registryDependencies: ["collapsible", "button"], + files: [ + { + path: "examples/collapsible-demo.tsx", + type: "registry:example" + } + ] + }, { name: "dropdown-menu-demo", type: "registry:example", diff --git a/apps/docs/src/registry/examples/collapsible-demo.tsx b/apps/docs/src/registry/examples/collapsible-demo.tsx new file mode 100644 index 00000000..7aca04fa --- /dev/null +++ b/apps/docs/src/registry/examples/collapsible-demo.tsx @@ -0,0 +1,40 @@ +import { createSignal } from "solid-js" +import { ChevronsUpDown } from "lucide-solid" + +import { Button } from "~/registry/ui/button" +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger +} from "~/registry/ui/collapsible" + +export default function CollapsibleDemo() { + const [isOpen, setIsOpen] = createSignal(false) + + return ( + +
+

@peduarte starred 3 repositories

+ + + Toggle + +
+
+ @radix-ui/primitives +
+ +
+ @radix-ui/colors +
+
+ @stitches/react +
+
+
+ ) +} diff --git a/apps/docs/src/registry/styles/style-lyra.css b/apps/docs/src/registry/styles/style-lyra.css index 47ca492d..37760afb 100644 --- a/apps/docs/src/registry/styles/style-lyra.css +++ b/apps/docs/src/registry/styles/style-lyra.css @@ -254,6 +254,11 @@ @apply rounded-none border-t p-4 group-data-[size=sm]/card:p-3; } + /* MARK: Collapsible */ + .cn-collapsible-content { + @apply data-expanded:animate-accordion-down data-closed:animate-accordion-up overflow-hidden; + } + /* MARK: Chart */ .cn-chart-tooltip { @apply border-border/50 bg-background gap-1.5 rounded-none border px-2.5 py-1.5 text-xs shadow-xl; diff --git a/apps/docs/src/registry/styles/style-maia.css b/apps/docs/src/registry/styles/style-maia.css index 63ff199a..8f399321 100644 --- a/apps/docs/src/registry/styles/style-maia.css +++ b/apps/docs/src/registry/styles/style-maia.css @@ -275,6 +275,11 @@ @apply rounded-full; } + /* MARK: Collapsible */ + .cn-collapsible-content { + @apply data-expanded:animate-accordion-down data-closed:animate-accordion-up overflow-hidden; + } + /* MARK: Chart */ .cn-chart-tooltip { @apply border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl; diff --git a/apps/docs/src/registry/styles/style-mira.css b/apps/docs/src/registry/styles/style-mira.css index 41b0418d..00d8b6ec 100644 --- a/apps/docs/src/registry/styles/style-mira.css +++ b/apps/docs/src/registry/styles/style-mira.css @@ -275,6 +275,11 @@ @apply rounded-full; } + /* MARK: Collapsible */ + .cn-collapsible-content { + @apply data-expanded:animate-accordion-down data-closed:animate-accordion-up overflow-hidden; + } + /* MARK: Chart */ .cn-chart-tooltip { @apply border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl; diff --git a/apps/docs/src/registry/styles/style-nova.css b/apps/docs/src/registry/styles/style-nova.css index 5aa1d70b..d983b501 100644 --- a/apps/docs/src/registry/styles/style-nova.css +++ b/apps/docs/src/registry/styles/style-nova.css @@ -275,6 +275,11 @@ @apply rounded-full; } + /* MARK: Collapsible */ + .cn-collapsible-content { + @apply data-expanded:animate-accordion-down data-closed:animate-accordion-up overflow-hidden; + } + /* MARK: Chart */ .cn-chart-tooltip { @apply border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl; diff --git a/apps/docs/src/registry/styles/style-vega.css b/apps/docs/src/registry/styles/style-vega.css index 76d971bf..852e9fbe 100644 --- a/apps/docs/src/registry/styles/style-vega.css +++ b/apps/docs/src/registry/styles/style-vega.css @@ -271,6 +271,11 @@ @apply rounded-full; } + /* MARK: Collapsible */ + .cn-collapsible-content { + @apply data-expanded:animate-accordion-down data-closed:animate-accordion-up overflow-hidden; + } + /* MARK: Chart */ .cn-chart-tooltip { @apply border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl; diff --git a/apps/docs/src/registry/ui/_registry.ts b/apps/docs/src/registry/ui/_registry.ts index ae680ef3..b93c3b6f 100644 --- a/apps/docs/src/registry/ui/_registry.ts +++ b/apps/docs/src/registry/ui/_registry.ts @@ -134,6 +134,17 @@ export const ui: Registry["items"] = [ } ] }, + { + name: "collapsible", + type: "registry:ui", + dependencies: ["@kobalte/core"], + files: [ + { + path: "ui/collapsible.tsx", + type: "registry:ui" + } + ] + }, { name: "dropdown-menu", type: "registry:ui", diff --git a/apps/docs/src/registry/ui/collapsible.tsx b/apps/docs/src/registry/ui/collapsible.tsx new file mode 100644 index 00000000..dbf923e9 --- /dev/null +++ b/apps/docs/src/registry/ui/collapsible.tsx @@ -0,0 +1,63 @@ +import type { ValidComponent } from "solid-js" +import { splitProps } from "solid-js" + +import * as CollapsiblePrimitive from "@kobalte/core/collapsible" +import type { PolymorphicProps } from "@kobalte/core/polymorphic" + +import { cn } from "~/lib/utils" + +type CollapsibleProps = + CollapsiblePrimitive.CollapsibleRootProps & { + class?: string | undefined + } + +const Collapsible = ( + props: PolymorphicProps> +) => { + const [local, others] = splitProps(props as CollapsibleProps, ["class"]) + return ( + + ) +} + +type CollapsibleTriggerProps = + CollapsiblePrimitive.CollapsibleTriggerProps & { + class?: string | undefined + } + +const CollapsibleTrigger = ( + props: PolymorphicProps> +) => { + const [local, others] = splitProps(props as CollapsibleTriggerProps, ["class"]) + return ( + + ) +} + +type CollapsibleContentProps = + CollapsiblePrimitive.CollapsibleContentProps & { + class?: string | undefined + } + +const CollapsibleContent = ( + props: PolymorphicProps> +) => { + const [local, others] = splitProps(props as CollapsibleContentProps, ["class"]) + return ( + + ) +} + +export { Collapsible, CollapsibleTrigger, CollapsibleContent } diff --git a/apps/docs/src/routes/docs/components/collapsible.mdx b/apps/docs/src/routes/docs/components/collapsible.mdx new file mode 100644 index 00000000..5a2fa0dd --- /dev/null +++ b/apps/docs/src/routes/docs/components/collapsible.mdx @@ -0,0 +1,64 @@ +--- +title: Collapsible +description: An interactive component which expands/collapses a panel. +links: + doc: https://kobalte.dev/docs/core/components/collapsible + api: https://kobalte.dev/docs/core/components/collapsible#api-reference +--- + +::::tab-group[preview] +:::tab[Preview] + + + +::: +:::tab[Code] + +```file="~/registry/examples/collapsible-demo" frame=none showLineNumbers + +``` + +::: +:::: + +## Installation + +### CLI + +```package-exec +solidui-cli@latest add collapsible +``` + +### Manual + +Install the following dependencies: + +```package-install +@kobalte/core +``` + +Copy and paste the following code into your project. + +```file="~/registry/ui/collapsible.tsx" showLineNumbers + +``` + +## Usage + +```tsx +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger +} from "~/components/ui/collapsible"; +``` + +```tsx + + Can I use this in my project? + + Yes. Free to use for personal and commercial projects. No attribution + required. + + +```