tinywidgets 0.0.3 → 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 (41) 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/Avatar/index.tsx +1 -4
  6. package/src/Axis/index.tsx +3 -5
  7. package/src/Button/index.tsx +7 -9
  8. package/src/Card/index.tsx +3 -5
  9. package/src/Collapsible/index.tsx +16 -12
  10. package/src/Detail/index.tsx +3 -5
  11. package/src/Hr/index.tsx +1 -3
  12. package/src/Metric/index.tsx +5 -7
  13. package/src/Summary/index.tsx +5 -7
  14. package/src/Tag/index.tsx +4 -6
  15. package/src/Ui/{Layout/Header → Header}/DarkButton/index.tsx +4 -5
  16. package/src/Ui/{Layout/Header → Header}/SideNav/index.css.ts +3 -3
  17. package/src/Ui/{Layout/Header → Header}/SideNav/index.tsx +4 -6
  18. package/src/Ui/Header/SideNavButton/index.css.ts +4 -0
  19. package/src/Ui/Header/SideNavButton/index.tsx +19 -0
  20. package/src/Ui/{Layout/Header → Header}/Title/index.css.ts +3 -3
  21. package/src/Ui/{Layout/Header → Header}/Title/index.tsx +3 -4
  22. package/src/Ui/Header/TopNav/index.css.ts +9 -0
  23. package/src/Ui/{Layout/Header → Header}/TopNav/index.tsx +3 -4
  24. package/src/Ui/{Layout/Header → Header}/index.css.ts +2 -2
  25. package/src/Ui/{Layout/Header → Header}/index.tsx +8 -9
  26. package/src/Ui/{Layout/Main → Main}/Article/index.css.ts +2 -2
  27. package/src/Ui/{Layout/Main → Main}/Article/index.tsx +3 -4
  28. package/src/Ui/{Layout/Main → Main}/Footer/index.css.ts +2 -2
  29. package/src/Ui/{Layout/Main → Main}/Footer/index.tsx +3 -4
  30. package/src/Ui/{Layout/Main → Main}/index.css.ts +3 -3
  31. package/src/Ui/{Layout/Main → Main}/index.tsx +5 -7
  32. package/src/Ui/index.css.ts +9 -0
  33. package/src/Ui/index.tsx +37 -13
  34. package/src/index.ts +11 -0
  35. package/src/{Ui → stores}/LocalStore.tsx +3 -6
  36. package/src/Ui/Layout/Header/SideNavButton/index.css.ts +0 -4
  37. package/src/Ui/Layout/Header/SideNavButton/index.tsx +0 -17
  38. package/src/Ui/Layout/Header/TopNav/index.css.ts +0 -9
  39. package/src/Ui/Layout/index.css.ts +0 -9
  40. package/src/Ui/Layout/index.tsx +0 -52
  41. /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.3",
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,11 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../index.ts';
3
+ import {classNames, createElement} from '../index.ts';
5
4
  import {avatar} from './index.css.ts';
6
5
 
