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.
Files changed (80) hide show
  1. package/.eslintrc.json +2 -1
  2. package/bun.lockb +0 -0
  3. package/package.json +19 -14
  4. package/src/common/functions.tsx +54 -0
  5. package/src/components/App/index.css.ts +81 -0
  6. package/src/components/App/index.tsx +177 -0
  7. package/src/components/Button/index.css.ts +66 -0
  8. package/src/components/Button/index.tsx +206 -0
  9. package/src/components/Card/index.css.ts +12 -0
  10. package/src/components/Card/index.tsx +34 -0
  11. package/src/components/Code/index.css.ts +49 -0
  12. package/src/components/Code/index.tsx +89 -0
  13. package/src/components/Collapsible/index.css.ts +37 -0
  14. package/src/components/Collapsible/index.tsx +132 -0
  15. package/src/{Detail → components/Detail}/index.css.ts +3 -3
  16. package/src/components/Detail/index.tsx +48 -0
  17. package/src/{Hr → components/Hr}/index.css.ts +3 -2
  18. package/src/components/Hr/index.tsx +26 -0
  19. package/src/components/Image/index.css.ts +38 -0
  20. package/src/components/Image/index.tsx +85 -0
  21. package/src/components/Metric/index.tsx +59 -0
  22. package/src/components/Row/index.css.ts +30 -0
  23. package/src/components/Row/index.tsx +104 -0
  24. package/src/components/Summary/index.css.ts +16 -0
  25. package/src/components/Summary/index.tsx +59 -0
  26. package/src/{Tag → components/Tag}/index.css.ts +9 -6
  27. package/src/components/Tag/index.tsx +73 -0
  28. package/src/css/code.css.ts +112 -0
  29. package/src/css/colors.css.ts +124 -0
  30. package/src/css/dimensions.css.ts +67 -0
  31. package/src/css/global.css.ts +11 -0
  32. package/src/css/screens.ts +15 -0
  33. package/src/index.css.ts +4 -137
  34. package/src/index.ts +16 -24
  35. package/src/stores/LocalStore.tsx +52 -19
  36. package/src/stores/RouteStore.tsx +103 -0
  37. package/src/stores/SessionStore.tsx +40 -25
  38. package/src/stores/common.ts +6 -0
  39. package/tsconfig.json +19 -0
  40. package/.prettierrc +0 -5
  41. package/index.css.ts +0 -1
  42. package/index.ts +0 -12
  43. package/src/App/index.tsx +0 -18
  44. package/src/Avatar/index.css.ts +0 -17
  45. package/src/Avatar/index.tsx +0 -25
  46. package/src/Axis/index.css.ts +0 -19
  47. package/src/Axis/index.tsx +0 -36
  48. package/src/Button/index.css.ts +0 -57
  49. package/src/Button/index.tsx +0 -63
  50. package/src/Card/index.css.ts +0 -9
  51. package/src/Card/index.tsx +0 -13
  52. package/src/Collapsible/index.css.ts +0 -34
  53. package/src/Collapsible/index.tsx +0 -75
  54. package/src/Detail/index.tsx +0 -26
  55. package/src/Hr/index.tsx +0 -8
  56. package/src/Metric/index.tsx +0 -26
  57. package/src/Summary/index.css.ts +0 -17
  58. package/src/Summary/index.tsx +0 -32
  59. package/src/Tag/index.tsx +0 -26
  60. package/src/Ui/Header/DarkButton/index.tsx +0 -19
  61. package/src/Ui/Header/SideNav/index.css.ts +0 -23
  62. package/src/Ui/Header/SideNav/index.tsx +0 -14
  63. package/src/Ui/Header/SideNavButton/index.css.ts +0 -4
  64. package/src/Ui/Header/SideNavButton/index.tsx +0 -19
  65. package/src/Ui/Header/Title/index.css.ts +0 -10
  66. package/src/Ui/Header/Title/index.tsx +0 -9
  67. package/src/Ui/Header/TopNav/index.css.ts +0 -9
  68. package/src/Ui/Header/TopNav/index.tsx +0 -18
  69. package/src/Ui/Header/index.css.ts +0 -18
  70. package/src/Ui/Header/index.tsx +0 -32
  71. package/src/Ui/Main/Article/index.css.ts +0 -13
  72. package/src/Ui/Main/Article/index.tsx +0 -9
  73. package/src/Ui/Main/Footer/index.css.ts +0 -12
  74. package/src/Ui/Main/Footer/index.tsx +0 -9
  75. package/src/Ui/Main/index.css.ts +0 -16
  76. package/src/Ui/Main/index.tsx +0 -24
  77. package/src/Ui/index.css.ts +0 -9
  78. package/src/Ui/index.tsx +0 -50
  79. package/utils.ts +0 -1
  80. /package/src/{Metric → components/Metric}/index.css.ts +0 -0
