@stainless-api/ui-primitives 0.1.0-beta.2 → 0.1.0-beta.21

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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +35 -0
  2. package/CHANGELOG.md +118 -0
  3. package/dist/Accordion-CJL9SWwS.d.ts +26 -0
  4. package/dist/Accordion-DLQE3Td6.js +31 -0
  5. package/dist/Button-DBhd6kU7.js +51 -0
  6. package/dist/Button-DwndlytB.d.ts +38 -0
  7. package/dist/Callout-CMz3Yl_5.d.ts +18 -0
  8. package/dist/Callout-UZQRuCQ5.js +28 -0
  9. package/dist/DropdownButton-DoYDi8tB.js +82 -0
  10. package/dist/DropdownButton-zcvep_xH.d.ts +50 -0
  11. package/dist/components/Accordion.d.ts +2 -0
  12. package/dist/components/Accordion.js +3 -0
  13. package/dist/components/Button.d.ts +2 -0
  14. package/dist/components/Button.js +3 -0
  15. package/dist/components/Callout.d.ts +2 -0
  16. package/dist/components/Callout.js +3 -0
  17. package/dist/components/DropdownButton.d.ts +2 -0
  18. package/dist/components/DropdownButton.js +3 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.js +6 -0
  21. package/dist/scripts/index.d.ts +12 -0
  22. package/dist/scripts/index.js +33 -0
  23. package/dist/styles.css +1181 -0
  24. package/dist/styles.js +1 -0
  25. package/package.json +9 -9
  26. package/src/components/Accordion.tsx +41 -0
  27. package/src/components/Button.tsx +1 -0
  28. package/src/components/accordion.css +145 -0
  29. package/src/components/button.css +165 -135
  30. package/src/components/callout.css +78 -57
  31. package/src/components/dropdown/Dropdown.tsx +51 -0
  32. package/src/components/dropdown/DropdownButton.tsx +54 -0
  33. package/src/components/dropdown/DropdownMenu.tsx +113 -0
  34. package/src/components/dropdown/dropdown.css +232 -0
  35. package/src/index.ts +3 -2
  36. package/src/scripts/dropdown-button.ts +20 -36
  37. package/src/scripts/dropdown.ts +193 -0
  38. package/src/scripts/index.ts +1 -0
  39. package/src/styles/layout.css +3 -1
  40. package/src/styles/scales.css +1 -1
  41. package/src/styles/starlight-compat.css +138 -107
  42. package/src/styles/swatches.css +2 -2
  43. package/src/styles/theme.css +2 -2
  44. package/src/styles/typography.css +117 -147
  45. package/src/styles.css +2 -2
  46. package/tsconfig.json +3 -7
  47. package/.env +0 -1
  48. package/src/components/DetailsGroup.tsx +0 -17
  49. package/src/components/DropdownButton.tsx +0 -98
  50. package/src/components/details.css +0 -126
  51. package/src/components/dropdown-button.css +0 -162
