tinywidgets 0.0.4 → 0.0.5

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 (31) hide show
  1. package/bun.lockb +0 -0
  2. package/index.ts +12 -11
  3. package/package.json +8 -8
  4. package/src/App/index.tsx +18 -0
  5. package/src/Collapsible/index.tsx +5 -5
  6. package/src/Ui/{Layout/Header → Header}/DarkButton/index.tsx +4 -4
  7. package/src/Ui/{Layout/Header → Header}/SideNav/index.css.ts +3 -3
  8. package/src/Ui/{Layout/Header → Header}/SideNav/index.tsx +4 -4
  9. package/src/Ui/Header/SideNavButton/index.css.ts +4 -0
  10. package/src/Ui/Header/SideNavButton/index.tsx +19 -0
  11. package/src/Ui/{Layout/Header → Header}/Title/index.css.ts +3 -3
  12. package/src/Ui/{Layout/Header → Header}/Title/index.tsx +3 -3
  13. package/src/Ui/Header/TopNav/index.css.ts +9 -0
  14. package/src/Ui/{Layout/Header → Header}/TopNav/index.tsx +3 -3
  15. package/src/Ui/{Layout/Header → Header}/index.css.ts +2 -2
  16. package/src/Ui/{Layout/Header → Header}/index.tsx +8 -8
  17. package/src/Ui/{Layout/Main → Main}/Article/index.css.ts +2 -2
  18. package/src/Ui/{Layout/Main → Main}/Article/index.tsx +3 -3
  19. package/src/Ui/{Layout/Main → Main}/Footer/index.css.ts +2 -2
  20. package/src/Ui/{Layout/Main → Main}/Footer/index.tsx +3 -3
  21. package/src/Ui/{Layout/Main → Main}/index.css.ts +3 -3
  22. package/src/Ui/{Layout/Main → Main}/index.tsx +5 -5
  23. package/src/Ui/index.css.ts +9 -0
  24. package/src/Ui/index.tsx +37 -12
  25. package/src/{Ui → stores}/LocalStore.tsx +3 -3
  26. package/src/Ui/Layout/Header/SideNavButton/index.css.ts +0 -4
  27. package/src/Ui/Layout/Header/SideNavButton/index.tsx +0 -16
  28. package/src/Ui/Layout/Header/TopNav/index.css.ts +0 -9
  29. package/src/Ui/Layout/index.css.ts +0 -9
  30. package/src/Ui/Layout/index.tsx +0 -50
  31. /package/src/{Ui → stores}/SessionStore.tsx +0 -0
package/bun.lockb CHANGED
Binary file
package/index.ts CHANGED
@@ -1,11 +1,12 @@
1
- export {Avatar} from './src/Avatar/index.tsx';
2
- export {Axis} from './src/Axis/index.tsx';
3
- export {Button} from './src/Button/index.tsx';
4
- export {Card} from './src/Card/index.tsx';
5
- export {Collapsible} from './src/Collapsible/index.tsx';
6
- export {Detail} from './src/Detail/index.tsx';
7
- export {Hr} from './src/Hr/index.tsx';
8
- export {Metric} from './src/Metric/index.tsx';
9
- export {Summary} from './src/Summary/index.tsx';
10
- export {Tag} from './src/Tag/index.tsx';
11
- export {Ui} from './src/Ui/index.tsx';
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/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "tinywidgets",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinywidgets",
6
6
  "module": "index.ts",
7
7
  "devDependencies": {
8
- "@types/react": "^18.3.3",
8
+ "@types/react": "^18.3.5",
9
9
  "@types/react-dom": "^18.3.0",
10
- "@typescript-eslint/eslint-plugin": "^7.16.1",
11
- "@typescript-eslint/parser": "^7.16.1",
10
+ "@typescript-eslint/eslint-plugin": "^8.4.0",
11
+ "@typescript-eslint/parser": "^8.4.0",
12
12
  "eslint": "^8.57.0",
13
13
  "eslint-config-prettier": "^9.1.0",
14
- "eslint-plugin-react": "^7.34.4",
14
+ "eslint-plugin-react": "^7.35.2",
15
15
  "eslint-plugin-react-hooks": "^4.6.2",
16
16
  "prettier": "^3.3.3",
17
- "typescript": "^5.5.3",
17
+ "typescript": "^5.5.4",
18
18
  "@vanilla-extract/css": "^1.15.5",
19
19
  "react": "^18.3.1",
20
20
  "react-dom": "^18.3.1",
21
- "tinybase": "^5.1.0"
21
+ "tinybase": "^5.3.0-beta.1"
22
22
  },
