From 86447b576490ee4cde0825418015652d8ed26794 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 24 Oct 2025 11:23:32 -0500 Subject: wip: desktop work --- packages/ui/src/components/accordion.css | 102 +++++++++++++++++++++++++++++ packages/ui/src/components/accordion.tsx | 92 ++++++++++++++++++++++++++ packages/ui/src/components/collapsible.tsx | 1 - packages/ui/src/components/icon.tsx | 1 + packages/ui/src/components/index.ts | 1 + 5 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 packages/ui/src/components/accordion.css create mode 100644 packages/ui/src/components/accordion.tsx (limited to 'packages/ui/src/components') diff --git a/packages/ui/src/components/accordion.css b/packages/ui/src/components/accordion.css new file mode 100644 index 000000000..c8dfdfab1 --- /dev/null +++ b/packages/ui/src/components/accordion.css @@ -0,0 +1,102 @@ +[data-component="accordion"] { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 0px; + align-self: stretch; + border-radius: 8px; + border: 1px solid var(--border-weak-base); + + [data-slot="accordion-item"] { + width: 100%; + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 0px; + align-self: stretch; + + [data-slot="accordion-header"] { + width: 100%; + display: flex; + align-items: center; + margin: 0; + padding: 0; + + [data-slot="accordion-trigger"] { + width: 100%; + display: flex; + height: 40px; + padding: 8px 12px; + justify-content: space-between; + align-items: center; + align-self: stretch; + cursor: default; + user-select: none; + + background-color: var(--surface-base); + border-bottom: 1px solid var(--border-weak-base); + color: var(--text-strong); + transition: background-color 0.15s ease; + + /* text-12-regular */ + font-family: var(--font-family-sans); + font-size: var(--font-size-small); + font-style: normal; + font-weight: var(--font-weight-regular); + line-height: var(--line-height-large); /* 166.667% */ + letter-spacing: var(--letter-spacing-normal); + + &:hover { + background-color: var(--surface-base); + } + + &:focus-visible { + outline: none; + } + + &[data-disabled] { + cursor: not-allowed; + } + } + } + + &:last-child { + [data-slot="accordion-trigger"] { + border-bottom: none; + } + } + + &[data-expanded] { + border-bottom: 1px solid var(--border-weak-base); + } + + [data-slot="accordion-content"] { + overflow: hidden; + width: 100%; + + /* animation: slideUp 250ms cubic-bezier(0.87, 0, 0.13, 1); */ + /**/ + /* &[data-expanded] { */ + /* animation: slideDown 250ms cubic-bezier(0.87, 0, 0.13, 1); */ + /* } */ + } + } +} + +@keyframes slideDown { + from { + height: 0; + } + to { + height: var(--kb-accordion-content-height); + } +} + +@keyframes slideUp { + from { + height: var(--kb-accordion-content-height); + } + to { + height: 0; + } +} diff --git a/packages/ui/src/components/accordion.tsx b/packages/ui/src/components/accordion.tsx new file mode 100644 index 000000000..535d38e3d --- /dev/null +++ b/packages/ui/src/components/accordion.tsx @@ -0,0 +1,92 @@ +import { Accordion as Kobalte } from "@kobalte/core/accordion" +import { splitProps } from "solid-js" +import type { ComponentProps, ParentProps } from "solid-js" + +export interface AccordionProps extends ComponentProps {} +export interface AccordionItemProps extends ComponentProps {} +export interface AccordionHeaderProps extends ComponentProps {} +export interface AccordionTriggerProps extends ComponentProps {} +export interface AccordionContentProps extends ComponentProps {} + +function AccordionRoot(props: AccordionProps) { + const [split, rest] = splitProps(props, ["class", "classList"]) + return ( + + ) +} + +function AccordionItem(props: AccordionItemProps) { + const [split, rest] = splitProps(props, ["class", "classList"]) + return ( + + ) +} + +function AccordionHeader(props: ParentProps) { + const [split, rest] = splitProps(props, ["class", "classList", "children"]) + return ( + + {split.children} + + ) +} + +function AccordionTrigger(props: ParentProps) { + const [split, rest] = splitProps(props, ["class", "classList", "children"]) + return ( + + {split.children} + + ) +} + +function AccordionContent(props: ParentProps) { + const [split, rest] = splitProps(props, ["class", "classList", "children"]) + return ( + + {split.children} + + ) +} + +export const Accordion = Object.assign(AccordionRoot, { + Item: AccordionItem, + Header: AccordionHeader, + Trigger: AccordionTrigger, + Content: AccordionContent, +}) diff --git a/packages/ui/src/components/collapsible.tsx b/packages/ui/src/components/collapsible.tsx index 011d103c1..f926192e8 100644 --- a/packages/ui/src/components/collapsible.tsx +++ b/packages/ui/src/components/collapsible.tsx @@ -8,7 +8,6 @@ export interface CollapsibleProps extends ParentProps { function CollapsibleRoot(props: CollapsibleProps) { const [local, others] = splitProps(props, ["class", "classList"]) - return ( `, folder: ``, "pencil-line": ``, + "chevron-grabber-vertical": ``, } export interface IconProps extends ComponentProps<"svg"> { diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts index 3691363cd..31672001b 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/ui/src/components/index.ts @@ -1,3 +1,4 @@ +export * from "./accordion" export * from "./button" export * from "./collapsible" export * from "./dialog" -- cgit v1.2.3