package/src/index.css.ts CHANGED
@@ -1,137 +1,4 @@
1
- import {
2
- createTheme,
3
- createThemeContract,
4
- createVar,
5
- fallbackVar,
6
- globalStyle,
7
- style,
8
- } from '@vanilla-extract/css';
9
- import {small} from './';
10
-
11
- export const accentHue = createVar();
12
-
13
- export const theme = createThemeContract({
14
- accentHue: null,
15
- backgroundHue: null,
16
- accent: null,
17
- accentLight: null,
18
- accentHover: null,
19
- accentContrast: null,
20
- underneath: null,
21
- background: null,
22
- background2: null,
23
- backgroundHaze: null,
24
- backgroundHover: null,
25
- foreground: null,
26
- foreground2: null,
27
- border: null,
28
- shadow: null,
29
- });
30
-
31
- const themeCommon = {
32
- accentHue: fallbackVar(accentHue, '8'),
33
- backgroundHue: `calc(${theme.accentHue} + 180)`,
34
- accent: `oklch(50% .11 ${theme.accentHue})`,
35
- accentLight: `oklch(71% .16 ${theme.accentHue})`,
36
- accentHover: `oklch(45% .1 ${theme.accentHue})`,
37
- accentContrast: '#fff',
38
- };
39
-
40
- const light = {
41
- ...themeCommon,
42
- underneath: '#fff',
43
- background: `oklch(99% .01 ${theme.backgroundHue})`,
44
- background2: `oklch(95% .01 ${theme.backgroundHue})`,
45
- backgroundHaze: `oklch(99% .01 ${theme.backgroundHue} / .5)`,
46
- backgroundHover: `oklch(90% .01 ${theme.backgroundHue})`,
47
- foreground: `oklch(30% .01 ${theme.accentHue})`,
48
- foreground2: `oklch(50% .01 ${theme.accentHue})`,
49
- border: `oklch(90% .01 ${theme.backgroundHue})`,
50
- shadow: '0 1px 4px 0 hsl(0 0 20 / .1)',
51
- };
52
-
53
- const dark = {
54
- ...themeCommon,
55
- underneath: '#000',
56
- background: `oklch(20% .01 ${theme.backgroundHue})`,
57
- background2: `oklch(15% .01 ${theme.backgroundHue})`,
58
- backgroundHaze: `oklch(21% 0% ${theme.backgroundHue} / .5)`,
59
- backgroundHover: `oklch(25% .01 ${theme.backgroundHue})`,
60
- foreground: `oklch(90% .01 ${theme.accentHue})`,
61
- foreground2: `oklch(50% .01 ${theme.accentHue})`,
62
- border: `oklch(30% .01 ${theme.backgroundHue})`,
63
- shadow: '0 1px 4px 0 #000',
64
- };
65
-
66
- export const dimensions = {
67
- padding: '1rem',
68
- radius: '0.5rem',
69
- titleWidth: '18rem',
70
- sideNavWidth: '20rem',
71
- sideNavWidthHidden: '-30rem',
72
- topNavHeight: '4rem',
73
- articleWidth: '60rem',
74
- footerHeight: '10rem',
75
- };
76
-
77
- export const shadowLike = {
78
- boxShadow: theme.shadow,
79
- };
80
-
81
- export const borderLike = {
82
- ...shadowLike,
83
- border: `1px solid ${theme.border}`,
84
- };
85
-
86
- export const radiusLike = {
87
- borderRadius: dimensions.radius,
88
- };
89
-
90
- export const paddingLike = {
91
- padding: dimensions.padding,
92
- };
93
-
94
- export const axisLike = {
95
- display: 'flex',
96
- justifyContent: 'space-between',
97
- alignItems: 'center',
98
- gap: dimensions.padding,
99
- };
100
-
101
- globalStyle('*', {
102
- margin: 0,
103
- padding: 0,
104
- boxSizing: 'border-box',
105
- scrollbarWidth: 'thin',
106
- color: 'inherit',
107
- fontSize: 'inherit',
108
- });
109
-
110
- globalStyle('html', {
111
- fontSize: '14px',
112
- lineHeight: '1.5em',
113
- textRendering: 'optimizeLegibility',
114
- fontWeight: 400,
115
- ...small({
116
- fontSize: '12px',
117
- }),
118
- });
119
-
120
- globalStyle('h1', {fontSize: '1.5rem'});
121
-
122
- globalStyle('h2', {fontSize: '1.25rem'});
123
-
124
- export const themeLight = createTheme(theme, light);
125
- globalStyle(`html:has(${themeLight})`, {
126
- backgroundColor: light.underneath,
127
- });
128
-
129
- export const themeDark = createTheme(theme, dark);
130
- globalStyle(`html:has(${themeDark})`, {
131
- backgroundColor: dark.underneath,
132
- });
133
-
134
- export const iconSize = style({
135
- width: '1rem',
136
- height: '1rem',
137
- });
1
+ export {colors} from './css/colors.css.ts';
2
+ export {code} from './css/code.css.ts';
3
+ export {dimensions} from './css/dimensions.css.ts';
4
+ export {screens} from './css/screens.ts';
package/src/index.ts CHANGED
@@ -1,26 +1,18 @@
1
- import React from 'react';
2
- import type {StyleRule} from '@vanilla-extract/css';
1
+ import './css/global.css.ts';
3
2
 