7
- const {createElement} = React;
8
-
9
6
  export const Avatar = ({
10
7
  src,
11
8
  title,
@@ -1,11 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {axis, gapStyle, justifyStyle, verticalStyle} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Axis = ({
10
8
  justify = true,
11
9
  gap = true,
@@ -17,7 +15,7 @@ export const Axis = ({
17
15
  justify?: boolean;
18
16
  gap?: boolean;
19
17
  vertical?: boolean;
20
- children: React.ReactNode;
18
+ children: ReactNode;
21
19
  className?: string;
22
20
  title?: string;
23
21
  }) => {
@@ -1,13 +1,11 @@
1
1
  /** @jsx createElement */
2
2
  /** @jsxFrag Fragment */
3
3
 
4
- import React from 'react';
4
+ import type {ComponentType, ReactNode, Ref} from 'react';
5
5
  import {iconSize} from '../index.css.ts';
6
- import {classNames} from '../index.ts';
6
+ import {classNames, createElement, forwardRef, useCallback} from '../index.ts';
7
7
  import {button, buttonVariant, highlight, labelStyle} from './index.css.ts';
8
8
 
9
- const {createElement, useCallback, forwardRef} = React;
10
-
11
9
  export const Button = forwardRef(
12
10
  (
13
11
  {
@@ -22,10 +20,10 @@ export const Button = forwardRef(
22
20
  title,
23
21
  current,
24
22
  }: {
25
- icon?: React.ComponentType<{className?: string}>;
26
- label?: React.ReactNode;
27
- labelRight?: React.ReactNode;
28
- iconRight?: React.ComponentType<{className?: string}>;
23
+ icon?: ComponentType<{className?: string}>;
24
+ label?: ReactNode;
25
+ labelRight?: ReactNode;
26
+ iconRight?: ComponentType<{className?: string}>;
29
27
  onClick?: () => void;
30
28
  variant?: keyof typeof buttonVariant;
31
29
  className?: string;
@@ -33,7 +31,7 @@ export const Button = forwardRef(
33
31
  title?: string;
34
32
  current?: boolean;
35
33
  },
36
- ref: React.Ref<HTMLButtonElement>,
34
+ ref: Ref<HTMLButtonElement>,
37
35
  ) => {
38
36
  const icon = Icon ? <Icon className={iconSize} /> : null;
39
37
  const iconRight = IconRight ? <IconRight className={iconSize} /> : null;
@@ -1,15 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {card} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Card = ({
10
8
  children,
11
9
  className,
12
10
  }: {
13
- children: React.ReactNode;
11
+ children: ReactNode;
14
12
  className?: string;
15
13
  }) => <div className={classNames(card, className)}>{children}</div>;
@@ -1,13 +1,19 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {ChevronDown, ChevronRight} from 'lucide-react';
5
- import {Button} from '../Button/index.tsx';
6
- import {classNames} from '../index.ts';
3
+ import type { ComponentType, ReactNode } from 'react';
4
+ import { ChevronDown, ChevronRight } from 'lucide-react';
5
+ import { Button } from '../Button/index.tsx';
6
+ import {
7
+ classNames,
8
+ createElement,
9
+ useCallback,
10
+ useRef,
11
+ useState,
12
+ } from '../index.ts';
7
13
  import {
8
14
  useCollapsibleOpen,
9
15
  useSetCollapsibleOpen,
10
- } from '../Ui/SessionStore.tsx';
16
+ } from '../stores/SessionStore.tsx';
11
17
  import {
12
18
  button,
13
19
  buttonOpen,
@@ -16,8 +22,6 @@ import {
16
22
  content,
17
23
  } from './index.css.ts';
18
24
 
19
- const {createElement, useState, useCallback, useRef} = React;
20
-
21
25
  export const Collapsible = ({
22
26
  id = '',
23
27
  icon: Icon,
@@ -27,11 +31,11 @@ export const Collapsible = ({
27
31
  children,
28
32
  }: {
29
33
  id?: string;
30
- icon?: React.ComponentType<{className?: string}>;
31
- label?: React.ReactNode;
32
- labelRight?: React.ReactNode;
34
+ icon?: ComponentType<{className?: string}>;
35
+ label?: ReactNode;
36
+ labelRight?: ReactNode;
33
37
  className?: string;
34
- children: React.ReactNode;
38
+ children: ReactNode;
35
39
  }) => {
36
40
  // State is in session Store if id is present, otherwise here in component.
37
41
  const storedIsOpen = useCollapsibleOpen(id) ?? false;
@@ -42,7 +46,7 @@ export const Collapsible = ({
42
46
  const setIsOpen = id ? setStoredIsOpen : setStateIsOpen;
43
47
 
44
48
  const [render, setRender] = useState(isOpen);
45
- const timer = useRef<Timer>();
49
+ const timer = useRef<NodeJS.Timer>();
46
50
 
47
51
  const toggle = useCallback(() => {
48
52
  setIsOpen(!isOpen);
@@ -1,16 +1,14 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {detailCell, detailRow, detailTable} from './index.css';
6
6
 
7
- const {createElement} = React;
8
-
9
7
  export const Detail = ({
10
8
  data,
11
9
  className,
12
10
  }: {
13
- data: Record<string, React.ReactNode>;
11
+ data: Record<string, ReactNode>;
14
12
  className?: string;
15
13
  }) => {
16
14
  return (
package/src/Hr/index.tsx CHANGED
@@ -1,10 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
3
+ import {createElement} from '../';
4
4
  import {hr} from './index.css';
5
5
 
6
- const {createElement} = React;
7
-
8
6
  export const Hr = () => {
9
7
  return <hr className={hr} />;
10
8
  };
@@ -1,21 +1,19 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {iconSize} from '../index.css';
6
6
  import {metric, metricLabel, metricNumber} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Metric = ({
11
9
  icon: Icon,
12
10
  label,
13
11
  number,
14
12
  className,
15
13
  }: {
16
- icon?: React.ComponentType<{className?: string}>;
17
- label: React.ReactNode;
18
- number: React.ReactNode;
14
+ icon?: ComponentType<{className?: string}>;
15
+ label: ReactNode;
16
+ number: ReactNode;
19
17
  className?: string;
20
18
  }) => (
21
19
  <div className={classNames(metric, className)}>
@@ -1,12 +1,10 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {Avatar} from '../Avatar';
6
6
  import {summary, summaryContent, summaryImage} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Summary = ({
11
9
  icon: Icon,
12
10
  src,
@@ -14,10 +12,10 @@ export const Summary = ({
14
12
  children,
15
13
  className,
16
14
  }: {
17
- icon?: React.ComponentType<{className?: string}>;
15
+ icon?: ComponentType<{className?: string}>;
18
16
  src?: string;
19
- label: React.ReactNode;
20
- children: React.ReactNode;
17
+ label: ReactNode;
18
+ children: ReactNode;
21
19
  className?: string;
22
20
  }) => (
23
21
  <div className={classNames(summary, className)}>
package/src/Tag/index.tsx CHANGED
@@ -1,20 +1,18 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {classNames} from '../';
3
+ import type {ComponentType, ReactNode} from 'react';
4
+ import {classNames, createElement} from '../';
5
5
  import {Axis} from '../Axis';
6
6
  import {tag, tagIcon, tagVariant} from './index.css';
7
7
 
8
- const {createElement} = React;
9
-
10
8
  export const Tag = ({
11
9
  icon: Icon,
12
10
  label,
13
11
  title,
14
12
  variant = 'default',
15
13
  }: {
16
- icon?: React.ComponentType<{className?: string}>;
17
- label?: React.ReactNode;
14
+ icon?: ComponentType<{className?: string}>;
15
+ label?: ReactNode;
18
16
  title?: string;
19
17
  variant?: keyof typeof tagVariant;
20
18
  }) => {
@@ -1,14 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React from 'react';
4
- import {Moon, Sun, SunMoon} from 'lucide-react';
5
- import {Button} from '../../../../Button/index.tsx';
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
- const {createElement} = React;
12
11
  const icons = [Sun, Moon, SunMoon];
13
12
 
14
13
  export const DarkButton = () => (
@@ -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,11 +1,9 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {classNames} from '../../../../index.ts';
5
- import {useSideNavOpen} from '../../../SessionStore.tsx';
6
- import {open, sideNav} from './index.css.ts';
7
-
8
- const {createElement} = React;
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';
9
7
 
10
8
  export const SideNav = ({sideNav: sideNavComponents}: {sideNav: ReactNode}) => {
11
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,9 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {title} from './index.css.ts';
5
-
6
- const {createElement} = React;
3
+ import { type ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { title } from './index.css.ts';
7
6
 
8
7
  export const Title = ({title: titleComponents}: {title: ReactNode}) => {
9
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,9 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {topNav} from './index.css.ts';
5
-
6
- const {createElement} = React;
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { topNav } from './index.css.ts';
7
6
 
8
7
  export const TopNav = ({
9
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,14 +1,13 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {DarkButton} from './DarkButton/index.tsx';
5
- import {header} from './index.css.ts';
6
- import {SideNav} from './SideNav/index.tsx';
7
- import {SideNavButton} from './SideNavButton/index.tsx';
8
- import {Title} from './Title/index.tsx';
9
- import {TopNav} from './TopNav/index.tsx';
10
-
11
- const {createElement} = React;
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';
12
11
 
13
12
  export const Header = ({
14
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,9 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {article} from './index.css.ts';
5
-
6
- const {createElement} = React;
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { article } from './index.css.ts';
7
6
 
8
7
  export const Article = ({article: articleComponents}: {article: ReactNode}) => {
9
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,9 +1,8 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {footer} from './index.css.ts';
5
-
6
- const {createElement} = React;
3
+ import type { ReactNode } from 'react';
4
+ import { createElement } from '../../../index.ts';
5
+ import { footer } from './index.css.ts';
7
6
 
8
7
  export const Footer = ({footer: footerComponents}: {footer: ReactNode}) => {
9
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,12 +1,10 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {classNames} 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
-
9
- const {createElement} = React;
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';
10
8
 
11
9
  export const Main = ({
12
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,14 +1,21 @@
1
1
  /** @jsx createElement */
2
2
 
3
- import React, {type ReactNode} from 'react';
4
- import {Provider} from 'tinybase/ui-react';
5
- import {Layout} from './Layout/index.tsx';
6
- import {LocalStore} from './LocalStore.tsx';
7
- 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';
8
10
 
9
- const {createElement} = React;
10
-
11
- export const Ui = (props: {
11
+ export const Ui = ({
12
+ title,
13
+ topNavLeft,
14
+ topNavRight,
15
+ sideNav,
16
+ article,
17
+ footer,
18
+ }: {
12
19
  title: ReactNode;
13
20
  topNavLeft?: ReactNode;
14
21
  topNavRight?: ReactNode;
@@ -16,11 +23,28 @@ export const Ui = (props: {
16
23
  article?: ReactNode;
17
24
  footer?: ReactNode;
18
25
  }) => {
26
+ const darkPreference = useDarkPreference();
27
+ const darkChoice = useDarkChoice();
19
28
  return (
20
- <Provider>
21
- <Layout {...props} />
22
- <SessionStore />
23
- <LocalStore />
24
- </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>
25
49
  );
26
50
  };
package/src/index.ts CHANGED
@@ -1,7 +1,18 @@
1
+ import React from 'react';
1
2
  import type {StyleRule} from '@vanilla-extract/css';
2
3
 
3
4
  const LARGE = 'screen and (min-width: 1000px)';
4
5
 
6
+ export const {
7
+ createElement,
8
+ Fragment,
9
+ useEffect,
10
+ useRef,
11
+ useState,
12
+ useCallback,
13
+ forwardRef,
14
+ } = React;
15
+
5
16
  export const large = (style: StyleRule) => ({
6
17
  '@media': {
7
18
  [LARGE]: style,
@@ -1,7 +1,5 @@
1
- /** @jsx createElement */
2
- import React from 'react';
3
- import {createStore} from 'tinybase';
4
- import {createLocalPersister} from 'tinybase/persisters/persister-browser';
1
+ import { createStore } from 'tinybase';
2
+ import { createLocalPersister } from 'tinybase/persisters/persister-browser';
5
3
  import {
6
4
  useCreatePersister,
7
5
  useCreateStore,
@@ -9,8 +7,7 @@ import {
9
7
  useSetValueCallback,
10
8
  useValue,
11
9
  } from 'tinybase/ui-react';
12
-
13
- const {useEffect} = React;
10
+ import { useEffect } from '../';
14
11
 
15
12
  const PREFERS_DARK = matchMedia?.('(prefers-color-scheme: dark)');
16
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,17 +0,0 @@
1
- /** @jsx createElement */
2
- import React from 'react';
3
- import {Menu, X} from 'lucide-react';
4
- import {Button} from '../../../../Button/index.tsx';
5
- import {useSideNavOpen, useToggleSideNavOpen} from '../../../SessionStore.tsx';
6
- import {sideNavButton} from './index.css';
7
-
8
- const {createElement} = React;
9
-
10
- export const SideNavButton = () => (
11
- <Button
12
- variant="icon"
13
- onClick={useToggleSideNavOpen()}
14
- icon={useSideNavOpen() ? X : Menu}
15
- className={sideNavButton}
16
- />
17
- );
@@ -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,52 +0,0 @@
1
- /** @jsx createElement */
2
-
3
- import React, {type ReactNode} from 'react';
4
- import {themeDark, themeLight} from '../../index.css.ts';
5
- import {classNames} 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
- const {createElement} = React;
12
-
13
- export const Layout = ({
14
- title,
15
- topNavLeft,
16
- topNavRight,
17
- sideNav,
18
- article,
19
- footer,
20
- }: {
21
- title: ReactNode;
22
- topNavLeft?: ReactNode;
23
- topNavRight?: ReactNode;
24
- sideNav?: ReactNode;
25
- article?: ReactNode;
26
- footer?: ReactNode;
27
- }) => {
28
- const darkPreference = useDarkPreference();
29
- const darkChoice = useDarkChoice();
30
- return (
31
- <div
32
- className={classNames(
33
- layout,
34
- darkChoice == 1 || (darkChoice == 2 && darkPreference)
35
- ? themeDark
36
- : themeLight,
37
- )}
38
- >
39
- <Header
40
- title={title}
41
- topNavLeft={topNavLeft}
42
- topNavRight={topNavRight}
43
- sideNav={sideNav}
44
- />
45
- <Main
46
- article={article}
47
- footer={footer}
48
- hasSideNav={sideNav ? true : false}
49
- />
50
- </div>
51
- );
52
- };
File without changes