summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-10-24 11:23:32 -0500
committerAdam <[email protected]>2025-10-24 12:16:33 -0500
commit86447b576490ee4cde0825418015652d8ed26794 (patch)
tree02f0a7780eb7c96d1fa7a801088743a29e265a9d /packages/ui/src
parentfe8f6d7a3eef34e932bd43d244460d417865de88 (diff)
downloadopencode-86447b576490ee4cde0825418015652d8ed26794.tar.gz
opencode-86447b576490ee4cde0825418015652d8ed26794.zip
wip: desktop work
Diffstat (limited to 'packages/ui/src')
-rw-r--r--packages/ui/src/components/accordion.css102
-rw-r--r--packages/ui/src/components/accordion.tsx92
-rw-r--r--packages/ui/src/components/collapsible.tsx1
-rw-r--r--packages/ui/src/components/icon.tsx1
-rw-r--r--packages/ui/src/components/index.ts1
-rw-r--r--packages/ui/src/demo.tsx36
-rw-r--r--packages/ui/src/styles/index.css2
7 files changed, 234 insertions, 1 deletions
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<typeof Kobalte> {}
+export interface AccordionItemProps extends ComponentProps<typeof Kobalte.Item> {}
+export interface AccordionHeaderProps extends ComponentProps<typeof Kobalte.Header> {}
+export interface AccordionTriggerProps extends ComponentProps<typeof Kobalte.Trigger> {}
+export interface AccordionContentProps extends ComponentProps<typeof Kobalte.Content> {}
+
+function AccordionRoot(props: AccordionProps) {
+ const [split, rest] = splitProps(props, ["class", "classList"])
+ return (
+ <Kobalte
+ {...rest}
+ data-component="accordion"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ />
+ )
+}
+
+function AccordionItem(props: AccordionItemProps) {
+ const [split, rest] = splitProps(props, ["class", "classList"])
+ return (
+ <Kobalte.Item
+ {...rest}
+ data-slot="accordion-item"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ />
+ )
+}
+
+function AccordionHeader(props: ParentProps<AccordionHeaderProps>) {
+ const [split, rest] = splitProps(props, ["class", "classList", "children"])
+ return (
+ <Kobalte.Header
+ {...rest}
+ data-slot="accordion-header"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ >
+ {split.children}
+ </Kobalte.Header>
+ )
+}
+
+function AccordionTrigger(props: ParentProps<AccordionTriggerProps>) {
+ const [split, rest] = splitProps(props, ["class", "classList", "children"])
+ return (
+ <Kobalte.Trigger
+ {...rest}
+ data-slot="accordion-trigger"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ >
+ {split.children}
+ </Kobalte.Trigger>
+ )
+}
+
+function AccordionContent(props: ParentProps<AccordionContentProps>) {
+ const [split, rest] = splitProps(props, ["class", "classList", "children"])
+ return (
+ <Kobalte.Content
+ {...rest}
+ data-slot="accordion-content"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ >
+ {split.children}
+ </Kobalte.Content>
+ )
+}
+
+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<CollapsibleRootProps> {
function CollapsibleRoot(props: CollapsibleProps) {
const [local, others] = splitProps(props, ["class", "classList"])
-
return (
<Kobalte
data-component="collapsible"
diff --git a/packages/ui/src/components/icon.tsx b/packages/ui/src/components/icon.tsx
index 0c42083de..0011a9676 100644
--- a/packages/ui/src/components/icon.tsx
+++ b/packages/ui/src/components/icon.tsx
@@ -138,6 +138,7 @@ const newIcons = {
"edit-small-2": `<path d="M17.0834 17.0833V17.5833H17.5834V17.0833H17.0834ZM2.91675 17.0833H2.41675V17.5833H2.91675V17.0833ZM2.91675 2.91659V2.41659H2.41675V2.91659H2.91675ZM9.58341 3.41659H10.0834V2.41659H9.58341V2.91659V3.41659ZM17.5834 10.4166V9.91659H16.5834V10.4166H17.0834H17.5834ZM10.4167 7.08325L10.0632 6.7297L9.91675 6.87615V7.08325H10.4167ZM10.4167 9.58325H9.91675V10.0833H10.4167V9.58325ZM12.9167 9.58325V10.0833H13.1239L13.2703 9.93681L12.9167 9.58325ZM15.4167 2.08325L15.7703 1.7297L15.4167 1.37615L15.0632 1.7297L15.4167 2.08325ZM17.9167 4.58325L18.2703 4.93681L18.6239 4.58325L18.2703 4.2297L17.9167 4.58325ZM17.0834 17.0833V16.5833H2.91675V17.0833V17.5833H17.0834V17.0833ZM2.91675 17.0833H3.41675V2.91659H2.91675H2.41675V17.0833H2.91675ZM2.91675 2.91659V3.41659H9.58341V2.91659V2.41659H2.91675V2.91659ZM17.0834 10.4166H16.5834V17.0833H17.0834H17.5834V10.4166H17.0834ZM10.4167 7.08325H9.91675V9.58325H10.4167H10.9167V7.08325H10.4167ZM10.4167 9.58325V10.0833H12.9167V9.58325V9.08325H10.4167V9.58325ZM10.4167 7.08325L10.7703 7.43681L15.7703 2.43681L15.4167 2.08325L15.0632 1.7297L10.0632 6.7297L10.4167 7.08325ZM15.4167 2.08325L15.0632 2.43681L17.5632 4.93681L17.9167 4.58325L18.2703 4.2297L15.7703 1.7297L15.4167 2.08325ZM17.9167 4.58325L17.5632 4.2297L12.5632 9.2297L12.9167 9.58325L13.2703 9.93681L18.2703 4.93681L17.9167 4.58325Z" fill="currentColor"/>`,
folder: `<path d="M2.08301 2.91675V16.2501H17.9163V5.41675H9.99967L8.33301 2.91675H2.08301Z" stroke="currentColor" stroke-linecap="round"/>`,
"pencil-line": `<path d="M9.58301 17.9166H17.9163M17.9163 5.83325L14.1663 2.08325L2.08301 14.1666V17.9166H5.83301L17.9163 5.83325Z" stroke="currentColor" stroke-linecap="square"/>`,
+ "chevron-grabber-vertical": `<path d="M6.66675 12.4998L10.0001 15.8332L13.3334 12.4998M6.66675 7.49984L10.0001 4.1665L13.3334 7.49984" stroke="currentColor" stroke-linecap="square"/>`,
}
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"
diff --git a/packages/ui/src/demo.tsx b/packages/ui/src/demo.tsx
index 7c507d7d9..791281815 100644
--- a/packages/ui/src/demo.tsx
+++ b/packages/ui/src/demo.tsx
@@ -1,6 +1,7 @@
import type { Component } from "solid-js"
import { createSignal } from "solid-js"
import {
+ Accordion,
Button,
Select,
Tabs,
@@ -214,6 +215,41 @@ const Demo: Component = () => {
</Collapsible.Content>
</Collapsible>
</section>
+ <h3>Accordion</h3>
+ <section>
+ <Accordion collapsible>
+ <Accordion.Item value="item-1">
+ <Accordion.Header>
+ <Accordion.Trigger>What is Kobalte?</Accordion.Trigger>
+ </Accordion.Header>
+ <Accordion.Content>
+ <div style={{ padding: "16px" }}>
+ <p>Kobalte is a UI toolkit for building accessible web apps and design systems with SolidJS.</p>
+ </div>
+ </Accordion.Content>
+ </Accordion.Item>
+ <Accordion.Item value="item-2">
+ <Accordion.Header>
+ <Accordion.Trigger>Is it accessible?</Accordion.Trigger>
+ </Accordion.Header>
+ <Accordion.Content>
+ <div style={{ padding: "16px" }}>
+ <p>Yes. It adheres to the WAI-ARIA design patterns.</p>
+ </div>
+ </Accordion.Content>
+ </Accordion.Item>
+ <Accordion.Item value="item-3">
+ <Accordion.Header>
+ <Accordion.Trigger>Can it be animated?</Accordion.Trigger>
+ </Accordion.Header>
+ <Accordion.Content>
+ <div style={{ padding: "16px" }}>
+ <p>Yes! You can animate the content height using CSS animations.</p>
+ </div>
+ </Accordion.Content>
+ </Accordion.Item>
+ </Accordion>
+ </section>
</div>
)
diff --git a/packages/ui/src/styles/index.css b/packages/ui/src/styles/index.css
index dc5335c43..7d426a83e 100644
--- a/packages/ui/src/styles/index.css
+++ b/packages/ui/src/styles/index.css
@@ -5,7 +5,9 @@
@import "./base.css" layer(base);
+@import "../components/accordion.css" layer(components);
@import "../components/button.css" layer(components);
+@import "../components/collapsible.css" layer(components);
@import "../components/dialog.css" layer(components);
@import "../components/icon.css" layer(components);
@import "../components/icon-button.css" layer(components);