4
- const LARGE = 'screen and (min-width: 768px)';
5
- const SMALL = 'screen and (max-width: 450px)';
3
+ export {App} from './components/App/index.tsx';
4
+ export {Button} from './components/Button/index.tsx';
5
+ export {Card} from './components/Card/index.tsx';
6
+ export {Code} from './components/Code/index.tsx';
7
+ export {Collapsible} from './components/Collapsible/index.tsx';
8
+ export {Detail} from './components/Detail/index.tsx';
9
+ export {Hr} from './components/Hr/index.tsx';
10
+ export {Image} from './components/Image/index.tsx';
11
+ export {Metric} from './components/Metric/index.tsx';
12
+ export {Row} from './components/Row/index.tsx';
13
+ export {Summary} from './components/Summary/index.tsx';
14
+ export {Tag} from './components/Tag/index.tsx';
6
15
 
7
- export const {
8
- createElement,
9
- Fragment,
10
- useEffect,
11
- useRef,
12
- useState,
13
- useCallback,
14
- forwardRef,
15
- } = React;
16
-
17
- export const large = (style: StyleRule) => ({
18
- '@media': {[LARGE]: style},
19
- });
20
-
21
- export const small = (style: StyleRule) => ({
22
- '@media': {[SMALL]: style},
23
- });
24
-
25
- export const classNames = (...classes: (string | boolean | undefined)[]) =>
26
- classes.filter(Boolean).join(' ');
16
+ export {useRoute, useSetRouteCallback} from './stores/RouteStore.tsx';
17
+ export {useDark} from './stores/LocalStore.tsx';
18
+ export {classNames} from './common/functions.tsx';
@@ -1,35 +1,67 @@
1
- import {createStore} from 'tinybase';
2
- import {createLocalPersister} from 'tinybase/persisters/persister-browser';
3
- import {
1
+ import * as UiReact from 'tinybase/ui-react/with-schemas';
2
+ import {CHANGE, READY, READY_SCHEMA} from './common';
3
+ import {type NoTablesSchema, createStore} from 'tinybase/with-schemas';
4
+ import {createLocalPersister} from 'tinybase/persisters/persister-browser/with-schemas';
5
+ import {useEffect} from 'react';
6
+
7
+ const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
8
+
9
+ const LOCAL_STORE = 'tinywidgets/Local';
10
+ const DARK_PREFERENCE = 'darkPreference';
11
+ const DARK_CHOICE = 'darkChoice';
12
+
13
+ const VALUES_SCHEMA = {
14
+ ...READY_SCHEMA,
15
+ [DARK_PREFERENCE]: {type: 'boolean', default: false},
16
+ [DARK_CHOICE]: {type: 'number', default: 2},
17
+ } as const;
18
+ type Schemas = [NoTablesSchema, typeof VALUES_SCHEMA];
19
+
20
+ const {
4
21
  useCreatePersister,
5
22
  useCreateStore,
6
23
  useProvideStore,
7
24
  useSetValueCallback,
8
25
  useValue,
9
- } from 'tinybase/ui-react';
10
- import {useEffect} from '../';
11
-
12
- const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
13
-
14
- const LOCAL_STORE = 'tinywidgets/Local';
15
- const DARK_PREFERENCE_VALUE = 'darkPreference';
16
- const DARK_CHOICE_VALUE = 'darkChoice';
26
+ } = UiReact as UiReact.WithSchemas<Schemas>;
17
27
 
