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,189 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Section, Typography, Box, Button } from '@/gui/components/atoms';
|
|
3
|
+
|
|
4
|
+
// ======================= Meta =======================
|
|
5
|
+
const meta: Meta<typeof Section> = {
|
|
6
|
+
title: 'Atoms/Containers/Section',
|
|
7
|
+
component: Section,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
decorators: [
|
|
10
|
+
(Story) => (
|
|
11
|
+
<div style={{ padding: 0, minHeight: 400 }}>
|
|
12
|
+
<Story />
|
|
13
|
+
</div>
|
|
14
|
+
),
|
|
15
|
+
],
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
description: {
|
|
19
|
+
component: `
|
|
20
|
+
The **Section** atom is a responsive container designed to create consistent layout sections that respect This.GUI’s **layout insets** and **theme palette**.
|
|
21
|
+
|
|
22
|
+
It supports theming via the \`section\` palette keys (\`default\`, \`subtle\`, \`strong\`) and allows custom background colors for flexibility.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
## Features
|
|
26
|
+
- Reacts to global layout insets for responsive spacing.
|
|
27
|
+
- Provides unified paddings with theme scaling.
|
|
28
|
+
- Accepts **custom backgroundColor**, or one from \`theme.palette.section\`.
|
|
29
|
+
- Supports responsive padding, height, and alignment.
|
|
30
|
+
- Can wrap any children content.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
## Margin Props
|
|
34
|
+
Section supports **margin props** for controlling the outer spacing around the section:
|
|
35
|
+
|
|
36
|
+
- \`marginTop\`
|
|
37
|
+
- \`marginBottom\`
|
|
38
|
+
- \`marginLeft\`
|
|
39
|
+
- \`marginRight\`
|
|
40
|
+
|
|
41
|
+
Each of these can be a \`number\`, \`string\`, or a **breakpoint object** (e.g. \`{ xs: 2, sm: 4, md: 6 }\`) for responsive margins.
|
|
42
|
+
|
|
43
|
+
If not provided, Section will use the layout insets as fallback margins to ensure consistent spacing with the overall layout.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
## Key Props
|
|
47
|
+
- \`colorVariant?: 'default' | 'subtle' | 'strong'\` — Selects section background color from theme.
|
|
48
|
+
- \`bgcolor?: string\` — Overrides the background with a custom color.
|
|
49
|
+
- \`padding?: number | string | object\` — Adjusts inner spacing responsively.
|
|
50
|
+
- \`height?: number | string\` — Sets the vertical height.
|
|
51
|
+
- \`sx?: object\` — MUI system style overrides.
|
|
52
|
+
- \`marginTop?: number | string | object\`
|
|
53
|
+
- \`marginBottom?: number | string | object\`
|
|
54
|
+
- \`marginLeft?: number | string | object\`
|
|
55
|
+
- \`marginRight?: number | string | object\`
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
## Basic usage (React)
|
|
59
|
+
~~~tsx
|
|
60
|
+
import { Section, Typography } from '@/gui/atoms';
|
|
61
|
+
|
|
62
|
+
<Section colorVariant="default" padding={4}>
|
|
63
|
+
<Typography variant="h4">Welcome</Typography>
|
|
64
|
+
<Typography>Section content goes here.</Typography>
|
|
65
|
+
</Section>
|
|
66
|
+
|
|
67
|
+
// Example with margin props
|
|
68
|
+
<Section colorVariant="subtle" padding={4} marginTop={2} marginBottom={3}>
|
|
69
|
+
<Typography variant="h5">Section with Margins</Typography>
|
|
70
|
+
<Typography>Section content with custom top and bottom margins.</Typography>
|
|
71
|
+
</Section>
|
|
72
|
+
~~~
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
## Declarative JSON / Config usage
|
|
76
|
+
~~~json
|
|
77
|
+
{
|
|
78
|
+
"type": "Section",
|
|
79
|
+
"props": {
|
|
80
|
+
"colorVariant": "subtle",
|
|
81
|
+
"padding": 4,
|
|
82
|
+
"marginTop": 2,
|
|
83
|
+
"marginBottom": 3,
|
|
84
|
+
"children": [
|
|
85
|
+
{ "type": "Typography", "props": { "variant": "h5", "children": "Hello world" } },
|
|
86
|
+
{ "type": "Typography", "props": { "children": "This is a declarative section example." } }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
~~~
|
|
91
|
+
`,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
argTypes: {
|
|
96
|
+
colorVariant: {
|
|
97
|
+
control: { type: 'select' },
|
|
98
|
+
options: ['default', 'subtle', 'strong'],
|
|
99
|
+
description: 'Predefined section variant based on theme.palette.section',
|
|
100
|
+
},
|
|
101
|
+
bgcolor: { control: 'color', description: 'Custom background color override' },
|
|
102
|
+
padding: { control: { type: 'number' }, description: 'Internal padding' },
|
|
103
|
+
height: { control: { type: 'text' }, description: 'Height (px, %, vh, etc.)' },
|
|
104
|
+
},
|
|
105
|
+
args: {
|
|
106
|
+
colorVariant: 'default',
|
|
107
|
+
padding: 4,
|
|
108
|
+
height: 'auto',
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
export default meta;
|
|
112
|
+
|
|
113
|
+
type Story = StoryObj<typeof Section>;
|
|
114
|
+
|
|
115
|
+
// ======================= Stories =======================
|
|
116
|
+
|
|
117
|
+
export const Playground: Story = {
|
|
118
|
+
render: (args) => (
|
|
119
|
+
<Section {...args}>
|
|
120
|
+
<Typography variant="h5" sx={{ mb: 1 }}>Playground Section</Typography>
|
|
121
|
+
<Typography variant="body2">Easily tweak padding, background, and height.</Typography>
|
|
122
|
+
</Section>
|
|
123
|
+
),
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const Variants: Story = {
|
|
127
|
+
render: (args) => (
|
|
128
|
+
<Box sx={{ display: 'grid', gap: 2 }}>
|
|
129
|
+
{(['default', 'subtle', 'strong'] as const).map((variant) => (
|
|
130
|
+
<Section key={variant} {...args} colorVariant={variant} padding={3}>
|
|
131
|
+
<Typography variant="subtitle1">colorVariant = {variant}</Typography>
|
|
132
|
+
<Typography variant="body2">
|
|
133
|
+
This uses <code>theme.palette.section.{variant}</code>
|
|
134
|
+
</Typography>
|
|
135
|
+
</Section>
|
|
136
|
+
))}
|
|
137
|
+
</Box>
|
|
138
|
+
),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const CustomBackground: Story = {
|
|
142
|
+
args: { padding: 4, bgcolor: '#2fb0a3ff' },
|
|
143
|
+
render: (args) => (
|
|
144
|
+
<Section {...args}>
|
|
145
|
+
<Typography variant="h6" sx={{ color: 'text.primary' }}>
|
|
146
|
+
Custom background color
|
|
147
|
+
</Typography>
|
|
148
|
+
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
|
|
149
|
+
You can set <code>bgcolor</code> manually for any theme or design, and it will maintain good contrast for both light and dark text.
|
|
150
|
+
</Typography>
|
|
151
|
+
</Section>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const WithContentComposition: Story = {
|
|
156
|
+
render: () => (
|
|
157
|
+
<Section colorVariant="default" padding={4}>
|
|
158
|
+
<Typography variant="h5" sx={{ mb: 1 }}>Section with Composition</Typography>
|
|
159
|
+
<Box display="flex" gap={2}>
|
|
160
|
+
<Button variant="contained" color="primary">Accept</Button>
|
|
161
|
+
<Button variant="outlined" color="secondary">Cancel</Button>
|
|
162
|
+
</Box>
|
|
163
|
+
</Section>
|
|
164
|
+
),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const ResponsivePadding: Story = {
|
|
168
|
+
args: { padding: { xs: 2, sm: 4, md: 6 } },
|
|
169
|
+
render: (args) => (
|
|
170
|
+
<Section {...args}>
|
|
171
|
+
<Typography variant="h5">Responsive Padding</Typography>
|
|
172
|
+
<Typography variant="body2">
|
|
173
|
+
Resize the viewport to see the padding adjust responsively.
|
|
174
|
+
</Typography>
|
|
175
|
+
</Section>
|
|
176
|
+
),
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const ResponsiveMargins: Story = {
|
|
180
|
+
args: { marginTop: { xs: 1, sm: 2, md: 4 }, marginBottom: { xs: 1, sm: 3, md: 5 } },
|
|
181
|
+
render: (args) => (
|
|
182
|
+
<Section {...args} padding={3}>
|
|
183
|
+
<Typography variant="h5">Responsive Margins</Typography>
|
|
184
|
+
<Typography variant="body2">
|
|
185
|
+
Adjusts top and bottom margins responsively across breakpoints.
|
|
186
|
+
</Typography>
|
|
187
|
+
</Section>
|
|
188
|
+
),
|
|
189
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from '@/gui/components/atoms';
|
|
3
|
+
import { useInsets, useGuiTheme } from '@/gui/hooks';
|
|
4
|
+
import type { SectionProps } from './Section.types';
|
|
5
|
+
|
|
6
|
+
const Section: React.FC<SectionProps> = ({
|
|
7
|
+
children,
|
|
8
|
+
sx,
|
|
9
|
+
maxWidth = '100%',
|
|
10
|
+
component = 'section',
|
|
11
|
+
bgcolor,
|
|
12
|
+
colorVariant,
|
|
13
|
+
padding,
|
|
14
|
+
height,
|
|
15
|
+
marginTop,
|
|
16
|
+
marginBottom,
|
|
17
|
+
marginLeft,
|
|
18
|
+
marginRight,
|
|
19
|
+
}) => {
|
|
20
|
+
const insets = useInsets();
|
|
21
|
+
const theme = useGuiTheme();
|
|
22
|
+
// Determine if bgcolor is a theme token or raw color
|
|
23
|
+
// We check if bgcolor matches a key path in theme.palette or if it is a raw color string
|
|
24
|
+
const isThemeToken = (color: string) => {
|
|
25
|
+
if (!color) return false;
|
|
26
|
+
// Simple heuristic: theme tokens contain dot notation or match keys in palette
|
|
27
|
+
if (color.includes('.')) {
|
|
28
|
+
const parts = color.split('.');
|
|
29
|
+
let obj: any = theme.palette;
|
|
30
|
+
for (const part of parts) {
|
|
31
|
+
if (obj && part in obj) {
|
|
32
|
+
obj = obj[part];
|
|
33
|
+
} else {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return color in theme.palette;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let finalBgcolor: string | undefined;
|
|
43
|
+
if (bgcolor) {
|
|
44
|
+
finalBgcolor = isThemeToken(bgcolor) ? bgcolor : bgcolor;
|
|
45
|
+
} else if (colorVariant && theme.palette.section && colorVariant in theme.palette.section) {
|
|
46
|
+
finalBgcolor = theme.palette.section[colorVariant];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Box
|
|
51
|
+
component={component}
|
|
52
|
+
sx={{
|
|
53
|
+
// Responsive width/height: fill viewport, but margin aligns with insets
|
|
54
|
+
width: `calc(100vw - ${insets.left + insets.right}px)`,
|
|
55
|
+
height: height ? height : `calc(100vh - ${insets.top + insets.bottom}px)`,
|
|
56
|
+
marginTop: marginTop !== undefined ? marginTop : insets.top,
|
|
57
|
+
marginBottom: marginBottom !== undefined ? marginBottom : insets.bottom,
|
|
58
|
+
marginLeft: marginLeft !== undefined ? marginLeft : insets.left,
|
|
59
|
+
marginRight: marginRight !== undefined ? marginRight : insets.right,
|
|
60
|
+
maxWidth,
|
|
61
|
+
// Responsive internal padding
|
|
62
|
+
padding: padding !== undefined ? padding : {
|
|
63
|
+
xs: 2,
|
|
64
|
+
sm: 3,
|
|
65
|
+
md: 4,
|
|
66
|
+
},
|
|
67
|
+
...(finalBgcolor ? { bgcolor: finalBgcolor } : {}),
|
|
68
|
+
...sx,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</Box>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Section;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@mui/material/styles';
|
|
3
|
+
import { SxProps } from '@mui/system';
|
|
4
|
+
|
|
5
|
+
export interface SectionProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
sx?: SxProps<Theme>;
|
|
9
|
+
colorVariant?: keyof Theme['palette']['section'];
|
|
10
|
+
bgcolor?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
component?: React.ElementType;
|
|
13
|
+
elevation?: number;
|
|
14
|
+
padded?: boolean;
|
|
15
|
+
centered?: boolean;
|
|
16
|
+
'data-testid'?: string;
|
|
17
|
+
maxWidth?: number | string;
|
|
18
|
+
padding?: number | string | Record<string, any>;
|
|
19
|
+
height?: number | string;
|
|
20
|
+
marginTop?: number | string | Record<string, any>;
|
|
21
|
+
marginBottom?: number | string | Record<string, any>;
|
|
22
|
+
marginLeft?: number | string | Record<string, any>;
|
|
23
|
+
marginRight?: number | string | Record<string, any>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// src/gui/atoms/Stack/Stack.resolver.tsx
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Stack from './Stack';
|
|
4
|
+
import Link from '@/gui/components/atoms/Link/Link';
|
|
5
|
+
import type { RegistryEntry, ResolveCtx } from '@/registry/types';
|
|
6
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
7
|
+
/**
|
|
8
|
+
* Declarative spec for Stack (layout primitive)
|
|
9
|
+
*
|
|
10
|
+
* Notes
|
|
11
|
+
* - Choose the rendered element via `component` (e.g. 'div', 'section', 'a', custom).
|
|
12
|
+
* - If `to` is provided (and no explicit component), the resolver will default to This.GUI `Link`.
|
|
13
|
+
* - If `external` is true (and no explicit component), it will default to an anchor (`'a'`) and apply
|
|
14
|
+
* safe `target`/`rel` defaults.
|
|
15
|
+
* - Common Stack props (direction, spacing, divider, alignItems, justifyContent, useFlexGap, flexWrap, etc.) are passed through.
|
|
16
|
+
*/
|
|
17
|
+
export type StackSpec = {
|
|
18
|
+
type: 'Stack';
|
|
19
|
+
props?: {
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
// Polymorphism / routing
|
|
22
|
+
component?: any; // 'div' | 'section' | 'a' | Link | custom
|
|
23
|
+
as?: any; // alias for component
|
|
24
|
+
to?: string; // router target (when component={Link})
|
|
25
|
+
href?: string; // anchor target (when component='a')
|
|
26
|
+
external?: boolean; // force external anchor
|
|
27
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
28
|
+
rel?: string;
|
|
29
|
+
// Core Stack props (subset; rest is passthrough)
|
|
30
|
+
direction?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
31
|
+
spacing?: number | string;
|
|
32
|
+
divider?: React.ReactNode;
|
|
33
|
+
useFlexGap?: boolean;
|
|
34
|
+
alignItems?: React.CSSProperties['alignItems'];
|
|
35
|
+
justifyContent?: React.CSSProperties['justifyContent'];
|
|
36
|
+
flexWrap?: React.CSSProperties['flexWrap'];
|
|
37
|
+
// Styling & misc
|
|
38
|
+
sx?: any;
|
|
39
|
+
className?: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
'data-testid'?: string;
|
|
42
|
+
// Allow system props / arbitrary passthrough
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const StackResolver: RegistryEntry = {
|
|
48
|
+
type: 'Stack',
|
|
49
|
+
resolve(spec: StackSpec, _ctx?: ResolveCtx) {
|
|
50
|
+
const p = spec.props ?? {};
|
|
51
|
+
const nodeId = ensureNodeId('Stack', p.id);
|
|
52
|
+
// Decide polymorphic target
|
|
53
|
+
const component = p.component ?? p.as ?? (p.to ? Link : p.external ? 'a' : undefined);
|
|
54
|
+
// Routing/anchor props
|
|
55
|
+
const routingProps =
|
|
56
|
+
component === 'a' || p.external
|
|
57
|
+
? {
|
|
58
|
+
href: p.href,
|
|
59
|
+
target: p.target ?? (p.external ? '_blank' : undefined),
|
|
60
|
+
rel: p.rel ?? (p.external ? 'noopener noreferrer' : undefined),
|
|
61
|
+
}
|
|
62
|
+
: component === Link || (p.to && !p.component)
|
|
63
|
+
? { to: p.to }
|
|
64
|
+
: {};
|
|
65
|
+
// Collect common props and avoid leaking resolver-only keys
|
|
66
|
+
const {
|
|
67
|
+
children,
|
|
68
|
+
as: _as,
|
|
69
|
+
external: _external,
|
|
70
|
+
to: _to,
|
|
71
|
+
href: _href,
|
|
72
|
+
target: _target,
|
|
73
|
+
rel: _rel,
|
|
74
|
+
id: _id,
|
|
75
|
+
'data-testid': _dataTestId,
|
|
76
|
+
...rest
|
|
77
|
+
} = p;
|
|
78
|
+
return (
|
|
79
|
+
<Stack
|
|
80
|
+
component={component}
|
|
81
|
+
sx={p.sx}
|
|
82
|
+
id={nodeId}
|
|
83
|
+
className={p.className}
|
|
84
|
+
data-testid={p['data-testid']}
|
|
85
|
+
{...routingProps}
|
|
86
|
+
{...rest}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</Stack>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default StackResolver;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import Stack from './Stack';
|
|
4
|
+
import Paper from '@/gui/components/atoms/Paper/Paper';
|
|
5
|
+
import Link from '@/gui/components/atoms/Link/Link';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Stack> = {
|
|
8
|
+
title: 'Atoms/Containers/Stack',
|
|
9
|
+
component: Stack,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<div style={{ padding: 16, minHeight: 240 }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
parameters: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: {
|
|
21
|
+
component: `
|
|
22
|
+
The **Stack** atom is a thin wrapper around MUI's \`MuiStack\` that preserves **polymorphism** and forwards all layout props.
|
|
23
|
+
It integrates with **This.GUI** theming and supports **declarative specs** through the Stack resolver.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
## Features
|
|
27
|
+
- Direction: \`row\`, \`column\`, and reverse variants
|
|
28
|
+
- Spacing/gap via \`spacing\`
|
|
29
|
+
- Optional \`divider\`
|
|
30
|
+
- Alignment: \`alignItems\`, \`justifyContent\`, \`flexWrap\`
|
|
31
|
+
- **Polymorphic** via \`component\` (e.g. 'div', 'section', 'a')
|
|
32
|
+
- Full **system props** passthrough via \`sx\`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
## Basic usage
|
|
36
|
+
~~~jsx
|
|
37
|
+
<Stack direction="row" spacing={2}>
|
|
38
|
+
<Item />
|
|
39
|
+
<Item />
|
|
40
|
+
</Stack>
|
|
41
|
+
~~~
|
|
42
|
+
|
|
43
|
+
## Declarative JSON / Resolver
|
|
44
|
+
~~~json
|
|
45
|
+
{
|
|
46
|
+
"type": "Stack",
|
|
47
|
+
"props": {
|
|
48
|
+
"direction": "row",
|
|
49
|
+
"spacing": 2,
|
|
50
|
+
"sx": { "alignItems": "center" },
|
|
51
|
+
"children": [
|
|
52
|
+
{ "type": "Paper", "props": { "sx": { "p": 1 }, "children": "A" } },
|
|
53
|
+
{ "type": "Paper", "props": { "sx": { "p": 1 }, "children": "B" } }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
~~~
|
|
58
|
+
|
|
59
|
+
*Note:* We demonstrate polymorphism in dedicated stories rather than Controls to avoid type-narrowing issues with MUI's OverridableComponent.
|
|
60
|
+
`,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
controls: {
|
|
64
|
+
exclude: ['component'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
argTypes: {
|
|
68
|
+
direction: {
|
|
69
|
+
control: { type: 'radio' },
|
|
70
|
+
options: ['row', 'row-reverse', 'column', 'column-reverse'],
|
|
71
|
+
},
|
|
72
|
+
spacing: {
|
|
73
|
+
control: { type: 'range', min: 0, max: 8, step: 0.5 },
|
|
74
|
+
},
|
|
75
|
+
useFlexGap: {
|
|
76
|
+
control: 'boolean',
|
|
77
|
+
},
|
|
78
|
+
sx: {
|
|
79
|
+
control: 'object',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
args: {
|
|
83
|
+
direction: 'row',
|
|
84
|
+
spacing: 1.5,
|
|
85
|
+
useFlexGap: true,
|
|
86
|
+
sx: {},
|
|
87
|
+
children: undefined,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default meta;
|
|
92
|
+
type Story = StoryObj<typeof Stack>;
|
|
93
|
+
|
|
94
|
+
const Item = ({ children }: { children: React.ReactNode }) => (
|
|
95
|
+
<Paper variant="outlined" sx={{ p: 1.5, borderRadius: 1 }}>
|
|
96
|
+
{children}
|
|
97
|
+
</Paper>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// ======================= Stories =======================
|
|
101
|
+
export const Playground: Story = {
|
|
102
|
+
render: (args) => (
|
|
103
|
+
<Stack {...args}>
|
|
104
|
+
<Item>A</Item>
|
|
105
|
+
<Item>B</Item>
|
|
106
|
+
<Item>C</Item>
|
|
107
|
+
</Stack>
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const RowSpacing: Story = {
|
|
112
|
+
args: { direction: 'row', spacing: 2 },
|
|
113
|
+
render: (args) => (
|
|
114
|
+
<Stack {...args}>
|
|
115
|
+
<Item>A</Item>
|
|
116
|
+
<Item>B</Item>
|
|
117
|
+
<Item>C</Item>
|
|
118
|
+
</Stack>
|
|
119
|
+
),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const ColumnSpacing: Story = {
|
|
123
|
+
args: { direction: 'column', spacing: 1.5 },
|
|
124
|
+
render: (args) => (
|
|
125
|
+
<Stack {...args} sx={{ width: 240 }}>
|
|
126
|
+
<Item>A</Item>
|
|
127
|
+
<Item>B</Item>
|
|
128
|
+
<Item>C</Item>
|
|
129
|
+
</Stack>
|
|
130
|
+
),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const WithDivider: Story = {
|
|
134
|
+
render: (args) => (
|
|
135
|
+
<Stack {...args} direction="row" spacing={2} divider={<span style={{ opacity: 0.5 }}>|</span>}>
|
|
136
|
+
<Item>A</Item>
|
|
137
|
+
<Item>B</Item>
|
|
138
|
+
<Item>C</Item>
|
|
139
|
+
</Stack>
|
|
140
|
+
),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const PolymorphicSection: Story = {
|
|
144
|
+
render: (args) => (
|
|
145
|
+
<Stack {...args} component="section" spacing={1.5}>
|
|
146
|
+
<Item>Section A</Item>
|
|
147
|
+
<Item>Section B</Item>
|
|
148
|
+
</Stack>
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const PolymorphicRouterLink: Story = {
|
|
153
|
+
render: (args) => (
|
|
154
|
+
<Link to="/docs" style={{ textDecoration: 'none' }}>
|
|
155
|
+
<Stack {...args} spacing={1.5}>
|
|
156
|
+
<Item>Go to Docs</Item>
|
|
157
|
+
</Stack>
|
|
158
|
+
</Link>
|
|
159
|
+
),
|
|
160
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This.GUI — Stack (polymorphic)
|
|
3
|
+
* Thin wrapper that preserves MUI's own typing and `component` API.
|
|
4
|
+
* Examples:
|
|
5
|
+
* <Stack direction="row" spacing={2} />
|
|
6
|
+
* <Stack component="section" gap={1} />
|
|
7
|
+
* <Stack component="a" href="/docs" />
|
|
8
|
+
*/
|
|
9
|
+
import MuiStack from '@mui/material/Stack';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
// Re-export using MUI's own component type to keep polymorphism and full typing
|
|
12
|
+
const Stack = MuiStack;
|
|
13
|
+
export type StackProps = React.ComponentProps<typeof Stack>;
|
|
14
|
+
(Stack as any).displayName = 'Gui.Stack';
|
|
15
|
+
export default Stack;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import Surface from './Surface';
|
|
4
|
+
import type { RegistryEntry } from '@/registry/types';
|
|
5
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
6
|
+
import type { SurfaceResolverSpec as SurfaceSpec } from './Surface.types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SurfaceResolver
|
|
10
|
+
* ---------------
|
|
11
|
+
* - Maps a JSON-friendly spec to <Surface /> props.
|
|
12
|
+
* - Preserves MUI styling (`sx`, `variant`, `elevation`).
|
|
13
|
+
* - Adds IDs and classNames for runtime targeting.
|
|
14
|
+
*/
|
|
15
|
+
const SurfaceResolver: RegistryEntry = {
|
|
16
|
+
type: 'Surface',
|
|
17
|
+
resolve(spec: SurfaceSpec) {
|
|
18
|
+
const p = spec.props ?? {};
|
|
19
|
+
const rootProps: any = {
|
|
20
|
+
variant: p.variant ?? 'elevation',
|
|
21
|
+
elevation: p.elevation ?? 1,
|
|
22
|
+
square: p.square ?? false,
|
|
23
|
+
sx: p.sx,
|
|
24
|
+
id: ensureNodeId('surface', p.id),
|
|
25
|
+
className: p.className,
|
|
26
|
+
'data-testid': p['data-testid'],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Surface {...rootProps}>
|
|
31
|
+
{p.children}
|
|
32
|
+
</Surface>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default SurfaceResolver;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MuiSurface from '@mui/material/Paper';
|
|
3
|
+
import type { SurfaceProps } from './Surface.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Surface
|
|
7
|
+
* -------
|
|
8
|
+
* A visual container primitive.
|
|
9
|
+
* Acts as a thin wrapper around MUI's Paper.
|
|
10
|
+
* Supports elevation, variant, square, and sx overrides.
|
|
11
|
+
*/
|
|
12
|
+
const Surface = React.forwardRef<HTMLDivElement, SurfaceProps>((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
variant = 'elevation',
|
|
15
|
+
elevation: elevationProp,
|
|
16
|
+
sx,
|
|
17
|
+
...rest
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const isCard = variant === 'card';
|
|
21
|
+
const mappedVariant = (isCard ? 'outlined' : variant) as 'elevation' | 'outlined';
|
|
22
|
+
const elevation = isCard ? 0 : elevationProp;
|
|
23
|
+
|
|
24
|
+
const cardSx = isCard
|
|
25
|
+
? [
|
|
26
|
+
(theme: any) => ({
|
|
27
|
+
borderRadius: theme.shape?.borderRadius ?? 8,
|
|
28
|
+
borderColor: 'divider',
|
|
29
|
+
backgroundColor: 'background.paper',
|
|
30
|
+
boxShadow: theme.customShadows?.card ?? theme.shadows?.[3] ?? 'none',
|
|
31
|
+
}),
|
|
32
|
+
]
|
|
33
|
+
: [];
|
|
34
|
+
const sxArray = Array.isArray(sx) ? sx : sx ? [sx] : [];
|
|
35
|
+
const composedSx = isCard ? [...cardSx, ...sxArray] : sx;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<MuiSurface
|
|
39
|
+
ref={ref}
|
|
40
|
+
variant={mappedVariant}
|
|
41
|
+
elevation={elevation}
|
|
42
|
+
sx={composedSx}
|
|
43
|
+
{...rest}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Surface.displayName = 'Surface';
|
|
49
|
+
export default Surface;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PaperProps } from '@mui/material/Paper';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export type SurfaceVariant = 'elevation' | 'outlined' | 'card';
|
|
4
|
+
export interface SurfaceProps extends Omit<PaperProps, 'variant'> {
|
|
5
|
+
/**
|
|
6
|
+
* Visual style for the surface.
|
|
7
|
+
* `card` maps to an outlined paper with subtle shadow + rounded corners.
|
|
8
|
+
*/
|
|
9
|
+
variant?: SurfaceVariant;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SurfaceResolverSpec = {
|
|
13
|
+
type?: 'Surface';
|
|
14
|
+
props?: Partial<SurfaceProps> & {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
id?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
'data-testid'?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|