nextia 7.0.10 → 7.0.12
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/package.json +1 -1
- package/src/bin.js +15 -18
- package/src/lib/ui.js +1 -2
package/package.json
CHANGED
package/src/bin.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* https://github.com/sinuhedev/nextia
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { writeFile } from 'node:fs/promises'
|
|
12
|
+
import { mkdir, writeFile } from 'node:fs/promises'
|
|
13
13
|
|
|
14
14
|
function toPascalCase(str) {
|
|
15
15
|
return str
|
|
@@ -31,7 +31,6 @@ async function createPage(name) {
|
|
|
31
31
|
writeFile(
|
|
32
32
|
`${dirName}/index.jsx`,
|
|
33
33
|
`import { css, useFx } from 'nextia'
|
|
34
|
-
import { useEffect } from 'react'
|
|
35
34
|
import functions from './functions'
|
|
36
35
|
import './style.css'
|
|
37
36
|
|
|
@@ -71,16 +70,15 @@ export default { initialState }
|
|
|
71
70
|
|
|
72
71
|
async function createComponent(name) {
|
|
73
72
|
const dirName = `./src/components/${name}`
|
|
73
|
+
const componentName = toPascalCase(name)
|
|
74
74
|
|
|
75
75
|
try {
|
|
76
76
|
await mkdir(dirName)
|
|
77
|
-
const componentName = toPascalCase(name)
|
|
78
77
|
|
|
79
78
|
// index.jsx
|
|
80
79
|
writeFile(
|
|
81
80
|
`${dirName}/index.jsx`,
|
|
82
81
|
`import { css } from 'nextia'
|
|
83
|
-
import { useEffect } from 'react'
|
|
84
82
|
import './style.css'
|
|
85
83
|
|
|
86
84
|
export default function ${componentName} ({ className, style }) {
|
|
@@ -106,27 +104,26 @@ export default function ${componentName} ({ className, style }) {
|
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
async function
|
|
107
|
+
async function createComponentFx(name) {
|
|
110
108
|
const dirName = `./src/components/${name}`
|
|
109
|
+
const componentFxName = toPascalCase(name)
|
|
111
110
|
|
|
112
111
|
try {
|
|
113
112
|
await mkdir(dirName)
|
|
114
|
-
const containerName = toPascalCase(name)
|
|
115
113
|
|
|
116
114
|
// index.jsx
|
|
117
115
|
writeFile(
|
|
118
116
|
`${dirName}/index.jsx`,
|
|
119
117
|
`import { css, useFx } from 'nextia'
|
|
120
|
-
import { useEffect } from 'react'
|
|
121
118
|
import functions from './functions'
|
|
122
119
|
import './style.css'
|
|
123
120
|
|
|
124
|
-
export default function ${
|
|
121
|
+
export default function ${componentFxName} ({ className, style }) {
|
|
125
122
|
const { state, fx } = useFx(functions)
|
|
126
123
|
|
|
127
124
|
return (
|
|
128
|
-
<article className={css('${
|
|
129
|
-
${
|
|
125
|
+
<article className={css('${componentFxName}', className, '')} style={style}>
|
|
126
|
+
${componentFxName}
|
|
130
127
|
</article>
|
|
131
128
|
)
|
|
132
129
|
}
|
|
@@ -136,7 +133,7 @@ export default function ${containerName} ({ className, style }) {
|
|
|
136
133
|
// style.css
|
|
137
134
|
writeFile(
|
|
138
135
|
`${dirName}/style.css`,
|
|
139
|
-
`.${
|
|
136
|
+
`.${componentFxName} {
|
|
140
137
|
}
|
|
141
138
|
`
|
|
142
139
|
)
|
|
@@ -149,9 +146,9 @@ export default function ${containerName} ({ className, style }) {
|
|
|
149
146
|
export default { initialState }
|
|
150
147
|
`
|
|
151
148
|
)
|
|
152
|
-
console.info(`✔
|
|
149
|
+
console.info(`✔ ComponentFx "${name}" created at ${dirName}`)
|
|
153
150
|
} catch (err) {
|
|
154
|
-
console.error(`Failed to create
|
|
151
|
+
console.error(`Failed to create component:fx: ${err.message}`)
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
154
|
|
|
@@ -162,17 +159,17 @@ async function main() {
|
|
|
162
159
|
switch (ARG1) {
|
|
163
160
|
case 'page':
|
|
164
161
|
if (ARG2) await createPage(ARG2)
|
|
165
|
-
else console.warn('node --run
|
|
162
|
+
else console.warn('node --run page -- <page-name>')
|
|
166
163
|
break
|
|
167
164
|
|
|
168
165
|
case 'component':
|
|
169
166
|
if (ARG2) await createComponent(ARG2)
|
|
170
|
-
else console.warn('node --run
|
|
167
|
+
else console.warn('node --run component -- <ComponentName>')
|
|
171
168
|
break
|
|
172
169
|
|
|
173
|
-
case '
|
|
174
|
-
if (ARG2) await
|
|
175
|
-
else console.warn('node --run
|
|
170
|
+
case 'component:fx':
|
|
171
|
+
if (ARG2) await createComponentFx(ARG2)
|
|
172
|
+
else console.warn('node --run component:fx -- <ComponentFxName>')
|
|
176
173
|
break
|
|
177
174
|
}
|
|
178
175
|
}
|
package/src/lib/ui.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import { createElement, useEffect, useRef } from 'react'
|
|
11
11
|
import { useFx } from './fx'
|
|
12
|
-
import { css } from './utils'
|
|
13
12
|
|
|
14
13
|
function Link({ children, href, value = {}, ...props }) {
|
|
15
14
|
href ??= window.location.hash.split('?')[0]
|
|
@@ -84,7 +83,7 @@ function Icon({
|
|
|
84
83
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
85
84
|
ref,
|
|
86
85
|
id,
|
|
87
|
-
className
|
|
86
|
+
className,
|
|
88
87
|
style,
|
|
89
88
|
width,
|
|
90
89
|
height: height ?? width,
|