18
- export const useDarkPreference = () =>
19
- useValue(DARK_PREFERENCE_VALUE, LOCAL_STORE) as boolean;
28
+ /**
29
+ * The useDark hook returns whether the user is viewing the application in dark
30
+ * mode.
31
+ *
32
+ * @returns A boolean where `true` means 'dark' and `false` means 'light' mode.
33
+ * @example
34
+ * ```tsx
35
+ * <Card>
36
+ * Currently in {useDark() ? 'dark' : 'light'} mode
37
+ * </Card>
38
+ * ```
39
+ * This example shows the hook returning the current mode.
40
+ */
41
+ export const useDark = () => {
42
+ const darkChoice = useDarkChoice();
43
+ const darkPreference = useValue(DARK_PREFERENCE, LOCAL_STORE);
44
+ return darkChoice == 1 || (darkChoice == 2 && darkPreference);
45
+ };
20
46
 
21
47
  export const useDarkChoice = () =>
22
- (useValue(DARK_CHOICE_VALUE, LOCAL_STORE) ?? 2) as 0 | 1 | 2;
48
+ (useValue(DARK_CHOICE, LOCAL_STORE) ?? 2) as 0 | 1 | 2;
49
+
23
50
  export const useToggleDarkChoiceCallback = () =>
24
51
  useSetValueCallback(
25
- DARK_CHOICE_VALUE,
52
+ DARK_CHOICE,
26
53
  () => (value) => (((value ?? 2) as number) + 1) % 3,
27
54
  [],
28
55
  LOCAL_STORE,
29
56
  );
30
57
 
