this.gui 1.3.22 → 1.3.26
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/dist/this-gui.es.js +0 -1
- package/dist/this-gui.umd.js +65 -65
- package/index.ts +3 -2
- package/init/index.html +4 -5
- package/init/package-lock.json +2 -2
- package/init/package.json +1 -1
- package/init/src/App.tsx +24 -0
- package/init/src/index.css +16 -0
- package/init/src/main.tsx +14 -0
- package/init/src/router/DerivableRouter.tsx +36 -0
- package/package.json +1 -1
- package/src/GUI.tsx +15 -0
- package/src/components/generics/Cards/Gridme.jsx +52 -0
- package/src/components/generics/Cards/LilBox.jsx +65 -0
- package/src/components/generics/Cards/ModuleCard.jsx +106 -0
- package/src/components/generics/Chats/FullChatBot.jsx +223 -0
- package/src/components/generics/Code/CodeBlock.jsx +33 -0
- package/src/components/generics/Feedback/Callout.jsx +92 -0
- package/src/components/generics/Layout/GridX.jsx +29 -0
- package/src/components/generics/Layout/Hero2.jsx +132 -0
- package/src/components/generics/Layout/PageContainer.jsx +29 -0
- package/src/components/generics/Layout/PageDivider.jsx +20 -0
- package/src/components/generics/Layout/Section.jsx +43 -0
- package/src/components/generics/Layout/SectionHeader.jsx +21 -0
- package/src/components/generics/Media/Img.jsx +58 -0
- package/src/components/generics/Media/VideoEmbed.jsx +51 -0
- package/src/components/generics/Organization/TableOfContents.jsx +51 -0
- package/src/components/generics/Organization/Tabs.jsx +45 -0
- package/src/components/generics/Text/TextList.jsx +41 -0
- package/src/components/generics/Text/TextParagraph.jsx +28 -0
- package/src/components/generics/Text/TextQuote.jsx +23 -0
- package/src/components/generics/Text/TextTitle.jsx +44 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.resolver.tsx +0 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.stories.tsx +88 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.tsx +53 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.types.tsx +40 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.resolver.tsx +45 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.stories.tsx +209 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.tsx +337 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.types.ts +40 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.resolver.tsx +37 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.stories.tsx +290 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.tsx +112 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.types.ts +56 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/useLayoutBreakpoints.ts +9 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.resolver.tsx +87 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.stories.tsx +199 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.tsx +311 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.types.ts +41 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/SidebarToggleButton.tsx +53 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarAction/LeftSidebarAction.resolver.tsx +19 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarAction/LeftSidebarAction.tsx +107 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.resolver.tsx +0 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.tsx +122 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.types.ts +13 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarMenu/LeftSidebarMenu.tsx +142 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarToggleButton/LeftSidebarToggleButton.tsx +23 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.resolver.tsx +35 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.stories.tsx +240 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.tsx +319 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.types.ts +17 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarAction/RightSidebarAction.tsx +102 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarLink/RightSidebarLink.tsx +132 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarMenu/RightSidebarMenu.tsx +140 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarToggleButton/RightSidebarToggleButton.tsx +22 -0
- package/src/gui/Layouts/ResponsiveUI/StickyOptions/StickyOptionsTop.stories.tsx +469 -0
- package/src/gui/Layouts/ResponsiveUI/StickyOptions/StickyOptionsTop.tsx +489 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.resolver.tsx +86 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.stories.tsx +350 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.tsx +281 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.types.ts +39 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.stories.tsx +83 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.tsx +18 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.types.ts +4 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.stories.tsx +189 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.tsx +30 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.types.ts +9 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.resolver.tsx +14 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.stories.tsx +56 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.tsx +123 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.types.ts +44 -0
- package/src/gui/Theme/GuiProvider.tsx +125 -0
- package/src/gui/Theme/Icon/Icon.resolver.tsx +29 -0
- package/src/gui/Theme/Icon/Icon.tsx +43 -0
- package/src/gui/Theme/catalog/CherryByte/CherryByte.png +0 -0
- package/src/gui/Theme/catalog/CherryByte/dark.tokens.ts +47 -0
- package/src/gui/Theme/catalog/CherryByte/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/CherryByte/manifest.ts +24 -0
- package/src/gui/Theme/catalog/GhostShell/dark.tokens.ts +43 -0
- package/src/gui/Theme/catalog/GhostShell/ghost.png +0 -0
- package/src/gui/Theme/catalog/GhostShell/light.tokens.ts +39 -0
- package/src/gui/Theme/catalog/GhostShell/manifest.ts +24 -0
- package/src/gui/Theme/catalog/LunaHex/LunaHex.png +0 -0
- package/src/gui/Theme/catalog/LunaHex/dark.tokens.ts +34 -0
- package/src/gui/Theme/catalog/LunaHex/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/LunaHex/manifest.ts +24 -0
- package/src/gui/Theme/catalog/MUI/MUI.png +0 -0
- package/src/gui/Theme/catalog/MUI/dark.tokens.ts +58 -0
- package/src/gui/Theme/catalog/MUI/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/MUI/manifest.ts +24 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/dark.tokens.ts +48 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/manifest.ts +24 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/prince.png +0 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/princeOfDarkness.png +0 -0
- package/src/gui/Theme/catalog/Seafoam/dark.tokens.ts +49 -0
- package/src/gui/Theme/catalog/Seafoam/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/Seafoam/manifest.ts +24 -0
- package/src/gui/Theme/catalog/Seafoam/seaFoam.png +0 -0
- package/src/gui/Theme/catalog/neurons/dark.tokens.ts +58 -0
- package/src/gui/Theme/catalog/neurons/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/neurons/manifest.ts +24 -0
- package/src/gui/Theme/catalog/neurons/neurons.me.png +0 -0
- package/src/gui/Theme/fromTokens.ts +273 -0
- package/src/gui/Theme/gui.css +31 -0
- package/src/gui/Theme/index.ts +17 -0
- package/src/gui/Theme/styles/buildShadows.ts +83 -0
- package/src/gui/Theme/styles/theme.tokens.ts +108 -0
- package/src/gui/Theme/utils/catalog.ts +61 -0
- package/src/gui/Theme/utils/persistence.ts +66 -0
- package/src/gui/Theme/utils/themeUtils.ts +34 -0
- package/src/gui/apis/codegen.api.ts +38 -0
- package/src/gui/components/atoms/AppBar/AppBar.resolver.tsx +41 -0
- package/src/gui/components/atoms/AppBar/AppBar.stories.tsx +225 -0
- package/src/gui/components/atoms/AppBar/AppBar.tsx +8 -0
- package/src/gui/components/atoms/AppBar/AppBar.types.ts +28 -0
- package/src/gui/components/atoms/Avatar/Avatar.resolver.tsx +61 -0
- package/src/gui/components/atoms/Avatar/Avatar.stories.tsx +36 -0
- package/src/gui/components/atoms/Avatar/Avatar.tsx +14 -0
- package/src/gui/components/atoms/Box/Box.resolver.tsx +171 -0
- package/src/gui/components/atoms/Box/Box.stories.tsx +263 -0
- package/src/gui/components/atoms/Box/Box.tsx +15 -0
- package/src/gui/components/atoms/Button/Button.resolver.tsx +103 -0
- package/src/gui/components/atoms/Button/Button.stories.tsx +219 -0
- package/src/gui/components/atoms/Button/Button.tsx +40 -0
- package/src/gui/components/atoms/Card/Card.resolver.tsx +63 -0
- package/src/gui/components/atoms/Card/Card.stories.tsx +54 -0
- package/src/gui/components/atoms/Card/Card.tsx +13 -0
- package/src/gui/components/atoms/CardActions/CardActions.resolver.tsx +59 -0
- package/src/gui/components/atoms/CardActions/CardActions.stories.tsx +32 -0
- package/src/gui/components/atoms/CardActions/CardActions.tsx +14 -0
- package/src/gui/components/atoms/CardContent/CardContent.resolver.tsx +60 -0
- package/src/gui/components/atoms/CardContent/CardContent.stories.tsx +34 -0
- package/src/gui/components/atoms/CardContent/CardContent.tsx +13 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.resolver.tsx +68 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.stories.tsx +40 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.tsx +12 -0
- package/src/gui/components/atoms/Collapse/Collapse.resolver.tsx +85 -0
- package/src/gui/components/atoms/Collapse/Collapse.stories.tsx +130 -0
- package/src/gui/components/atoms/Collapse/Collapse.tsx +17 -0
- package/src/gui/components/atoms/Divider/Divider.resolver.tsx +95 -0
- package/src/gui/components/atoms/Divider/Divider.stories.tsx +108 -0
- package/src/gui/components/atoms/Divider/Divider.tsx +14 -0
- package/src/gui/components/atoms/Drawer/Drawer.resolver.tsx +116 -0
- package/src/gui/components/atoms/Drawer/Drawer.stories.tsx +223 -0
- package/src/gui/components/atoms/Drawer/Drawer.tsx +25 -0
- package/src/gui/components/atoms/Grid/Grid.resolver.tsx +33 -0
- package/src/gui/components/atoms/Grid/Grid.stories.tsx +136 -0
- package/src/gui/components/atoms/Grid/Grid.tsx +15 -0
- package/src/gui/components/atoms/Grid/Grid.types.ts +9 -0
- package/src/gui/components/atoms/IconButton/IconButton.resolver.tsx +137 -0
- package/src/gui/components/atoms/IconButton/IconButton.stories.tsx +134 -0
- package/src/gui/components/atoms/IconButton/IconButton.tsx +22 -0
- package/src/gui/components/atoms/Link/Link.resolver.tsx +74 -0
- package/src/gui/components/atoms/Link/Link.stories.tsx +157 -0
- package/src/gui/components/atoms/Link/Link.tsx +36 -0
- package/src/gui/components/atoms/List/List.resolver.tsx +94 -0
- package/src/gui/components/atoms/List/List.stories.tsx +137 -0
- package/src/gui/components/atoms/List/List.tsx +20 -0
- package/src/gui/components/atoms/ListItem/ListItem.resolver.tsx +88 -0
- package/src/gui/components/atoms/ListItem/ListItem.stories.tsx +151 -0
- package/src/gui/components/atoms/ListItem/ListItem.tsx +19 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.resolver.tsx +214 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.stories.tsx +155 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.tsx +15 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.resolver.tsx +102 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.stories.tsx +132 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.tsx +11 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.resolver.tsx +112 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.stories.tsx +156 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.tsx +15 -0
- package/src/gui/components/atoms/Menu/Menu.resolver.tsx +112 -0
- package/src/gui/components/atoms/Menu/Menu.stories.tsx +162 -0
- package/src/gui/components/atoms/Menu/Menu.tsx +17 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.resolver.tsx +183 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.stories.tsx +134 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.tsx +14 -0
- package/src/gui/components/atoms/Paper/Paper.resolver.tsx +98 -0
- package/src/gui/components/atoms/Paper/Paper.stories.tsx +184 -0
- package/src/gui/components/atoms/Paper/Paper.tsx +15 -0
- package/src/gui/components/atoms/Section/Section.resolver.tsx +10 -0
- package/src/gui/components/atoms/Section/Section.stories.tsx +189 -0
- package/src/gui/components/atoms/Section/Section.tsx +76 -0
- package/src/gui/components/atoms/Section/Section.types.tsx +24 -0
- package/src/gui/components/atoms/Stack/Stack.resolver.tsx +94 -0
- package/src/gui/components/atoms/Stack/Stack.stories.tsx +160 -0
- package/src/gui/components/atoms/Stack/Stack.tsx +15 -0
- package/src/gui/components/atoms/Surface/Surface.resolver.tsx +37 -0
- package/src/gui/components/atoms/Surface/Surface.tsx +49 -0
- package/src/gui/components/atoms/Surface/Surface.types.ts +20 -0
- package/src/gui/components/atoms/Switch/Switch.resolver.tsx +53 -0
- package/src/gui/components/atoms/Switch/Switch.stories.tsx +236 -0
- package/src/gui/components/atoms/Switch/Switch.tsx +22 -0
- package/src/gui/components/atoms/TextField/TextField.stories.tsx +28 -0
- package/src/gui/components/atoms/TextField/TextField.tsx +15 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.resolver.tsx +60 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.stories.tsx +155 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.tsx +16 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.resolver.tsx +142 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.stories.tsx +117 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.tsx +70 -0
- package/src/gui/components/atoms/Typography/Typography.resolver.tsx +158 -0
- package/src/gui/components/atoms/Typography/Typography.stories.tsx +222 -0
- package/src/gui/components/atoms/Typography/Typography.tsx +27 -0
- package/src/gui/components/atoms.tsx +138 -0
- package/src/gui/components/molecules/Dialog/Dialog.stories.tsx +18 -0
- package/src/gui/components/molecules/Dialog/Dialog.tsx +5 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.stories.tsx +141 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.tsx +152 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.types.tsx +18 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.resolver.tsx +38 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.stories.tsx +82 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.tsx +106 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.types.ts +29 -0
- package/src/gui/components/molecules/Page/Page.stories.tsx +135 -0
- package/src/gui/components/molecules/Page/Page.tsx +94 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.resolver.tsx +58 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.stories.tsx +133 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.tsx +101 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.types.ts +29 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.resolver.tsx +15 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.stories.tsx +88 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.tsx +167 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.types.ts +34 -0
- package/src/gui/components/organism/ChatGPTInterface/ChatGPTInterface.stories.tsx +17 -0
- package/src/gui/components/organism/ChatGPTInterface/ChatGPTInterface.tsx +71 -0
- package/src/gui/components/organism/RootDomain/RootDomain.stories.tsx +31 -0
- package/src/gui/components/organism/RootDomain/RootDomain.tsx +100 -0
- package/src/gui/components/organism/RootDomain/staticServices.ts +66 -0
- package/src/gui/components/window/Nodes/node.ts +0 -0
- package/src/gui/components/window/code/block/node.tsx +0 -0
- package/src/gui/components/window/code/hugging.face.api.ts +11 -0
- package/src/gui/components/window/connectors/index.ts +19 -0
- package/src/gui/components/window/window.stories.tsx +20 -0
- package/src/gui/components/window/window.tsx +633 -0
- package/src/gui/contexts/InsetsContext.tsx +38 -0
- package/src/gui/contexts/LeftSidebarContext.tsx +20 -0
- package/src/gui/contexts/RightSidebarContext.tsx +25 -0
- package/src/gui/contexts/ThemeContext.ts +34 -0
- package/src/gui/contexts/index.ts +4 -0
- package/src/gui/hooks/index.ts +11 -0
- package/src/gui/hooks/resolveColorToken.ts +39 -0
- package/src/gui/hooks/useCodeGen.ts +12 -0
- package/src/gui/hooks/useGuiMediaQuery.ts +18 -0
- package/src/gui/hooks/useGuiTheme.ts +18 -0
- package/src/gui/hooks/useInsets.ts +26 -0
- package/src/gui/hooks/useIsMobile.ts +13 -0
- package/src/gui/hooks/useIsTouchDevice.ts +25 -0
- package/src/gui/hooks/useLeftSidebar.ts +10 -0
- package/src/gui/hooks/useRightSidebar.ts +12 -0
- package/src/gui/hooks/useViewportKey.ts +19 -0
- package/src/gui/hooks/useViewportProp.ts +17 -0
- package/src/gui/me/Logic.tsx +31 -0
- package/src/gui/me/Me.stories.tsx +8 -0
- package/src/gui/me/Me.tsx +197 -0
- package/src/gui/me/fundamentals/verbs/verbs.tsx +94 -0
- package/src/gui/me/modificators/Adjectives.ts +0 -0
- package/src/gui/me/modificators/Adverbs.ts +0 -0
- package/src/gui/me/modificators/Complements.ts +27 -0
- package/src/gui/me/utils/Context.tsx +14 -0
- package/src/gui/me/utils/hooks/useMe.js +37 -0
- package/src/gui/utils/nodeID.ts +11 -0
- package/src/registry/GuiRegistry.ts +19 -0
- package/src/registry/factory.ts +12 -0
- package/src/registry/index.ts +3 -0
- package/src/registry/types.ts +6 -0
- package/src/stories/01.Home.mdx +22 -0
- package/src/stories/02.Understanding.This.GUI.mdx +149 -0
- package/src/stories/Theme/Palette.stories.tsx +86 -0
- package/src/stories/Theme/ThemeViewer.stories.tsx +91 -0
- package/src/stories/Theme/Typography.stories.jsx +211 -0
- package/src/types/gui.d.ts +67 -0
- package/src/types/theme.d.ts +191 -0
- package/src/types/viewport.ts +132 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useEffect } from "react";
|
|
2
|
+
import { meCore, MeIdentity } from "./Logic";
|
|
3
|
+
const MeContext = createContext<{ me: MeIdentity | null }>({ me: null });
|
|
4
|
+
export const MeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
5
|
+
const [me, setMe] = useState<MeIdentity | null>(null);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
meCore.init().then(setMe);
|
|
9
|
+
}, []);
|
|
10
|
+
|
|
11
|
+
return <MeContext.Provider value={{ me }}>{children}</MeContext.Provider>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const useMe = () => useContext(MeContext);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { me } from "../../../../../../../../npm/this/me/dist/this-me.es";
|
|
3
|
+
/**
|
|
4
|
+
* ✅ useMe - React bridge for `.me`
|
|
5
|
+
* Keeps React in sync with the live `me` instance.
|
|
6
|
+
*/
|
|
7
|
+
export default function useMe() {
|
|
8
|
+
const [status, setStatus] = useState(me.state.status);
|
|
9
|
+
const [listUs, setListUs] = useState(me.state.listUs || []);
|
|
10
|
+
const [loading, setLoading] = useState(true);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
// ✅ Sync React state with me instance
|
|
13
|
+
const handleStatusChange = () => setStatus({ ...me.state.status });
|
|
14
|
+
const handleListUsChange = () => setListUs([...me.state.listUs]);
|
|
15
|
+
me.on("statusChange", handleStatusChange);
|
|
16
|
+
me.on("listUsChange", handleListUsChange);
|
|
17
|
+
// Initial load
|
|
18
|
+
(async () => {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
await me.status(); // triggers internal update
|
|
21
|
+
await me.listUs(); // updates list
|
|
22
|
+
setLoading(false);
|
|
23
|
+
})();
|
|
24
|
+
return () => {
|
|
25
|
+
me.off("statusChange", handleStatusChange);
|
|
26
|
+
me.off("listUsChange", handleListUsChange);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return {
|
|
30
|
+
status,
|
|
31
|
+
listUs,
|
|
32
|
+
loading,
|
|
33
|
+
checkStatus: () => me.status(),
|
|
34
|
+
fetchListUs: () => me.listUs(),
|
|
35
|
+
loadMe: (alias, hash) => me.loadMe(alias, hash),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/gui/utils/nodeID.ts
|
|
2
|
+
// Utility to ensure a unique node ID for each component in DOM.
|
|
3
|
+
// using crypto.randomUUID if available
|
|
4
|
+
// otherwise falling back to Math.random.
|
|
5
|
+
export function ensureNodeId(type: string, providedId?: string): string {
|
|
6
|
+
if (providedId) return providedId;
|
|
7
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
8
|
+
return `${type}-${crypto.randomUUID()}`;
|
|
9
|
+
}
|
|
10
|
+
return `${type}-${Math.random().toString(36).slice(2)}`;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRegistry } from "./factory";
|
|
2
|
+
import ButtonResolver from "../gui/atoms/Button/Button.resolver";
|
|
3
|
+
import LinkResolver from "../gui/atoms/Link/Link.resolver";
|
|
4
|
+
import TypographyResolver from "@/gui/atoms/Typography/Typography.resolver";
|
|
5
|
+
import DrawerResolver from "@/gui/atoms/Drawer/Drawer.resolver";
|
|
6
|
+
import NavBarResolver from "@/gui/Layout/TopBar/TopBar.resolver";
|
|
7
|
+
import FooterResolver from "@/gui/Layouts/ResponsiveUI/Footer/Footer.resolver";
|
|
8
|
+
// etc...
|
|
9
|
+
export const GuiRegistry = createRegistry([
|
|
10
|
+
//Atoms
|
|
11
|
+
ButtonResolver,
|
|
12
|
+
TypographyResolver,
|
|
13
|
+
LinkResolver,
|
|
14
|
+
DrawerResolver,
|
|
15
|
+
//Molecules
|
|
16
|
+
NavBarResolver,
|
|
17
|
+
FooterResolver,
|
|
18
|
+
// ...
|
|
19
|
+
]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RegistryEntry, GuiRegistry } from "./types";
|
|
2
|
+
|
|
3
|
+
export function createRegistry(entries: RegistryEntry[]): GuiRegistry {
|
|
4
|
+
return entries.reduce<GuiRegistry>((acc, e) => {
|
|
5
|
+
acc[e.type] = e;
|
|
6
|
+
return acc;
|
|
7
|
+
}, {} as GuiRegistry);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function extendRegistry(base: GuiRegistry, entries: RegistryEntry[]): GuiRegistry {
|
|
11
|
+
return { ...base, ...createRegistry(entries) };
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export type RegistryEntry = {
|
|
3
|
+
type: string;
|
|
4
|
+
resolve: (spec: any, ctx?: ResolveCtx) => React.ReactElement | null;};
|
|
5
|
+
export type GuiRegistry = Record<string, RegistryEntry>;
|
|
6
|
+
export type ResolveCtx = { theme?: any; [key: string]: any };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div
|
|
2
|
+
style={{
|
|
3
|
+
display: 'flex',
|
|
4
|
+
flexDirection: 'column',
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
justifyContent: 'center',
|
|
7
|
+
minHeight: '70vh',
|
|
8
|
+
background: 'var(--gui-bg-default)',
|
|
9
|
+
color: 'var(--gui-text-primary)',
|
|
10
|
+
padding: '40px',
|
|
11
|
+
}}
|
|
12
|
+
>
|
|
13
|
+
<img
|
|
14
|
+
src="/GUI.png"
|
|
15
|
+
alt="This.GUI"
|
|
16
|
+
style={{ width: '377px', height: 'auto', imageRendering: 'auto', marginBottom: '10px', marginTop: '-34px' }}
|
|
17
|
+
/>
|
|
18
|
+
<h1 style={{ fontSize: '4rem', margin: '0 0 5px 0' }}>.GUI</h1>
|
|
19
|
+
<div style={{ maxWidth: '600px', textAlign: 'center', fontSize: '1.2rem', lineHeight: '1.3', marginTop: '-8px' }}>
|
|
20
|
+
A collection of components and building blocks for the neurons.me environment, enabling declarative GUI generation powered by AI.
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Declarative GUI with `this.GUI`
|
|
2
|
+
`this.GUI` is designed as a **declarative layout system**, where all building blocks (NavBar, Drawers, StickyOptions, Footer) expose **clear JSON-friendly props**.
|
|
3
|
+
This **allows UIs to be described** and even generated by tools like **LLMs**, using nothing more than structured data.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🔑 Core Idea
|
|
8
|
+
- Every component exposes a **schema-like props API**.
|
|
9
|
+
- Layout respects **insets** (nav height, drawer widths) reported into the theme via `CustomThemeProvider`.
|
|
10
|
+
- The provider also mirrors these values into CSS variables (`--gui-inset-left`, `--gui-inset-right`, `--gui-nav-height`).
|
|
11
|
+
- With this contract, GUIs can be built from **JSON specs** instead of imperative React code.
|
|
12
|
+
|
|
13
|
+
Example JSON spec:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"route": "/dashboard",
|
|
18
|
+
"layout": {
|
|
19
|
+
"navbar": { "title": "Dashboard", "position": "fixed" },
|
|
20
|
+
"stickyOptions": {
|
|
21
|
+
"items": [
|
|
22
|
+
{ "icon": "mui:BarChart", "label": "Stats", "href": "/stats" },
|
|
23
|
+
{ "icon": "lucide:bolt", "label": "Power", "href": "/power" }
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"drawerLeft": { "title": "Menu", "items": [...] },
|
|
27
|
+
"drawerRight": { "title": "Context", "items": [...] },
|
|
28
|
+
"footer": { "text": "© 2025 neurons.me" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Your renderer simply hydrates this into React components.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 📦 Components
|
|
38
|
+
|
|
39
|
+
### NavBar
|
|
40
|
+
|
|
41
|
+
**Props:**
|
|
42
|
+
- `title`: string
|
|
43
|
+
- `logo`: string (URL)
|
|
44
|
+
- `NavBarLinks`: array of `{ label, href, icon?, children? }`
|
|
45
|
+
- `position`: `"fixed"` | `"static"` | `"sticky"` (default: `"fixed"`)
|
|
46
|
+
- `showMenuButton`, `showThemeToggle`
|
|
47
|
+
|
|
48
|
+
NavBar measures its height and updates `theme.layout.insets.nav`.
|
|
49
|
+
|
|
50
|
+
```jsx
|
|
51
|
+
<NavBar title="Demo" position="fixed" />
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### LeftDrawer & RightDrawer
|
|
57
|
+
|
|
58
|
+
**Props:**
|
|
59
|
+
- `drawerWidth`: number (default: 260)
|
|
60
|
+
- `variant`: `"permanent"` | `"temporary"` (auto-chooses based on screen size)
|
|
61
|
+
- `title`: optional with label + icon
|
|
62
|
+
|
|
63
|
+
Each drawer updates `theme.layout.insets.left` or `theme.layout.insets.right` when permanent.
|
|
64
|
+
|
|
65
|
+
```jsx
|
|
66
|
+
<LeftDrawer title="Menu" items={[{ icon: 'mui:Home', label: 'Home' }]} />
|
|
67
|
+
<RightDrawer title="Context" items={[{ icon: 'mui:Info', label: 'Details' }]} />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### StickyOptionsTop
|
|
73
|
+
|
|
74
|
+
Compact quick-actions bar that lives under the NavBar.
|
|
75
|
+
|
|
76
|
+
**Props:**
|
|
77
|
+
- `items`: actions `{ icon, label?, href?, iconColor?, variant? }`
|
|
78
|
+
- `positioning`: `{ mode: 'sticky' | 'fixed', topOffset, reserveSpace }`
|
|
79
|
+
- `mobileVariant`: `"auto"` | `"fab"` | `"inline"`
|
|
80
|
+
- `dense`: boolean
|
|
81
|
+
|
|
82
|
+
```jsx
|
|
83
|
+
<StickyOptionsTop
|
|
84
|
+
items={[
|
|
85
|
+
{ icon: 'mui:Settings', label: 'Settings', href: '/settings' },
|
|
86
|
+
{ icon: 'lucide:bolt', label: 'Power', href: '/power', iconColor: 'primary' }
|
|
87
|
+
]}
|
|
88
|
+
positioning={{ mode: 'sticky' }}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### Footer
|
|
95
|
+
|
|
96
|
+
**Props:**
|
|
97
|
+
- `text`: string or ReactNode
|
|
98
|
+
- Automatically respects left/right insets from permanent drawers.
|
|
99
|
+
|
|
100
|
+
```jsx
|
|
101
|
+
<Footer text="© 2025 neurons.me" />
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🌐 Why Declarative?
|
|
107
|
+
|
|
108
|
+
Every prop is JSON-serializable, so LLMs or external systems can generate full UIs declaratively:
|
|
109
|
+
- “Add a right drawer with a title and an insights icon”
|
|
110
|
+
- “Place a sticky options bar under the navbar with capture + settings”
|
|
111
|
+
- “On /reports, show the drawer and a compact navbar”
|
|
112
|
+
|
|
113
|
+
These map directly into JSON specs that your app hydrates into React.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🚀 Benefits
|
|
118
|
+
- **Schema-driven:** easy to serialize, validate, and diff.
|
|
119
|
+
- **LLM-ready:** prompt-to-UI becomes natural.
|
|
120
|
+
- **Layout-safe:** insets keep everything aligned automatically.
|
|
121
|
+
- **Composable:** any route can declare its layout in one object.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Example: Full Route Layout
|
|
126
|
+
|
|
127
|
+
```jsx
|
|
128
|
+
<NavBar title="Dashboard" />
|
|
129
|
+
<LeftDrawer title="Menu" />
|
|
130
|
+
<StickyOptionsTop items={items} />
|
|
131
|
+
<PageContent />
|
|
132
|
+
<Footer text="© 2025 neurons.me" />
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or as JSON:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"navbar": { "title": "Dashboard" },
|
|
140
|
+
"drawerLeft": { "title": "Menu" },
|
|
141
|
+
"stickyOptions": { "items": [ ... ] },
|
|
142
|
+
"footer": { "text": "© 2025 neurons.me" }
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
That’s the philosophy: declarative contracts for every GUI building block, so your UI can be described, generated, and remixed by humans, scripts, or LLMs.
|
|
148
|
+
---
|
|
149
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { useTheme, Box, Typography } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
const meta: Meta = {
|
|
6
|
+
title: 'Theme/Palette',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
|
|
11
|
+
const PaletteViewer: React.FC = () => {
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
const palette = theme.palette;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Box
|
|
17
|
+
sx={{
|
|
18
|
+
display: 'grid',
|
|
19
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(160px, 1fr))',
|
|
20
|
+
gap: 2,
|
|
21
|
+
maxHeight: '80vh',
|
|
22
|
+
overflowY: 'auto',
|
|
23
|
+
p: 2,
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
{Object.entries(palette).map(([colorKey, colorValue]) => {
|
|
27
|
+
if (typeof colorValue === 'string') {
|
|
28
|
+
// Sometimes palette keys can be strings (rare)
|
|
29
|
+
return (
|
|
30
|
+
<Box key={colorKey} sx={{ border: '1px solid', borderColor: 'divider', borderRadius: 1, p: 1 }}>
|
|
31
|
+
<Typography variant="subtitle1" gutterBottom>
|
|
32
|
+
{colorKey}
|
|
33
|
+
</Typography>
|
|
34
|
+
<Box
|
|
35
|
+
sx={{
|
|
36
|
+
backgroundColor: colorValue,
|
|
37
|
+
height: 48,
|
|
38
|
+
borderRadius: 1,
|
|
39
|
+
mb: 1,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
<Typography variant="caption">{colorValue}</Typography>
|
|
43
|
+
</Box>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof colorValue === 'object' && colorValue !== null) {
|
|
48
|
+
return (
|
|
49
|
+
<Box
|
|
50
|
+
key={colorKey}
|
|
51
|
+
sx={{ border: '1px solid', borderColor: 'divider', borderRadius: 1, p: 1, display: 'flex', flexDirection: 'column' }}
|
|
52
|
+
>
|
|
53
|
+
<Typography variant="subtitle1" gutterBottom>
|
|
54
|
+
{colorKey}
|
|
55
|
+
</Typography>
|
|
56
|
+
{Object.entries(colorValue).map(([shadeKey, shadeValue]) => {
|
|
57
|
+
if (typeof shadeValue !== 'string') return null;
|
|
58
|
+
return (
|
|
59
|
+
<Box key={shadeKey} sx={{ mb: 1 }}>
|
|
60
|
+
<Box
|
|
61
|
+
sx={{
|
|
62
|
+
backgroundColor: shadeValue,
|
|
63
|
+
height: 32,
|
|
64
|
+
borderRadius: 1,
|
|
65
|
+
mb: 0.5,
|
|
66
|
+
border: '1px solid',
|
|
67
|
+
borderColor: 'divider',
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
<Typography variant="caption" sx={{ userSelect: 'text' }}>
|
|
71
|
+
{shadeKey}: {shadeValue}
|
|
72
|
+
</Typography>
|
|
73
|
+
</Box>
|
|
74
|
+
);
|
|
75
|
+
})}
|
|
76
|
+
</Box>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
})}
|
|
82
|
+
</Box>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Default: StoryFn = () => <PaletteViewer />;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ## Theme Viewer Story
|
|
3
|
+
*
|
|
4
|
+
* This story provides a live JSON visualization of your theme context and MUI theme.
|
|
5
|
+
*
|
|
6
|
+
* ### What you will see:
|
|
7
|
+
* - `mode`: Comes from your `ThemeContext`, shows if your theme is in `light` or `dark` mode.
|
|
8
|
+
* - `palette`: Full palette details from MUI's `createTheme`, including all primary/secondary colors, actions, background, etc.
|
|
9
|
+
* - `insets`: Comes from `InsetsContext`, gives layout-safe-area insets for notch-aware designs (top, right, bottom, left).
|
|
10
|
+
*
|
|
11
|
+
* ### Why use this?
|
|
12
|
+
* It’s useful for debugging:
|
|
13
|
+
* - If your theme is being applied correctly
|
|
14
|
+
* - How your layout adjusts with different inset values
|
|
15
|
+
* - How palettes resolve across modes
|
|
16
|
+
*
|
|
17
|
+
* Great for verifying dynamic theme changes or testing new color tokens.
|
|
18
|
+
*/
|
|
19
|
+
import type { Meta } from '@storybook/react';
|
|
20
|
+
import { useTheme } from '@mui/material/styles';
|
|
21
|
+
import { useThemeContext } from '@/gui/contexts/ThemeContext';
|
|
22
|
+
import { useInsets } from '@/gui/hooks';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Story: CurrentThemeState
|
|
26
|
+
*
|
|
27
|
+
* This Storybook story displays the current theme state injected via MUI's ThemeProvider
|
|
28
|
+
* along with custom context values such as `mode` (from ThemeContext) and `insets` (from InsetsContext).
|
|
29
|
+
*
|
|
30
|
+
* The output includes:
|
|
31
|
+
* - `mode`: Light/dark mode from the app's ThemeContext
|
|
32
|
+
* - `palette`: Full palette object from MUI's `createTheme`, including color tokens and UI actions
|
|
33
|
+
* - `insets`: Safe area insets (top/right/bottom/left) for layout padding/margin
|
|
34
|
+
*
|
|
35
|
+
* Useful for debugging how the current theme looks, understanding the applied color system,
|
|
36
|
+
* and ensuring injected context values are correctly picked up across the app.
|
|
37
|
+
*/
|
|
38
|
+
export const CurrentThemeState = () => {
|
|
39
|
+
const theme = useTheme();
|
|
40
|
+
const { mode, themeId } = useThemeContext();
|
|
41
|
+
const { insets } = useInsets();
|
|
42
|
+
return (
|
|
43
|
+
<pre style={{ padding: 16 }}>
|
|
44
|
+
<code>
|
|
45
|
+
{JSON.stringify(
|
|
46
|
+
{
|
|
47
|
+
mode,
|
|
48
|
+
themeId,
|
|
49
|
+
palette: theme.palette,
|
|
50
|
+
fontFamily: theme.typography?.fontFamily,
|
|
51
|
+
typography: theme.typography,
|
|
52
|
+
insets,
|
|
53
|
+
},
|
|
54
|
+
null,
|
|
55
|
+
2
|
|
56
|
+
)}
|
|
57
|
+
</code>
|
|
58
|
+
</pre>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
title: 'Theme/Viewer',
|
|
64
|
+
component: CurrentThemeState,
|
|
65
|
+
tags: ['autodocs'],
|
|
66
|
+
parameters: {
|
|
67
|
+
docs: {
|
|
68
|
+
description: {
|
|
69
|
+
component: `
|
|
70
|
+
This story renders the **active theme state** used throughout your app.
|
|
71
|
+
|
|
72
|
+
### What you will see:
|
|
73
|
+
- \`mode\`: Current light/dark mode from ThemeContext
|
|
74
|
+
- \`palette\`: Full MUI palette object generated from createTheme(), including:
|
|
75
|
+
- primary, secondary, error, warning, success, info colors
|
|
76
|
+
- background and text colors
|
|
77
|
+
- action states (hover, focus, selected, etc.)
|
|
78
|
+
- \`insets\`: Safe area layout padding (top/right/bottom/left) from InsetsContext (useful for notch-aware design)
|
|
79
|
+
|
|
80
|
+
### Why this is useful:
|
|
81
|
+
- Debug whether the correct theme is being used
|
|
82
|
+
- Inspect how palette tokens resolve dynamically
|
|
83
|
+
- Verify how inset values change (iOS, Android, desktop)
|
|
84
|
+
- Helps debug dynamic theme toggles and token propagation
|
|
85
|
+
|
|
86
|
+
Ideal for inspecting changes in real-time while modifying theme-related code or tokens.
|
|
87
|
+
`,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
} satisfies Meta<typeof CurrentThemeState>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// src/stories/Theme/Typography.stories.jsx
|
|
2
|
+
import { Box, Typography, Paper, Divider, Stack, Chip } from '@mui/material';
|
|
3
|
+
import { useTheme } from '@mui/material/styles';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Small helper to render a sample block for a variant
|
|
7
|
+
*/
|
|
8
|
+
const TypeRow = ({ variant, sample = 'The quick brown fox jumps over the lazy dog 1234', extra }) => {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const v = theme.typography?.[variant] || {};
|
|
11
|
+
const lineHeight = typeof v.lineHeight === 'number' ? v.lineHeight : String(v.lineHeight || '');
|
|
12
|
+
const fontSize = v.fontSize || '';
|
|
13
|
+
const weight = v.fontWeight || '';
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Paper
|
|
17
|
+
variant="outlined"
|
|
18
|
+
sx={{
|
|
19
|
+
p: 1.25,
|
|
20
|
+
borderColor: theme.custom?.border || theme.palette.divider,
|
|
21
|
+
bgcolor: 'background.paper',
|
|
22
|
+
minWidth: 280,
|
|
23
|
+
flex: '1 1 320px',
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Typography variant="caption" sx={{ color: 'text.secondary', fontWeight: 700 }}>
|
|
27
|
+
{variant}
|
|
28
|
+
</Typography>
|
|
29
|
+
<Typography variant={variant} sx={{ mt: 0.5 }}>
|
|
30
|
+
{sample}
|
|
31
|
+
</Typography>
|
|
32
|
+
<Divider sx={{ my: 1 }} />
|
|
33
|
+
<Typography variant="caption" sx={{ color: 'text.secondary' }}>
|
|
34
|
+
<strong>font-size:</strong> {fontSize}{' '}
|
|
35
|
+
<strong>line-height:</strong> {lineHeight}{' '}
|
|
36
|
+
<strong>font-weight:</strong> {weight || '—'}
|
|
37
|
+
{extra ? <> · {extra}</> : null}
|
|
38
|
+
</Typography>
|
|
39
|
+
</Paper>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const Section = ({ title, hint, children }) => (
|
|
44
|
+
<Box sx={{ my: 3 }}>
|
|
45
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
46
|
+
<Typography variant="h5" sx={{ fontWeight: 700 }}>
|
|
47
|
+
{title}
|
|
48
|
+
</Typography>
|
|
49
|
+
{hint ? <Chip size="small" label={hint} /> : null}
|
|
50
|
+
</Box>
|
|
51
|
+
<Divider sx={{ my: 1.5 }} />
|
|
52
|
+
{children}
|
|
53
|
+
</Box>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Preview of the main typography scale coming from the active theme.
|
|
58
|
+
* Uses whatever your token engine compiled into theme.typography.
|
|
59
|
+
*/
|
|
60
|
+
function TypographyScale() {
|
|
61
|
+
const theme = useTheme();
|
|
62
|
+
|
|
63
|
+
const variants = [
|
|
64
|
+
'h1',
|
|
65
|
+
'h2',
|
|
66
|
+
'h3',
|
|
67
|
+
'h4',
|
|
68
|
+
'h5',
|
|
69
|
+
'subtitle1',
|
|
70
|
+
'body1',
|
|
71
|
+
'body2',
|
|
72
|
+
'button',
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Box sx={{ p: 2, bgcolor: 'background.default', color: 'text.primary' }}>
|
|
77
|
+
<Section title="Font Family">
|
|
78
|
+
<Typography variant="body2">
|
|
79
|
+
<strong>theme.typography.fontFamily:</strong>{' '}
|
|
80
|
+
<code>{theme.typography?.fontFamily}</code>
|
|
81
|
+
</Typography>
|
|
82
|
+
</Section>
|
|
83
|
+
|
|
84
|
+
<Section title="Variants">
|
|
85
|
+
<Stack direction="row" spacing={1.25} useFlexGap flexWrap="wrap">
|
|
86
|
+
{variants.map((v) => (
|
|
87
|
+
<TypeRow key={v} variant={v} />
|
|
88
|
+
))}
|
|
89
|
+
</Stack>
|
|
90
|
+
</Section>
|
|
91
|
+
</Box>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Extra details from tokens exposed in the runtime:
|
|
97
|
+
* - lineHeights scale (if defined in theme.typography.lineHeights)
|
|
98
|
+
* - weights (if your tokens encode them)
|
|
99
|
+
*/
|
|
100
|
+
function TypographyDetails() {
|
|
101
|
+
const theme = useTheme();
|
|
102
|
+
const lh = theme.typography?.lineHeights || {};
|
|
103
|
+
const weights = {
|
|
104
|
+
bold: theme.typography?.fontWeightBold,
|
|
105
|
+
medium: theme.typography?.fontWeightMedium,
|
|
106
|
+
regular: theme.typography?.fontWeightRegular,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Box sx={{ p: 2, bgcolor: 'background.default', color: 'text.primary' }}>
|
|
111
|
+
<Section title="Line Heights Scale" hint="From tokens → theme.typography.lineHeights">
|
|
112
|
+
{Object.keys(lh).length ? (
|
|
113
|
+
<Stack direction="row" spacing={1.25} useFlexGap flexWrap="wrap">
|
|
114
|
+
{Object.entries(lh).map(([k, v]) => (
|
|
115
|
+
<Paper
|
|
116
|
+
key={k}
|
|
117
|
+
variant="outlined"
|
|
118
|
+
sx={{
|
|
119
|
+
p: 1.25,
|
|
120
|
+
minWidth: 160,
|
|
121
|
+
borderColor: theme.custom?.border || theme.palette.divider,
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<Typography variant="body2" sx={{ fontWeight: 700 }}>
|
|
125
|
+
{k}
|
|
126
|
+
</Typography>
|
|
127
|
+
<Typography variant="caption" sx={{ color: 'text.secondary' }}>
|
|
128
|
+
{String(v)}
|
|
129
|
+
</Typography>
|
|
130
|
+
<Divider sx={{ my: 1 }} />
|
|
131
|
+
<Typography sx={{ lineHeight: Number(v) || v }}>
|
|
132
|
+
The quick brown fox jumps over the lazy dog.
|
|
133
|
+
</Typography>
|
|
134
|
+
</Paper>
|
|
135
|
+
))}
|
|
136
|
+
</Stack>
|
|
137
|
+
) : (
|
|
138
|
+
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
|
|
139
|
+
No custom line height scale found in theme.typography.lineHeights.
|
|
140
|
+
</Typography>
|
|
141
|
+
)}
|
|
142
|
+
</Section>
|
|
143
|
+
|
|
144
|
+
<Section title="Font Weights (if provided)">
|
|
145
|
+
<Stack direction="row" spacing={1.25} useFlexGap flexWrap="wrap">
|
|
146
|
+
{Object.entries(weights).map(([k, v]) => (
|
|
147
|
+
<Paper
|
|
148
|
+
key={k}
|
|
149
|
+
variant="outlined"
|
|
150
|
+
sx={{
|
|
151
|
+
p: 1.25,
|
|
152
|
+
minWidth: 160,
|
|
153
|
+
borderColor: theme.custom?.border || theme.palette.divider,
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<Typography variant="body2" sx={{ fontWeight: 700 }}>
|
|
157
|
+
{k}
|
|
158
|
+
</Typography>
|
|
159
|
+
<Typography variant="caption" sx={{ color: 'text.secondary' }}>
|
|
160
|
+
{v ?? '—'}
|
|
161
|
+
</Typography>
|
|
162
|
+
<Divider sx={{ my: 1 }} />
|
|
163
|
+
<Typography sx={{ fontWeight: v ?? 600 }}>
|
|
164
|
+
The quick brown fox jumps over the lazy dog.
|
|
165
|
+
</Typography>
|
|
166
|
+
</Paper>
|
|
167
|
+
))}
|
|
168
|
+
</Stack>
|
|
169
|
+
</Section>
|
|
170
|
+
</Box>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export default {
|
|
175
|
+
title: 'Theme/Typography',
|
|
176
|
+
tags: ['autodocs'],
|
|
177
|
+
parameters: {
|
|
178
|
+
docs: {
|
|
179
|
+
description: {
|
|
180
|
+
component:
|
|
181
|
+
'Typography scale compiled from tokens. Shows font family, variant sizes/weights/line-height, and optional line-height scale & weights if your tokens expose them.',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const Scale = {
|
|
188
|
+
name: 'Scale',
|
|
189
|
+
render: () => <TypographyScale />,
|
|
190
|
+
parameters: {
|
|
191
|
+
docs: {
|
|
192
|
+
description: {
|
|
193
|
+
story:
|
|
194
|
+
'Core typography variants from the active theme (h1–h5, subtitle1, body1, body2, button).',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const Details = {
|
|
201
|
+
name: 'Details (Line Heights & Weights)',
|
|
202
|
+
render: () => <TypographyDetails />,
|
|
203
|
+
parameters: {
|
|
204
|
+
docs: {
|
|
205
|
+
description: {
|
|
206
|
+
story:
|
|
207
|
+
'Optional token-driven extras: line-height scale and font weights if present in the compiled theme.',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|