frontend-hamroun 1.2.5 → 1.2.7
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/context.d.ts +3 -4
- package/dist/context.js +6 -8
- package/dist/frontend-hamroun.es.js +331 -301
- package/dist/frontend-hamroun.umd.js +13 -13
- package/dist/index.d.ts +58 -14
- package/dist/index.js +26 -13
- package/package.json +1 -1
- package/src/context.ts +11 -14
- package/src/index.ts +72 -43
- package/templates/basic/tsconfig.json +14 -4
- package/templates/basic-app/src/App.tsx +53 -1
- package/templates/basic-app/src/main.tsx +18 -1
- package/templates/basic-app/tsconfig.json +14 -4
- package/templates/basic-app/vite.config.ts +2 -1
- package/templates/full-stack/tsconfig.json +16 -15
- package/templates/full-stack/vite.config.ts +2 -1
@@ -1,8 +1,9 @@
|
|
1
|
-
import { useState, useEffect } from 'frontend-hamroun';
|
1
|
+
import { useState, useEffect, useContext } from 'frontend-hamroun';
|
2
2
|
import { Header } from './components/Header';
|
3
3
|
import { Counter } from './components/Counter';
|
4
4
|
import { ApiClient } from './api.js';
|
5
5
|
import { TodoList } from './components/TodoList.js';
|
6
|
+
import { AppContext } from './main';
|
6
7
|
|
7
8
|
interface AppProps {
|
8
9
|
api: ApiClient;
|
@@ -12,6 +13,8 @@ export function App({ api }: AppProps) {
|
|
12
13
|
const [todos, setTodos] = useState([]);
|
13
14
|
const [isLoading, setIsLoading] = useState(true);
|
14
15
|
const [error, setError] = useState<string | null>(null);
|
16
|
+
const [count, setCount] = useState(0);
|
17
|
+
const { theme } = useContext(AppContext);
|
15
18
|
|
16
19
|
useEffect(() => {
|
17
20
|
// Fetch data when component mounts
|
@@ -59,6 +62,55 @@ export function App({ api }: AppProps) {
|
|
59
62
|
)}
|
60
63
|
</div>
|
61
64
|
</div>
|
65
|
+
|
66
|
+
<div style={{ fontFamily: 'Arial, sans-serif', maxWidth: '600px', margin: '0 auto', padding: '2rem' }}>
|
67
|
+
<h1 style={{ color: '#333', textAlign: 'center' }}>Frontend Hamroun App</h1>
|
68
|
+
<p style={{ textAlign: 'center' }}>
|
69
|
+
Current theme: <strong>{theme}</strong>
|
70
|
+
</p>
|
71
|
+
<div style={{
|
72
|
+
display: 'flex',
|
73
|
+
flexDirection: 'column',
|
74
|
+
alignItems: 'center',
|
75
|
+
marginTop: '2rem',
|
76
|
+
padding: '1rem',
|
77
|
+
border: '1px solid #ccc',
|
78
|
+
borderRadius: '8px',
|
79
|
+
backgroundColor: theme === 'dark' ? '#333' : '#fff',
|
80
|
+
color: theme === 'dark' ? '#fff' : '#333'
|
81
|
+
}}>
|
82
|
+
<h2>Counter Example</h2>
|
83
|
+
<p>Count: {count}</p>
|
84
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
85
|
+
<button
|
86
|
+
onClick={() => setCount(count - 1)}
|
87
|
+
style={{
|
88
|
+
padding: '8px 16px',
|
89
|
+
background: '#ff4d4d',
|
90
|
+
color: 'white',
|
91
|
+
border: 'none',
|
92
|
+
borderRadius: '4px',
|
93
|
+
cursor: 'pointer'
|
94
|
+
}}
|
95
|
+
>
|
96
|
+
Decrement
|
97
|
+
</button>
|
98
|
+
<button
|
99
|
+
onClick={() => setCount(count + 1)}
|
100
|
+
style={{
|
101
|
+
padding: '8px 16px',
|
102
|
+
background: '#4d79ff',
|
103
|
+
color: 'white',
|
104
|
+
border: 'none',
|
105
|
+
borderRadius: '4px',
|
106
|
+
cursor: 'pointer'
|
107
|
+
}}
|
108
|
+
>
|
109
|
+
Increment
|
110
|
+
</button>
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
</div>
|
62
114
|
</main>
|
63
115
|
</div>
|
64
116
|
);
|
@@ -141,4 +141,21 @@ function ContextConsumer() {
|
|
141
141
|
);
|
142
142
|
}
|
143
143
|
|
144
|
-
render
|
144
|
+
import { render, createContext } from 'frontend-hamroun';
|
145
|
+
import { App } from './App';
|
146
|
+
|
147
|
+
// Create an example context
|
148
|
+
export const AppContext = createContext({ theme: 'light' });
|
149
|
+
|
150
|
+
document.addEventListener('DOMContentLoaded', () => {
|
151
|
+
const rootElement = document.getElementById('app');
|
152
|
+
if (rootElement) {
|
153
|
+
render(
|
154
|
+
<AppContext.Provider value={{ theme: 'light' }}>
|
155
|
+
<App />
|
156
|
+
</AppContext.Provider>,
|
157
|
+
rootElement
|
158
|
+
);
|
159
|
+
console.log('App rendered successfully');
|
160
|
+
}
|
161
|
+
});
|
@@ -1,13 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"module": "ESNext",
|
5
6
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6
|
-
"
|
7
|
+
"skipLibCheck": true,
|
7
8
|
"moduleResolution": "bundler",
|
8
|
-
"
|
9
|
+
"allowImportingTsExtensions": true,
|
10
|
+
"resolveJsonModule": true,
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
13
|
+
"jsx": "react-jsx",
|
14
|
+
"jsxFactory": "jsx",
|
15
|
+
"jsxFragmentFactory": "Fragment",
|
9
16
|
"strict": true,
|
10
|
-
"
|
17
|
+
"noUnusedLocals": true,
|
18
|
+
"noUnusedParameters": true,
|
19
|
+
"noFallthroughCasesInSwitch": true
|
11
20
|
},
|
12
|
-
"include": ["src"]
|
21
|
+
"include": ["src"],
|
22
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
13
23
|
}
|
@@ -4,7 +4,8 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
4
|
export default defineConfig({
|
5
5
|
esbuild: {
|
6
6
|
jsxFactory: 'jsx',
|
7
|
-
jsxFragment: 'Fragment'
|
7
|
+
jsxFragment: 'Fragment',
|
8
|
+
jsxInject: `import { jsx, Fragment } from 'frontend-hamroun'`
|
8
9
|
},
|
9
10
|
build: {
|
10
11
|
outDir: 'dist',
|
@@ -1,22 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
"target": "
|
3
|
+
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"module": "ESNext",
|
5
|
-
"
|
6
|
-
"jsx": "react",
|
7
|
-
"jsxFactory": "createElement",
|
8
|
-
"jsxFragmentFactory": "Fragment",
|
9
|
-
"strict": true,
|
10
|
-
"esModuleInterop": true,
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
11
7
|
"skipLibCheck": true,
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"allowJs": true,
|
15
|
-
"noEmit": true,
|
16
|
-
"isolatedModules": true,
|
8
|
+
"moduleResolution": "bundler",
|
9
|
+
"allowImportingTsExtensions": true,
|
17
10
|
"resolveJsonModule": true,
|
18
|
-
"
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
13
|
+
"jsx": "react-jsx",
|
14
|
+
"jsxFactory": "jsx",
|
15
|
+
"jsxFragmentFactory": "Fragment",
|
16
|
+
"strict": true,
|
17
|
+
"noUnusedLocals": true,
|
18
|
+
"noUnusedParameters": true,
|
19
|
+
"noFallthroughCasesInSwitch": true
|
19
20
|
},
|
20
|
-
"include": ["src
|
21
|
-
"
|
21
|
+
"include": ["src"],
|
22
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
22
23
|
}
|
@@ -4,7 +4,8 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
4
|
export default defineConfig({
|
5
5
|
esbuild: {
|
6
6
|
jsxFactory: 'jsx',
|
7
|
-
jsxFragment: 'Fragment'
|
7
|
+
jsxFragment: 'Fragment',
|
8
|
+
jsxInject: `import { jsx, Fragment } from 'frontend-hamroun'`
|
8
9
|
},
|
9
10
|
build: {
|
10
11
|
outDir: 'dist',
|