this.gui 1.0.16 → 1.0.17
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/README.md +191 -23
- package/dist/style.css +1 -1
- package/dist/this-gui.es.js +2777 -1923
- package/dist/this-gui.umd.js +23 -23
- package/package.json +2 -4
- package/src/App.jsx +4 -1
- package/src/Page.jsx +28 -0
- package/src/example.json +43 -0
- package/src/scripts/ComponentRegistry.js +70 -0
- package/src/scripts/postinstall.js +40 -1
- package/src/scripts/renderComponents.js +11 -0
- package/src/stories/Atoms/Badge/Badge.css +1 -0
- package/src/stories/Atoms/Badge/Badge.stories.jsx +1 -0
- package/src/stories/Atoms/Grid/Grid.css +160 -0
- package/src/stories/Atoms/Grid/Grid.jsx +43 -0
- package/src/stories/Atoms/Grid/Grid.stories.jsx +84 -0
- package/src/stories/Atoms/ProgressBar/ProgressBar.css +1 -1
- package/src/stories/Atoms/ProgressBar/ProgressBar.jsx +1 -1
- package/src/stories/Atoms/ProgressBar/ProgressBar.stories.jsx +1 -1
- package/src/stories/Atoms/Section/Section.css +268 -0
- package/src/stories/Atoms/Section/Section.jsx +63 -0
- package/src/stories/Atoms/Section/Section.stories.jsx +46 -0
- package/src/stories/Atoms/TextArea/TextArea.css +1 -0
- package/src/stories/Atoms/TextArea/TextArea.jsx +1 -0
- package/src/stories/Atoms/TextArea/TextArea.stories.jsx +1 -0
- package/src/stories/Atoms/TextInput/TextInput.css +1 -0
- package/src/stories/Atoms/TextInput/TextInput.jsx +1 -0
- package/src/stories/Atoms/TextInput/TextInput.stories.jsx +1 -0
- package/src/stories/Atoms/Toggle/Toggle.css +1 -0
- package/src/stories/Atoms/Toggle/Toggle.jsx +1 -0
- package/src/stories/Atoms/Toggle/Toggle.stories.jsx +1 -0
- package/src/stories/Atoms/Tooltip/Tooltip.css +1 -0
- package/src/stories/Atoms/Tooltip/Tooltip.jsx +1 -0
- package/src/stories/Atoms/Tooltip/Tooltip.stories.jsx +1 -0
- package/src/stories/Atoms/Video/Video.css +1 -0
- package/src/stories/Atoms/Video/Video.jsx +1 -0
- package/src/stories/Atoms/Video/Video.stories.jsx +1 -0
- package/src/stories/Atoms/index.js +4 -0
- package/src/stories/Atoms/meta_Atoms.js +4 -1
- package/src/stories/Layouts/Accordion/Accordion.css +285 -8
- package/src/stories/Layouts/Accordion/Accordion.jsx +62 -19
- package/src/stories/Layouts/Accordion/Accordion.stories.jsx +30 -19
- package/src/stories/Layouts/index.js +0 -6
- package/src/stories/Layouts/meta_Layouts.js +2 -5
- package/src/stories/Molecules/Accordion/Accordion.css +1 -1
- package/src/stories/Molecules/Accordion/Accordion.jsx +1 -1
- package/src/stories/Molecules/Accordion/Accordion.stories.jsx +1 -1
- package/src/stories/Molecules/AudioPlayer/AudioPlayer.css +95 -2
- package/src/stories/Molecules/AudioPlayer/AudioPlayer.jsx +232 -13
- package/src/stories/Molecules/AudioPlayer/AudioPlayer.stories.jsx +46 -11
- package/src/stories/Molecules/AvatarWithName/AvatarWithName.css +128 -2
- package/src/stories/Molecules/AvatarWithName/AvatarWithName.jsx +69 -14
- package/src/stories/Molecules/AvatarWithName/AvatarWithName.stories.jsx +12 -12
- package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.css +145 -2
- package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.jsx +39 -13
- package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.stories.jsx +27 -11
- package/src/stories/Molecules/ButtonGroup/ButtonGroup.css +463 -2
- package/src/stories/Molecules/ButtonGroup/ButtonGroup.jsx +34 -12
- package/src/stories/Molecules/ButtonGroup/ButtonGroup.stories.jsx +36 -12
- package/src/stories/Molecules/Card/Card.css +39 -2
- package/src/stories/Molecules/Card/Card.jsx +80 -13
- package/src/stories/Molecules/Card/Card.stories.jsx +27 -13
- package/src/stories/Molecules/ComparisonTable/ComparisonTable.css +33 -2
- package/src/stories/Molecules/ComparisonTable/ComparisonTable.jsx +91 -12
- package/src/stories/Molecules/ComparisonTable/ComparisonTable.stories.jsx +73 -12
- package/src/stories/Molecules/Dropdown/Dropdown.css +192 -0
- package/src/stories/Molecules/Dropdown/Dropdown.jsx +96 -0
- package/src/stories/Molecules/Dropdown/Dropdown.stories.jsx +45 -0
- package/src/stories/Molecules/index.js +2 -1
- package/src/stories/Molecules/meta_Molecules.js +6 -3
- package/dist/Styles.md +0 -446
- package/dist/context.md +0 -942
- package/src/Theme.jsx +0 -28
- package/src/components/CodeBlock.jsx +0 -22
- package/src/components/ComponentFactory.jsx +0 -36
- package/src/components/ComponentRegistry.js +0 -21
- package/src/scripts/generateComponents.js +0 -166
- package/src/scripts/verifyLayouts.js +0 -175
- package/src/scripts/verifyMolecules.js +0 -158
- package/src/scripts/verifyTemplates.js +0 -154
- package/src/scripts/verify_and_install_atoms.js +0 -211
- package/src/stories/Layouts/DropdownMenu/DropdownMenu.css +0 -16
- package/src/stories/Layouts/DropdownMenu/DropdownMenu.jsx +0 -31
- package/src/stories/Layouts/DropdownMenu/DropdownMenu.stories.jsx +0 -28
- package/src/stories/Layouts/Grid/Grid.css +0 -4
- package/src/stories/Layouts/Grid/Grid.jsx +0 -13
- package/src/stories/Layouts/Grid/Grid.stories.jsx +0 -28
- package/src/stories/Layouts/Section/Section.css +0 -16
- package/src/stories/Layouts/Section/Section.jsx +0 -31
- package/src/stories/Layouts/Section/Section.stories.jsx +0 -28
- /package/src/themes/{README.md → README_Styles.md} +0 -0
package/src/Theme.jsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// this.GUI/src/Theme.jsx
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { CssVarsProvider } from '@mui/joy/styles'; // Import MUI Joy's CssVarsProvider
|
|
4
|
-
import lightTheme from './themes/light'; // Import light theme
|
|
5
|
-
import darkTheme from './themes/dark'; // Import dark theme
|
|
6
|
-
|
|
7
|
-
const Theme = ({ children }) => {
|
|
8
|
-
const [theme, setTheme] = useState(localStorage.getItem('theme') || 'light');
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
localStorage.setItem('theme', theme); // Persist theme preference in localStorage
|
|
12
|
-
}, [theme]);
|
|
13
|
-
|
|
14
|
-
const currentTheme = theme === 'dark' ? darkTheme : lightTheme;
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<CssVarsProvider theme={currentTheme}> {/* Wrap with the correct theme */}
|
|
18
|
-
<div>
|
|
19
|
-
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
20
|
-
Toggle Theme
|
|
21
|
-
</button>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
</CssVarsProvider>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default Theme;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/components/CodeBlock.jsx
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
5
|
-
// Import the language(s) you need
|
|
6
|
-
import javascript from 'react-syntax-highlighter/dist/esm/languages/hljs/javascript';
|
|
7
|
-
// Import a syntax highlighting style
|
|
8
|
-
import { atomOneLight } from 'react-syntax-highlighter/dist/esm/styles/hljs';
|
|
9
|
-
|
|
10
|
-
SyntaxHighlighter.registerLanguage('javascript', javascript);
|
|
11
|
-
|
|
12
|
-
const CodeBlock = ({ className, children }) => {
|
|
13
|
-
const language = className ? className.replace('language-', '') : 'javascript';
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SyntaxHighlighter language={language} style={atomOneLight}>
|
|
17
|
-
{children}
|
|
18
|
-
</SyntaxHighlighter>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default CodeBlock;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// src/components/ComponentFactory.jsx
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import GUI from '../../index';
|
|
4
|
-
|
|
5
|
-
const ComponentFactory = ({ category, subcategory, componentName, ...props }) => {
|
|
6
|
-
const Category = GUI[category];
|
|
7
|
-
|
|
8
|
-
if (!Category) {
|
|
9
|
-
console.error(`Category "${category}" not found.`);
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let Component;
|
|
14
|
-
|
|
15
|
-
if (subcategory) {
|
|
16
|
-
const Subcategory = Category[subcategory];
|
|
17
|
-
|
|
18
|
-
if (!Subcategory) {
|
|
19
|
-
console.error(`Subcategory "${subcategory}" not found in category "${category}".`);
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Component = Subcategory[componentName];
|
|
24
|
-
} else {
|
|
25
|
-
Component = Category[componentName];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!Component) {
|
|
29
|
-
console.error(`Component "${componentName}" not found in category "${category}"${subcategory ? ` and subcategory "${subcategory}"` : ''}.`);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return <Component {...props} />;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default ComponentFactory;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/components/ComponentRegistry.js
|
|
2
|
-
import { Button } from '../stories/_Atomic/Button/Button';
|
|
3
|
-
import { Input } from '../stories/_Atomic/Input/Input';
|
|
4
|
-
// Import the Navbar component
|
|
5
|
-
import { Navbar } from '../stories/_Molecules/Navbar/Navbar';
|
|
6
|
-
// ... import other components
|
|
7
|
-
|
|
8
|
-
const ComponentRegistry = {
|
|
9
|
-
_Atomic: {
|
|
10
|
-
Button,
|
|
11
|
-
Input,
|
|
12
|
-
// ... other atomic components
|
|
13
|
-
},
|
|
14
|
-
_Molecules: {
|
|
15
|
-
Navbar,
|
|
16
|
-
// ... other molecule components
|
|
17
|
-
},
|
|
18
|
-
// ... other categories
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default ComponentRegistry;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
const components = {
|
|
2
|
-
"Atomic": {
|
|
3
|
-
"Text": ["Heading", "Paragraph", "Label", "Caption"],
|
|
4
|
-
"Interactive": [
|
|
5
|
-
"Button",
|
|
6
|
-
"Link",
|
|
7
|
-
"Icon",
|
|
8
|
-
"Checkbox",
|
|
9
|
-
"RadioButton",
|
|
10
|
-
"Toggle",
|
|
11
|
-
"TextInput",
|
|
12
|
-
"TextArea",
|
|
13
|
-
"Select",
|
|
14
|
-
"Slider",
|
|
15
|
-
"RangeInput"
|
|
16
|
-
],
|
|
17
|
-
"Media": ["Image", "Video", "Audio", "Icon"],
|
|
18
|
-
"Visual": [
|
|
19
|
-
"Divider",
|
|
20
|
-
"Spacer",
|
|
21
|
-
"Tooltip",
|
|
22
|
-
"Badge",
|
|
23
|
-
"Tag"
|
|
24
|
-
],
|
|
25
|
-
"Feedback": [
|
|
26
|
-
"Loader",
|
|
27
|
-
"Spinner",
|
|
28
|
-
"ProgressBar",
|
|
29
|
-
"Alert",
|
|
30
|
-
"Snackbar"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
"Molecules": {
|
|
35
|
-
"FormElements": [
|
|
36
|
-
"InputGroup",
|
|
37
|
-
"InputWithLabel",
|
|
38
|
-
"SearchBar",
|
|
39
|
-
"FileUpload",
|
|
40
|
-
"FormField"
|
|
41
|
-
],
|
|
42
|
-
"ButtonsWithIcons": [
|
|
43
|
-
"IconButton",
|
|
44
|
-
"ButtonGroup"
|
|
45
|
-
],
|
|
46
|
-
"MediaMolecules": [
|
|
47
|
-
"ImageWithCaption",
|
|
48
|
-
"VideoWithDescription",
|
|
49
|
-
"AvatarWithName",
|
|
50
|
-
"AudioPlayer"
|
|
51
|
-
],
|
|
52
|
-
"FeedbackMolecules": [
|
|
53
|
-
"Notification",
|
|
54
|
-
"Modal"
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
"Organisms": {
|
|
59
|
-
"Forms": [
|
|
60
|
-
"SignInForm",
|
|
61
|
-
"RegistrationForm",
|
|
62
|
-
"ContactForm"
|
|
63
|
-
],
|
|
64
|
-
"ContentDisplay": [
|
|
65
|
-
"Card",
|
|
66
|
-
"MediaCard",
|
|
67
|
-
"List",
|
|
68
|
-
"Accordion"
|
|
69
|
-
],
|
|
70
|
-
"Navigation": [
|
|
71
|
-
"Navbar",
|
|
72
|
-
"Sidebar",
|
|
73
|
-
"Breadcrumbs"
|
|
74
|
-
],
|
|
75
|
-
"MediaCollections": [
|
|
76
|
-
"ImageGallery",
|
|
77
|
-
"VideoPlaylist",
|
|
78
|
-
"Carousel"
|
|
79
|
-
],
|
|
80
|
-
"Tables": [
|
|
81
|
-
"DataTable",
|
|
82
|
-
"PricingTable",
|
|
83
|
-
"ComparisonTable"
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
"Layout": {
|
|
88
|
-
"Grid": ["Grid"],
|
|
89
|
-
"Section": ["Section"],
|
|
90
|
-
"FlexboxLayout": ["Flexbox"],
|
|
91
|
-
"NavigationAndMenus": [
|
|
92
|
-
"Header",
|
|
93
|
-
"Footer",
|
|
94
|
-
"DropdownMenu",
|
|
95
|
-
"Pagination"
|
|
96
|
-
],
|
|
97
|
-
"ContentOrganization": [
|
|
98
|
-
"Sidebar",
|
|
99
|
-
"Tabs",
|
|
100
|
-
"Accordion"
|
|
101
|
-
],
|
|
102
|
-
"HeroSections": [
|
|
103
|
-
"HeroBanner",
|
|
104
|
-
"HeroImageVideo"
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
"Templates": {
|
|
109
|
-
"LandingPages": [
|
|
110
|
-
"HeroSection",
|
|
111
|
-
"FeaturesList",
|
|
112
|
-
"CallToAction",
|
|
113
|
-
"Testimonials"
|
|
114
|
-
],
|
|
115
|
-
"DashboardLayouts": [
|
|
116
|
-
"AdminDashboard",
|
|
117
|
-
"SidebarTopNav"
|
|
118
|
-
],
|
|
119
|
-
"ECommercePages": [
|
|
120
|
-
"ProductPage",
|
|
121
|
-
"ShoppingCart"
|
|
122
|
-
],
|
|
123
|
-
"AuthenticationPages": [
|
|
124
|
-
"SignInPage",
|
|
125
|
-
"RegistrationPage"
|
|
126
|
-
],
|
|
127
|
-
"ContactUsPages": [
|
|
128
|
-
"FormSection",
|
|
129
|
-
"LocationInfo",
|
|
130
|
-
"SocialMediaLinks"
|
|
131
|
-
]
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
"Pages": {
|
|
135
|
-
"HomePage": ["HomePage"],
|
|
136
|
-
"AboutUsPage": ["AboutUsPage"],
|
|
137
|
-
"ContactUsPage": ["ContactUsPage"],
|
|
138
|
-
"UserProfilePage": ["UserProfilePage"],
|
|
139
|
-
"ProductDetailPage": ["ProductDetailPage"],
|
|
140
|
-
"CheckoutPage": ["CheckoutPage"],
|
|
141
|
-
"BlogPage": ["BlogPage"],
|
|
142
|
-
"AdminDashboard": ["AdminDashboard"],
|
|
143
|
-
"SearchResultsPage": ["SearchResultsPage"]
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
"Miscellaneous": {
|
|
147
|
-
"TooltipsPopovers": [
|
|
148
|
-
"Tooltip",
|
|
149
|
-
"Popover"
|
|
150
|
-
],
|
|
151
|
-
"Overlays": [
|
|
152
|
-
"ModalWindow",
|
|
153
|
-
"Drawer"
|
|
154
|
-
],
|
|
155
|
-
"SearchComponents": [
|
|
156
|
-
"SearchBox",
|
|
157
|
-
"Autocomplete"
|
|
158
|
-
],
|
|
159
|
-
"MediaAndContentControls": [
|
|
160
|
-
"AudioControls",
|
|
161
|
-
"VideoControls",
|
|
162
|
-
"Filters"
|
|
163
|
-
],
|
|
164
|
-
"InteractiveMaps": ["Map"]
|
|
165
|
-
}
|
|
166
|
-
};
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import Layout from '../stories/Layouts/meta_Layouts.js'; // Import the Layout constant
|
|
5
|
-
|
|
6
|
-
// Define __dirname for ES modules
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
// Helper function to check if a file exists relative to the script's directory
|
|
11
|
-
const fileExists = (relativeFilePath) => {
|
|
12
|
-
const fullPath = path.resolve(__dirname, relativeFilePath);
|
|
13
|
-
return fs.existsSync(fullPath);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// Default CSS template for Layouts
|
|
17
|
-
const createDefaultCSSTemplate = (componentName) => `
|
|
18
|
-
.${componentName.toLowerCase()} {
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-wrap: wrap;
|
|
21
|
-
padding: 16px;
|
|
22
|
-
gap: 8px;
|
|
23
|
-
border: 1px solid #ddd;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.${componentName.toLowerCase()}--primary {
|
|
27
|
-
background-color: #e3f2fd;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.${componentName.toLowerCase()}--secondary {
|
|
31
|
-
background-color: #fff;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
// Default JSX template for Layouts
|
|
36
|
-
const createDefaultJSX = (componentName) => `
|
|
37
|
-
import React from 'react';
|
|
38
|
-
import PropTypes from 'prop-types';
|
|
39
|
-
import './${componentName}.css';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* ${componentName} layout component
|
|
43
|
-
*/
|
|
44
|
-
export const ${componentName} = ({ children, primary, ...props }) => {
|
|
45
|
-
const mode = primary ? '${componentName.toLowerCase()}--primary' : '${componentName.toLowerCase()}--secondary';
|
|
46
|
-
return (
|
|
47
|
-
<div className={['${componentName.toLowerCase()}', mode].join(' ')} {...props}>
|
|
48
|
-
{children}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
${componentName}.propTypes = {
|
|
54
|
-
/**
|
|
55
|
-
* Primary style for the layout
|
|
56
|
-
*/
|
|
57
|
-
primary: PropTypes.bool,
|
|
58
|
-
/**
|
|
59
|
-
* Children components to be rendered inside the layout
|
|
60
|
-
*/
|
|
61
|
-
children: PropTypes.node.isRequired,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
${componentName}.defaultProps = {
|
|
65
|
-
primary: false,
|
|
66
|
-
};
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
// Default Storybook template for Layouts
|
|
70
|
-
const createDefaultStorybookTemplate = (componentName) => `
|
|
71
|
-
import { ${componentName} } from './${componentName}';
|
|
72
|
-
|
|
73
|
-
// Storybook configuration for ${componentName} component
|
|
74
|
-
export default {
|
|
75
|
-
title: 'Layouts/${componentName}',
|
|
76
|
-
component: ${componentName},
|
|
77
|
-
parameters: {
|
|
78
|
-
layout: 'fullscreen',
|
|
79
|
-
},
|
|
80
|
-
argTypes: {
|
|
81
|
-
children: { control: 'text' },
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const Primary = {
|
|
86
|
-
args: {
|
|
87
|
-
primary: true,
|
|
88
|
-
children: 'This is a primary ${componentName} layout.',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const Secondary = {
|
|
93
|
-
args: {
|
|
94
|
-
primary: false,
|
|
95
|
-
children: 'This is a secondary ${componentName} layout.',
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
// Helper function to write files
|
|
101
|
-
const writeFile = (filePath, content) => {
|
|
102
|
-
const fullPath = path.resolve(__dirname, filePath);
|
|
103
|
-
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
104
|
-
fs.writeFileSync(fullPath, content, 'utf8');
|
|
105
|
-
console.log(`✅ Created: ${filePath}`);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Function to verify each path and create missing files with default content
|
|
109
|
-
async function verifyPaths(component, paths) {
|
|
110
|
-
const missingFiles = []; // Initialize missingFiles array
|
|
111
|
-
|
|
112
|
-
for (const [key, filePath] of Object.entries(paths)) {
|
|
113
|
-
const adjustedPath = path.join('..', 'stories', 'Layouts', filePath);
|
|
114
|
-
|
|
115
|
-
if (!fileExists(adjustedPath)) {
|
|
116
|
-
console.log(`❌ Missing: ${adjustedPath}`);
|
|
117
|
-
missingFiles.push(adjustedPath);
|
|
118
|
-
|
|
119
|
-
// Automatically create the missing file with default content
|
|
120
|
-
if (key === 'css') {
|
|
121
|
-
writeFile(adjustedPath, createDefaultCSSTemplate(component.name.trim()));
|
|
122
|
-
} else if (key === 'jsx') {
|
|
123
|
-
writeFile(adjustedPath, createDefaultJSX(component.name.trim()));
|
|
124
|
-
} else if (key === 'stories') {
|
|
125
|
-
writeFile(adjustedPath, createDefaultStorybookTemplate(component.name.trim()));
|
|
126
|
-
}
|
|
127
|
-
} else {
|
|
128
|
-
console.log(`✅ Exists: ${adjustedPath}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return missingFiles; // Return missingFiles array
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Main function to handle installation and verification
|
|
136
|
-
async function installAndVerifyLayouts(Layout) {
|
|
137
|
-
const missingFilesReport = [];
|
|
138
|
-
|
|
139
|
-
// Loop through each category (Grid, Navigation, etc.)
|
|
140
|
-
for (const category of Object.keys(Layout.Layout)) {
|
|
141
|
-
console.log(`\nVerifying category: ${category}`);
|
|
142
|
-
|
|
143
|
-
// Loop through each component in the category
|
|
144
|
-
for (const component of Layout.Layout[category]) {
|
|
145
|
-
console.log(`\nVerifying component: ${component.name}`);
|
|
146
|
-
|
|
147
|
-
// Verify each path for the component and get missing files
|
|
148
|
-
const missingFiles = await verifyPaths(component, component.paths);
|
|
149
|
-
|
|
150
|
-
// If files are missing, report them
|
|
151
|
-
if (missingFiles.length > 0) {
|
|
152
|
-
missingFilesReport.push({
|
|
153
|
-
component: component.name,
|
|
154
|
-
missingFiles,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// If there are missing files, summarize the report
|
|
161
|
-
if (missingFilesReport.length > 0) {
|
|
162
|
-
console.log("\nInstallation or verification required for the following components:");
|
|
163
|
-
missingFilesReport.forEach((report) => {
|
|
164
|
-
console.log(`\nComponent: ${report.component}`);
|
|
165
|
-
report.missingFiles.forEach((file) => {
|
|
166
|
-
console.log(` ❌ Missing file: ${file}`);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
console.log("\nAll components verified successfully! ✅");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Run the verification script
|
|
175
|
-
installAndVerifyLayouts(Layout);
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// verifyMolecules.js
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import Molecules from '../stories/Molecules/Molecules.js'; // Import the Molecules constant
|
|
7
|
-
|
|
8
|
-
// Define __dirname for ES modules
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = path.dirname(__filename);
|
|
11
|
-
|
|
12
|
-
// Helper function to check if a file exists relative to the script's directory
|
|
13
|
-
const fileExists = (relativeFilePath) => {
|
|
14
|
-
const fullPath = path.resolve(__dirname, relativeFilePath);
|
|
15
|
-
return fs.existsSync(fullPath);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Default CSS template
|
|
19
|
-
const createDefaultCSSTemplate = (componentName) => `
|
|
20
|
-
.${componentName.toLowerCase()} {
|
|
21
|
-
/* Default styles for ${componentName} */
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
// Default JSX template
|
|
26
|
-
const createDefaultJSX = (componentName) => `
|
|
27
|
-
import React from 'react';
|
|
28
|
-
import PropTypes from 'prop-types';
|
|
29
|
-
import './${componentName}.css';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* ${componentName} component
|
|
33
|
-
*/
|
|
34
|
-
export const ${componentName} = (props) => {
|
|
35
|
-
return (
|
|
36
|
-
<div className="${componentName.toLowerCase()}" {...props}>
|
|
37
|
-
{/* Component implementation */}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
${componentName}.propTypes = {
|
|
43
|
-
// Define prop types here
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
${componentName}.defaultProps = {
|
|
47
|
-
// Define default props here
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default ${componentName};
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
// Default Storybook template
|
|
54
|
-
const createDefaultStorybookTemplate = (componentName, category) => `
|
|
55
|
-
import { ${componentName} } from './${componentName}';
|
|
56
|
-
|
|
57
|
-
// Storybook configuration for ${componentName} component
|
|
58
|
-
export default {
|
|
59
|
-
title: 'Molecules/${category}/${componentName}',
|
|
60
|
-
component: ${componentName},
|
|
61
|
-
parameters: {
|
|
62
|
-
layout: 'centered',
|
|
63
|
-
},
|
|
64
|
-
argTypes: {
|
|
65
|
-
// Define argTypes here
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const Default = {
|
|
70
|
-
args: {
|
|
71
|
-
// Define default args here
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
// Helper function to write files
|
|
77
|
-
const writeFile = (filePath, content) => {
|
|
78
|
-
const fullPath = path.resolve(__dirname, filePath);
|
|
79
|
-
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
80
|
-
fs.writeFileSync(fullPath, content, 'utf8');
|
|
81
|
-
console.log(`✅ Created: ${filePath}`);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Function to verify each path and create missing files with default content
|
|
85
|
-
async function verifyPaths(component, paths, category) {
|
|
86
|
-
const missingFiles = []; // Initialize missingFiles array
|
|
87
|
-
|
|
88
|
-
for (const [key, filePath] of Object.entries(paths)) {
|
|
89
|
-
const componentName = component.name.trim();
|
|
90
|
-
const adjustedPath = path.join(
|
|
91
|
-
'..',
|
|
92
|
-
'stories',
|
|
93
|
-
'Molecules',
|
|
94
|
-
componentName,
|
|
95
|
-
filePath.replace('./', '')
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
if (!fileExists(adjustedPath)) {
|
|
99
|
-
console.log(`❌ Missing: ${adjustedPath}`);
|
|
100
|
-
missingFiles.push(adjustedPath);
|
|
101
|
-
|
|
102
|
-
// Automatically create the missing file with default content
|
|
103
|
-
if (key === 'css') {
|
|
104
|
-
writeFile(adjustedPath, createDefaultCSSTemplate(componentName));
|
|
105
|
-
} else if (key === 'jsx') {
|
|
106
|
-
writeFile(adjustedPath, createDefaultJSX(componentName));
|
|
107
|
-
} else if (key === 'stories') {
|
|
108
|
-
writeFile(adjustedPath, createDefaultStorybookTemplate(componentName, category));
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
console.log(`✅ Exists: ${adjustedPath}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return missingFiles; // Return missingFiles array
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Main function to handle installation and verification
|
|
119
|
-
async function installAndVerifyMolecules(Molecules) {
|
|
120
|
-
const missingFilesReport = [];
|
|
121
|
-
|
|
122
|
-
// Loop through each category (Navigation, FormElements, etc.)
|
|
123
|
-
for (const category of Object.keys(Molecules.Molecules)) {
|
|
124
|
-
console.log(`\nVerifying category: ${category}`);
|
|
125
|
-
|
|
126
|
-
// Loop through each component in the category
|
|
127
|
-
for (const component of Molecules.Molecules[category]) {
|
|
128
|
-
console.log(`\nVerifying component: ${component.name.trim()}`);
|
|
129
|
-
|
|
130
|
-
// Verify each path for the component and get missing files
|
|
131
|
-
const missingFiles = await verifyPaths(component, component.paths, category);
|
|
132
|
-
|
|
133
|
-
// If files are missing, report them
|
|
134
|
-
if (missingFiles.length > 0) {
|
|
135
|
-
missingFilesReport.push({
|
|
136
|
-
component: component.name.trim(),
|
|
137
|
-
missingFiles,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// If there are missing files, summarize the report
|
|
144
|
-
if (missingFilesReport.length > 0) {
|
|
145
|
-
console.log('\nInstallation or verification required for the following components:');
|
|
146
|
-
missingFilesReport.forEach((report) => {
|
|
147
|
-
console.log(`\nComponent: ${report.component}`);
|
|
148
|
-
report.missingFiles.forEach((file) => {
|
|
149
|
-
console.log(` ❌ Missing file: ${file}`);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
} else {
|
|
153
|
-
console.log('\nAll components verified successfully! ✅');
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Run the verification script
|
|
158
|
-
installAndVerifyMolecules(Molecules);
|