@opencode/ui 0.0.0-dev-566 → 0.0.0-dev-569

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,13 @@
1
1
  import { Root } from "@kobalte/core/checkbox";
2
2
  import type { ComponentProps, JSX, ParentProps } from "solid-js";
3
+ import "./checkbox-compact.css";
3
4
  export interface CheckboxProps extends ParentProps<ComponentProps<typeof Root>> {
5
+ /** `compact` is the design system checkbox; `standard` keeps the legacy look. */
6
+ appearance?: "standard" | "compact";
7
+ /** Background of the compact control. */
8
+ surface?: "base" | "layer-1";
4
9
  hideLabel?: boolean;
5
- description?: string;
10
+ description?: JSX.Element;
6
11
  icon?: JSX.Element;
7
12
  }
8
13
  export declare function Checkbox(props: CheckboxProps): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "0.0.0-dev-566",
3
+ "version": "0.0.0-dev-569",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -288,7 +288,7 @@
288
288
  "dependencies": {
289
289
  "@kitlangton/solid-motion": "0.2.2",
290
290
  "@kobalte/core": "0.13.13",
291
- "@opencode/util": "0.0.0-dev-566",
291
+ "@opencode/util": "0.0.0-dev-569",
292
292
  "@pierre/diffs": "1.6.1",
293
293
  "@pierre/highlights": "0.2.0",
294
294
  "@solid-primitives/event-listener": "2.4.6",
@@ -0,0 +1,169 @@
1
+ /* Vite can link this before the app entry CSS, so name every layer here or `components` ranks below Tailwind's base reset. */
2
+ @layer properties, theme, base, components, utilities;
3
+
4
+ @layer components {
5
+ [data-slot="checkbox-v2"] {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 6px;
9
+ cursor: default;
10
+
11
+ &:where([data-disabled]) {
12
+ cursor: not-allowed;
13
+ }
14
+
15
+ &:where([data-readonly]) {
16
+ pointer-events: none;
17
+ }
18
+ }
19
+
20
+ [data-slot="checkbox-v2-error"] {
21
+ color: var(--v2-state-fg-danger);
22
+ font-size: 12px;
23
+ font-weight: 440;
24
+ line-height: var(--line-height-compact);
25
+ }
26
+
27
+ [data-slot="checkbox-v2-error"]:empty {
28
+ display: none;
29
+ }
30
+
31
+ [data-slot="checkbox-v2-row"] {
32
+ position: relative;
33
+ display: flex;
34
+ flex-direction: row;
35
+ align-items: flex-start;
36
+ gap: 8px;
37
+ }
38
+
39
+ [data-slot="checkbox-v2-input"] {
40
+ position: absolute;
41
+ width: 1px;
42
+ height: 1px;
43
+ padding: 0;
44
+ margin: -1px;
45
+ overflow: hidden;
46
+ clip: rect(0, 0, 0, 0);
47
+ white-space: nowrap;
48
+ border-width: 0;
49
+ }
50
+
51
+ /* 20px tall so the 16px control centres on the first 20px line of the label. */
52
+ [data-slot="checkbox-v2-control-stack"] {
53
+ position: relative;
54
+ width: 16px;
55
+ height: 20px;
56
+ flex: none;
57
+ }
58
+
59
+ [data-slot="checkbox-v2-control"] {
60
+ box-sizing: border-box;
61
+ position: absolute;
62
+ top: 2px;
63
+ left: 0;
64
+ width: 16px;
65
+ height: 16px;
66
+ border-radius: 4px;
67
+ color: var(--v2-icon-icon-contrast);
68
+ background: var(--v2-background-bg-base);
69
+ box-shadow: inset 0 0 0 0.5px var(--v2-border-border-strong);
70
+ transition:
71
+ background 85ms ease-out,
72
+ box-shadow 85ms ease-out;
73
+ }
74
+
75
+ [data-slot="checkbox-v2"][data-surface="layer-1"] [data-slot="checkbox-v2-control"] {
76
+ background: var(--v2-background-bg-layer-01);
77
+ }
78
+
79
+ [data-slot="checkbox-v2-indicator"] {
80
+ position: absolute;
81
+ inset: 0;
82
+ pointer-events: none;
83
+ }
84
+
85
+ [data-slot="checkbox-v2-text"] {
86
+ display: flex;
87
+ flex-direction: column;
88
+ justify-content: center;
89
+ align-items: flex-start;
90
+ gap: 6px;
91
+ min-width: 0;
92
+ }
93
+
94
+ [data-slot="checkbox-v2-label"] {
95
+ user-select: none;
96
+ color: var(--v2-text-text-base);
97
+ font-size: 13px;
98
+ font-weight: 440;
99
+ line-height: var(--line-height-base);
100
+ letter-spacing: -0.04px;
101
+ font-variation-settings: "slnt" 0;
102
+ }
103
+
104
+ [data-slot="checkbox-v2-description"] {
105
+ color: var(--v2-text-text-muted);
106
+ font-size: 11px;
107
+ font-weight: 440;
108
+ line-height: var(--line-height-tight);
109
+ letter-spacing: 0.05px;
110
+ user-select: none;
111
+ }
112
+
113
+ [data-slot="checkbox-v2"]:where(:not([data-readonly]))
114
+ [data-slot="checkbox-v2-input"]:focus-visible
115
+ ~ [data-slot="checkbox-v2-control-stack"]
116
+ [data-slot="checkbox-v2-control"] {
117
+ outline: 2px solid var(--v2-border-border-focus);
118
+ outline-offset: 2px;
119
+ }
120
+
121
+ @media (hover: hover) {
122
+ [data-slot="checkbox-v2"]:where(:hover):where(:not([data-disabled], [data-readonly], [data-invalid])):where(
123
+ :not([data-checked], [data-indeterminate])
124
+ )
125
+ [data-slot="checkbox-v2-control"] {
126
+ box-shadow:
127
+ inset 0 0 0 0.5px var(--v2-border-border-strong),
128
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-hover);
129
+ }
130
+
131
+ [data-slot="checkbox-v2"]:where([data-checked], [data-indeterminate]):where(:hover):where(
132
+ :not([data-disabled], [data-readonly])
133
+ )
134
+ [data-slot="checkbox-v2-control"] {
135
+ box-shadow:
136
+ inset 0 0 0 0.5px var(--v2-border-border-strong),
137
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-contrast-hover);
138
+ }
139
+ }
140
+
141
+ /* The depth gradient is Figma's white-to-clear fill at 20% opacity over the accent. */
142
+ [data-slot="checkbox-v2"]:where([data-checked], [data-indeterminate]) [data-slot="checkbox-v2-control"] {
143
+ background:
144
+ linear-gradient(180deg, var(--v2-alpha-light-20) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-accent);
145
+ }
146
+
147
+ [data-slot="checkbox-v2"]:where([data-invalid]):where(:not([data-checked], [data-indeterminate]))
148
+ [data-slot="checkbox-v2-control"] {
149
+ background: var(--v2-state-bg-danger);
150
+ box-shadow: inset 0 0 0 0.5px var(--v2-state-fg-danger);
151
+ }
152
+
153
+ [data-slot="checkbox-v2"] .checkbox-v2-icon {
154
+ position: absolute;
155
+ left: 50%;
156
+ top: 50%;
157
+ transform: translate(-50%, -50%);
158
+ display: none;
159
+ }
160
+
161
+ [data-slot="checkbox-v2"]:where([data-checked]):where(:not([data-indeterminate])) .checkbox-v2-icon--check,
162
+ [data-slot="checkbox-v2"]:where([data-indeterminate]) .checkbox-v2-icon--minus {
163
+ display: block;
164
+ }
165
+
166
+ [data-slot="checkbox-v2"]:where([data-disabled]) [data-slot="checkbox-v2-row"] {
167
+ opacity: 0.5;
168
+ }
169
+ }
@@ -1,44 +1,106 @@
1
1
  import { Control, Description, ErrorMessage, Indicator, Input, Label, Root } from "@kobalte/core/checkbox"
