@stainless-api/ui-primitives 0.1.0-beta.7 → 0.1.0-beta.9

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,6 +1,6 @@
1
- @layer stl-ui {
1
+ @layer stl-ui.tokens {
2
2
  /* Swatches - Light */
3
- :root[data-theme='light'] {
3
+ :root {
4
4
  --stl-ui-background: var(--stl-ui-swatch-gray-white);
5
5
  --stl-ui-card-background: var(--stl-ui-swatch-gray-white);
6
6
  --stl-ui-muted-background: var(--stl-ui-swatch-gray-gray-8);
@@ -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,166 +30,154 @@
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
- p {
57
- margin-top: 16px;
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
- li {
62
- color: var(--stl-ui-foreground-secondary);
63
- }
46
+ .stl-ui-prose {
47
+ p:not(.stl-ui-not-prose *) {
48
+ color: var(--stl-ui-foreground-secondary);
49
+ font-weight: 400;
50
+ line-height: var(--stl-ui-typography-line-height);
51
+ letter-spacing: -0.01em;
52
+ font-size: var(--stl-ui-typography-text-body);
53
+ margin-top: 16px;
54
+ }
64
55
 
65
- strong {
66
- color: var(--stl-ui-foreground);
67
- }
56
+ p,
57
+ li {
58
+ &:not(.stl-ui-not-prose *) {
59
+ color: var(--stl-ui-foreground-secondary);
60
+ }
61
+ }
68
62
 
69
- aside {
70
- p,
71
- li {
72
- color: var(--stl-ui-foreground);
73
- }
74
- }
63
+ strong:not(.stl-ui-not-prose *) {
64
+ color: var(--stl-ui-foreground);
65
+ }
75
66
 
76
- a {
77
- color: var(--stl-ui-foreground-accent);
78
-
79
- /* Body/Link */
80
- font-weight: 600;
81
- text-decoration-line: underline;
82
- text-decoration-style: solid;
83
- text-decoration-skip-ink: auto;
84
- text-decoration-thickness: auto;
85
- text-underline-offset: auto;
86
- text-underline-position: from-font;
87
- }
67
+ aside:not(.stl-ui-not-prose *) {
68
+ p,
69
+ li {
70
+ color: var(--stl-ui-foreground);
71
+ }
72
+ }
88
73
 
89
- h1,
90
- h2,
91
- h3,
92
- h4,
93
- h5,
94
- h6 {
74
+ h1,
75
+ h2,
76
+ h3,
77
+ h4,
78
+ h5,
79
+ h6 {
80
+ &:not(.stl-ui-not-prose *) {
81
+ &,
82
+ * {
95
83
  color: var(--stl-ui-foreground);
96
84
  font-weight: 500;
97
85
  line-height: var(--stl-ui-typography-line-height-headings);
98
86
  }
87
+ }
88
+ }
99
89
 
100
- h1 {
101
- /* Heading 1/Medium */
102
- font-size: var(--stl-ui-typography-text-h1);
103
- letter-spacing: -0.03em;
90
+ h1:not(.stl-ui-not-prose *) {
91
+ /* Heading 1/Medium */
92
+ font-size: var(--stl-ui-typography-text-h1);
93
+ letter-spacing: -0.03em;
104
94
 
105
- margin-top: 64px;
106
- }
95
+ margin-top: 64px;
96
+ }
107
97
 
108
- h2 {
109
- /* Heading 2/Medium */
110
- font-size: var(--stl-ui-typography-text-h2);
111
- letter-spacing: -0.03em;
112
- margin-top: 48px;
113
- }
98
+ h2:not(.stl-ui-not-prose *) {
99
+ /* Heading 2/Medium */
100
+ font-size: var(--stl-ui-typography-text-h2);
101
+ letter-spacing: -0.03em;
114
102
 
115
- h3 {
116
- /* Heading 3/Medium */
117
- font-size: var(--stl-ui-typography-text-h3);
118
- letter-spacing: -0.02em;
119
- margin-top: 40px;
120
- }
103
+ margin-top: 48px;
104
+ }
121
105
 
122
- h4 {
123
- /* Heading 4/Medium */
124
- font-size: var(--stl-ui-typography-text-h4);
125
- letter-spacing: -0.02em;
126
- margin-top: 32px;
127
- }
106
+ h3:not(.stl-ui-not-prose *) {
107
+ /* Heading 3/Medium */
108
+ font-size: var(--stl-ui-typography-text-h3);
109
+ letter-spacing: -0.02em;
110
+ margin-top: 40px;
111
+ }
128
112
 
129
- h5 {
130
- /* Heading 5/Medium */
131
- font-size: var(--stl-ui-typography-text-h5);
132
- letter-spacing: -0.02em;
133
- margin-top: 24px;
134
- }
113
+ h4:not(.stl-ui-not-prose *) {
114
+ /* Heading 4/Medium */
115
+ font-size: var(--stl-ui-typography-text-h4);
116
+ letter-spacing: -0.02em;
117
+ margin-top: 32px;
118
+ }
135
119
 
136
- li {
137
- &:not(:last-child) {
138
- margin-bottom: 8px;
139
- }
140
-
141
- h1,
142
- h2,
143
- h3,
144
- h4,
145
- h5,
146
- p,
147
- a {
148
- &:first-child {
149
- display: inline;
150
- }
151
- }
152
- }
120
+ h5:not(.stl-ui-not-prose *) {
121
+ /* Heading 5/Medium */
122
+ font-size: var(--stl-ui-typography-text-h5);
123
+ letter-spacing: -0.02em;
124
+ margin-top: 24px;
125
+ }
153
126
 
154
- ol,
155
- ul {
156
- padding-left: 26px;
157
- }
127
+ li:not(.stl-ui-not-prose *) {
128
+ &:not(:last-child) {
129
+ margin-bottom: 8px;
130
+ }
158
131
 
159
- ol,
160
- ul,
161
- aside,
162
- img,
163
- svg,
164
- figure,
165
- details {
166
- margin-top: 16px;
132
+ h1,
133
+ h2,
134
+ h3,
135
+ h4,
136
+ h5,
137
+ p,
138
+ a {
139
+ &:first-child {
140
+ display: inline;
167
141
  }
142
+ }
143
+ }
168
144
 
169
- :not(pre) > code {
170
- color: var(--stl-ui-foreground);
171
- font-feature-settings:
172
- 'ss01' on,
173
- 'ss03' on,
174
- 'ss04' on,
175
- 'ss06' on;
176
-
177
- /* Code/Regular */
178
- font-family: var(--stl-ui-typography-font-mono);
179
- font-size: var(--stl-ui-typography-text-body-sm);
180
- font-style: normal;
181
- font-weight: 400;
182
- line-height: 150%; /* 21px */
183
-
184
- padding: 0 4px;
185
- background-color: oklch(from var(--stl-ui-foreground) l c h / 0.1);
186
- border-radius: var(--stl-ui-layout-border-radius-xs);
187
- }
145
+ ol,
146
+ ul {
147
+ &:not(.stl-ui-not-prose *) {
148
+ padding-left: 26px;
149
+ }
150
+ }
188
151
 
189
- /* Escape hatch for non-prose content */
190
- .stl-ui-not-prose * {
191
- all: revert-layer;
192
- }
152
+ ol,
153
+ ul,
154
+ aside,
155
+ img,
156
+ svg,
157
+ figure,
158
+ details {
159
+ &:not(.stl-ui-not-prose *) {
160
+ margin-top: 16px;
193
161
  }
194
162
  }
163
+
164
+ :where(:not(pre) > code):not(.stl-ui-not-prose *) {
165
+ color: var(--stl-ui-foreground);
166
+ font-feature-settings:
167
+ 'ss01' on,
168
+ 'ss03' on,
169
+ 'ss04' on,
170
+ 'ss06' on;
171
+
172
+ /* Code/Regular */
173
+ font-family: var(--stl-ui-typography-font-mono);
174
+ font-size: var(--stl-ui-typography-text-body-sm);
175
+ font-style: normal;
176
+ font-weight: 400;
177
+ line-height: 150%; /* 21px */
178
+
179
+ padding: 0 4px;
180
+ background-color: oklch(from var(--stl-ui-foreground) l c h / 0.1);
181
+ border-radius: var(--stl-ui-layout-border-radius-xs);
182
+ }
195
183
  }
package/src/styles.css CHANGED
@@ -6,5 +6,6 @@
6
6
  @import './styles/starlight-compat.css';
7
7
 
8
8
  @import './components/button.css';
9
+ @import './components/dropdown-button.css';
9
10
  @import './components/callout.css';
10
- @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
8
  "jsx": "react-jsx",
9
- "esModuleInterop": true,
10
- "moduleResolution": "Node",
11
- "skipLibCheck": true,
12
- "strict": true
13
9
  },
14
10
  "include": ["src"]
15
11
  }
@@ -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,124 +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.components {
15
- .stl-ui-prose {
16
- details {
17
- --stl-ui-details-padding: 12px;
18
- --stl-ui-details-content-padding-bottom: 4px;
19
- --stl-ui-details-marker-size: 1em;
20
- --stl-ui-details-marker-margin: calc((1lh - var(--stl-ui-details-marker-size)) / 2);
21
- --stl-ui-details-row-gap: 8px;
22
- --stl-ui-details-summary-column-gap: 8px;
23
- --stl-ui-details-border-radius: var(--stl-ui-layout-border-radius);
24
- /* left inset to make content line up with summary content (after chevron) */
25
- --stl-ui--internal--details-padding-start: calc(
26
- var(--stl-ui-details-padding)
27
- + var(--stl-ui-details-marker-size)
28
- + var(--stl-ui-details-marker-margin) * 2
29
- + var(--stl-ui-details-summary-column-gap)
30
- );
31
-
32
- background-color: var(--stl-ui-card-background);
33
- border: 1px solid var(--stl-ui-border);
34
- border-radius: var(--stl-ui-details-border-radius);
35
- font-size: var(--stl-ui-typography-text-body);
36
-
37
- padding: var(--stl-ui-details-padding);
38
- /* indent content to line up with left edge of summary content */
39
- padding-inline-start: var(--stl-ui--internal--details-padding-start);
40
-
41
- summary {
42
- display: block;
43
- list-style: none;
44
-
45
- /* summary extends to the edges of the element in order to increase click target */
46
- padding: var(--stl-ui-details-padding);
47
- padding-inline-start: var(--stl-ui--internal--details-padding-start);
48
- margin: calc(-1 * var(--stl-ui-details-padding));
49
- margin-inline-start: calc(-1 * var(--stl-ui--internal--details-padding-start));
50
-
51
- cursor: pointer;
52
- font-weight: 500;
53
-
54
- border-radius: var(--stl-ui-details-border-radius);
55
-
56
- &::before {
57
- content: '';
58
- width: var(--stl-ui-details-marker-size);
59
- height: var(--stl-ui-details-marker-size);
60
- margin: var(--stl-ui-details-marker-margin);
61
- background-color: currentColor;
62
- display: block;
63
- position: absolute;
64
- --stl-ui-details--internal--marker-width: calc(var(--stl-ui-details-marker-size) + var(--stl-ui-details-marker-margin) * 2);
65
- --stl-ui-details--internal--summary-marker-transform: translateX(calc(-1 * var(--stl-ui-details--internal--marker-width) - var(--stl-ui-details-summary-column-gap)));
66
- transform: var(--stl-ui-details--internal--summary-marker-transform);
67
-
68
- --lucide-chevron-right: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQtaWNvbiBsdWNpZGUtY2hldnJvbi1yaWdodCI+PHBhdGggZD0ibTkgMTggNi02LTYtNiIvPjwvc3ZnPg==');
69
- mask-image: var(--lucide-chevron-right);
70
- mask-size: contain;
71
- mask-repeat: no-repeat;
72
-
73
- transition: transform 0.1s ease-out;
74
- }
75
-
76
- & > :first-child {
77
- margin-top: 0;
78
- }
79
- }
80
-
81
- &[open] {
82
- padding-bottom: calc(var(--stl-ui-details-padding) + var(--stl-ui-details-content-padding-bottom));
83
-
84
- summary {
85
- /* padding-bottom shouldn’t extend beyond the row gap while open, i.e. we shouldn’t be negative-margin-placing content overlapping summary */
86
- --stl-ui--internal--summary-padding-bottom: min(var(--stl-ui-details-padding), var(--stl-ui-details-row-gap));
87
- padding-bottom: var(--stl-ui--internal--summary-padding-bottom);
88
- margin-bottom: calc(var(--stl-ui-details-row-gap) - var(--stl-ui--internal--summary-padding-bottom));
89
- border-bottom-left-radius: 0;
90
- border-bottom-right-radius: 0;
91
-
92
- &::before {
93
- transform: var(--stl-ui-details--internal--summary-marker-transform) rotate(90deg);
94
- }
95
- }
96
- }
97
-
98
- summary + * {
99
- margin-top: 0;
100
- }
101
- }
102
- }
103
-
104
- .stl-ui-details-group {
105
- & > details:has(+ details) {
106
- border-bottom-left-radius: 0;
107
- border-bottom-right-radius: 0;
108
- summary {
109
- border-bottom-left-radius: 0;
110
- border-bottom-right-radius: 0;
111
- }
112
- }
113
- & > details + details {
114
- margin-top: 0;
115
- border-top: 0;
116
- border-top-left-radius: 0;
117
- border-top-right-radius: 0;
118
- summary {
119
- border-top-left-radius: 0;
120
- border-top-right-radius: 0;
121
- }
122
- }
123
- }
124
- }