this.gui 1.0.16 → 1.0.18

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 (104) hide show
  1. package/README.md +191 -23
  2. package/dist/style.css +1 -1
  3. package/dist/this-gui.es.js +2879 -1945
  4. package/dist/this-gui.umd.js +24 -24
  5. package/package.json +3 -4
  6. package/src/App.jsx +19 -40
  7. package/src/CreatePage.jsx +61 -0
  8. package/src/MDXEditor.jsx +51 -0
  9. package/src/Page.jsx +28 -0
  10. package/src/PageDashboard.jsx +56 -0
  11. package/src/SiteBuilder.jsx +95 -26
  12. package/src/example.json +43 -0
  13. package/src/scripts/ComponentRegistry.js +70 -0
  14. package/src/scripts/postinstall.js +60 -10
  15. package/src/scripts/renderComponents.js +11 -0
  16. package/src/stories/Atoms/Badge/Badge.css +1 -0
  17. package/src/stories/Atoms/Badge/Badge.stories.jsx +1 -0
  18. package/src/stories/Atoms/Button/Button.css +259 -58
  19. package/src/stories/Atoms/Button/Button.jsx +8 -11
  20. package/src/stories/Atoms/Button/Button.stories.jsx +65 -40
  21. package/src/stories/Atoms/Container/Container.css +420 -39
  22. package/src/stories/Atoms/Container/Container.jsx +98 -36
  23. package/src/stories/Atoms/Container/Container.stories.jsx +120 -79
  24. package/src/stories/Atoms/Grid/Grid.css +160 -0
  25. package/src/stories/Atoms/Grid/Grid.jsx +43 -0
  26. package/src/stories/Atoms/Grid/Grid.stories.jsx +84 -0
  27. package/src/stories/Atoms/Link/Link.css +6 -26
  28. package/src/stories/Atoms/Link/Link.jsx +11 -21
  29. package/src/stories/Atoms/ProgressBar/ProgressBar.css +1 -1
  30. package/src/stories/Atoms/ProgressBar/ProgressBar.jsx +1 -1
  31. package/src/stories/Atoms/ProgressBar/ProgressBar.stories.jsx +1 -1
  32. package/src/stories/Atoms/Section/Section.css +268 -0
  33. package/src/stories/Atoms/Section/Section.jsx +63 -0
  34. package/src/stories/Atoms/Section/Section.stories.jsx +46 -0
  35. package/src/stories/Atoms/TextArea/TextArea.css +1 -0
  36. package/src/stories/Atoms/TextArea/TextArea.jsx +1 -0
  37. package/src/stories/Atoms/TextArea/TextArea.stories.jsx +1 -0
  38. package/src/stories/Atoms/TextInput/TextInput.css +1 -0
  39. package/src/stories/Atoms/TextInput/TextInput.jsx +1 -0
  40. package/src/stories/Atoms/TextInput/TextInput.stories.jsx +1 -0
  41. package/src/stories/Atoms/Toggle/Toggle.css +1 -0
  42. package/src/stories/Atoms/Toggle/Toggle.jsx +1 -0
  43. package/src/stories/Atoms/Toggle/Toggle.stories.jsx +1 -0
  44. package/src/stories/Atoms/Tooltip/Tooltip.css +1 -0
  45. package/src/stories/Atoms/Tooltip/Tooltip.jsx +1 -0
  46. package/src/stories/Atoms/Tooltip/Tooltip.stories.jsx +1 -0
  47. package/src/stories/Atoms/Video/Video.css +1 -0
  48. package/src/stories/Atoms/Video/Video.jsx +1 -0
  49. package/src/stories/Atoms/Video/Video.stories.jsx +1 -0
  50. package/src/stories/Atoms/index.js +4 -0
  51. package/src/stories/Atoms/meta_Atoms.js +4 -1
  52. package/src/stories/Layouts/Accordion/Accordion.css +285 -8
  53. package/src/stories/Layouts/Accordion/Accordion.jsx +62 -19
  54. package/src/stories/Layouts/Accordion/Accordion.stories.jsx +30 -19
  55. package/src/stories/Layouts/index.js +0 -6
  56. package/src/stories/Layouts/meta_Layouts.js +2 -5
  57. package/src/stories/Molecules/Accordion/Accordion.css +1 -1
  58. package/src/stories/Molecules/Accordion/Accordion.jsx +1 -1
  59. package/src/stories/Molecules/Accordion/Accordion.stories.jsx +1 -1
  60. package/src/stories/Molecules/AudioPlayer/AudioPlayer.css +95 -2
  61. package/src/stories/Molecules/AudioPlayer/AudioPlayer.jsx +232 -13
  62. package/src/stories/Molecules/AudioPlayer/AudioPlayer.stories.jsx +46 -11
  63. package/src/stories/Molecules/AvatarWithName/AvatarWithName.css +128 -2
  64. package/src/stories/Molecules/AvatarWithName/AvatarWithName.jsx +69 -14
  65. package/src/stories/Molecules/AvatarWithName/AvatarWithName.stories.jsx +12 -12
  66. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.css +145 -2
  67. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.jsx +39 -13
  68. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.stories.jsx +27 -11
  69. package/src/stories/Molecules/ButtonGroup/ButtonGroup.css +463 -2
  70. package/src/stories/Molecules/ButtonGroup/ButtonGroup.jsx +34 -12
  71. package/src/stories/Molecules/ButtonGroup/ButtonGroup.stories.jsx +36 -12
  72. package/src/stories/Molecules/Card/Card.css +39 -2
  73. package/src/stories/Molecules/Card/Card.jsx +80 -13
  74. package/src/stories/Molecules/Card/Card.stories.jsx +27 -13
  75. package/src/stories/Molecules/ComparisonTable/ComparisonTable.css +33 -2
  76. package/src/stories/Molecules/ComparisonTable/ComparisonTable.jsx +91 -12
  77. package/src/stories/Molecules/ComparisonTable/ComparisonTable.stories.jsx +73 -12
  78. package/src/stories/Molecules/Dropdown/Dropdown.css +192 -0
  79. package/src/stories/Molecules/Dropdown/Dropdown.jsx +96 -0
  80. package/src/stories/Molecules/Dropdown/Dropdown.stories.jsx +45 -0
  81. package/src/stories/Molecules/index.js +2 -1
  82. package/src/stories/Molecules/meta_Molecules.js +6 -3
  83. package/src/themes/styles/neurons/light.css +94 -204
  84. package/dist/Styles.md +0 -446
  85. package/dist/context.md +0 -942
  86. package/src/Theme.jsx +0 -28
  87. package/src/components/CodeBlock.jsx +0 -22
  88. package/src/components/ComponentFactory.jsx +0 -36
  89. package/src/components/ComponentRegistry.js +0 -21
  90. package/src/scripts/generateComponents.js +0 -166
  91. package/src/scripts/verifyLayouts.js +0 -175
  92. package/src/scripts/verifyMolecules.js +0 -158
  93. package/src/scripts/verifyTemplates.js +0 -154
  94. package/src/scripts/verify_and_install_atoms.js +0 -211
  95. package/src/stories/Layouts/DropdownMenu/DropdownMenu.css +0 -16
  96. package/src/stories/Layouts/DropdownMenu/DropdownMenu.jsx +0 -31
  97. package/src/stories/Layouts/DropdownMenu/DropdownMenu.stories.jsx +0 -28
  98. package/src/stories/Layouts/Grid/Grid.css +0 -4
  99. package/src/stories/Layouts/Grid/Grid.jsx +0 -13
  100. package/src/stories/Layouts/Grid/Grid.stories.jsx +0 -28
  101. package/src/stories/Layouts/Section/Section.css +0 -16
  102. package/src/stories/Layouts/Section/Section.jsx +0 -31
  103. package/src/stories/Layouts/Section/Section.stories.jsx +0 -28
  104. /package/src/themes/{README.md → README_Styles.md} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.gui",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "This Graphic User Interface.",
