@meonode/ui 0.1.0 → 0.1.2
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 +100 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@meonode/ui)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
<!-- Add other badges as needed: build status, coverage, etc. -->
|
|
6
5
|
|
|
7
6
|
`@meonode/ui` is a lightweight yet powerful utility for the programmatic creation and manipulation of React elements. It
|
|
8
7
|
offers an enhanced, structured way to define components, manage props (separating CSS from DOM attributes), handle
|
|
@@ -24,10 +23,22 @@ especially for dynamic UIs and design systems.
|
|
|
24
23
|
* **Seamless Integration:** Works with existing React components and fits naturally into any React workflow.
|
|
25
24
|
* **`Component` HOC:** A higher-order component to easily wrap functions that return `@meonode/ui` instances, making
|
|
26
25
|
them standard React components.
|
|
26
|
+
* **Pre-built HTML Element Components:** Offers a suite of convenience functions (e.g., `Div`, `Span`, `H1`, `Button`) that wrap `Node()` for common HTML tags, streamlining development.
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
First, ensure you have `react` installed as a dependency.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
yarn add react @meonode/ui
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To use the built-in integration with Material UI, install the following:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
yarn add react @mui/material @meonode/ui @meonode/mui
|
|
41
|
+
```
|
|
31
42
|
|
|
32
43
|
---
|
|
33
44
|
|
|
@@ -81,6 +92,93 @@ The `Component` HOC simplifies creating standard React components from functions
|
|
|
81
92
|
|
|
82
93
|
You can easily incorporate existing React components into your `@meonode/ui` structures.
|
|
83
94
|
|
|
95
|
+
|
|
96
|
+
### 7. Using Pre-built HTML Components
|
|
97
|
+
|
|
98
|
+
`@meonode/ui` includes a set of pre-built components for common HTML elements, making it even quicker to construct your UI. These are essentially convenience wrappers around the `Node()` factory, accepting the same props (including direct CSS styles, `theme` references, and `children`).
|
|
99
|
+
|
|
100
|
+
Examples include: `Div`, `Span`, `P`, `H1`-`H6`, `Img`, `Button`, `Input`, `Form`, layout components like `Column`, `Row`, `Grid`, `Center`, and many more.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { Component, Div, H1, P, Button } from '@meonode/ui';
|
|
104
|
+
|
|
105
|
+
// Define a simple theme (for example purposes)
|
|
106
|
+
const myTheme = {
|
|
107
|
+
colors: {
|
|
108
|
+
primary: 'dodgerblue',
|
|
109
|
+
secondary: 'lightgray',
|
|
110
|
+
surface: '#ffffff',
|
|
111
|
+
text: '#333333',
|
|
112
|
+
textOnPrimary: 'white',
|
|
113
|
+
},
|
|
114
|
+
spacing: {
|
|
115
|
+
small: '8px',
|
|
116
|
+
medium: '16px',
|
|
117
|
+
large: '24px',
|
|
118
|
+
},
|
|
119
|
+
typography: {
|
|
120
|
+
h1Size: '2.5rem',
|
|
121
|
+
pSize: '1rem',
|
|
122
|
+
},
|
|
123
|
+
borders: {
|
|
124
|
+
radius: '4px',
|
|
125
|
+
thin: '1px solid #cccccc',
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const MyStyledCard = Component(() => {
|
|
130
|
+
return Div({
|
|
131
|
+
theme: myTheme, // Apply the theme to this node and its descendants
|
|
132
|
+
padding: 'theme.spacing.large',
|
|
133
|
+
backgroundColor: 'theme.colors.surface',
|
|
134
|
+
borderRadius: 'theme.borders.radius',
|
|
135
|
+
boxShadow: '0 4px 8px rgba(0,0,0,0.1)',
|
|
136
|
+
maxWidth: '400px',
|
|
137
|
+
margin: 'theme.spacing.medium auto', // Center the card
|
|
138
|
+
border: 'theme.borders.thin',
|
|
139
|
+
children: [
|
|
140
|
+
H1({
|
|
141
|
+
fontSize: 'theme.typography.h1Size',
|
|
142
|
+
color: 'theme.colors.primary',
|
|
143
|
+
marginBottom: 'theme.spacing.medium',
|
|
144
|
+
children: 'Interactive Card',
|
|
145
|
+
}),
|
|
146
|
+
P({
|
|
147
|
+
fontSize: 'theme.typography.pSize',
|
|
148
|
+
color: 'theme.colors.text',
|
|
149
|
+
lineHeight: '1.6',
|
|
150
|
+
marginBottom: 'theme.spacing.large',
|
|
151
|
+
children: 'This card is built using pre-built HTML components from @meonode/ui, styled with a custom theme.',
|
|
152
|
+
}),
|
|
153
|
+
Button({
|
|
154
|
+
backgroundColor: 'theme.colors.primary',
|
|
155
|
+
color: 'theme.colors.textOnPrimary',
|
|
156
|
+
padding: 'theme.spacing.small theme.spacing.medium',
|
|
157
|
+
border: 'none',
|
|
158
|
+
borderRadius: 'theme.borders.radius',
|
|
159
|
+
fontSize: 'theme.typography.pSize',
|
|
160
|
+
cursor: 'pointer',
|
|
161
|
+
children: 'Learn More',
|
|
162
|
+
onClick: () => alert('Button clicked!'),
|
|
163
|
+
// Example of hover style (though direct CSS-in-JS hover is more complex without a helper)
|
|
164
|
+
// For simple cases, you might rely on global CSS or a more advanced styling solution.
|
|
165
|
+
// This is a placeholder to show where you might think about interactions.
|
|
166
|
+
// Real hover effects would typically be handled by CSS classes or a more robust styling library.
|
|
167
|
+
}),
|
|
168
|
+
],
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
To use it in a React application (example):
|
|
174
|
+
```ts
|
|
175
|
+
import React from 'react';
|
|
176
|
+
import ReactDOM from 'react-dom/client';
|
|
177
|
+
|
|
178
|
+
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
179
|
+
root.render(MyStyledCard());
|
|
180
|
+
```
|
|
181
|
+
|
|
84
182
|
---
|
|
85
183
|
|
|
86
184
|
## Usage Implementation
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meonode/ui",
|
|
3
3
|
"description": "`@meonode/ui` is a lightweight yet powerful utility for the programmatic creation and manipulation of React elements. It offers an enhanced, structured way to define components, manage props (separating CSS from DOM attributes), handle theming, and compose children *before* they are rendered by React. This provides greater control and flexibility, especially for dynamic UIs and design systems.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|