@@ -1,5 +1,5 @@
1
- @layer stl-ui {
2
- /* Typography - Stainless */
1
+ /* Typography - Stainless */
2
+ @layer stl-ui.tokens {
3
3
  :root {
4
4
  --stl-ui-typography-font: 'Geist', system-ui, sans-serif;
5
5
  --stl-ui-typography-font-mono: 'Geist Mono', ui-monospace, monospace;
@@ -30,170 +30,140 @@
30
30
  --stl-ui-type-scale-text-5xl: 42px;
31
31
  --stl-ui-type-scale-text-6xl: 64px;
32
32
  }
33
+ }
33
34
 
34
- /* Prose exists in its own sub-layer for easy reverting */
35
- @layer typography {
36
- body {
37
- font-family: var(--stl-ui-typography-font);
38
- font-feature-settings:
39
- 'ss01' on,
40
- 'ss03' on,
41
- 'ss04' on,
42
- 'ss06' on,
43
- 'ss08' on;
44
- }
45
-
46
- .stl-ui-prose {
47
- color: var(--stl-ui-foreground-secondary);
48
-
49
- /* Body/Regular */
50
- font-size: var(--stl-ui-typography-text-body);
51
- font-style: normal;
52
- font-weight: 400;
53
- line-height: var(--stl-ui-typography-line-height);
54
- letter-spacing: -0.01em;
55
-
56
- * {
57
- margin: 0;
58
- }
35
+ /* Prose exists in its own sub-layer for easy reverting */
36
+ body {
37
+ font-family: var(--stl-ui-typography-font);
38
+ font-feature-settings:
39
+ 'ss01' on,
40
+ 'ss03' on,
41
+ 'ss04' on,
42
+ 'ss06' on,
43
+ 'ss08' on;
44
+ }
59
45
 
60
- p {
61
- margin-top: 16px;
62
- }
46
+ .stl-ui-prose {
47
+ letter-spacing: -0.01em;
48
+ font-weight: 400;
49
+ line-height: var(--stl-ui-typography-line-height);
50
+ font-size: var(--stl-ui-typography-text-body);
51
+ color: var(--stl-ui-foreground-secondary);
52
+
53
+ :where(.stl-ui-not-prose) {
54
+ letter-spacing: initial;
55
+ font-weight: initial;
56
+ line-height: initial;
57
+ font-size: initial;
58
+ color: initial;
59
+ }
63
60
 
64
- p,
65
- li {
66
- color: var(--stl-ui-foreground-secondary);
67
- }
61
+ :where(p):not(.stl-ui-not-prose *) {
62
+ margin-top: 16px;
63
+ }
68
64
 
69
- strong {
70
- color: var(--stl-ui-foreground);
71
- }
65
+ :where(p, li) {
66
+ &:not(.stl-ui-not-prose *) {
67
+ color: var(--stl-ui-foreground-secondary);
68
+ }
69
+ }
72
70
 
73
- aside {
74
- p,
75
- li {
76
- color: var(--stl-ui-foreground);
77
- }
78
- }
71
+ :where(strong):not(.stl-ui-not-prose *) {
72
+ color: var(--stl-ui-foreground);
73
+ }
79
74
 
80
- a {
81
- color: var(--stl-ui-foreground-accent);
82
-
83
- /* Body/Link */
84
- font-weight: 600;
85
- text-decoration-line: underline;
86
- text-decoration-style: solid;
87
- text-decoration-skip-ink: auto;
88
- text-decoration-thickness: auto;
89
- text-underline-offset: auto;
90
- text-underline-position: from-font;
91
- }
75
+ :where(aside):not(.stl-ui-not-prose *) {
76
+ color: var(--stl-ui-foreground);
77
+ }
92
78
 
93
- h1,
94
- h2,
95
- h3,
96
- h4,
97
- h5,
98
- h6 {
99
- color: var(--stl-ui-foreground);
100
- font-weight: 500;
101
- line-height: var(--stl-ui-typography-line-height-headings);
102
- }
79
+ :is(h1, h2, h3, h4, h5, h6):not(.stl-ui-not-prose *) {
80
+ color: var(--stl-ui-foreground);
81
+ font-weight: 500;
82
+ line-height: var(--stl-ui-typography-line-height-headings);
83
+ }
103
84
 
104
- h1 {
105
- /* Heading 1/Medium */
106
- font-size: var(--stl-ui-typography-text-h1);
107
- letter-spacing: -0.03em;
85
+ h1:not(.stl-ui-not-prose *) {
86
+ /* Heading 1/Medium */
87
+ font-size: var(--stl-ui-typography-text-h1);
88
+ letter-spacing: -0.03em;
108
89
 
109
- margin-top: 64px;
110
- }
90
+ margin-top: 64px;
91
+ }
111
92
 
112
- h2 {
113
- /* Heading 2/Medium */
114
- font-size: var(--stl-ui-typography-text-h2);
115
- letter-spacing: -0.03em;
116
- margin-top: 48px;
117
- }
93
+ h2:not(.stl-ui-not-prose *) {
94
+ /* Heading 2/Medium */
95
+ font-size: var(--stl-ui-typography-text-h2);
96
+ letter-spacing: -0.03em;
118
97
 
119
- h3 {
120
- /* Heading 3/Medium */
121
- font-size: var(--stl-ui-typography-text-h3);
122
- letter-spacing: -0.02em;
123
- margin-top: 40px;
124
- }
98
+ margin-top: 48px;
99
+ }
125
100
 
126
- h4 {
127
- /* Heading 4/Medium */
128
- font-size: var(--stl-ui-typography-text-h4);
129
- letter-spacing: -0.02em;
130
- margin-top: 32px;
131
- }
101
+ h3:not(.stl-ui-not-prose *) {
102
+ /* Heading 3/Medium */
103
+ font-size: var(--stl-ui-typography-text-h3);
104
+ letter-spacing: -0.02em;
105
+ margin-top: 40px;
106
+ }
132
107
 
133
- h5 {
134
- /* Heading 5/Medium */
135
- font-size: var(--stl-ui-typography-text-h5);
136
- letter-spacing: -0.02em;
137
- margin-top: 24px;
138
- }
108
+ h4:not(.stl-ui-not-prose *) {
109
+ /* Heading 4/Medium */
110
+ font-size: var(--stl-ui-typography-text-h4);
111
+ letter-spacing: -0.02em;
112
+ margin-top: 32px;
113
+ }
139
114
 
140
- li {
141
- &:not(:last-child) {
142
- margin-bottom: 8px;
143
- }
144
-
145
- h1,
146
- h2,
147
- h3,
148
- h4,
149
- h5,
150
- p,
151
- a {
152
- &:first-child {
153
- display: inline;
154
- }
155
- }
156
- }
115
+ h5:not(.stl-ui-not-prose *) {
116
+ /* Heading 5/Medium */
117
+ font-size: var(--stl-ui-typography-text-h5);
118
+ letter-spacing: -0.02em;
119
+ margin-top: 24px;
120
+ }
157
121
 
158
- ol,
159
- ul {
160
- padding-left: 26px;
161
- }
122
+ li:not(.stl-ui-not-prose *) {
123
+ &:not(:last-child) {
124
+ margin-bottom: 8px;
125
+ }
162
126
 
163
- ol,
164
- ul,
165
- aside,
166
- img,
167
- svg,
168
- figure,
169
- details {
170
- margin-top: 16px;
127
+ h1,
128
+ h2,
129
+ h3,
130
+ h4,
131
+ h5,
132
+ p,
133
+ a {
134
+ &:first-child {
135
+ display: inline;
171
136
  }
137
+ }
138
+ }
172
139
 
173
- :not(pre) > code {
174
- color: var(--stl-ui-foreground);
175
- font-feature-settings:
176
- 'ss01' on,
177
- 'ss03' on,
178
- 'ss04' on,
179
- 'ss06' on;
180
-
181
- /* Code/Regular */
182
- font-family: var(--stl-ui-typography-font-mono);
183
- font-size: var(--stl-ui-typography-text-body-sm);
184
- font-style: normal;
185
- font-weight: 400;
186
- line-height: 150%; /* 21px */
187
-
188
- padding: 0 4px;
189
- background-color: oklch(from var(--stl-ui-foreground) l c h / 0.1);
190
- border-radius: var(--stl-ui-layout-border-radius-xs);
191
- }
140
+ :where(ol, ul) {
141
+ &:not(.stl-ui-not-prose *) {
142
+ padding-left: 26px;
143
+ }
144
+ }
192
145
 
193
- /* Escape hatch for non-prose content */
194
- .stl-ui-not-prose * {
195
- all: revert-layer;
196
- }
146
+ :where(ol, ul, aside, img, figure, details) {
147
+ &:not(.stl-ui-not-prose *) {
148
+ margin-top: 16px;
197
149
  }
198
150
  }
151
+
152
+ :where(:not(pre) > code):not(.stl-ui-not-prose *) {
153
+ color: var(--stl-ui-foreground);
154
+ font-feature-settings:
155
+ 'ss01' on,
156
+ 'ss03' on,
157
+ 'ss04' on,
158
+ 'ss06' on;
159
+
160
+ /* Code/Regular */
161
+ font-family: var(--stl-ui-typography-font-mono);
162
+ font-size: 0.9em;
163
+ font-weight: inherit;
164
+
165
+ padding: 0 0.2em;
166
+ background-color: oklch(from var(--stl-ui-foreground) l c h / 0.1);
167
+ border-radius: 0.2em;
168
+ }
199
169
  }
package/src/styles.css CHANGED
@@ -6,6 +6,6 @@
6
6
  @import './styles/starlight-compat.css';
7
7
 
8
8
  @import './components/button.css';
9
- @import './components/dropdown-button.css';
9
+ @import './components/dropdown/dropdown.css';
10
10
  @import './components/callout.css';
11
- @import './components/details.css';
11
+ @import './components/accordion.css';
package/tsconfig.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
+ "extends": "../../tsconfig.base.json",
2
3
  "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
4
+ "noEmit": false,
5
5
  "declaration": true,
6
6
  "declarationDir": "dist",
7
7
  "outDir": "dist",
8
- "jsx": "react-jsx",
9
- "esModuleInterop": true,
10
- "moduleResolution": "Node",
11
- "skipLibCheck": true,
12
- "strict": true
8
+ "jsx": "react-jsx"
13
9
  },
14
10
  "include": ["src"]
15
11
  }
package/.env DELETED
@@ -1 +0,0 @@
1
- STAINLESS_API_KEY=stl_sk_001uwmod48VpDm2a1bvB1tUTdJ1ooZ5I
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import clsx from 'clsx';
3
-
4
- export type DetailsGroupProps = React.ComponentProps<'div'>;
5
-
6
- export function DetailsGroup({ className, children, ...props }: DetailsGroupProps) {
7
- const classes = clsx('stl-ui-details-group', className);
8
-
9
- // TODO: boolean `exclusive` prop assigns a unique `name` to each of the child <details> elements
10
- // For now this can be handled by the user
11
-
12
- return (
13
- <div className={classes} {...props}>
14
- {children}
15
- </div>
16
- );
17
- }
@@ -1,98 +0,0 @@
1
- import { ChevronsUpDown, ExternalLink } from 'lucide-react';
2
-
3
- export function DropdownButtonPrimaryActionText({ children }: { children?: React.ReactNode }) {
4
- return <span data-part="primary-action-text">{children}</span>;
5
- }
6
-
7
- export function DropdownButtonPrimaryAction({ children }: { children?: React.ReactNode }) {
8
- return (
9
- <button
10
- type="button"
11
- data-part="primary-action"
12
- className="stl-ui-dropdown-button__button stl-ui-dropdown-button--action"
13
- >
14
- {children}
15
- </button>
16
- );
17
- }
18
-
19
- export function DropdownButtonTrigger() {
20
- return (
21
- <button
22
- className="stl-ui-dropdown-button__button stl-ui-dropdown-button__trigger"
23
- aria-haspopup="listbox"
24
- aria-expanded="false"
25
- data-part="trigger"
26
- >
27
- <ChevronsUpDown size={16} />
28
- </button>
29
- );
30
- }
31
-
32
- export function DropdownButtonMenu({ children }: { children?: React.ReactNode }) {
33
- return (
34
- <div className="stl-ui-dropdown-button__menu" data-state="closed" data-part="menu">
35
- {children}
36
- </div>
37
- );
38
- }
39
-
40
- export function DropdownButtonItemIcon({ children }: { children?: React.ReactNode }) {
41
- return (
42
- <div className="stl-ui-dropdown-button__menu-item-icon" data-part="item-icon">
43
- {children}
44
- </div>
45
- );
46
- }
47
-
48
- export function DropdownButtonItemText({ children }: { children?: React.ReactNode }) {
49
- return (
50
- <span className="stl-ui-dropdown-button__menu-item-text" data-part="item-text">
51
- {children}
52
- </span>
53
- );
54
- }
55
-
56
- export function DropdownButtonItemTextSubtle({ children }: { children?: React.ReactNode }) {
57
- return (
58
- <span className="stl-ui-dropdown-button__menu-item-text-subtle" data-part="item-text-subtle">
59
- {children}
60
- </span>
61
- );
62
- }
63
-
64
- export function DropdownButtonItem({
65
- children,
66
- value,
67
- isExternalLink,
68
- }: {
69
- children?: React.ReactNode;
70
- value: string;
71
- isExternalLink?: boolean;
72
- }) {
73
- return (
74
- <div className="stl-ui-dropdown-button__menu-item" data-part="item" data-value={value}>
75
- <div className="stl-ui-dropdown-button__menu-item-content">{children}</div>
76
- {isExternalLink && (
77
- <div
78
- className="stl-ui-dropdown-button__menu-item-external-link-icon"
79
- data-part="item-external-link-icon"
80
- >
81
- <ExternalLink size={16} />
82
- </div>
83
- )}
84
- </div>
85
- );
86
- }
87
-
88
- export function DropdownButtonDivider() {
89
- return <div className="stl-ui-dropdown-button__divider" data-part="divider" />;
90
- }
91
-
92
- export function DropdownButton({ id, children }: { id: string; children?: React.ReactNode }) {
93
- return (
94
- <div className="stl-ui-dropdown-button stl-ui-not-prose not-content" id={id}>
95
- {children}
96
- </div>
97
- );
98
- }
@@ -1,126 +0,0 @@
1
- /* revert starlight details styles */
2
- @layer starlight.content {
3
- /* artificially increase specificity to outcompete selectors in the same layer whose styles we want to revert */
4
- .stl-ui-prose .sl-markdown-content.sl-markdown-content.sl-markdown-content {
5
- details,
6
- summary,
7
- summary::before,
8
- summary::marker {
9
- all: revert-layer;
10
- }
11
- }
12
- }
13
-
14
- @layer stl-ui {
15
- @layer typography {
16
- .stl-ui-prose {
17
- details {
18
- --stl-ui-details-padding: 12px;
19
- --stl-ui-details-content-padding-bottom: 4px;
20
- --stl-ui-details-marker-size: 1em;
21
- --stl-ui-details-marker-margin: calc((1lh - var(--stl-ui-details-marker-size)) / 2);
22
- --stl-ui-details-row-gap: 8px;
23
- --stl-ui-details-summary-column-gap: 8px;
24
- --stl-ui-details-border-radius: var(--stl-ui-layout-border-radius);
25
- /* left inset to make content line up with summary content (after chevron) */
26
- --stl-ui--internal--details-padding-start: calc(
27
- var(--stl-ui-details-padding)
28
- + var(--stl-ui-details-marker-size)
29
- + var(--stl-ui-details-marker-margin) * 2
30
- + var(--stl-ui-details-summary-column-gap)
31
- );
32
-
33
- background-color: var(--stl-ui-card-background);
34
- border: 1px solid var(--stl-ui-border);
35
- border-radius: var(--stl-ui-details-border-radius);
36
- font-size: var(--stl-ui-typography-text-body);
37
-
38
- padding: var(--stl-ui-details-padding);
39
- /* indent content to line up with left edge of summary content */
40
- padding-inline-start: var(--stl-ui--internal--details-padding-start);
41
-
42
- summary {
43
- display: block;
44
- list-style: none;
45
-
46
- /* summary extends to the edges of the element in order to increase click target */
47
- padding: var(--stl-ui-details-padding);
48
- padding-inline-start: var(--stl-ui--internal--details-padding-start);
49
- margin: calc(-1 * var(--stl-ui-details-padding));
50
- margin-inline-start: calc(-1 * var(--stl-ui--internal--details-padding-start));
51
-
52
- cursor: pointer;
53
- font-weight: 500;
54
-
55
- border-radius: var(--stl-ui-details-border-radius);
56
-
57
- &::before {
58
- content: '';
59
- width: var(--stl-ui-details-marker-size);
60
- height: var(--stl-ui-details-marker-size);
61
- margin: var(--stl-ui-details-marker-margin);
62
- background-color: currentColor;
63
- display: block;
64
- position: absolute;
65
- --stl-ui-details--internal--marker-width: calc(var(--stl-ui-details-marker-size) + var(--stl-ui-details-marker-margin) * 2);
66
- --stl-ui-details--internal--summary-marker-transform: translateX(calc(-1 * var(--stl-ui-details--internal--marker-width) - var(--stl-ui-details-summary-column-gap)));
67
- transform: var(--stl-ui-details--internal--summary-marker-transform);
68
-
69
- --lucide-chevron-right: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQtaWNvbiBsdWNpZGUtY2hldnJvbi1yaWdodCI+PHBhdGggZD0ibTkgMTggNi02LTYtNiIvPjwvc3ZnPg==');
70
- mask-image: var(--lucide-chevron-right);
71
- mask-size: contain;
72
- mask-repeat: no-repeat;
73
-
74
- transition: transform 0.1s ease-out;
75
- }
76
-
77
- & > :first-child {
78
- margin-top: 0;
79
- }
80
- }
81
-
82
- &[open] {
83
- padding-bottom: calc(var(--stl-ui-details-padding) + var(--stl-ui-details-content-padding-bottom));
84
-
85
- summary {
86
- /* padding-bottom shouldn’t extend beyond the row gap while open, i.e. we shouldn’t be negative-margin-placing content overlapping summary */
87
- --stl-ui--internal--summary-padding-bottom: min(var(--stl-ui-details-padding), var(--stl-ui-details-row-gap));
88
- padding-bottom: var(--stl-ui--internal--summary-padding-bottom);
89
- margin-bottom: calc(var(--stl-ui-details-row-gap) - var(--stl-ui--internal--summary-padding-bottom));
90
- border-bottom-left-radius: 0;
91
- border-bottom-right-radius: 0;
92
-
93
- &::before {
94
- transform: var(--stl-ui-details--internal--summary-marker-transform) rotate(90deg);
95
- }
96
- }
97
- }
98
-
99
- summary + * {
100
- margin-top: 0;
101
- }
102
- }
103
- }
104
-
105
- .stl-ui-details-group {
106
- & > details:has(+ details) {
107
- border-bottom-left-radius: 0;
108
- border-bottom-right-radius: 0;
109
- summary {
110
- border-bottom-left-radius: 0;
111
- border-bottom-right-radius: 0;
112
- }
113
- }
114
- & > details + details {
115
- margin-top: 0;
116
- border-top: 0;
117
- border-top-left-radius: 0;
118
- border-top-right-radius: 0;
119
- summary {
120
- border-top-left-radius: 0;
121
- border-top-right-radius: 0;
122
- }
123
- }
124
- }
125
- }
126
- }