5
5
  "main": "dist/this-gui.umd.js",
6
6
  "module": "dist/this-gui.es.js",
@@ -22,14 +22,13 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@storybook/builder-vite": "^8.2.9",
25
- "autoprefixer": "^10.4.20",
26
25
  "classnames": "^2.5.1",
27
26
  "dotenv": "^16.4.5",
28
27
  "figlet": "^1.7.0",
28
+ "fs": "^0.0.1-security",
29
29
  "postcss": "^8.4.45",
30
30
  "react-icons": "^5.3.0",
31
- "react-router-dom": "^6.26.2",
32
- "tailwindcss": "^3.4.10"
31
+ "react-router-dom": "^6.26.2"
33
32
  },
34
33
  "peerDependencies": {
35
34
  "react": "^18.0.0",
package/src/App.jsx CHANGED
@@ -1,53 +1,32 @@
1
- // This.GUI/src/App.jsx
2
1
  import React from 'react';
3
- import { BrowserRouter as Router, Route, Routes, Link } from 'react-router-dom';
2
+ import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
4
3
  import { ThemeProvider } from './themes/ThemeProvider';
5
- import MdxProvider from './MdxProvider'; // MDX Provider
6
- import SiteBuilder from './SiteBuilder'; // Import the site builder component
7
- import { SelectTheme } from './stories/Molecules/SelectTheme/SelectTheme'; // Import SelectTheme
8
- import { useTheme } from './themes/ThemeProvider'; // Import the hook
4
+ import PageDashboard from './PageDashboard'; // Pages dashboard view
5
+ import CreatePage from './CreatePage'; // Create page view
6
+ import Page from './Page'; // Render dynamic pages
7
+ import SiteBuilder from './SiteBuilder'; // JSON Site builder
8
+ import MDXEditor from './MDXEditor'; // MDX Site builder
9
9
 
10
10
  const App = () => {
11
11
  return (
12
12
  <ThemeProvider>
13
- <MdxProvider>
14
- <Router>
15
- {/* Top navigation */}
16
- <nav>
17
- <Link to="/" style={{ marginRight: '20px' }}>Site Builder</Link>
18
- <Link to="/storybook" style={{ marginRight: '20px' }}>Storybook</Link>
19
- </nav>
20
-
21
- {/* Render SelectTheme in the main app */}
22
- <ThemeSwitcher />
23
-
24
- {/* Route definitions */}
25
- <Routes>
26
- <Route path="/" element={<SiteBuilder />} /> {/* Site builder interface */}
27
- <Route path="/storybook" element={<Storybook />} /> {/* Documentation */}
28
- </Routes>
29
- </Router>
30
- </MdxProvider>
13
+ <Router>
14
+ <Routes>
15
+ {/* Main Dashboard */}
16
+ <Route path="/" element={<PageDashboard />} />
17
+ {/* Create new page */}
18
+ <Route path="/create-page" element={<CreatePage />} />
19
+ {/* Site builders for JSON and MDX */}
20
+ <Route path="/site-builder/json/:pageName" element={<SiteBuilder />} />
21
+ <Route path="/site-builder/mdx/:pageName" element={<MDXEditor />} />
22
+ {/* Storybook Route */}
23
+ <Route path="/storybook" element={<Storybook />} />
24
+ </Routes>
25
+ </Router>
31
26
  </ThemeProvider>
32
27
  );
33
28
  };
34
29
 
35
- // Component to handle theme switching using the context
36
- const ThemeSwitcher = () => {
37
- const { setTheme, setMode } = useTheme();
38
-
39
- return (
40
- <SelectTheme
41
- onThemeChange={(newTheme) => {
42
- setTheme(newTheme);
43
- }}
44
- onModeChange={(newMode) => {
45
- setMode(newMode);
46
- }}
47
- />
48
- );
49
- };
50
-
51
30
  // Storybook IFrame for browsing documentation
52
31
  const Storybook = () => (
53
32
  <iframe
@@ -0,0 +1,61 @@
1
+ import React, { useState } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+
4
+ const CreatePage = () => {
5
+ const navigate = useNavigate();
6
+ const [pageName, setPageName] = useState('');
7
+ const [pageType, setPageType] = useState('json'); // Default to JSON
8
+ const [errorMessage, setErrorMessage] = useState('');
9
+
10
+ const handleCreatePage = () => {
11
+ const newPage = {
12
+ pageName,
13
+ pageType,
14
+ content: '', // Optional: You can pass default content here if needed
15
+ };
16
+
17
+ // Call API to create the page on the backend
18
+ fetch('/api/create-page', {
19
+ method: 'POST',
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ body: JSON.stringify(newPage),
24
+ })
25
+ .then((response) => response.json())
26
+ .then((data) => {
27
+ if (data.error) {
28
+ setErrorMessage(data.error);
29
+ } else {
30
+ // Navigate to the corresponding builder
31
+ if (pageType === 'json') {
32
+ navigate(`/site-builder/json/${pageName}`);
33
+ } else {
34
+ navigate(`/site-builder/mdx/${pageName}`);
35
+ }
36
+ }
37
+ })
38
+ .catch((error) => setErrorMessage(`Error: ${error.message}`));
39
+ };
40
+
41
+ return (
42
+ <div>
43
+ <h1>Create a New Page</h1>
44
+ <input
45
+ type="text"
46
+ placeholder="Enter page name"
47
+ value={pageName}
48
+ onChange={(e) => setPageName(e.target.value)}
49
+ />
50
+ <select value={pageType} onChange={(e) => setPageType(e.target.value)}>
51
+ <option value="json">JSON Format</option>
52
+ <option value="mdx">MDX Format</option>
53
+ </select>
54
+ <button onClick={handleCreatePage}>Create Page</button>
55
+
56
+ {errorMessage && <p style={{ color: 'red' }}>{errorMessage}</p>}
57
+ </div>
58
+ );
59
+ };
60
+
61
+ export default CreatePage;
@@ -0,0 +1,51 @@
1
+ //this.GUI/src/MDXEditor.jsx
2
+ import React, { useState } from 'react';
3
+ import { useNavigate, useParams } from 'react-router-dom';
4
+ import MdxProvider from './MdxProvider'; // Correct
5
+
6
+ const MDXEditor = () => {
7
+ const navigate = useNavigate();
8
+ const { pageName } = useParams();
9
+ const [mdxContent, setMdxContent] = useState(''); // Initial blank content
10
+
11
+ const handleInputChange = (e) => {
12
+ setMdxContent(e.target.value);
13
+ };
14
+
15
+ const handleSavePage = () => {
16
+ console.log('Saving MDX content:', mdxContent);
17
+ // Replace this with actual save functionality (e.g., send to a backend API)
18
+
19
+ // Optionally navigate back to the main dashboard or SiteBuilder
20
+ navigate(`/`);
21
+ };
22
+
23
+ return (
24
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
25
+ {/* MDX Editor */}
26
+ <textarea
27
+ value={mdxContent}
28
+ onChange={handleInputChange}
29
+ rows="15"
30
+ cols="80"
31
+ placeholder="Write your MDX content here..."
32
+ style={{ padding: '10px', fontSize: '16px' }}
33
+ />
34
+
35
+ {/* Live Preview */}
36
+ <div style={{ padding: '20px', border: '1px solid #ccc', marginTop: '20px' }}>
37
+ <h2>Live Preview</h2>
38
+ <MdxProvider>
39
+ <div>{mdxContent ? mdxContent : 'Your MDX preview will appear here.'}</div>
40
+ </MdxProvider>
41
+ </div>
42
+
43
+ {/* Save Button */}
44
+ <button onClick={handleSavePage} style={{ padding: '10px 20px', fontSize: '16px' }}>
45
+ Save MDX Page
46
+ </button>
47
+ </div>
48
+ );
49
+ };
50
+
51
+ export default MDXEditor;
package/src/Page.jsx ADDED
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { renderComponent } from './scripts/renderComponents';
3
+
4
+ const Page = ({ config }) => {
5
+ return (
6
+ <div>
7
+ {config.layout.map((item, index) => {
8
+ const Component = renderComponent(item.type);
9
+ return Component ? (
10
+ <Component key={index} {...item.props}>
11
+ {item.children && item.children.map((child, childIndex) => {
12
+ const ChildComponent = renderComponent(child.type);
13
+ return ChildComponent ? (
14
+ <ChildComponent key={childIndex} {...child.props} />
15
+ ) : (
16
+ <p key={childIndex}>Component "{child.type}" not found</p>
17
+ );
18
+ })}
19
+ </Component>
20
+ ) : (
21
+ <p key={index}>Component "{item.type}" not found</p>
22
+ );
23
+ })}
24
+ </div>
25
+ );
26
+ };
27
+
28
+ export default Page;
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ import Atoms from './stories/Atoms'; // Import the Atoms object
4
+ import Molecules from './stories/Molecules'; // Import the Atoms object
5
+ import siteConfig from '../GUI/config/siteConfig.json'; // Import the config
6
+
7
+ const PageDashboard = () => {
8
+ const navigate = useNavigate();
9
+
10
+ return (
11
+ <Atoms.Container
12
+ size='medium'>
13
+ <h1>Pages Dashboard</h1>
14
+
15
+ {/* Use this.GUI Button for "Add New Page" */}
16
+ <Atoms.Button
17
+ label="+ Add New Page"
18
+ variant="solid"
19
+ color="primary-color" // Correct color value
20
+ onClick={() => navigate('/create-page')}
21
+ style={{ marginBottom: '20px' }}
22
+ />
23
+
24
+ {siteConfig.pages.length === 0 ? (
25
+ <p>No pages created yet.</p>
26
+ ) : (
27
+ <div className="page-grid" style={{ display: 'flex', flexWrap: 'wrap', gap: '20px' }}>
28
+ {siteConfig.pages.map((page, index) => (
29
+ <Molecules.Card
30
+ key={index}
31
+ variant="outlined"
32
+ color="secondary"
33
+ style={{
34
+ width: '200px',
35
+ padding: '20px',
36
+ borderRadius: '8px',
37
+ boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
38
+ }}
39
+ >
40
+ <h3>{page.name}</h3>
41
+ <p>Type: {page.type}</p>
42
+ <Atoms.Button
43
+ label="Edit Page"
44
+ variant="outline"
45
+ color="secondary-color" // Correct the color value here
46
+ onClick={() => navigate(page.path)}
47
+ />
48
+ </Molecules.Card>
49
+ ))}
50
+ </div>
51
+ )}
52
+ </Atoms.Container>
53
+ );
54
+ };
55
+
56
+ export default PageDashboard;
@@ -1,39 +1,108 @@
1
+ //this.GUI/src/SiteBuilder.jsx
1
2
  import React, { useState } from 'react';
2
- import GUI from '../index';
3
+ import { renderComponent } from './scripts/renderComponents';
4
+ import ComponentRegistry from './scripts/ComponentRegistry'; // Import the component registry
3
5
 
4
6
  const SiteBuilder = () => {
5
- const [pageContent, setPageContent] = useState([]); // Store the page components
6
-
7
- // Example links for the sidebar
8
- const sidebarLinks = [
9
- { label: 'Dashboard', url: '/dashboard' },
10
- { label: 'Settings', url: '/settings' },
11
- { label: 'Profile', url: '/profile' },
12
- ];
13
-
14
- // Function to handle adding components
15
- const addComponent = (component) => {
16
- setPageContent([...pageContent, component]);
7
+ const [pageContent, setPageContent] = useState([]); // Stores the components added to the page
8
+ const [selectedComponent, setSelectedComponent] = useState(null); // Currently selected component for configuration
9
+
10
+ // Generate available components from the ComponentRegistry
11
+ const availableComponents = Object.keys(ComponentRegistry).map((key) => ({
12
+ type: key,
13
+ label: key,
14
+ }));
15
+
16
+ // Add a new component to the page
17
+ const addComponent = (componentType) => {
18
+ setPageContent([...pageContent, { type: componentType, props: {} }]);
19
+ };
20
+
21
+ // Update a component's properties
22
+ const updateComponentProps = (index, newProps) => {
23
+ const updatedPage = [...pageContent];
24
+ updatedPage[index].props = newProps;
25
+ setPageContent(updatedPage);
26
+ };
27
+
28
+ // Render components on the page
29
+ const renderPageContent = () => {
30
+ return pageContent.map((component, index) => {
31
+ const Component = renderComponent(component.type);
32
+ return (
33
+ <div
34
+ key={index}
35
+ onClick={() => setSelectedComponent(index)} // Select component for editing
36
+ style={{ border: selectedComponent === index ? '2px solid blue' : 'none' }}
37
+ >
38
+ {Component ? <Component {...component.props} /> : <p>Component not found</p>}
39
+ </div>
40
+ );
41
+ });
17
42
  };
18
43
 
19
44
  return (
20
- <div className="site-builder">
21
- {/* Fixed Navbar at the top */}
22
- <GUI.Molecules.Navbar links={sidebarLinks} /> {/* Using the same links for simplicity */}
23
-
24
- <div style={{ display: 'flex' }}>
25
- {/* Sidebar with components to drag and drop */}
26
- <GUI.Molecules.Sidebar links={sidebarLinks} addComponent={addComponent} />
27
-
28
- {/* Main content area where components are dropped */}
29
- <main className="builder-content" style={{ flex: 1, padding: '20px' }}>
30
- {pageContent.map((Component, idx) => (
31
- <div key={idx}>{Component}</div>
45
+ <div style={{ display: 'flex' }}>
46
+ {/* Sidebar with available components */}
47
+ <div style={{ width: '20%', padding: '10px', backgroundColor: '#f0f0f0' }}>
48
+ <h4>Available Components</h4>
49
+ <ul>
50
+ {availableComponents.map((comp, index) => (
51
+ <li key={index}>
52
+ <button onClick={() => addComponent(comp.type)}>{comp.label}</button>
53
+ </li>
32
54
  ))}
33
- </main>
55
+ </ul>
56
+ </div>
57
+
58
+ {/* Main canvas area for dragging and arranging components */}
59
+ <div style={{ width: '60%', padding: '10px' }}>
60
+ <h4>Canvas</h4>
61
+ {renderPageContent()}
62
+ </div>
63
+
64
+ {/* Configuration panel for the selected component */}
65
+ <div style={{ width: '20%', padding: '10px', backgroundColor: '#f9f9f9' }}>
66
+ <h4>Component Properties</h4>
67
+ {selectedComponent !== null && (
68
+ <ComponentConfigPanel
69
+ component={pageContent[selectedComponent]}
70
+ onUpdate={(newProps) => updateComponentProps(selectedComponent, newProps)}
71
+ />
72
+ )}
34
73
  </div>
35
74
  </div>
36
75
  );
37
76
  };
38
77
 
78
+ // A simple panel to edit component properties
79
+ const ComponentConfigPanel = ({ component, onUpdate }) => {
80
+ const [props, setProps] = useState(component.props);
81
+
82
+ const handleInputChange = (key, value) => {
83
+ setProps({ ...props, [key]: value });
84
+ };
85
+
86
+ const handleSave = () => {
87
+ onUpdate(props); // Send the updated props to the SiteBuilder
88
+ };
89
+
90
+ return (
91
+ <div>
92
+ <h5>Edit {component.type} Properties</h5>
93
+ {Object.keys(props).map((key) => (
94
+ <div key={key}>
95
+ <label>{key}</label>
96
+ <input
97
+ type="text"
98
+ value={props[key]}
99
+ onChange={(e) => handleInputChange(key, e.target.value)}
100
+ />
101
+ </div>
102
+ ))}
103
+ <button onClick={handleSave}>Save</button>
104
+ </div>
105
+ );
106
+ };
107
+
39
108
  export default SiteBuilder;
@@ -0,0 +1,43 @@
1
+ {
2
+ "layout": [
3
+ {
4
+ "type": "Card",
5
+ "props": {
6
+ "variant": "solid",
7
+ "color": "primary-color",
8
+ "width": "300px"
9
+ },
10
+ "children": [
11
+ {
12
+ "type": "Heading",
13
+ "props": {
14
+ "text": "Welcome to the Site!"
15
+ }
16
+ },
17
+ {
18
+ "type": "Paragraph",
19
+ "props": {
20
+ "text": "This is a description inside the card."
21
+ }
22
+ },
23
+ {
24
+ "type": "Button",
25
+ "props": {
26
+ "label": "Click Me",
27
+ "color": "secondary-color"
28
+ }
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "type": "Navbar",
34
+ "props": {
35
+ "links": [
36
+ { "label": "Home", "url": "/" },
37
+ { "label": "About", "url": "/about" },
38
+ { "label": "Contact", "url": "/contact" }
39
+ ]
40
+ }
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,70 @@
1
+ // src/ComponentRegistry.js
2
+ import Atoms from '../stories/Atoms/index';
3
+ import Molecules from '../stories/Molecules/index';
4
+ const ComponentRegistry = {
5
+ // Atoms
6
+ Alert: Atoms.Alert,
7
+ Audio: Atoms.Audio,
8
+ Badge: Atoms.Badge,
9
+ Button: Atoms.Button,
10
+ Caption: Atoms.Caption,
11
+ Checkbox: Atoms.Checkbox,
12
+ Container: Atoms.Container,
13
+ Divider: Atoms.Divider,
14
+ Grid: Atoms.Grid,
15
+ Heading: Atoms.Heading,
16
+ Icon: Atoms.Icon,
17
+ Image: Atoms.Image,
18
+ Label: Atoms.Label,
19
+ Link: Atoms.Link,
20
+ Loader: Atoms.Loader,
21
+ Logo: Atoms.Logo,
22
+ Paragraph: Atoms.Paragraph,
23
+ ProgressBar: Atoms.ProgressBar,
24
+ RadioButton: Atoms.RadioButton,
25
+ Range: Atoms.Range,
26
+ Section: Atoms.Section,
27
+ Select: Atoms.Select,
28
+ Slider: Atoms.Slider,
29
+ Snackbar: Atoms.Snackbar,
30
+ Spacer: Atoms.Spacer,
31
+ Spinner: Atoms.Spinner,
32
+ Tag: Atoms.Tag,
33
+ TextArea: Atoms.TextArea,
34
+ TextInput: Atoms.TextInput,
35
+ Toggle: Atoms.Toggle,
36
+ Tooltip: Atoms.Tooltip,
37
+ Video: Atoms.Video,
38
+
39
+ // Molecules
40
+ Accordion: Molecules.Accordion,
41
+ AudioPlayer: Molecules.AudioPlayer,
42
+ AvatarWithName: Molecules.AvatarWithName,
43
+ Breadcrumbs: Molecules.Breadcrumbs,
44
+ ButtonGroup: Molecules.ButtonGroup,
45
+ Card: Molecules.Card,
46
+ ComparisonTable: Molecules.ComparisonTable,
47
+ DataTable: Molecules.DataTable,
48
+ Dropdown: Molecules.Dropdown,
49
+ FileUpload: Molecules.FileUpload,
50
+ FormField: Molecules.FormField,
51
+ IconButton: Molecules.IconButton,
52
+ ImageWithCaption: Molecules.ImageWithCaption,
53
+ InputGroup: Molecules.InputGroup,
54
+ InputWithLabel: Molecules.InputWithLabel,
55
+ List: Molecules.List,
56
+ MediaCard: Molecules.MediaCard,
57
+ Modal: Molecules.Modal,
58
+ Navbar: Molecules.Navbar,
59
+ Notification: Molecules.Notification,
60
+ PricingTable: Molecules.PricingTable,
61
+ SearchBar: Molecules.SearchBar,
62
+ SelectTheme: Molecules.SelectTheme,
63
+ Sidebar: Molecules.Sidebar,
64
+ VideoWithDescription: Molecules.VideoWithDescription,
65
+
66
+ // Layouts and Templates
67
+ // Add more components as needed
68
+ };
69
+
70
+ export default ComponentRegistry;
@@ -1,15 +1,15 @@
1
1
  // this.GUI/scripts/postinstall.js
2
- import { mkdir, writeFile, access } from 'fs/promises';
2
+ import { mkdir, writeFile, access, readFile } from 'fs/promises';
3
3
  import { join } from 'path';
4
4
 
5
- // Use process.env.INIT_CWD to get the root of the user's project during npm install
6
5
  const appRootDir = process.env.INIT_CWD || process.cwd();
7
6
 
8
7
  // Define paths for directories at the app level
9
8
  const guiDir = join(appRootDir, 'GUI');
10
9
  const componentsDir = join(guiDir, 'components');
11
- const mdxDir = join(guiDir, 'mdx');
12
- const stylesDir = join(guiDir, 'styles');
10
+ const pagesDir = join(guiDir, 'pages'); // Pages directory for JSON layouts
11
+ const configDir = join(guiDir, 'config');
12
+ const configFile = join(configDir, 'siteConfig.json');
13
13
 
14
14
  // Helper function to create directories only if they don't already exist
15
15
  async function createDir(dirPath) {
@@ -33,28 +33,78 @@ async function createFile(filePath, content) {
33
33
  }
34
34
  }
35
35
 
36
+ // Helper function to update siteConfig.json
37
+ async function updateSiteConfig(newPages) {
38
+ try {
39
+ const configContent = await readFile(configFile, 'utf-8');
40
+ const config = JSON.parse(configContent);
41
+
42
+ // Add new pages if they don't already exist in the config
43
+ newPages.forEach((newPage) => {
44
+ const exists = config.pages.find((page) => page.name === newPage.name);
45
+ if (!exists) {
46
+ config.pages.push(newPage);
47
+ }
48
+ });
49
+
50
+ await writeFile(configFile, JSON.stringify(config, null, 2));
51
+ console.log(`Updated: ${configFile}`);
52
+ } catch (err) {
53
+ console.error(`Failed to update siteConfig: ${err}`);
54
+ }
55
+ }
56
+
36
57
  // Function to initialize the directory structure and files
37
58
  async function initializeFiles() {
38
- const mdxWelcomeFile = join(mdxDir, 'Welcome.mdx');
39
- const stylesFile = join(stylesDir, 'global.css');
59
+ const mdxWelcomeFile = join(pagesDir, 'Welcome.mdx');
60
+ const samplePageFile = join(pagesDir, 'home.json'); // Sample JSON page
40
61
 
62
+ // Create siteConfig.json
63
+ await createFile(
64
+ configFile,
65
+ `{
66
+ "pages": []
67
+ }`
68
+ );
69
+
70
+ // Create Welcome.mdx as a sample MDX file
41
71
  await createFile(
42
72
  mdxWelcomeFile,
43
73
  `# Welcome to Your Custom GUI\n\nThis is your first MDX file. Edit it to start building your pages!`
44
74
  );
45
75
 
76
+ // Create a sample JSON page layout
46
77
  await createFile(
47
- stylesFile,
48
- `/* Add your custom styles here */\nbody { font-family: 'Roboto', sans-serif; }`
78
+ samplePageFile,
79
+ `{
80
+ "layout": [
81
+ {
82
+ "type": "Card",
83
+ "props": { "variant": "solid", "color": "primary-color", "width": "300px" },
84
+ "children": [
85
+ {
86
+ "type": "Paragraph",
87
+ "props": { "text": "Welcome to our site!" }
88
+ }
89
+ ]
90
+ }
91
+ ]
92
+ }`
49
93
  );
94
+
95
+ // Update siteConfig.json with the sample pages
96
+ await updateSiteConfig([
97
+ { name: 'Welcome', path: '/welcome', type: 'mdx', file: './pages/Welcome.mdx' },
98
+ { name: 'Home', path: '/home', type: 'json', file: './pages/home.json' },
99
+ ]);
50
100
  }
51
101
 
52
102
  // Create the directory structure and initialize files at the app level
53
103
  (async () => {
54
104
  await createDir(guiDir);
55
105
  await createDir(componentsDir);
56
- await createDir(mdxDir);
57
- await createDir(stylesDir);
106
+ await createDir(pagesDir); // New directory for JSON and MDX pages
107
+ await createDir(configDir); // Create config directory
58
108
  await initializeFiles();
59
109
 
60
110
  console.log('this.GUI setup complete at the app level!');
@@ -0,0 +1,11 @@
1
+ // this.GUI/src/renderComponent.js
2
+ import ComponentRegistry from './ComponentRegistry';
3
+
4
+ export function renderComponent(type) {
5
+ const Component = ComponentRegistry[type];
6
+ if (!Component) {
7
+ console.warn(`Component type "${type}" not found in the registry.`);
8
+ return null;
9
+ }
10
+ return Component;
11
+ }
@@ -1,3 +1,4 @@
1
+ /*this.GUI/src/stories/Atoms/Badge/Badge.css*/
1
2
  .badge {
2
3
  display: inline-block;
3
4
  padding: 4px 8px;
@@ -1,3 +1,4 @@
1
+ //this.GUI/src/stories/Atoms/Badge/Badge.stories.jsx
1
2
  import React from 'react';
2
3
  import { Badge } from './Badge';
3
4
  import './Badge.css';