@stainless-api/ui-primitives 0.1.0-beta.1 → 0.1.0-beta.10

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,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,143 @@
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
- }
59
-
60
- p {
61
- margin-top: 16px;
62
- }
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
+ }
63
45
 
64
- p,
65
- li {
66
- color: var(--stl-ui-foreground-secondary);
67
- }
46
+ .stl-ui-prose {
47
+ :where(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
+ }
68
55
 
69
- strong {
70
- color: var(--stl-ui-foreground);
71
- }
56
+ :where(p, li) {
57
+ &:not(.stl-ui-not-prose *) {
58
+ color: var(--stl-ui-foreground-secondary);
59
+ }
60
+ }
72
61
 
73
- aside {
74
- p,
75
- li {
76
- color: var(--stl-ui-foreground);
77
- }
78
- }
62
+ :where(strong):not(.stl-ui-not-prose *) {
63
+ color: var(--stl-ui-foreground);
64
+ }
79
65
 
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
- }
66
+ :where(aside):not(.stl-ui-not-prose *) {
67
+ color: var(--stl-ui-foreground);
68
+ }
92
69
 
93
- h1,
94
- h2,
95
- h3,
96
- h4,
97
- h5,
98
- h6 {
70
+ h1,
71
+ h2,
72
+ h3,
73
+ h4,
74
+ h5,
75
+ h6 {
76
+ &:not(.stl-ui-not-prose *) {
77
+ &,
78
+ * {
99
79
  color: var(--stl-ui-foreground);
100
80
  font-weight: 500;
101
81
  line-height: var(--stl-ui-typography-line-height-headings);
102
82
  }
83
+ }
84
+ }
103
85
 
104
- h1 {
105
- /* Heading 1/Medium */
106
- font-size: var(--stl-ui-typography-text-h1);
107
- letter-spacing: -0.03em;
86
+ h1:not(.stl-ui-not-prose *) {
87
+ /* Heading 1/Medium */
88
+ font-size: var(--stl-ui-typography-text-h1);
89
+ letter-spacing: -0.03em;
108
90
 
109
- margin-top: 64px;
110
- }
91
+ margin-top: 64px;
92
+ }
111
93
 
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
- }
94
+ h2:not(.stl-ui-not-prose *) {
95
+ /* Heading 2/Medium */
96
+ font-size: var(--stl-ui-typography-text-h2);
97
+ letter-spacing: -0.03em;
118
98
 
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
- }
99
+ margin-top: 48px;
100
+ }
125
101
 
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
- }
102
+ h3:not(.stl-ui-not-prose *) {
103
+ /* Heading 3/Medium */
104
+ font-size: var(--stl-ui-typography-text-h3);
105
+ letter-spacing: -0.02em;
106
+ margin-top: 40px;
107
+ }
132
108
 
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
- }
109
+ h4:not(.stl-ui-not-prose *) {
110
+ /* Heading 4/Medium */
111
+ font-size: var(--stl-ui-typography-text-h4);
112
+ letter-spacing: -0.02em;
113
+ margin-top: 32px;
114
+ }
139
115
 
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
- }
116
+ h5:not(.stl-ui-not-prose *) {
117
+ /* Heading 5/Medium */
118
+ font-size: var(--stl-ui-typography-text-h5);
119
+ letter-spacing: -0.02em;
120
+ margin-top: 24px;
121
+ }
157
122
 
158
- ol,
159
- ul {
160
- padding-left: 26px;
161
- }
123
+ li:not(.stl-ui-not-prose *) {
124
+ &:not(:last-child) {
125
+ margin-bottom: 8px;
126
+ }
162
127
 
163
- ol,
164
- ul,
165
- aside,
166
- img,
167
- svg,
168
- figure,
169
- details {
170
- margin-top: 16px;
128
+ h1,
129
+ h2,
130
+ h3,
131
+ h4,
132
+ h5,
133
+ p,
134
+ a {
135
+ &:first-child {
136
+ display: inline;
171
137
  }
138
+ }
139
+ }
172
140
 
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
- }
141
+ :where(ol, ul) {
142
+ &:not(.stl-ui-not-prose *) {
143
+ padding-left: 26px;
144
+ }
145
+ }
192
146
 
193
- /* Escape hatch for non-prose content */
194
- .stl-ui-not-prose * {
195
- all: revert-layer;
196
- }
147
+ :where(ol, ul, aside, img, figure, details) {
148
+ &:not(.stl-ui-not-prose *) {
149
+ margin-top: 16px;
197
150
  }
198
151
  }
152
+
153
+ :where(:not(pre) > code):not(.stl-ui-not-prose *) {
154
+ color: var(--stl-ui-foreground);
155
+ font-feature-settings:
156
+ 'ss01' on,
157
+ 'ss03' on,
158
+ 'ss04' on,
159
+ 'ss06' on;
160
+
161
+ /* Code/Regular */
162
+ font-family: var(--stl-ui-typography-font-mono);
163
+ font-size: var(--stl-ui-typography-text-body-sm);
164
+ font-style: normal;
165
+ font-weight: 400;
166
+ line-height: 150%; /* 21px */
167
+
168
+ padding: 0 4px;
169
+ background-color: oklch(from var(--stl-ui-foreground) l c h / 0.1);
170
+ border-radius: var(--stl-ui-layout-border-radius-xs);
171
+ }
199
172
  }
package/src/styles.css CHANGED
@@ -8,4 +8,4 @@
8
8
  @import './components/button.css';
9
9
  @import './components/dropdown-button.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
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,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
- }