2
- import { Show, splitProps } from "solid-js"
2
+ import { Match, Show, Switch, splitProps } from "solid-js"
3
3
  import type { ComponentProps, JSX, ParentProps } from "solid-js"
4
+ import "./checkbox-compact.css"
4
5
 
5
6
  export interface CheckboxProps extends ParentProps<ComponentProps<typeof Root>> {
7
+ /** `compact` is the design system checkbox; `standard` keeps the legacy look. */
8
+ appearance?: "standard" | "compact"
9
+ /** Background of the compact control. */
10
+ surface?: "base" | "layer-1"
6
11
  hideLabel?: boolean
7
- description?: string
12
+ description?: JSX.Element
8
13
  icon?: JSX.Element
9
14
  }
10
15
 
11
16
  export function Checkbox(props: CheckboxProps) {
12
- const [local, others] = splitProps(props, ["children", "class", "label", "hideLabel", "description", "icon"])
17
+ const [local, others] = splitProps(props, [
18
+ "children",
19
+ "class",
20
+ "label",
21
+ "appearance",
22
+ "surface",
23
+ "hideLabel",
24
+ "description",
25
+ "icon",
26
+ ])
13
27
 
14
28
  return (
15
- <Root {...others} data-component="checkbox">
16
- <Input data-slot="checkbox-checkbox-input" />
17
- <Control data-slot="checkbox-checkbox-control">
18
- <Indicator data-slot="checkbox-checkbox-indicator">
19
- {local.icon || (
20
- <svg viewBox="0 0 12 12" fill="none" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
21
- <path
22
- d="M3 7.17905L5.02703 8.85135L9 3.5"
23
- stroke="currentColor"
24
- stroke-width="1.5"
25
- stroke-linecap="square"
26
- />
27
- </svg>
28
- )}
29
- </Indicator>
30
- </Control>
31
- <div data-slot="checkbox-checkbox-content">
32
- <Show when={props.children}>
33
- <Label data-slot="checkbox-checkbox-label" classList={{ "sr-only": local.hideLabel }}>
34
- {props.children}
35
- </Label>
36
- </Show>
37
- <Show when={local.description}>
38
- <Description data-slot="checkbox-checkbox-description">{local.description}</Description>
39
- </Show>
40
- <ErrorMessage data-slot="checkbox-checkbox-error" />
41
- </div>
42
- </Root>
29
+ <Switch>
30
+ <Match when={local.appearance === "compact"}>
31
+ <Root {...others} class={local.class} data-slot="checkbox-v2" data-surface={local.surface ?? "base"}>
32
+ <div data-slot="checkbox-v2-row">
33
+ <Input data-slot="checkbox-v2-input" />
34
+ <div data-slot="checkbox-v2-control-stack">
35
+ <Control data-slot="checkbox-v2-control">
36
+ <Indicator data-slot="checkbox-v2-indicator">
37
+ <svg
38
+ class="checkbox-v2-icon checkbox-v2-icon--check"
39
+ width="16"
40
+ height="16"
41
+ viewBox="0 0 16 16"
42
+ fill="none"
43
+ aria-hidden="true"
44
+ >
45
+ <path d="M3.53564 8.17857L6.39279 11.75L12.4642 4.25" stroke="currentColor" stroke-width="1" />
46
+ </svg>
47
+ <svg
48
+ class="checkbox-v2-icon checkbox-v2-icon--minus"
49
+ width="16"
50
+ height="16"
51
+ viewBox="0 0 16 16"
52
+ fill="none"
53
+ aria-hidden="true"
54
+ >
55
+ <path d="M12.75 8H3.25" stroke="currentColor" stroke-linejoin="round" stroke-width="1" />
56
+ </svg>
57
+ </Indicator>
58
+ </Control>
59
+ </div>
60
+ <div data-slot="checkbox-v2-text">
61
+ <Show when={local.children}>
62
+ <Label data-slot="checkbox-v2-label" classList={{ "sr-only": local.hideLabel }}>
63
+ {local.children}
64
+ </Label>
65
+ </Show>
66
+ <Show when={local.description}>
67
+ <Description data-slot="checkbox-v2-description">{local.description}</Description>
68
+ </Show>
69
+ </div>
70
+ </div>
71
+ <ErrorMessage data-slot="checkbox-v2-error" />
72
+ </Root>
73
+ </Match>
74
+ <Match when={true}>
75
+ <Root {...others} class={local.class} data-component="checkbox">
76
+ <Input data-slot="checkbox-checkbox-input" />
77
+ <Control data-slot="checkbox-checkbox-control">
78
+ <Indicator data-slot="checkbox-checkbox-indicator">
79
+ {local.icon || (
80
+ <svg viewBox="0 0 12 12" fill="none" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
81
+ <path
82
+ d="M3 7.17905L5.02703 8.85135L9 3.5"
83
+ stroke="currentColor"
84
+ stroke-width="1.5"
85
+ stroke-linecap="square"
86
+ />
87
+ </svg>
88
+ )}
89
+ </Indicator>
90
+ </Control>
91
+ <div data-slot="checkbox-checkbox-content">
92
+ <Show when={props.children}>
93
+ <Label data-slot="checkbox-checkbox-label" classList={{ "sr-only": local.hideLabel }}>
94
+ {props.children}
95
+ </Label>
96
+ </Show>
97
+ <Show when={local.description}>
98
+ <Description data-slot="checkbox-checkbox-description">{local.description}</Description>
99
+ </Show>
100
+ <ErrorMessage data-slot="checkbox-checkbox-error" />
101
+ </div>
102
+ </Root>
103
+ </Match>
104
+ </Switch>
43
105
  )
44
106
  }