23
23
  "exports": {
24
24
  ".": "./index.ts",
@@ -28,6 +28,6 @@
28
28
  "description": "reserved",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "lucide-react": "^0.438.0"
31
+ "lucide-react": "^0.439.0"
32
32
  }
33
33
  }
@@ -0,0 +1,18 @@
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,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,
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  useCollapsibleOpen,
15
15
  useSetCollapsibleOpen,
16
- } from '../Ui/SessionStore.tsx';
16
+ } from '../stores/SessionStore.tsx';
17
17
  import {
18
18
  button,
19
19
  buttonOpen,
@@ -46,7 +46,7 @@ export const Collapsible = ({
46
46
  const setIsOpen = id ? setStoredIsOpen : setStateIsOpen;
47
47
 
48
48
  const [render, setRender] = useState(isOpen);
49
- const timer = useRef<NodeJS.Timeout>();
49
+ const timer = useRef<NodeJS.Timer>();
50
50
 
51
51
  const toggle = useCallback(() => {
52
52
  setIsOpen(!isOpen);
@@ -1,12 +1,12 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import {Moon, Sun, SunMoon} from 'lucide-react';
4
- import {Button} from '../../../../Button/index.tsx';
5
- import {createElement} from '../../../../index.ts';
3
+ import { Moon, Sun, SunMoon } from 'lucide-react';
4
+ import { Button } from '../../../Button/index.tsx';
5
+ import { createElement } from '../../../index.ts';
6
6
  import {
7
7
  useDarkChoice,
8
8
  useToggleDarkChoiceCallback,
9
- } from '../../../LocalStore.tsx';
9
+ } from '../../../stores/LocalStore.tsx';
10
10
 
11
11
  const icons = [Sun, Moon, SunMoon];
12
12
 
@@ -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,
@@ -1,9 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import {type ReactNode} from 'react';
4
- import {classNames, createElement} from '../../../../index.ts';
5
- import {useSideNavOpen} from '../../../SessionStore.tsx';
6
- import {open, sideNav} from './index.css.ts';
3
+ import { type ReactNode } from 'react';
4
+ import { classNames, createElement } from '../../../index.ts';
5
+ import { useSideNavOpen } from '../../../stores/SessionStore.tsx';
6
+ import { open, sideNav } from './index.css.ts';
7
7
 
8
8
  export const SideNav = ({sideNav: sideNavComponents}: {sideNav: ReactNode}) => {
9
9
  return (
@@ -0,0 +1,4 @@
1
+ import { style } from '@vanilla-extract/css';
2
+ import { large } from '../../../index.ts';
3
+
4
+ export const sideNavButton = style(large({display: 'none'}));
@@ -0,0 +1,19 @@
1
+ /** @jsx createElement */
2
+
3
+ import { Menu, X } from 'lucide-react';
4
+ import { Button } from '../../../Button/index.tsx';
5
+ import { createElement } from '../../../index.ts';
6
+ import {
7
+ useSideNavOpen,
8
+ useToggleSideNavOpen,
9
+ } from '../../../stores/SessionStore.tsx';
10
+ import { sideNavButton } from './index.css.ts';
11
+
12
+ export const SideNavButton = () => (
13
+ <Button
14
+ variant="icon"
15
+ onClick={useToggleSideNavOpen()}
16
+ icon={useSideNavOpen() ? X : Menu}
17
+ className={sideNavButton}
18
+ />
19
+ );
@@ -1,6 +1,6 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {dimensions} from '../../../../index.css';
3
- import {large} from '../../../../index.ts';
1
+ import { style } from '@vanilla-extract/css';
2
+ import { dimensions } from '../../../index.css.ts';
3
+ import { large } from '../../../index.ts';
4
4
 
5
5
  export const title = style({
6
6
  display: 'flex',
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import {type ReactNode} from 'react';
4
- import {createElement} from '../../../../index.ts';
5
- import {title} from './index.css.ts';
3
+ import { type ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { title } from './index.css.ts';
6
6
 
7
7
  export const Title = ({title: titleComponents}: {title: ReactNode}) => {
8
8
  return <nav className={title}>{titleComponents}</nav>;
@@ -0,0 +1,9 @@
1
+ import { style } from '@vanilla-extract/css';
2
+ import { axisLike } from '../../../index.css';
3
+
4
+ export const topNav = style([
5
+ {
6
+ ...axisLike,
7
+ flex: 1,
8
+ },
9
+ ]);
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {createElement} from '../../../../index.ts';
5
- import {topNav} from './index.css.ts';
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { topNav } from './index.css.ts';
6
6
 
7
7
  export const TopNav = ({
8
8
  topNavLeft = <div />,
@@ -1,5 +1,5 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {axisLike, dimensions, paddingLike, theme} from '../../../index.css';
1
+ import { style } from '@vanilla-extract/css';
2
+ import { axisLike, dimensions, paddingLike, theme } from '../../index.css';
3
3
 
4
4
  export const header = style([
5
5
  paddingLike,
@@ -1,13 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {createElement} from '../../../index.ts';
5
- import {DarkButton} from './DarkButton/index.tsx';
6
- import {header} from './index.css.ts';
7
- import {SideNav} from './SideNav/index.tsx';
8
- import {SideNavButton} from './SideNavButton/index.tsx';
9
- import {Title} from './Title/index.tsx';
10
- import {TopNav} from './TopNav/index.tsx';
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../index.ts';
5
+ import { DarkButton } from './DarkButton/index.tsx';
6
+ import { header } from './index.css.ts';
7
+ import { SideNav } from './SideNav/index.tsx';
8
+ import { SideNavButton } from './SideNavButton/index.tsx';
9
+ import { Title } from './Title/index.tsx';
10
+ import { TopNav } from './TopNav/index.tsx';
11
11
 
12
12
  export const Header = ({
13
13
  title,
@@ -1,5 +1,5 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {dimensions, paddingLike} from '../../../../index.css';
1
+ import { style } from '@vanilla-extract/css';
2
+ import { dimensions, paddingLike } from '../../../index.css';
3
3
 
4
4
  export const article = style([
5
5
  paddingLike,
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {createElement} from '../../../../index.ts';
5
- import {article} from './index.css.ts';
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { article } from './index.css.ts';
6
6
 
7
7
  export const Article = ({article: articleComponents}: {article: ReactNode}) => {
8
8
  return <article className={article}>{articleComponents}</article>;
@@ -1,5 +1,5 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {axisLike, dimensions, paddingLike, theme} from '../../../../index.css';
1
+ import { style } from '@vanilla-extract/css';
2
+ import { axisLike, dimensions, paddingLike, theme } from '../../../index.css';
3
3
 
4
4
  export const footer = style([
5
5
  {
@@ -1,8 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {createElement} from '../../../../index.ts';
5
- import {footer} from './index.css.ts';
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { footer } from './index.css.ts';
6
6
 
7
7
  export const Footer = ({footer: footerComponents}: {footer: ReactNode}) => {
8
8
  return <footer className={footer}>{footerComponents}</footer>;
@@ -1,6 +1,6 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {dimensions, theme} from '../../../index.css';
3
- import {large} from '../../../index.ts';
1
+ import { style } from '@vanilla-extract/css';
2
+ import { dimensions, theme } from '../../index.css.ts';
3
+ import { large } from '../../index.ts';
4
4
 
5
5
  export const main = style({
6
6
  display: 'flex',
@@ -1,10 +1,10 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {classNames, createElement} from '../../../index.ts';
5
- import {Article} from './Article/index.tsx';
6
- import {Footer} from './Footer/index.tsx';
7
- import {main, mainHasSideNav} from './index.css.ts';
3
+ import type { ReactNode } from 'react';
4
+ import { classNames, createElement } from '../../index.ts';
5
+ import { Article } from './Article/index.tsx';
6
+ import { Footer } from './Footer/index.tsx';
7
+ import { main, mainHasSideNav } from './index.css.ts';
8
8
 
9
9
  export const Main = ({
10
10
  article,
@@ -0,0 +1,9 @@
1
+ import { style } from '@vanilla-extract/css';
2
+ import { theme } from '../index.css.ts';
3
+
4
+ export const ui = style({
5
+ display: 'flex',
6
+ height: '100vh',
7
+ width: '100vw',
8
+ color: theme.foreground,
9
+ });
package/src/Ui/index.tsx CHANGED
@@ -1,13 +1,21 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import type {ReactNode} from 'react';
4
- import {Provider} from 'tinybase/ui-react';
5
- import {createElement} from '../index.ts';
6
- import {Layout} from './Layout/index.tsx';
7
- import {LocalStore} from './LocalStore.tsx';
8
- import {SessionStore} from './SessionStore.tsx';
3
+ import type { ReactNode } from 'react';
4
+ import { themeDark, themeLight } from '../index.css.ts';
5
+ import { classNames, createElement } from '../index.ts';
6
+ import { useDarkChoice, useDarkPreference } from '../stores/LocalStore.tsx';
7
+ import { Header } from './Header/index.tsx';
8
+ import { ui } from './index.css.ts';
9
+ import { Main } from './Main/index.tsx';
9
10
 
10
- export const Ui = (props: {
11
+ export const Ui = ({
12
+ title,
13
+ topNavLeft,
14
+ topNavRight,
15
+ sideNav,
16
+ article,
17
+ footer,
18
+ }: {
11
19
  title: ReactNode;
12
20
  topNavLeft?: ReactNode;
13
21
  topNavRight?: ReactNode;
@@ -15,11 +23,28 @@ export const Ui = (props: {
15
23
  article?: ReactNode;
16
24
  footer?: ReactNode;
17
25
  }) => {
26
+ const darkPreference = useDarkPreference();
27
+ const darkChoice = useDarkChoice();
18
28
  return (
19
- <Provider>
20
- <Layout {...props} />
21
- <SessionStore />
22
- <LocalStore />
23
- </Provider>
29
+ <div
30
+ className={classNames(
31
+ ui,
32
+ darkChoice == 1 || (darkChoice == 2 && darkPreference)
33
+ ? themeDark
34
+ : themeLight,
35
+ )}
36
+ >
37
+ <Header
38
+ title={title}
39
+ topNavLeft={topNavLeft}
40
+ topNavRight={topNavRight}
41
+ sideNav={sideNav}
42
+ />
43
+ <Main
44
+ article={article}
45
+ footer={footer}
46
+ hasSideNav={sideNav ? true : false}
47
+ />
48
+ </div>
24
49
  );
25
50
  };
@@ -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,7 +7,7 @@ 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
 
@@ -1,4 +0,0 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {large} from '../../../../index.ts';
3
-
4
- export const sideNavButton = style(large({display: 'none'}));
@@ -1,16 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import {Menu, X} from 'lucide-react';
4
- import {Button} from '../../../../Button/index.tsx';
5
- import {createElement} from '../../../../index.ts';
6
- import {useSideNavOpen, useToggleSideNavOpen} from '../../../SessionStore.tsx';
7
- import {sideNavButton} from './index.css';
8
-
9
- export const SideNavButton = () => (
10
- <Button
11
- variant="icon"
12
- onClick={useToggleSideNavOpen()}
13
- icon={useSideNavOpen() ? X : Menu}
14
- className={sideNavButton}
15
- />
16
- );
@@ -1,9 +0,0 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {axisLike} from '../../../../index.css';
3
-
4
- export const topNav = style([
5
- {
6
- ...axisLike,
7
- flex: 1,
8
- },
9
- ]);
@@ -1,9 +0,0 @@
1
- import {style} from '@vanilla-extract/css';
2
- import {theme} from '../../index.css.ts';
3
-
4
- export const layout = style({
5
- display: 'flex',
6
- height: '100vh',
7
- width: '100vw',
8
- color: theme.foreground,
9
- });
@@ -1,50 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import type {ReactNode} from 'react';
4
- import {themeDark, themeLight} from '../../index.css.ts';
5
- import {classNames, createElement} from '../../index.ts';
6
- import {useDarkChoice, useDarkPreference} from '../LocalStore.tsx';
7
- import {Header} from './Header/index.tsx';
8
- import {layout} from './index.css.ts';
9
- import {Main} from './Main/index.tsx';
10
-
11
- export const Layout = ({
12
- title,
13
- topNavLeft,
14
- topNavRight,
15
- sideNav,
16
- article,
17
- footer,
18
- }: {
19
- title: ReactNode;
20
- topNavLeft?: ReactNode;
21
- topNavRight?: ReactNode;
22
- sideNav?: ReactNode;
23
- article?: ReactNode;
24
- footer?: ReactNode;
25
- }) => {
26
- const darkPreference = useDarkPreference();
27
- const darkChoice = useDarkChoice();
28
- return (
29
- <div
30
- className={classNames(
31
- layout,
32
- darkChoice == 1 || (darkChoice == 2 && darkPreference)
33
- ? themeDark
34
- : themeLight,
35
- )}
36
- >
37
- <Header
38
- title={title}
39
- topNavLeft={topNavLeft}
40
- topNavRight={topNavRight}
41
- sideNav={sideNav}
42
- />
43
- <Main
44
- article={article}
45
- footer={footer}
46
- hasSideNav={sideNav ? true : false}
47
- />
48
- </div>
49
- );
50
- };
File without changes