tinywidgets 0.0.11 → 1.0.0
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/.eslintrc.json +2 -1
- package/bun.lockb +0 -0
- package/package.json +19 -14
- package/src/common/functions.tsx +54 -0
- package/src/components/App/index.css.ts +81 -0
- package/src/components/App/index.tsx +177 -0
- package/src/components/Button/index.css.ts +66 -0
- package/src/components/Button/index.tsx +206 -0
- package/src/components/Card/index.css.ts +12 -0
- package/src/components/Card/index.tsx +34 -0
- package/src/components/Code/index.css.ts +49 -0
- package/src/components/Code/index.tsx +89 -0
- package/src/components/Collapsible/index.css.ts +37 -0
- package/src/components/Collapsible/index.tsx +132 -0
- package/src/{Detail → components/Detail}/index.css.ts +3 -3
- package/src/components/Detail/index.tsx +48 -0
- package/src/{Hr → components/Hr}/index.css.ts +3 -2
- package/src/components/Hr/index.tsx +26 -0
- package/src/components/Image/index.css.ts +38 -0
- package/src/components/Image/index.tsx +85 -0
- package/src/components/Metric/index.tsx +59 -0
- package/src/components/Row/index.css.ts +30 -0
- package/src/components/Row/index.tsx +104 -0
- package/src/components/Summary/index.css.ts +16 -0
- package/src/components/Summary/index.tsx +59 -0
- package/src/{Tag → components/Tag}/index.css.ts +9 -6
- package/src/components/Tag/index.tsx +73 -0
- package/src/css/code.css.ts +112 -0
- package/src/css/colors.css.ts +124 -0
- package/src/css/dimensions.css.ts +67 -0
- package/src/css/global.css.ts +11 -0
- package/src/css/screens.ts +15 -0
- package/src/index.css.ts +4 -137
- package/src/index.ts +16 -24
- package/src/stores/LocalStore.tsx +52 -19
- package/src/stores/RouteStore.tsx +103 -0
- package/src/stores/SessionStore.tsx +40 -25
- package/src/stores/common.ts +6 -0
- package/tsconfig.json +19 -0
- package/.prettierrc +0 -5
- package/index.css.ts +0 -1
- package/index.ts +0 -12
- package/src/App/index.tsx +0 -18
- package/src/Avatar/index.css.ts +0 -17
- package/src/Avatar/index.tsx +0 -25
- package/src/Axis/index.css.ts +0 -19
- package/src/Axis/index.tsx +0 -36
- package/src/Button/index.css.ts +0 -57
- package/src/Button/index.tsx +0 -63
- package/src/Card/index.css.ts +0 -9
- package/src/Card/index.tsx +0 -13
- package/src/Collapsible/index.css.ts +0 -34
- package/src/Collapsible/index.tsx +0 -75
- package/src/Detail/index.tsx +0 -26
- package/src/Hr/index.tsx +0 -8
- package/src/Metric/index.tsx +0 -26
- package/src/Summary/index.css.ts +0 -17
- package/src/Summary/index.tsx +0 -32
- package/src/Tag/index.tsx +0 -26
- package/src/Ui/Header/DarkButton/index.tsx +0 -19
- package/src/Ui/Header/SideNav/index.css.ts +0 -23
- package/src/Ui/Header/SideNav/index.tsx +0 -14
- package/src/Ui/Header/SideNavButton/index.css.ts +0 -4
- package/src/Ui/Header/SideNavButton/index.tsx +0 -19
- package/src/Ui/Header/Title/index.css.ts +0 -10
- package/src/Ui/Header/Title/index.tsx +0 -9
- package/src/Ui/Header/TopNav/index.css.ts +0 -9
- package/src/Ui/Header/TopNav/index.tsx +0 -18
- package/src/Ui/Header/index.css.ts +0 -18
- package/src/Ui/Header/index.tsx +0 -32
- package/src/Ui/Main/Article/index.css.ts +0 -13
- package/src/Ui/Main/Article/index.tsx +0 -9
- package/src/Ui/Main/Footer/index.css.ts +0 -12
- package/src/Ui/Main/Footer/index.tsx +0 -9
- package/src/Ui/Main/index.css.ts +0 -16
- package/src/Ui/Main/index.tsx +0 -24
- package/src/Ui/index.css.ts +0 -9
- package/src/Ui/index.tsx +0 -50
- package/utils.ts +0 -1
- /package/src/{Metric → components/Metric}/index.css.ts +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {row, rowVariants} from './index.css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type {ReactNode} from 'react';
|
|
4
|
+
import {classNames} from '../../common/functions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `Row` component displays a row of 'cell' components, with a number of
|
|
8
|
+
* common variants representing the relative sizes of those cells within it.
|
|
9
|
+
*
|
|
10
|
+
* @param props The props for the component.
|
|
11
|
+
* @returns The Row component.
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Row>
|
|
15
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>1</div>
|
|
16
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>1</div>
|
|
17
|
+
* </Row>
|
|
18
|
+
* ```
|
|
19
|
+
* This example shows the default `1|1` variant of the Row component.
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <Row variant="1|2">
|
|
23
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>1</div>
|
|
24
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>2</div>
|
|
25
|
+
* </Row>
|
|
26
|
+
* ```
|
|
27
|
+
* This example shows the `1|2` variant of the Row component.
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <Row variant="2|1">
|
|
31
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>2</div>
|
|
32
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>1</div>
|
|
33
|
+
* </Row>
|
|
34
|
+
* ```
|
|
35
|
+
* This example shows the `2|1` variant of the Row component.
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Row variant="1|1|1">
|
|
39
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>1</div>
|
|
40
|
+
* <div style={{background: 'oklch(50% 0.11 120)'}}>1</div>
|
|
41
|
+
* <div style={{background: 'oklch(50% 0.11 240)'}}>1</div>
|
|
42
|
+
* </Row>
|
|
43
|
+
* ```
|
|
44
|
+
* This example shows the `1|1|1` variant of the Row component.
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Row variant="1|3">
|
|
48
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>1</div>
|
|
49
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>3</div>
|
|
50
|
+
* </Row>
|
|
51
|
+
* ```
|
|
52
|
+
* This example shows the `1|3` variant of the Row component.
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <Row variant="3|1">
|
|
56
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>3</div>
|
|
57
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>1</div>
|
|
58
|
+
* </Row>
|
|
59
|
+
* ```
|
|
60
|
+
* This example shows the `3|1` variant of the Row component.
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <Row variant="1|1|1|1">
|
|
64
|
+
* <div style={{background: 'oklch(50% 0.11 0)'}}>1</div>
|
|
65
|
+
* <div style={{background: 'oklch(50% 0.11 90)'}}>1</div>
|
|
66
|
+
* <div style={{background: 'oklch(50% 0.11 180)'}}>1</div>
|
|
67
|
+
* <div style={{background: 'oklch(50% 0.11 270)'}}>1</div>
|
|
68
|
+
* </Row>
|
|
69
|
+
* ```
|
|
70
|
+
* This example shows the `1|1|1|1` variant of the Row component.
|
|
71
|
+
* @icon Lucide.Columns3
|
|
72
|
+
*/
|
|
73
|
+
export const Row = ({
|
|
74
|
+
variant = '1|1',
|
|
75
|
+
className,
|
|
76
|
+
children,
|
|
77
|
+
}: {
|
|
78
|
+
/**
|
|
79
|
+
* A variant of the row, representing the relative 'cell' sizes within it, one
|
|
80
|
+
* of:
|
|
81
|
+
* - `1|1`
|
|
82
|
+
* - `1|2`
|
|
83
|
+
* - `2|1`
|
|
84
|
+
* - `1|1|1`
|
|
85
|
+
* - `1|3`
|
|
86
|
+
* - `3|1`
|
|
87
|
+
* - `1|1|1|1`
|
|
88
|
+
*/
|
|
89
|
+
readonly variant?: keyof typeof rowVariants;
|
|
90
|
+
/**
|
|
91
|
+
* An extra CSS class name for the component.
|
|
92
|
+
*/
|
|
93
|
+
readonly className?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The children of the component, each occupying one 'cell'.
|
|
96
|
+
*/
|
|
97
|
+
readonly children: ReactNode;
|
|
98
|
+
}) => {
|
|
99
|
+
return (
|
|
100
|
+
<div className={classNames(row, rowVariants[variant], className)}>
|
|
101
|
+
{children}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {dimensions} from '../../css/dimensions.css.ts';
|
|
2
|
+
import {notLarge} from '../../common/functions.tsx';
|
|
3
|
+
import {style} from '@vanilla-extract/css';
|
|
4
|
+
|
|
5
|
+
export const summary = style({
|
|
6
|
+
display: 'grid',
|
|
7
|
+
width: '100%',
|
|
8
|
+
gap: dimensions.padding,
|
|
9
|
+
gridTemplateColumns: `6rem 1fr`,
|
|
10
|
+
...notLarge({gridTemplateColumns: '1fr'}),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const image = style({
|
|
14
|
+
height: '6rem',
|
|
15
|
+
width: '6rem',
|
|
16
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {ComponentType, ReactNode} from 'react';
|
|
2
|
+
import {image, summary} from './index.css';
|
|
3
|
+
import {Image} from '../Image';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import {classNames} from '../../common/functions';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The `Summary` component displays an image on the left, and other content
|
|
9
|
+
* (probably text) on the right.
|
|
10
|
+
*
|
|
11
|
+
* @param props The props for the component.
|
|
12
|
+
* @returns The Summary component.
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Summary src="/favicon.svg">
|
|
16
|
+
* <h2>TinyWidgets</h2>
|
|
17
|
+
* <p>Widgets for the modern web.</p>
|
|
18
|
+
* </Summary>
|
|
19
|
+
* ```
|
|
20
|
+
* This example shows a default Summary component.
|
|
21
|
+
* @icon Lucide.LayoutList
|
|
22
|
+
*/
|
|
23
|
+
export const Summary = ({
|
|
24
|
+
src,
|
|
25
|
+
icon: Icon,
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
}: {
|
|
29
|
+
/**
|
|
30
|
+
* An optional component which renders an icon for the summary, and which
|
|
31
|
+
* must accept a className prop.
|
|
32
|
+
*/
|
|
33
|
+
readonly icon?: ComponentType<{className?: string}>;
|
|
34
|
+
/**
|
|
35
|
+
* The source of the image, which used if the `icon` prop is not present.
|
|
36
|
+
*/
|
|
37
|
+
readonly src?: string;
|
|
38
|
+
/**
|
|
39
|
+
* An extra CSS class name for the component.
|
|
40
|
+
*/
|
|
41
|
+
readonly className?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The children of the component, shown to the right of the image.
|
|
44
|
+
*/
|
|
45
|
+
readonly children: ReactNode;
|
|
46
|
+
}) => {
|
|
47
|
+
return (
|
|
48
|
+
<div className={classNames(summary, className)}>
|
|
49
|
+
{Icon ? (
|
|
50
|
+
<Icon className={image} />
|
|
51
|
+
) : src ? (
|
|
52
|
+
<Image src={src} className={image} />
|
|
53
|
+
) : (
|
|
54
|
+
<div />
|
|
55
|
+
)}
|
|
56
|
+
<div>{children}</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {style, styleVariants} from '@vanilla-extract/css';
|
|
2
|
-
import {
|
|
2
|
+
import {colors} from '../../css/colors.css';
|
|
3
3
|
|
|
4
4
|
export const tag = style({
|
|
5
|
+
display: 'flex',
|
|
6
|
+
alignItems: 'center',
|
|
5
7
|
fontSize: '0.625rem',
|
|
6
8
|
lineHeight: '0.625rem',
|
|
7
9
|
padding: '0.1rem 0.25rem',
|
|
@@ -10,14 +12,15 @@ export const tag = style({
|
|
|
10
12
|
flexShrink: 0,
|
|
11
13
|
});
|
|
12
14
|
|
|
13
|
-
export const
|
|
15
|
+
export const tagVariants = styleVariants({
|
|
14
16
|
default: {
|
|
15
|
-
backgroundColor:
|
|
16
|
-
color:
|
|
17
|
+
backgroundColor: colors.backgroundHover,
|
|
18
|
+
color: colors.foregroundDim,
|
|
17
19
|
},
|
|
18
20
|
accent: {
|
|
19
|
-
backgroundColor:
|
|
20
|
-
color:
|
|
21
|
+
backgroundColor: colors.accent,
|
|
22
|
+
color: colors.accentContrast,
|
|
23
|
+
boxShadow: colors.shadow,
|
|
21
24
|
},
|
|
22
25
|
});
|
|
23
26
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {ComponentType, ReactNode} from 'react';
|
|
2
|
+
import {classNames, renderComponentOrNode} from '../../common/functions';
|
|
3
|
+
import {tag, tagIcon, tagVariants} from './index.css';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `Tag` component displays a small rectangular tag, suitable for minimal
|
|
8
|
+
* amounts of metadata, such as a notification count.
|
|
9
|
+
*
|
|
10
|
+
* @param props The props for the component.
|
|
11
|
+
* @returns The Tag component.
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Tag
|
|
15
|
+
* title="TinyWidgets"
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
* This example shows the `default` variant of the Tag component.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Tag
|
|
22
|
+
* title="57"
|
|
23
|
+
* variant="accent"
|
|
24
|
+
* icon={Lucide.Bell}
|
|
25
|
+
* alt="You have lots of notifications"
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
* This example shows the `accent` variant of the Tag component with an icon.
|
|
29
|
+
* @icon Lucide.RectangleEllipsis
|
|
30
|
+
*/
|
|
31
|
+
export const Tag = ({
|
|
32
|
+
icon: Icon,
|
|
33
|
+
title,
|
|
34
|
+
variant = 'default',
|
|
35
|
+
alt,
|
|
36
|
+
className,
|
|
37
|
+
}: {
|
|
38
|
+
/**
|
|
39
|
+
* An optional component which renders an icon for the tag, and which
|
|
40
|
+
* must accept a className prop.
|
|
41
|
+
*/
|
|
42
|
+
readonly icon?: ComponentType<{className?: string}>;
|
|
43
|
+
/**
|
|
44
|
+
* An optional component, element, or string which renders the title of
|
|
45
|
+
* the tag.
|
|
46
|
+
*/
|
|
47
|
+
readonly title?: ComponentType | ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* A variant of the tag, one of:
|
|
50
|
+
* - `default`
|
|
51
|
+
* - `accent`
|
|
52
|
+
*/
|
|
53
|
+
readonly variant?: keyof typeof tagVariants;
|
|
54
|
+
/**
|
|
55
|
+
* Alternative text shown when the user hovers over the component.
|
|
56
|
+
*/
|
|
57
|
+
readonly alt?: string;
|
|
58
|
+
/**
|
|
59
|
+
* An extra CSS class name for the component.
|
|
60
|
+
*/
|
|
61
|
+
readonly className?: string;
|
|
62
|
+
}) => {
|
|
63
|
+
const icon = Icon ? <Icon className={tagIcon} /> : null;
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className={classNames(tag, tagVariants[variant], className)}
|
|
67
|
+
title={alt}
|
|
68
|
+
>
|
|
69
|
+
{icon}
|
|
70
|
+
{renderComponentOrNode(title)}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import {createTheme, createThemeContract} from '@vanilla-extract/css';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `code` object exposes the CSS variables used by TinyWidgets for coloring
|
|
6
|
+
* the code blocks, so that you can use them directly in your own application.
|
|
7
|
+
*
|
|
8
|
+
* The values are derived from the [prism-one-dark](https://github.com/PrismJS/prism-themes/blob/master/themes/prism-one-dark.css) and [prism-one-light](https://github.com/PrismJS/prism-themes/blob/master/themes/prism-one-light.css) themes. The full set of members is:
|
|
9
|
+
* - `mono-1`
|
|
10
|
+
* - `mono-2`
|
|
11
|
+
* - `mono-3`
|
|
12
|
+
* - `hue-1`
|
|
13
|
+
* - `hue-2`
|
|
14
|
+
* - `hue-3`
|
|
15
|
+
* - `hue-4`
|
|
16
|
+
* - `hue-5`
|
|
17
|
+
* - `hue-5-2`
|
|
18
|
+
* - `hue-6`
|
|
19
|
+
* - `hue-6-2`
|
|
20
|
+
* - `syntax-fg`
|
|
21
|
+
* - `syntax-bg`
|
|
22
|
+
* - `syntax-gutter`
|
|
23
|
+
* - `syntax-guide`
|
|
24
|
+
* - `syntax-accent`
|
|
25
|
+
*
|
|
26
|
+
* You can use these variables directly in React components that take style
|
|
27
|
+
* attributes, like this:
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <code style={{color: code['hue-2']}}>function</code>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* And if you are using Vanilla-Extract for your app's styles, use them in your
|
|
34
|
+
* style declarations like this:
|
|
35
|
+
*
|
|
36
|
+
* ```tsx
|
|
37
|
+
* export const functionStyle = style({color: code['hue-2']});
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <Card>
|
|
43
|
+
* <Code code={code['mono-1']} />
|
|
44
|
+
* <Hr />
|
|
45
|
+
* <Row variant="1|1|1">
|
|
46
|
+
* <code style={{color: code['hue-2']}}>function</code>
|
|
47
|
+
* <code style={{color: code['hue-3']}}>keyword</code>
|
|
48
|
+
* <code style={{color: code['hue-4']}}>string</code>
|
|
49
|
+
* </Row>
|
|
50
|
+
* </Card>
|
|
51
|
+
* ```
|
|
52
|
+
* This example shows one of the values within the `code` object, and then
|
|
53
|
+
* applies some of them to custom code components. Change the dark mode to see
|
|
54
|
+
* the colors respond.
|
|
55
|
+
* @icon Lucide.Palette
|
|
56
|
+
*/
|
|
57
|
+
export const code = createThemeContract({
|
|
58
|
+
'mono-1': null,
|
|
59
|
+
'mono-2': null,
|
|
60
|
+
'mono-3': null,
|
|
61
|
+
'hue-1': null,
|
|
62
|
+
'hue-2': null,
|
|
63
|
+
'hue-3': null,
|
|
64
|
+
'hue-4': null,
|
|
65
|
+
'hue-5': null,
|
|
66
|
+
'hue-5-2': null,
|
|
67
|
+
'hue-6': null,
|
|
68
|
+
'hue-6-2': null,
|
|
69
|
+
'syntax-fg': null,
|
|
70
|
+
'syntax-bg': null,
|
|
71
|
+
'syntax-gutter': null,
|
|
72
|
+
'syntax-guide': null,
|
|
73
|
+
'syntax-accent': null,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const codeLight = createTheme(code, {
|
|
77
|
+
'mono-1': `hsl(230, 8%, 24%)`,
|
|
78
|
+
'mono-2': `hsl(230, 6%, 44%)`,
|
|
79
|
+
'mono-3': `hsl(230, 4%, 64%)`,
|
|
80
|
+
'hue-1': `hsl(198, 99%, 37%)`,
|
|
81
|
+
'hue-2': `hsl(221, 87%, 60%)`,
|
|
82
|
+
'hue-3': `hsl(301, 63%, 40%)`,
|
|
83
|
+
'hue-4': `hsl(119, 34%, 47%)`,
|
|
84
|
+
'hue-5': `hsl(5, 74%, 59%)`,
|
|
85
|
+
'hue-5-2': `hsl(344, 84%, 43%)`,
|
|
86
|
+
'hue-6': `hsl(35, 99%, 36%)`,
|
|
87
|
+
'hue-6-2': `hsl(35, 99%, 40%)`,
|
|
88
|
+
'syntax-fg': `hsl(230, 8%, 24%)`,
|
|
89
|
+
'syntax-bg': `hsl(230, 1%, 98%)`,
|
|
90
|
+
'syntax-gutter': `hsl(230, 1%, 62%)`,
|
|
91
|
+
'syntax-guide': `hsla(230, 8%, 24%, 0.2)`,
|
|
92
|
+
'syntax-accent': `hsl(230, 100%, 66%)`,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const codeDark = createTheme(code, {
|
|
96
|
+
'mono-1': `hsl(220, 14%, 71%)`,
|
|
97
|
+
'mono-2': `hsl(220, 9%, 55%)`,
|
|
98
|
+
'mono-3': `hsl(220, 10%, 40%)`,
|
|
99
|
+
'hue-1': `hsl(187, 47%, 55%)`,
|
|
100
|
+
'hue-2': `hsl(207, 82%, 66%)`,
|
|
101
|
+
'hue-3': `hsl(286, 60%, 67%)`,
|
|
102
|
+
'hue-4': `hsl(95, 38%, 62%)`,
|
|
103
|
+
'hue-5': `hsl(355, 65%, 65%)`,
|
|
104
|
+
'hue-5-2': `hsl(5, 48%, 51%)`,
|
|
105
|
+
'hue-6': `hsl(29, 54%, 61%)`,
|
|
106
|
+
'hue-6-2': `hsl(39, 67%, 69%)`,
|
|
107
|
+
'syntax-fg': `hsl(220, 14%, 71%)`,
|
|
108
|
+
'syntax-bg': `hsl(220, 13%, 18%)`,
|
|
109
|
+
'syntax-gutter': `hsl(220, 14%, 45%)`,
|
|
110
|
+
'syntax-guide': `hsla(220, 14%, 71%, 0.15)`,
|
|
111
|
+
'syntax-accent': `hsl(220, 100%, 66%)`,
|
|
112
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTheme,
|
|
3
|
+
createThemeContract,
|
|
4
|
+
fallbackVar,
|
|
5
|
+
globalStyle,
|
|
6
|
+
} from '@vanilla-extract/css';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The `colors` object exposes the CSS variables used by TinyWidgets for color
|
|
10
|
+
* theming, so that you can use them directly in your own application.
|
|
11
|
+
*
|
|
12
|
+
* The full set of members is:
|
|
13
|
+
* - `accentHue`
|
|
14
|
+
* - `backgroundHue`
|
|
15
|
+
* - `accent`
|
|
16
|
+
* - `accentLight`
|
|
17
|
+
* - `accentHover`
|
|
18
|
+
* - `accentContrast`
|
|
19
|
+
* - `background`
|
|
20
|
+
* - `background2`
|
|
21
|
+
* - `backgroundHaze`
|
|
22
|
+
* - `backgroundHover`
|
|
23
|
+
* - `foreground`
|
|
24
|
+
* - `foregroundBright`
|
|
25
|
+
* - `foregroundDim`
|
|
26
|
+
* - `border`
|
|
27
|
+
* - `shadow`
|
|
28
|
+
*
|
|
29
|
+
* You can use these variables directly in React components that take style
|
|
30
|
+
* attributes, like this:
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <div style={{color: colors.accent}}>Accent</div>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* And if you are using Vanilla-Extract for your app's styles, use them in your
|
|
37
|
+
* style declarations like this:
|
|
38
|
+
*
|
|
39
|
+
* ```tsx
|
|
40
|
+
* export const titleStyle = style({color: colors.accent});
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <Card>
|
|
46
|
+
* <Code code={colors.accentHue} />
|
|
47
|
+
* <Hr />
|
|
48
|
+
* <div style={{
|
|
49
|
+
* color: colors.accent,
|
|
50
|
+
* background: colors.background2,
|
|
51
|
+
* border: colors.border,
|
|
52
|
+
* boxShadow: colors.shadow,
|
|
53
|
+
* textAlign: 'center',
|
|
54
|
+
* }}>
|
|
55
|
+
* Accent on a background
|
|
56
|
+
* </div>
|
|
57
|
+
* </Card>
|
|
58
|
+
* ```
|
|
59
|
+
* This example shows one of the values within the `colors` object, and then
|
|
60
|
+
* applies some of them to a custom component. Change the dark mode to see the
|
|
61
|
+
* background respond.
|
|
62
|
+
* @icon Lucide.Palette
|
|
63
|
+
*/
|
|
64
|
+
export const colors = createThemeContract({
|
|
65
|
+
accentHue: null,
|
|
66
|
+
backgroundHue: null,
|
|
67
|
+
accent: null,
|
|
68
|
+
accentLight: null,
|
|
69
|
+
accentHover: null,
|
|
70
|
+
accentContrast: null,
|
|
71
|
+
background: null,
|
|
72
|
+
background2: null,
|
|
73
|
+
backgroundHaze: null,
|
|
74
|
+
backgroundHover: null,
|
|
75
|
+
foreground: null,
|
|
76
|
+
foregroundBright: null,
|
|
77
|
+
foregroundDim: null,
|
|
78
|
+
border: null,
|
|
79
|
+
shadow: null,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const common = {
|
|
83
|
+
accentHue: fallbackVar('var(--tinyWidgets-accentHue)', '8'),
|
|
84
|
+
backgroundHue: fallbackVar(
|
|
85
|
+
'var(--tinyWidgets-backgroundHue)',
|
|
86
|
+
`calc(${colors.accentHue} + 180)`,
|
|
87
|
+
),
|
|
88
|
+
accent: `oklch(50% .11 ${colors.accentHue})`,
|
|
89
|
+
accentLight: `oklch(71% .16 ${colors.accentHue})`,
|
|
90
|
+
accentHover: `oklch(45% .1 ${colors.accentHue})`,
|
|
91
|
+
accentContrast: '#fff',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const colorsLight = createTheme(colors, {
|
|
95
|
+
...common,
|
|
96
|
+
background: `oklch(99% .01 ${colors.backgroundHue})`,
|
|
97
|
+
background2: `oklch(95% .01 ${colors.backgroundHue})`,
|
|
98
|
+
backgroundHaze: `oklch(99% .01 ${colors.backgroundHue} / .5)`,
|
|
99
|
+
backgroundHover: `oklch(90% .01 ${colors.backgroundHue})`,
|
|
100
|
+
foreground: `oklch(50% .01 ${colors.accentHue})`,
|
|
101
|
+
foregroundBright: `oklch(10% .01 ${colors.accentHue})`,
|
|
102
|
+
foregroundDim: `oklch(60% .01 ${colors.accentHue})`,
|
|
103
|
+
border: `1px solid oklch(90% .01 ${colors.backgroundHue})`,
|
|
104
|
+
shadow: '0 1px 4px 0 hsl(0 0 20 / .1)',
|
|
105
|
+
});
|
|
106
|
+
globalStyle(`html:has(${colorsLight})`, {
|
|
107
|
+
backgroundColor: '#fff',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const colorsDark = createTheme(colors, {
|
|
111
|
+
...common,
|
|
112
|
+
background: `oklch(20% .01 ${colors.backgroundHue})`,
|
|
113
|
+
background2: `oklch(15% .01 ${colors.backgroundHue})`,
|
|
114
|
+
backgroundHaze: `oklch(21% 0% ${colors.backgroundHue} / .5)`,
|
|
115
|
+
backgroundHover: `oklch(25% .01 ${colors.backgroundHue})`,
|
|
116
|
+
foreground: `oklch(85% .01 ${colors.accentHue})`,
|
|
117
|
+
foregroundBright: `oklch(95% .01 ${colors.accentHue})`,
|
|
118
|
+
foregroundDim: `oklch(60% .01 ${colors.accentHue})`,
|
|
119
|
+
border: `1px solid oklch(30% .01 ${colors.backgroundHue})`,
|
|
120
|
+
shadow: '0 1px 4px 0 #000',
|
|
121
|
+
});
|
|
122
|
+
globalStyle(`html:has(${colorsDark})`, {
|
|
123
|
+
backgroundColor: '#000',
|
|
124
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {createTheme, fallbackVar, style} from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
const classAndObject = createTheme({
|
|
4
|
+
logo: fallbackVar('var(--tinyWidgets-logo)', '2rem'),
|
|
5
|
+
avatar: fallbackVar('var(--tinyWidgets-avatar)', '2rem'),
|
|
6
|
+
icon: fallbackVar('var(--tinyWidgets-icon)', '1rem'),
|
|
7
|
+
padding: fallbackVar('var(--tinyWidgets-padding)', '1rem'),
|
|
8
|
+
radius: fallbackVar('var(--tinyWidgets-radius)', '0.5rem'),
|
|
9
|
+
sideNavWidth: fallbackVar('var(--tinyWidgets-sideNavWidth)', '20rem'),
|
|
10
|
+
topNavHeight: fallbackVar('var(--tinyWidgets-topNavHeight)', '4rem'),
|
|
11
|
+
});
|
|
12
|
+
export const dimensionsClass = classAndObject[0];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The `dimensions` object exposes the CSS variables used by TinyWidgets for
|
|
16
|
+
* various sizes and lengths, so that you can use them directly in your own
|
|
17
|
+
* application.
|
|
18
|
+
*
|
|
19
|
+
* The full set of members is:
|
|
20
|
+
* - `logo`
|
|
21
|
+
* - `avatar`
|
|
22
|
+
* - `icon`
|
|
23
|
+
* - `padding`
|
|
24
|
+
* - `radius`
|
|
25
|
+
* - `sideNavWidth`
|
|
26
|
+
* - `topNavHeight`
|
|
27
|
+
*
|
|
28
|
+
* You can use these variables directly in React components that take style
|
|
29
|
+
* attributes, like this:
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <div style={{width: dimensions.logo, height: dimensions.logo}} />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* And if you are using Vanilla-Extract for your app's styles, use them in your
|
|
36
|
+
* style declarations like this:
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* export const logoStyle = style({
|
|
40
|
+
* width: dimensions.logo,
|
|
41
|
+
* height: dimensions.logo,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Card>
|
|
48
|
+
* <Code code={dimensions['logo']} />
|
|
49
|
+
* <Hr />
|
|
50
|
+
* <div style={{
|
|
51
|
+
* width: dimensions.logo,
|
|
52
|
+
* height: dimensions.logo,
|
|
53
|
+
* background: 'oklch(50% 0.11 0)',
|
|
54
|
+
* }}/>
|
|
55
|
+
* </Card>
|
|
56
|
+
* ```
|
|
57
|
+
* This example shows one of the values within the `dimensions` object, and then
|
|
58
|
+
* applies some of them to a custom component.
|
|
59
|
+
* @icon Lucide.Ruler
|
|
60
|
+
*/
|
|
61
|
+
export const dimensions = classAndObject[1];
|
|
62
|
+
|
|
63
|
+
export const iconSize = style({
|
|
64
|
+
flexShrink: 0,
|
|
65
|
+
height: dimensions.icon,
|
|
66
|
+
width: dimensions.icon,
|
|
67
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `screens` object contains the media query breakpoints that TinyWidget
|
|
3
|
+
* uses to distinguish small, medium, and large screens.
|
|
4
|
+
*
|
|
5
|
+
* Currently, the main impact of the `large` member is that screens narrower
|
|
6
|
+
* than this number of pixels will get a collapsed side bar. Screens narrower
|
|
7
|
+
* than the `small` number of pixels will get a slightly smaller font.
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Code code={JSON.stringify(screens, null, 2)} />
|
|
11
|
+
* ```
|
|
12
|
+
* This example gets the breakpoint values.
|
|
13
|
+
* @icon Lucide.Ruler
|
|
14
|
+
*/
|
|
15
|
+
export const screens = {small: 448, large: 768};
|