58
+ export const useLocalStoreIsReady = () =>
59
+ useValue(READY, LOCAL_STORE) as boolean;
60
+
31
61
  export const LocalStore = () => {
32
- const localStore = useCreateStore(createStore);
62
+ const localStore = useCreateStore(() =>
63
+ createStore().setValuesSchema(VALUES_SCHEMA),
64
+ );
33
65
  useCreatePersister(
34
66
  localStore,
35
67
  (localStore) => createLocalPersister(localStore, LOCAL_STORE),
@@ -37,14 +69,15 @@ export const LocalStore = () => {
37
69
  async (persister) => {
38
70
  await persister.startAutoLoad();
39
71
  await persister.startAutoSave();
72
+ persister.getStore().setValue(READY, true);
40
73
  },
41
74
  );
42
75
  useEffect(() => {
43
76
  const preferenceListener = () =>
44
- localStore.setValue(DARK_PREFERENCE_VALUE, PREFERS_DARK.matches);
45
- PREFERS_DARK.addEventListener('change', preferenceListener);
77
+ localStore.setValue(DARK_PREFERENCE, PREFERS_DARK.matches);
78
+ PREFERS_DARK.addEventListener(CHANGE, preferenceListener);
46
79
  preferenceListener();
47
- return () => PREFERS_DARK.removeEventListener('change', preferenceListener);
80
+ return () => PREFERS_DARK.removeEventListener(CHANGE, preferenceListener);
48
81
  }, [localStore]);
49
82
 
50
83
  useProvideStore(LOCAL_STORE, localStore);
@@ -0,0 +1,103 @@
1
+ import * as UiReact from 'tinybase/ui-react/with-schemas';
2
+ import {type NoTablesSchema, createStore} from 'tinybase/with-schemas';
3
+ import {READY, READY_SCHEMA} from './common';
4
+ import {createCustomPersister} from 'tinybase/persisters/with-schemas';
5
+
6
+ const ROUTE_STORE = 'tinywidgets/Route';
7
+ const ROUTE = 'route';
8
+
9
+ const VALUES_SCHEMA = {
10
+ ...READY_SCHEMA,
11
+ [ROUTE]: {type: 'string', default: ''},
12
+ } as const;
13
+ type Schemas = [NoTablesSchema, typeof VALUES_SCHEMA];
14
+
15
+ const {
16
+ useCreateStore,
17
+ useProvideStore,
18
+ useCreatePersister,
19
+ useValue,
20
+ useSetValueCallback,
21
+ } = UiReact as UiReact.WithSchemas<Schemas>;
22
+
23
+ /**
24
+ * The useRoute hook returns the current route, assuming the app is using the
25
+ * basic TinyWidgets routing system.
26
+ *
27
+ * This 'system' simply involves using this hook to get a string which may have
28
+ * been persisted to the hash part of the browser's URL.
29
+ * @returns The current route.
30
+ * @example
31
+ * ```tsx
32
+ * <Card>
33
+ * Current route
34
+ * <Hr />
35
+ * <code>{useRoute()}</code>
36
+ * </Card>
37
+ * ```
38
+ * This example shows the hook returning the current route.
39
+ */
40
+ export const useRoute = () => useValue(ROUTE, ROUTE_STORE);
41
+
42
+ /**
43
+ * The useSetRouteCallback hook a callback for setting the current route,
44
+ * assuming the app is using the basic TinyWidgets routing system.
45
+ *
46
+ * This 'system' simply involves using this hook to set a string to be persisted
47
+ * to the hash part of the browser's URL.
48
+ * @returns The current route.
49
+ * @example
50
+ * ```tsx
51
+ * const setRoute = useSetRouteCallback();
52
+ * // ...
53
+ * <Button
54
+ * icon={Lucide.Home}
55
+ * title="Home"
56
+ * onClick={() => setRoute('home')}
57
+ * />
58
+ * ```
59
+ * This example shows the hook returning a callback that will change the current
60
+ * route when called as a click handler.
61
+ */
62
+ export const useSetRouteCallback = () =>
63
+ useSetValueCallback(ROUTE, (route: string) => route, [], ROUTE_STORE);
64
+
65
+ export const useRouteStoreIsReady = () =>
66
+ useValue(READY, ROUTE_STORE) as boolean;
67
+
68
+ export const RouteStore = () => {
69
+ const routeStore = useCreateStore(() =>
70
+ createStore().setValuesSchema(VALUES_SCHEMA),
71
+ );
72
+ useProvideStore(ROUTE_STORE, routeStore);
73
+
74
+ useCreatePersister(
75
+ routeStore,
76
+ (routeStore) =>
77
+ createCustomPersister(
78
+ routeStore,
79
+ async () => [{}, {route: location.hash.slice(1), ready: true}],
80
+ async (getContent) => {
81
+ const route = getContent()[1].route;
82
+ if (route) {
83
+ location.hash = route;
84
+ }
85
+ },
86
+ (listener) => {
87
+ const hashListener = () => listener();
88
+ window.addEventListener('hashchange', hashListener);
89
+ return hashListener;
90
+ },
91
+ (hashListener) =>
92
+ window.removeEventListener('hashchange', hashListener),
93
+ ),
94
+ [],
95
+ async (persister) => {
96
+ await persister.startAutoLoad();
97
+ await persister.startAutoSave();
98
+ persister.getStore().setValue(READY, true);
99
+ },
100
+ );
101
+
102
+ return null;
103
+ };
@@ -1,6 +1,25 @@
1
- import {createStore, type Id} from 'tinybase';
2
- import {createSessionPersister} from 'tinybase/persisters/persister-browser';
3
- import {
1
+ import * as UiReact from 'tinybase/ui-react/with-schemas';
2
+ import {READY, READY_SCHEMA} from './common';
3
+ import {createSessionPersister} from 'tinybase/persisters/persister-browser/with-schemas';
4
+ import {createStore} from 'tinybase/with-schemas';
5
+
6
+ const SESSION_STORE = 'tinywidgets/Session';
7
+ const COLLAPSIBLE = 'collapsible';
8
+ const IS_OPEN = 'isOpen';
9
+ const SIDE_NAV_IS_OPEN = 'sideNavIsOpen';
10
+
11
+ const TABLES_SCHEMA = {
12
+ [COLLAPSIBLE]: {
13
+ [IS_OPEN]: {type: 'boolean', default: false},
14
+ },
15
+ } as const;
16
+ const VALUES_SCHEMA = {
17
+ ...READY_SCHEMA,
18
+ [SIDE_NAV_IS_OPEN]: {type: 'boolean', default: false},
19
+ } as const;
20
+ type Schemas = [typeof TABLES_SCHEMA, typeof VALUES_SCHEMA];
21
+
22
+ const {
4
23
  useCell,
5
24
  useCreatePersister,
6
25
  useCreateStore,
@@ -8,44 +27,39 @@ import {
8
27
  useSetCellCallback,
9
28
  useSetValueCallback,
10
29
  useValue,
11
- } from 'tinybase/ui-react';
12
-
13
- const SESSION_STORE = 'tinywidgets/Session';
30
+ } = UiReact as UiReact.WithSchemas<Schemas>;
14
31
 
15
- const COLLAPSIBLE_TABLE = 'collapsible';
16
- const COLLAPSIBLE_OPEN_CELL = 'open';
32
+ export const useCollapsibleIsOpen = (collapsibleId: string) =>
33
+ useCell(COLLAPSIBLE, collapsibleId, IS_OPEN, SESSION_STORE) as any;
17
34
 
18
- const SIDE_NAV_OPEN_VALUE = 'sideNavOpen';
19
-
20
- export const useCollapsibleOpen = (collapsibleId: Id) =>
21
- useCell(
22
- COLLAPSIBLE_TABLE,
23
- collapsibleId,
24
- COLLAPSIBLE_OPEN_CELL,
25
- SESSION_STORE,
26
- ) as any;
27
- export const useSetCollapsibleOpen = (collapsibleId: Id) =>
35
+ export const useSetCollapsibleIsOpenCallback = (collapsibleId: string) =>
28
36
  useSetCellCallback(
29
- COLLAPSIBLE_TABLE,
37
+ COLLAPSIBLE,
30
38
  collapsibleId,
31
- COLLAPSIBLE_OPEN_CELL,
39
+ IS_OPEN,
32
40
  (open: boolean) => open,
33
41
  [collapsibleId],
34
42
  SESSION_STORE,
35
43
  );
36
44
 
37
- export const useSideNavOpen = () =>
38
- useValue(SIDE_NAV_OPEN_VALUE, SESSION_STORE) as any;
39
- export const useToggleSideNavOpen = () =>
45
+ export const useSideNavIsOpen = () =>
46
+ useValue(SIDE_NAV_IS_OPEN, SESSION_STORE) as any;
47
+
48
+ export const useToggleSideNavIsOpenCallback = () =>
40
49
  useSetValueCallback(
41
- SIDE_NAV_OPEN_VALUE,
50
+ SIDE_NAV_IS_OPEN,
42
51
  () => (value) => !value,
43
52
  [],
44
53
  SESSION_STORE,
45
54
  );
46
55
 
56
+ export const useSessionStoreIsReady = () =>
57
+ useValue(READY, SESSION_STORE) as boolean;
58
+
47
59
  export const SessionStore = () => {
48
- const sessionStore = useCreateStore(createStore);
60
+ const sessionStore = useCreateStore(() =>
61
+ createStore().setSchema(TABLES_SCHEMA, VALUES_SCHEMA),
62
+ );
49
63
  useCreatePersister(
50
64
  sessionStore,
51
65
  (sessionStore) => createSessionPersister(sessionStore, SESSION_STORE),
@@ -53,6 +67,7 @@ export const SessionStore = () => {
53
67
  async (persister) => {
54
68
  await persister.startAutoLoad();
55
69
  await persister.startAutoSave();
70
+ persister.getStore().setValue(READY, true);
56
71
  },
57
72
  );
58
73
  useProvideStore(SESSION_STORE, sessionStore);
@@ -0,0 +1,6 @@
1
+ export const READY = 'ready';
2
+ export const CHANGE = 'change';
3
+
4
+ export const READY_SCHEMA = {
5
+ [READY]: {type: 'boolean', default: false},
6
+ } as const;
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
18
+ }
19
+ }
package/.prettierrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "bracketSpacing": false,
3
- "singleQuote": true,
4
- "trailingComma": "all"
5
- }
package/index.css.ts DELETED
@@ -1 +0,0 @@
1
- export {accentHue, theme} from './src/index.css.ts';
package/index.ts DELETED
@@ -1,12 +0,0 @@
1
- export { App } from './src/App/index.tsx';
2
- export { Avatar } from './src/Avatar/index.tsx';
3
- export { Axis } from './src/Axis/index.tsx';
4
- export { Button } from './src/Button/index.tsx';
5
- export { Card } from './src/Card/index.tsx';
6
- export { Collapsible } from './src/Collapsible/index.tsx';
7
- export { Detail } from './src/Detail/index.tsx';
8
- export { Hr } from './src/Hr/index.tsx';
9
- export { Metric } from './src/Metric/index.tsx';
10
- export { Summary } from './src/Summary/index.tsx';
11
- export { Tag } from './src/Tag/index.tsx';
12
- export { Ui } from './src/Ui/index.tsx';
package/src/App/index.tsx DELETED
@@ -1,18 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import type { ReactNode } from 'react';
4
- import { Provider } from 'tinybase/ui-react';
5
- import { createElement } from '../index.ts';
6
- import { LocalStore } from '../stores/LocalStore.tsx';
7
- import { SessionStore } from '../stores/SessionStore.tsx';
8
-
9
- export const App = ({ui, stores}: {ui: ReactNode; stores?: ReactNode}) => {
10
- return (
11
- <Provider>
12
- {ui}
13
- {stores}
14
- <SessionStore />
15
- <LocalStore />
16
- </Provider>
17
- );
18
- };
@@ -1,17 +0,0 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {theme} from '../index.css';
3
-
4
- export const avatar = style({
5
- display: 'inline-block',
6
- width: '2rem',
7
- height: '2rem',
8
- boxShadow: theme.shadow,
9
- borderRadius: '50%',
10
- border: `1px solid ${theme.border}`,
11
- flexShrink: 0,
12
- selectors: {
13
- '&:hover': {
14
- backgroundColor: theme.backgroundHover,
15
- },
16
- },
17
- });
@@ -1,25 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import {classNames, createElement} from '../index.ts';
4
- import {avatar} from './index.css.ts';
5
-
6
- export const Avatar = ({
7
- src,
8
- title,
9
- onClick,
10
- className,
11
- }: {
12
- src: string;
13
- title?: string;
14
- onClick?: () => void;
15
- className?: string;
16
- }) => {
17
- return (
18
- <img
19
- src={src}
20
- title={title}
21
- onClick={onClick}
22
- className={classNames(avatar, className)}
23
- />
24
- );
25
- };
@@ -1,19 +0,0 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {dimensions} from '../index.css';
3
-
4
- export const axis = style({
5
- display: 'flex',
6
- alignItems: 'center',
7
- });
8
-
9
- export const justifyStyle = style({
10
- justifyContent: 'space-between',
11
- });
12
-
13
- export const verticalStyle = style({
14
- flexDirection: 'column',
15
- });
16
-
17
- export const gapStyle = style({
18
- gap: dimensions.padding,
19
- });
@@ -1,36 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import type {ReactNode} from 'react';
4
- import {classNames, createElement} from '../';
5
- import {axis, gapStyle, justifyStyle, verticalStyle} from './index.css';
6
-
7
- export const Axis = ({
8
- justify = true,
9
- gap = true,
10
- vertical,
11
- children,
12
- className,
13
- title,
14
- }: {
15
- justify?: boolean;
16
- gap?: boolean;
17
- vertical?: boolean;
18
- children: ReactNode;
19
- className?: string;
20
- title?: string;
21
- }) => {
22
- return (
23
- <div
24
- className={classNames(
25
- axis,
26
- justify && justifyStyle,
27
- vertical && verticalStyle,
28
- gap && gapStyle,
29
- className,
30
- )}
31
- title={title}
32
- >
33
- {children}
34
- </div>
35
- );
36
- };