tinywidgets 0.0.5 → 0.0.7

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/bun.lockb CHANGED
Binary file
package/index.css.ts CHANGED
@@ -1 +1 @@
1
- export {accent, accentContrast, theme} from './src/index.css.ts';
1
+ export {accentHue, theme} from './src/index.css.ts';
package/media.ts CHANGED
@@ -1 +1 @@
1
- export {large} from './src/index.ts';
1
+ export {large, small} from './src/index.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinywidgets",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinywidgets",
6
6
  "module": "index.ts",
@@ -18,7 +18,7 @@
18
18
  "@vanilla-extract/css": "^1.15.5",
19
19
  "react": "^18.3.1",
20
20
  "react-dom": "^18.3.1",
21
- "tinybase": "^5.3.0-beta.1"
21
+ "tinybase": "^5.3.0-beta.2"
22
22
  },
23
23
  "exports": {
24
24
  ".": "./index.ts",
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type { ComponentType, ReactNode } from 'react';
4
- import { ChevronDown, ChevronRight } from 'lucide-react';
5
- import { Button } from '../Button/index.tsx';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {ChevronDown, ChevronRight} from 'lucide-react';
5
+ import {Button} from '../Button/index.tsx';
6
6
  import {
7
7
  classNames,
8
8
  createElement,
@@ -27,6 +27,7 @@ export const Collapsible = ({
27
27
  icon: Icon,
28
28
  label = <div />,
29
29
  labelRight = <div />,
30
+ startOpen = false,
30
31
  className,
31
32
  children,
32
33
  }: {
@@ -34,19 +35,20 @@ export const Collapsible = ({
34
35
  icon?: ComponentType<{className?: string}>;
35
36
  label?: ReactNode;
36
37
  labelRight?: ReactNode;
38
+ startOpen?: boolean;
37
39
  className?: string;
38
40
  children: ReactNode;
39
41
  }) => {
40
42
  // State is in session Store if id is present, otherwise here in component.
41
- const storedIsOpen = useCollapsibleOpen(id) ?? false;
43
+ const storedIsOpen = useCollapsibleOpen(id) ?? startOpen;
42
44
  const setStoredIsOpen = useSetCollapsibleOpen(id);
43
- const [stateIsOpen, setStateIsOpen] = useState(false);
45
+ const [stateIsOpen, setStateIsOpen] = useState(startOpen);
44
46
 
45
47
  const isOpen = id ? storedIsOpen : stateIsOpen;
46
48
  const setIsOpen = id ? setStoredIsOpen : setStateIsOpen;
47
49
 
48
50
  const [render, setRender] = useState(isOpen);
49
- const timer = useRef<NodeJS.Timer>();
51
+ const timer = useRef<Timer>();
50
52
 
51
53
  const toggle = useCallback(() => {
52
54
  setIsOpen(!isOpen);
@@ -1,6 +1,6 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { dimensions, paddingLike, theme } from '../../../index.css.ts';
3
- import { large } from '../../../index.ts';
1
+ import {style} from '@vanilla-extract/css';
2
+ import {dimensions, paddingLike, theme} from '../../../index.css.ts';
3
+ import {large} from '../../../index.ts';
4
4
 
5
5
  export const sideNav = style([
6
6
  paddingLike,
@@ -11,9 +11,9 @@ export const sideNav = style([
11
11
  borderRight: `1px solid ${theme.border}`,
12
12
  width: dimensions.sideNavWidth,
13
13
  bottom: 0,
14
- left: '-' + dimensions.sideNavWidth,
14
+ left: dimensions.sideNavWidthHidden,
15
15
  top: dimensions.topNavHeight,
16
- height: `calc(100vh - ${dimensions.topNavHeight})`,
16
+ height: `calc(100dvh - ${dimensions.topNavHeight})`,
17
17
  overscrollBehavior: 'contain',
18
18
  transition: 'left .2s ease-in-out',
19
19
  },
@@ -1,9 +1,9 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { theme } from '../index.css.ts';
1
+ import {style} from '@vanilla-extract/css';
2
+ import {theme} from '../index.css.ts';
3
3
 
4
4
  export const ui = style({
5
5
  display: 'flex',
6
- height: '100vh',
7
- width: '100vw',
6
+ height: '100dvh',
7
+ width: '100dvw',
8
8
  color: theme.foreground,
9
9
  });
package/src/index.css.ts CHANGED
@@ -6,12 +6,16 @@ import {
6
6
  globalStyle,
7
7
  style,
8
8
  } from '@vanilla-extract/css';
9
+ import {small} from './';
9
10
 
10
- export const accent = createVar();
11
- export const accentContrast = createVar();
11
+ export const accentHue = createVar();
12
12
 
13
13
  export const theme = createThemeContract({
14
+ accentHue: null,
15
+ backgroundHue: null,
14
16
  accent: null,
17
+ accentLight: null,
18
+ accentHover: null,
15
19
  accentContrast: null,
16
20
  underneath: null,
17
21
  background: null,
@@ -22,37 +26,41 @@ export const theme = createThemeContract({
22
26
  foreground2: null,
23
27
  border: null,
24
28
  shadow: null,
25
- accentHover: null,
26
29
  });
27
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
+
28
40
  const light = {
29
- accent: fallbackVar(accent, '#d81b60'),
30
- accentContrast: fallbackVar(accentContrast, `#fff`),
41
+ ...themeCommon,
31
42
  underneath: '#fff',
32
- background: `oklch(from ${theme.accent} 98% 1% calc(h + 180))`,
33
- background2: `oklch(from ${theme.accent} 95% 1% calc(h + 180))`,
34
- backgroundHaze: `oklch(from ${theme.background} l c h / .5)`,
35
- backgroundHover: `oklch(from ${theme.accent} 90% 1% calc(h + 180))`,
36
- foreground: `oklch(from ${theme.accent} 30% 1% h)`,
37
- foreground2: `oklch(from ${theme.accent} 50% 1% h)`,
38
- border: `oklch(from ${theme.accent} 90% 1% calc(h + 180))`,
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})`,
39
50
  shadow: '0 1px 4px 0 hsl(0 0 20 / .1)',
40
- accentHover: `oklch(from ${theme.accent} calc(l * 90%) c h)`,
41
51
  };
42
52
 
43
53
  const dark = {
44
- accent: fallbackVar(accent, '#d81b60'),
45
- accentContrast: fallbackVar(accentContrast, `#fff`),
54
+ ...themeCommon,
46
55
  underneath: '#000',
47
- background: `oklch(from ${theme.accent} 20% 1% calc(h + 180))`,
48
- background2: `oklch(from ${theme.accent} 15% 1% calc(h + 180))`,
49
- backgroundHaze: `oklch(from ${theme.background} 21% 0% h / .5)`,
50
- backgroundHover: `oklch(from ${theme.accent} 25% 1% calc(h + 180))`,
51
- foreground: `oklch(from ${theme.accent} 90% 1% h)`,
52
- foreground2: `oklch(from ${theme.accent} 50% 1% h)`,
53
- border: `oklch(from ${theme.accent} 30% 1% calc(h + 180))`,
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})`,
54
63
  shadow: '0 1px 4px 0 #000',
55
- accentHover: `oklch(from ${theme.accent} calc(l * 90%) c h)`,
56
64
  };
57
65
 
58
66
  export const dimensions = {
@@ -60,6 +68,7 @@ export const dimensions = {
60
68
  radius: '0.5rem',
61
69
  titleWidth: '18rem',
62
70
  sideNavWidth: '20rem',
71
+ sideNavWidthHidden: '-30rem',
63
72
  topNavHeight: '4rem',
64
73
  articleWidth: '60rem',
65
74
  footerHeight: '10rem',
@@ -103,6 +112,9 @@ globalStyle('html', {
103
112
  lineHeight: '1.5em',
104
113
  textRendering: 'optimizeLegibility',
105
114
  fontWeight: 400,
115
+ ...small({
116
+ fontSize: '11px',
117
+ }),
106
118
  });
107
119
 
108
120
  globalStyle('h1', {fontSize: '1.5rem'});
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import type {StyleRule} from '@vanilla-extract/css';
3
3
 
4
- const LARGE = 'screen and (min-width: 1000px)';
4
+ const LARGE = 'screen and (min-width: 768px)';
5
+ const SMALL = 'screen and (max-width: 450px)';
5
6
 
6
7
  export const {
7
8
  createElement,
@@ -14,9 +15,11 @@ export const {
14
15
  } = React;
15
16
 
16
17
  export const large = (style: StyleRule) => ({
17
- '@media': {
18
- [LARGE]: style,
19
- },
18
+ '@media': {[LARGE]: style},
19
+ });
20
+
21
+ export const small = (style: StyleRule) => ({
22
+ '@media': {[SMALL]: style},
20
23
  });
21
24
 
22
25
  export const classNames = (...classes: (string | boolean | undefined)[]) =>
@@ -1,5 +1,5 @@
1
- import { createStore } from 'tinybase';
2
- import { createLocalPersister } from 'tinybase/persisters/persister-browser';
1
+ import {createStore} from 'tinybase';
2
+ import {createLocalPersister} from 'tinybase/persisters/persister-browser';
3
3
  import {
4
4
  useCreatePersister,
5
5
  useCreateStore,
@@ -7,11 +7,11 @@ import {
7
7
  useSetValueCallback,
8
8
  useValue,
9
9
  } from 'tinybase/ui-react';
10
- import { useEffect } from '../';
10
+ import {useEffect} from '../';
11
11
 
12
12
  const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
13
13
 
14
- const LOCAL_STORE = 'uiLocal';
14
+ const LOCAL_STORE = 'tinywidgets/Local';
15
15
  const DARK_PREFERENCE_VALUE = 'darkPreference';
16
16
  const DARK_CHOICE_VALUE = 'darkChoice';
17
17
 
@@ -10,7 +10,7 @@ import {
10
10
  useValue,
11
11
  } from 'tinybase/ui-react';
12
12
 
13
- const SESSION_STORE = 'uiSession';
13
+ const SESSION_STORE = 'tinywidgets/Session';
14
14
 
15
15
  const COLLAPSIBLE_TABLE = 'collapsible';
16
16
  const COLLAPSIBLE_OPEN_CELL = 'open';