@a-type/ui 1.8.9 → 1.8.11
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.
- package/dist/cjs/colorMode.d.ts +1 -0
- package/dist/cjs/colorMode.js +10 -0
- package/dist/cjs/colorMode.js.map +1 -1
- package/dist/cjs/components/box/Box.js +3 -3
- package/dist/cjs/components/box/Box.js.map +1 -1
- package/dist/cjs/components/card/Card.d.ts +1 -1
- package/dist/cjs/components/navBar/NavBar.js +1 -1
- package/dist/cjs/components/scrollArea/ScrollArea.js +8 -11
- package/dist/cjs/components/scrollArea/ScrollArea.js.map +1 -1
- package/dist/cjs/components/typography/typography.js +4 -4
- package/dist/cjs/components/typography/typography.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useOverrideTheme.d.ts +2 -0
- package/dist/cjs/hooks/useOverrideTheme.js +17 -0
- package/dist/cjs/hooks/useOverrideTheme.js.map +1 -0
- package/dist/cjs/themes.stories.d.ts +2 -0
- package/dist/cjs/themes.stories.js +17 -3
- package/dist/cjs/themes.stories.js.map +1 -1
- package/dist/cjs/uno.preset.js +187 -140
- package/dist/cjs/uno.preset.js.map +1 -1
- package/dist/css/main.css +674 -129
- package/dist/esm/colorMode.d.ts +1 -0
- package/dist/esm/colorMode.js +9 -0
- package/dist/esm/colorMode.js.map +1 -1
- package/dist/esm/components/box/Box.js +3 -3
- package/dist/esm/components/box/Box.js.map +1 -1
- package/dist/esm/components/card/Card.d.ts +1 -1
- package/dist/esm/components/navBar/NavBar.js +1 -1
- package/dist/esm/components/scrollArea/ScrollArea.js +8 -11
- package/dist/esm/components/scrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/components/typography/typography.js +4 -4
- package/dist/esm/components/typography/typography.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useOverrideTheme.d.ts +2 -0
- package/dist/esm/hooks/useOverrideTheme.js +14 -0
- package/dist/esm/hooks/useOverrideTheme.js.map +1 -0
- package/dist/esm/themes.stories.d.ts +2 -0
- package/dist/esm/themes.stories.js +17 -3
- package/dist/esm/themes.stories.js.map +1 -1
- package/dist/esm/uno.preset.js +187 -140
- package/dist/esm/uno.preset.js.map +1 -1
- package/package.json +1 -1
- package/src/colorMode.ts +10 -0
- package/src/components/box/Box.tsx +3 -3
- package/src/components/navBar/NavBar.tsx +1 -1
- package/src/components/scrollArea/ScrollArea.tsx +8 -19
- package/src/components/typography/typography.tsx +4 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useOverrideTheme.ts +14 -0
- package/src/themes.stories.tsx +108 -32
- package/src/uno.preset.ts +227 -140
|
@@ -4,22 +4,22 @@ const baseHeadingClass = 'layer-components:my-0';
|
|
|
4
4
|
export const H1 = withClassName(
|
|
5
5
|
'h1',
|
|
6
6
|
baseHeadingClass,
|
|
7
|
-
'layer-components:(font-title text-2xl font-semibold)',
|
|
7
|
+
'layer-components:(font-title text-2xl font-semibold color-inherit color-darken-1)',
|
|
8
8
|
);
|
|
9
9
|
export const H2 = withClassName(
|
|
10
10
|
'h2',
|
|
11
11
|
baseHeadingClass,
|
|
12
|
-
'layer-components:(text-lg font-title font-bold color-
|
|
12
|
+
'layer-components:(text-lg font-title font-bold color-inherit color-lighten-2)',
|
|
13
13
|
);
|
|
14
14
|
export const H3 = withClassName(
|
|
15
15
|
'h3',
|
|
16
16
|
baseHeadingClass,
|
|
17
|
-
'layer-components:(font-title text-md font-500 color-
|
|
17
|
+
'layer-components:(font-title text-md font-500 color-inherit color-lighten-4)',
|
|
18
18
|
);
|
|
19
19
|
export const H4 = withClassName(
|
|
20
20
|
'h4',
|
|
21
21
|
baseHeadingClass,
|
|
22
|
-
'layer-components:(text-xs uppercase color-
|
|
22
|
+
'layer-components:(text-xs uppercase color-inherit color-lighten-6)',
|
|
23
23
|
);
|
|
24
24
|
export const H5 = withClassName('h5', baseHeadingClass);
|
|
25
25
|
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './useAnimationFrame.js';
|
|
|
2
2
|
export * from './useLongPress.js';
|
|
3
3
|
export * from './useMergedRef.js';
|
|
4
4
|
export * from './useOnUnmount.js';
|
|
5
|
+
export * from './useOverrideTheme.js';
|
|
5
6
|
export * from './useSize.js';
|
|
6
7
|
export * from './useStableCallback.js';
|
|
7
8
|
export * from './useTitleBarColor.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { ThemeName } from '../components/index.js';
|
|
3
|
+
|
|
4
|
+
export function useOverrideTheme(theme: ThemeName | null | undefined) {
|
|
5
|
+
useLayoutEffect(() => {
|
|
6
|
+
if (!theme) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
document.body.classList.add(`theme-override-${theme}`);
|
|
10
|
+
return () => {
|
|
11
|
+
document.body.classList.remove(`theme-override-${theme}`);
|
|
12
|
+
};
|
|
13
|
+
}, [theme]);
|
|
14
|
+
}
|
package/src/themes.stories.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import { ActionBar, ActionButton } from './components/actions/index.js';
|
|
4
5
|
import { Button } from './components/button/index.js';
|
|
5
6
|
import { Card } from './components/card/index.js';
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
AvatarList,
|
|
9
10
|
Box,
|
|
10
11
|
Checkbox,
|
|
12
|
+
ColorPicker,
|
|
11
13
|
ContextMenu,
|
|
12
14
|
DateRangePicker,
|
|
13
15
|
Dialog,
|
|
@@ -30,13 +32,17 @@ import {
|
|
|
30
32
|
PageNav,
|
|
31
33
|
PageRoot,
|
|
32
34
|
Progress,
|
|
35
|
+
Provider,
|
|
36
|
+
ScrollArea,
|
|
33
37
|
TextSkeleton,
|
|
38
|
+
ThemeName,
|
|
34
39
|
ToggleGroup,
|
|
35
40
|
Tooltip,
|
|
36
41
|
} from './components/index.js';
|
|
37
42
|
import { Input } from './components/input/index.js';
|
|
38
43
|
import { Tabs } from './components/tabs/tabs.js';
|
|
39
44
|
import { TextArea } from './components/textArea/index.js';
|
|
45
|
+
import { useOverrideTheme } from './hooks/useOverrideTheme.js';
|
|
40
46
|
|
|
41
47
|
const meta = {
|
|
42
48
|
title: 'themes',
|
|
@@ -55,9 +61,9 @@ function DemoUI({ className }: { className?: string }) {
|
|
|
55
61
|
const nextWeek = new Date();
|
|
56
62
|
nextWeek.setDate(nextWeek.getDate() + 7);
|
|
57
63
|
return (
|
|
58
|
-
<PageRoot>
|
|
64
|
+
<PageRoot className={clsx('flex-1', className)}>
|
|
59
65
|
<PageContent>
|
|
60
|
-
<div className={clsx('grid gap-2 grid-cols-2'
|
|
66
|
+
<div className={clsx('grid gap-2 grid-cols-2')}>
|
|
61
67
|
<Box gap wrap p>
|
|
62
68
|
<Button color="primary">Primary</Button>
|
|
63
69
|
<Button color="accent">Accent</Button>
|
|
@@ -85,32 +91,50 @@ function DemoUI({ className }: { className?: string }) {
|
|
|
85
91
|
<ToggleGroup.Item value="2">Toggle 2</ToggleGroup.Item>
|
|
86
92
|
</ToggleGroup>
|
|
87
93
|
</Box>
|
|
88
|
-
<Box layout="start center" d="col" gap p>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
<Box layout="start center" d="col" gap p className="max-h-200px">
|
|
95
|
+
<ScrollArea>
|
|
96
|
+
<H1>Heading 1</H1>
|
|
97
|
+
<H2>Heading 2</H2>
|
|
98
|
+
<H3>Heading 3</H3>
|
|
99
|
+
<H4>Heading 4</H4>
|
|
100
|
+
<P>
|
|
101
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
102
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
103
|
+
</P>
|
|
104
|
+
<TextSkeleton maxLength={30} />
|
|
105
|
+
<TextSkeleton maxLength={10} />
|
|
106
|
+
</ScrollArea>
|
|
107
|
+
</Box>
|
|
108
|
+
<Box d="col" gap>
|
|
109
|
+
<Card>
|
|
110
|
+
<Card.Main onClick={() => {}}>
|
|
111
|
+
<Card.Title>Card Title</Card.Title>
|
|
112
|
+
<Card.Content>Card Content</Card.Content>
|
|
113
|
+
</Card.Main>
|
|
114
|
+
<Card.Footer>
|
|
115
|
+
<Card.Actions>
|
|
116
|
+
<Button size="small">Action 1</Button>
|
|
117
|
+
<Button size="icon-small" color="ghost">
|
|
118
|
+
<Icon name="placeholder" />
|
|
119
|
+
</Button>
|
|
120
|
+
</Card.Actions>
|
|
121
|
+
</Card.Footer>
|
|
122
|
+
</Card>
|
|
123
|
+
<Card>
|
|
124
|
+
<Card.Main compact onClick={() => {}}>
|
|
125
|
+
<Card.Title>Card Title</Card.Title>
|
|
126
|
+
<Card.Content>Card Content</Card.Content>
|
|
127
|
+
</Card.Main>
|
|
128
|
+
<Card.Footer>
|
|
129
|
+
<Card.Actions>
|
|
130
|
+
<Button size="small">Action 1</Button>
|
|
131
|
+
<Button size="icon-small" color="ghost">
|
|
132
|
+
<Icon name="placeholder" />
|
|
133
|
+
</Button>
|
|
134
|
+
</Card.Actions>
|
|
135
|
+
</Card.Footer>
|
|
136
|
+
</Card>
|
|
99
137
|
</Box>
|
|
100
|
-
<Card>
|
|
101
|
-
<Card.Main onClick={() => {}}>
|
|
102
|
-
<Card.Title>Card Title</Card.Title>
|
|
103
|
-
<Card.Content>Card Content</Card.Content>
|
|
104
|
-
</Card.Main>
|
|
105
|
-
<Card.Footer>
|
|
106
|
-
<Card.Actions>
|
|
107
|
-
<Button size="small">Action 1</Button>
|
|
108
|
-
<Button size="icon-small" color="ghost">
|
|
109
|
-
<Icon name="placeholder" />
|
|
110
|
-
</Button>
|
|
111
|
-
</Card.Actions>
|
|
112
|
-
</Card.Footer>
|
|
113
|
-
</Card>
|
|
114
138
|
<Tabs defaultValue="tab1">
|
|
115
139
|
<Tabs.List>
|
|
116
140
|
<Tabs.Trigger value="tab1">Tab 1</Tabs.Trigger>
|
|
@@ -159,6 +183,7 @@ function DemoUI({ className }: { className?: string }) {
|
|
|
159
183
|
<Dialog.Description>Im a dialog</Dialog.Description>
|
|
160
184
|
<Dialog.Actions>
|
|
161
185
|
<Dialog.Close>Close</Dialog.Close>
|
|
186
|
+
<Button color="primary">Action</Button>
|
|
162
187
|
</Dialog.Actions>
|
|
163
188
|
</Dialog.Content>
|
|
164
189
|
</Dialog>
|
|
@@ -171,17 +196,40 @@ function DemoUI({ className }: { className?: string }) {
|
|
|
171
196
|
onChange={() => {}}
|
|
172
197
|
/>
|
|
173
198
|
<Progress value={50} className="m-auto" />
|
|
174
|
-
<Box surface="primary" p gap>
|
|
199
|
+
<Box surface="primary" p gap d="col">
|
|
200
|
+
<H1>Primary surface</H1>
|
|
201
|
+
<H2>Primary surface</H2>
|
|
202
|
+
<H3>Primary surface</H3>
|
|
175
203
|
<div>Primary surface</div>
|
|
176
204
|
<Button color="ghost">Ghost</Button>
|
|
177
205
|
</Box>
|
|
178
|
-
<Box surface="accent" p>
|
|
179
|
-
|
|
206
|
+
<Box surface="accent" p d="col" className="max-h-200px">
|
|
207
|
+
<ScrollArea>
|
|
208
|
+
<H2>Accent surface</H2>
|
|
209
|
+
<H3>Accent surface</H3>
|
|
210
|
+
<P>
|
|
211
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
212
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
213
|
+
</P>
|
|
214
|
+
<P>
|
|
215
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
216
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
217
|
+
</P>
|
|
218
|
+
<P>
|
|
219
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
220
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
221
|
+
</P>
|
|
222
|
+
<TextSkeleton maxLength={30} />
|
|
223
|
+
<TextSkeleton maxLength={10} />
|
|
224
|
+
Accent surface
|
|
225
|
+
</ScrollArea>
|
|
180
226
|
</Box>
|
|
181
|
-
<Box surface="default" p>
|
|
227
|
+
<Box surface="default" p d="col">
|
|
182
228
|
Default surface
|
|
183
229
|
</Box>
|
|
184
|
-
<Box surface="attention" p>
|
|
230
|
+
<Box surface="attention" p d="col">
|
|
231
|
+
<H2>Attention surface</H2>
|
|
232
|
+
<H3>Attention surface</H3>
|
|
185
233
|
Attention surface
|
|
186
234
|
</Box>
|
|
187
235
|
<Box>
|
|
@@ -247,3 +295,31 @@ export const Default: Story = {
|
|
|
247
295
|
return <DemoUI />;
|
|
248
296
|
},
|
|
249
297
|
};
|
|
298
|
+
|
|
299
|
+
export const Nesting: Story = {
|
|
300
|
+
render() {
|
|
301
|
+
return (
|
|
302
|
+
<Box d="col" p gap>
|
|
303
|
+
<Box d="row" gap surface="primary">
|
|
304
|
+
<Button color="primary">Root theme</Button>
|
|
305
|
+
</Box>
|
|
306
|
+
<DemoUI className="theme-eggplant override-dark flex-1" />
|
|
307
|
+
</Box>
|
|
308
|
+
);
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export const Override: Story = {
|
|
313
|
+
render() {
|
|
314
|
+
const [theme, setTheme] = useState<ThemeName | null>(null);
|
|
315
|
+
useOverrideTheme(theme);
|
|
316
|
+
return (
|
|
317
|
+
<Provider>
|
|
318
|
+
<Box d="col" p gap>
|
|
319
|
+
<ColorPicker value={theme} onChange={setTheme} />
|
|
320
|
+
<DemoUI />
|
|
321
|
+
</Box>
|
|
322
|
+
</Provider>
|
|
323
|
+
);
|
|
324
|
+
},
|
|
325
|
+
};
|