nextia 3.0.2 → 4.0.0
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 +2 -7
- package/create-nextia/LICENSE +21 -0
- package/create-nextia/README.md +17 -0
- package/create-nextia/package.json +38 -0
- package/{src → create-nextia/src}/bin.js +76 -22
- package/create-nextia/templates/nextjs/README.md +34 -0
- package/create-nextia/templates/nextjs/_env.development +4 -0
- package/create-nextia/templates/nextjs/_env.production +3 -0
- package/create-nextia/templates/nextjs/_env.test +3 -0
- package/create-nextia/templates/nextjs/_gitignore +9 -0
- package/create-nextia/templates/nextjs/jsconfig.json +5 -0
- package/create-nextia/templates/nextjs/next.config.js +18 -0
- package/create-nextia/templates/nextjs/package.json +39 -0
- package/create-nextia/templates/nextjs/public/logo.svg +865 -0
- package/create-nextia/templates/nextjs/src/app/counter/functions.js +6 -0
- package/create-nextia/templates/nextjs/src/app/counter/page.js +42 -0
- package/create-nextia/templates/nextjs/src/app/counter/style.css +2 -0
- package/create-nextia/templates/nextjs/src/app/env/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/env/page.js +24 -0
- package/create-nextia/templates/nextjs/src/app/env/style.css +1 -0
- package/create-nextia/templates/nextjs/src/app/functions.js +33 -0
- package/create-nextia/templates/nextjs/src/app/home/functions.js +43 -0
- package/create-nextia/templates/nextjs/src/app/home/page.js +184 -0
- package/create-nextia/templates/nextjs/src/app/home/style.css +51 -0
- package/create-nextia/templates/nextjs/src/app/images/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/images/page.jsx +26 -0
- package/create-nextia/templates/nextjs/src/app/images/style.css +10 -0
- package/create-nextia/templates/nextjs/src/app/layout.js +109 -0
- package/create-nextia/templates/nextjs/src/app/media-query/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/media-query/page.js +33 -0
- package/create-nextia/templates/nextjs/src/app/media-query/style.css +38 -0
- package/create-nextia/templates/nextjs/src/app/mockapi/functions.js +71 -0
- package/create-nextia/templates/nextjs/src/app/mockapi/page.js +95 -0
- package/create-nextia/templates/nextjs/src/app/mockapi/style.css +57 -0
- package/create-nextia/templates/nextjs/src/app/my-context/functions.js +11 -0
- package/create-nextia/templates/nextjs/src/app/my-context/page.js +27 -0
- package/create-nextia/templates/nextjs/src/app/my-context/style.css +1 -0
- package/create-nextia/templates/nextjs/src/app/not-found.js +7 -0
- package/create-nextia/templates/nextjs/src/app/page.js +3 -0
- package/create-nextia/templates/nextjs/src/app/search-params/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/search-params/page.js +49 -0
- package/create-nextia/templates/nextjs/src/app/search-params/style.css +1 -0
- package/create-nextia/templates/nextjs/src/app/subpage/hello/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/subpage/hello/page.js +16 -0
- package/create-nextia/templates/nextjs/src/app/subpage/hello/style.css +1 -0
- package/create-nextia/templates/nextjs/src/app/translate/functions.js +4 -0
- package/create-nextia/templates/nextjs/src/app/translate/page.js +35 -0
- package/create-nextia/templates/nextjs/src/app/translate/style.css +1 -0
- package/create-nextia/templates/nextjs/src/assets/fonts/Roboto-Regular.ttf +0 -0
- package/create-nextia/templates/nextjs/src/assets/i18n/index.js +26 -0
- package/create-nextia/templates/nextjs/src/assets/icon/icons.svg +498 -0
- package/create-nextia/templates/nextjs/src/assets/img/image.jpg +0 -0
- package/create-nextia/templates/nextjs/src/assets/theme/animations.css +89 -0
- package/create-nextia/templates/nextjs/src/assets/theme/index.css +38 -0
- package/create-nextia/templates/nextjs/src/assets/theme/util.css +71 -0
- package/create-nextia/templates/nextjs/src/components/Counter/index.js +37 -0
- package/create-nextia/templates/nextjs/src/components/Counter/style.css +5 -0
- package/create-nextia/templates/nextjs/src/components/Icon/index.jsx +55 -0
- package/create-nextia/templates/nextjs/src/components/Link/index.jsx +10 -0
- package/create-nextia/templates/nextjs/src/components/Translation/index.jsx +12 -0
- package/create-nextia/templates/nextjs/src/components/Translation/style.css +1 -0
- package/create-nextia/templates/nextjs/src/components/index.js +6 -0
- package/create-nextia/templates/nextjs/src/containers/I18n/index.jsx +23 -0
- package/create-nextia/templates/nextjs/src/containers/Translate/index.jsx +30 -0
- package/create-nextia/templates/nextjs/src/containers/Translate/style.css +2 -0
- package/create-nextia/templates/nextjs/src/containers/index.js +7 -0
- package/create-nextia/templates/nextjs/src/services/api.js +10 -0
- package/create-nextia/templates/nextjs/src/services/http.js +135 -0
- package/create-nextia/templates/nextjs/src/utils/hooks.js +26 -0
- package/create-nextia/templates/nextjs/src/utils/index.js +21 -0
- package/create-nextia/templates/nextjs/vitest.config.js +38 -0
- package/create-nextia/templates/vitejs/README.md +33 -0
- package/create-nextia/templates/vitejs/_env.development +4 -0
- package/create-nextia/templates/vitejs/_env.production +2 -0
- package/create-nextia/templates/vitejs/_env.test +2 -0
- package/create-nextia/templates/vitejs/_gitignore +6 -0
- package/create-nextia/templates/vitejs/package.json +39 -0
- package/create-nextia/templates/vitejs/public/error.html +14 -0
- package/create-nextia/templates/vitejs/public/logo.svg +865 -0
- package/create-nextia/templates/vitejs/src/assets/fonts/Roboto-Regular.ttf +0 -0
- package/create-nextia/templates/vitejs/src/assets/i18n/index.js +26 -0
- package/create-nextia/templates/vitejs/src/assets/icon/icons.svg +498 -0
- package/create-nextia/templates/vitejs/src/assets/img/image.jpg +0 -0
- package/create-nextia/templates/vitejs/src/assets/theme/animations.css +89 -0
- package/create-nextia/templates/vitejs/src/assets/theme/index.css +38 -0
- package/create-nextia/templates/vitejs/src/assets/theme/util.css +71 -0
- package/create-nextia/templates/vitejs/src/components/Counter/index.jsx +38 -0
- package/create-nextia/templates/vitejs/src/components/Counter/style.css +5 -0
- package/create-nextia/templates/vitejs/src/components/Icon/index.jsx +51 -0
- package/create-nextia/templates/vitejs/src/components/Link/index.jsx +12 -0
- package/create-nextia/templates/vitejs/src/components/Translation/index.jsx +12 -0
- package/create-nextia/templates/vitejs/src/components/Translation/style.css +1 -0
- package/create-nextia/templates/vitejs/src/components/index.js +6 -0
- package/create-nextia/templates/vitejs/src/containers/I18n/index.jsx +23 -0
- package/create-nextia/templates/vitejs/src/containers/Translate/index.jsx +30 -0
- package/create-nextia/templates/vitejs/src/containers/Translate/style.css +2 -0
- package/create-nextia/templates/vitejs/src/containers/index.js +7 -0
- package/create-nextia/templates/vitejs/src/index.html +18 -0
- package/create-nextia/templates/vitejs/src/index.jsx +9 -0
- package/create-nextia/templates/vitejs/src/pages/counter/functions.js +6 -0
- package/create-nextia/templates/vitejs/src/pages/counter/index.jsx +39 -0
- package/create-nextia/templates/vitejs/src/pages/counter/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/env/functions.js +4 -0
- package/create-nextia/templates/vitejs/src/pages/env/index.jsx +28 -0
- package/create-nextia/templates/vitejs/src/pages/env/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/functions.js +27 -0
- package/create-nextia/templates/vitejs/src/pages/home/functions.js +43 -0
- package/create-nextia/templates/vitejs/src/pages/home/index.jsx +182 -0
- package/create-nextia/templates/vitejs/src/pages/home/style.css +51 -0
- package/create-nextia/templates/vitejs/src/pages/http/not-found/index.jsx +17 -0
- package/create-nextia/templates/vitejs/src/pages/http/not-found/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/images/functions.js +4 -0
- package/create-nextia/templates/vitejs/src/pages/images/index.jsx +23 -0
- package/create-nextia/templates/vitejs/src/pages/images/style.css +9 -0
- package/create-nextia/templates/vitejs/src/pages/index.jsx +104 -0
- package/create-nextia/templates/vitejs/src/pages/media-query/functions.js +4 -0
- package/create-nextia/templates/vitejs/src/pages/media-query/index.jsx +30 -0
- package/create-nextia/templates/vitejs/src/pages/media-query/style.css +38 -0
- package/create-nextia/templates/vitejs/src/pages/mockapi/functions.js +71 -0
- package/create-nextia/templates/vitejs/src/pages/mockapi/index.jsx +98 -0
- package/create-nextia/templates/vitejs/src/pages/mockapi/style.css +57 -0
- package/create-nextia/templates/vitejs/src/pages/my-context/functions.js +8 -0
- package/create-nextia/templates/vitejs/src/pages/my-context/index.jsx +27 -0
- package/create-nextia/templates/vitejs/src/pages/my-context/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/search-params/functions.js +4 -0
- package/create-nextia/templates/vitejs/src/pages/search-params/index.jsx +42 -0
- package/create-nextia/templates/vitejs/src/pages/search-params/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/subpage/hello/functions.js +3 -0
- package/create-nextia/templates/vitejs/src/pages/subpage/hello/index.jsx +14 -0
- package/create-nextia/templates/vitejs/src/pages/subpage/hello/style.css +1 -0
- package/create-nextia/templates/vitejs/src/pages/translate/functions.js +5 -0
- package/create-nextia/templates/vitejs/src/pages/translate/index.jsx +32 -0
- package/create-nextia/templates/vitejs/src/pages/translate/style.css +12 -0
- package/create-nextia/templates/vitejs/src/services/api.js +9 -0
- package/create-nextia/templates/vitejs/src/services/http.js +135 -0
- package/create-nextia/templates/vitejs/src/utils/hooks.js +44 -0
- package/create-nextia/templates/vitejs/src/utils/index.js +25 -0
- package/create-nextia/templates/vitejs/vite.config.js +100 -0
- package/package.json +3 -8
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fonts
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@font-face {
|
|
6
|
+
font-family: Roboto;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
font-display: swap;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
src: url('assets/fonts/Roboto-Regular.ttf');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Scrollbar
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
@media (pointer: fine) {
|
|
18
|
+
::-webkit-scrollbar {
|
|
19
|
+
width: 14px;
|
|
20
|
+
height: 14px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
::-webkit-scrollbar-thumb {
|
|
24
|
+
border-radius: 14px;
|
|
25
|
+
border: 3px solid transparent;
|
|
26
|
+
background-clip: content-box;
|
|
27
|
+
background-color: var(--primary-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
::-webkit-scrollbar-thumb:hover {
|
|
31
|
+
background-color: var(--primary-color-50);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
::-webkit-scrollbar,
|
|
35
|
+
::-webkit-scrollbar-track,
|
|
36
|
+
::-webkit-scrollbar-corner {
|
|
37
|
+
background-color: transparent;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Media query
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
:root {
|
|
46
|
+
--sm: false;
|
|
47
|
+
--md: false;
|
|
48
|
+
--lg: false;
|
|
49
|
+
--xl: false;
|
|
50
|
+
--xxl: false;
|
|
51
|
+
|
|
52
|
+
@media (640px <=width <768px) {
|
|
53
|
+
--sm: true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@media (768px <=width <1024px) {
|
|
57
|
+
--md: true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (1024px <=width <1280px) {
|
|
61
|
+
--lg: true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (1280px <=width < 1536px) {
|
|
65
|
+
--xl: true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (width >=1536px) {
|
|
69
|
+
--xxl: true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import './style.css'
|
|
3
|
+
import { css } from 'nextia'
|
|
4
|
+
import { startViewTransition } from 'utils'
|
|
5
|
+
|
|
6
|
+
export default function Counter ({
|
|
7
|
+
children,
|
|
8
|
+
name,
|
|
9
|
+
value,
|
|
10
|
+
type,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
readOnly,
|
|
14
|
+
disabled,
|
|
15
|
+
animation = 'count',
|
|
16
|
+
onChange
|
|
17
|
+
}) {
|
|
18
|
+
const ref = useRef()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<article
|
|
22
|
+
className={css('Counter-component', className)}
|
|
23
|
+
style={style}
|
|
24
|
+
name={name}
|
|
25
|
+
|
|
26
|
+
>
|
|
27
|
+
<button
|
|
28
|
+
onClick={e => {
|
|
29
|
+
startViewTransition(onChange(e), ref.current, animation)
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
Increment
|
|
33
|
+
</button>
|
|
34
|
+
|
|
35
|
+
<label ref={ref}>{value}</label>
|
|
36
|
+
</article>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
import icons from 'assets/icon/icons.svg?raw'
|
|
3
|
+
import { css } from 'nextia'
|
|
4
|
+
|
|
5
|
+
export default function Icon ({
|
|
6
|
+
value,
|
|
7
|
+
className,
|
|
8
|
+
style,
|
|
9
|
+
width = '48',
|
|
10
|
+
height,
|
|
11
|
+
viewBox = '0 0 48 48',
|
|
12
|
+
fill = 'none',
|
|
13
|
+
stroke = 'currentColor',
|
|
14
|
+
strokeWidth = '2',
|
|
15
|
+
strokeLinecap = 'round',
|
|
16
|
+
strokeLinejoin = 'round',
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const ref = useRef()
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const svg = new window.DOMParser().parseFromString(icons, 'image/svg+xml')
|
|
23
|
+
.documentElement.getElementById(value)
|
|
24
|
+
|
|
25
|
+
if (svg) {
|
|
26
|
+
if (svg.getAttribute('x-animation') === 'true') {
|
|
27
|
+
import(`assets/icon/${value}.css`).catch(() => {})
|
|
28
|
+
}
|
|
29
|
+
ref.current.innerHTML = svg.innerHTML
|
|
30
|
+
}
|
|
31
|
+
}, [value])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<svg
|
|
35
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
36
|
+
ref={ref}
|
|
37
|
+
id={value}
|
|
38
|
+
className={css('Icon-component', className)}
|
|
39
|
+
style={style}
|
|
40
|
+
width={width}
|
|
41
|
+
height={height}
|
|
42
|
+
viewBox={viewBox}
|
|
43
|
+
fill={fill}
|
|
44
|
+
stroke={stroke}
|
|
45
|
+
strokeWidth={strokeWidth}
|
|
46
|
+
strokeLinecap={strokeLinecap}
|
|
47
|
+
strokeLinejoin={strokeLinejoin}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export default function Link ({ children, href, value = {}, ...props }) {
|
|
4
|
+
href ??= window.location.hash.split('?')[0]
|
|
5
|
+
value = Object.keys(value).length ? '?' + new URLSearchParams(value).toString() : ''
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<a href={href + value} {...props}>
|
|
9
|
+
{children}
|
|
10
|
+
</a>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import './style.css'
|
|
3
|
+
import { css } from 'nextia'
|
|
4
|
+
import { I18n } from 'containers'
|
|
5
|
+
|
|
6
|
+
export default function Translation ({ children, name, value, type, className, style, readOnly, disabled, onClick = () => {} }) {
|
|
7
|
+
return (
|
|
8
|
+
<article className={css('Translation-component', className)} style={style} name={name}>
|
|
9
|
+
TranslationComponent-component : <span><I18n value='page.user.family' /></span>
|
|
10
|
+
</article>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Translation-component {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useFx } from 'nextia'
|
|
2
|
+
import i18nFile from 'assets/i18n'
|
|
3
|
+
|
|
4
|
+
export default function I18n ({ value, args = [] }) {
|
|
5
|
+
const { context } = useFx()
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
let text = value.split('.').reduce((ac, el) => ac[el], i18nFile)
|
|
9
|
+
text = text[i18nFile.locales.indexOf(context.state.i18n)]
|
|
10
|
+
|
|
11
|
+
if (args) {
|
|
12
|
+
text = text.replace(
|
|
13
|
+
/([{}])\\1|[{](.*?)(?:!(.+?))?[}]/g,
|
|
14
|
+
(match, literal, number) => args[number] || match
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return text
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error('Error in [il8n] => ' + value)
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useFx, css } from 'nextia'
|
|
3
|
+
import i18nFile from 'assets/i18n'
|
|
4
|
+
import './style.css'
|
|
5
|
+
|
|
6
|
+
export default function Translate ({ className, style }) {
|
|
7
|
+
const { context } = useFx()
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<article className={css('Translate-container', className, '')} style={style}>
|
|
11
|
+
|
|
12
|
+
<select
|
|
13
|
+
name='i18n'
|
|
14
|
+
value={context.state.i18n}
|
|
15
|
+
onChange={e => {
|
|
16
|
+
const { value } = e.target
|
|
17
|
+
context.fx.set({ i18n: value })
|
|
18
|
+
window.localStorage.setItem('i18n', value)
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
{i18nFile.locales.map(e => (
|
|
22
|
+
<option key={e} value={e} className='m-2'>
|
|
23
|
+
{e}
|
|
24
|
+
</option>
|
|
25
|
+
))}
|
|
26
|
+
</select>
|
|
27
|
+
|
|
28
|
+
</article>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<title>%VITE_TITLE%</title>
|
|
7
|
+
<link rel="shortcut icon" href="logo.svg" />
|
|
8
|
+
<meta name="version" content="%VERSION%" />
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
|
10
|
+
<link rel="stylesheet" href="assets/theme/index.css" />
|
|
11
|
+
<script type="module" src="index.jsx"></script>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { useFx, css } from 'nextia'
|
|
3
|
+
import functions from './functions'
|
|
4
|
+
import { Counter } from 'components'
|
|
5
|
+
import './style.css'
|
|
6
|
+
|
|
7
|
+
export default function CounterPage () {
|
|
8
|
+
const { state, fx } = useFx(functions)
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<section className={css('CounterPage', '', 'class-test', 'class-test', {}, null, true, false, [], { 'css-false': false }, undefined, { 'css-true': true }, { 'css-true': true })}>
|
|
12
|
+
|
|
13
|
+
Counters
|
|
14
|
+
|
|
15
|
+
<div className={css(null)} />
|
|
16
|
+
<div className={css(undefined)} />
|
|
17
|
+
<div className={css([])} />
|
|
18
|
+
<div className={css({})} />
|
|
19
|
+
<div className={css()} />
|
|
20
|
+
|
|
21
|
+
<Counter
|
|
22
|
+
value={state.count}
|
|
23
|
+
animation='count'
|
|
24
|
+
onChange={() => {
|
|
25
|
+
fx.set({ count: state.count + 1 })
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
<br />
|
|
29
|
+
<br />
|
|
30
|
+
<Counter
|
|
31
|
+
value={state.count2}
|
|
32
|
+
animation='count2'
|
|
33
|
+
onChange={() => {
|
|
34
|
+
fx.set({ count2: state.count2 + 10 })
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</section>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.CounterPage {}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { useFx, css } from 'nextia'
|
|
3
|
+
import functions from './functions'
|
|
4
|
+
import { env } from 'utils'
|
|
5
|
+
import './style.css'
|
|
6
|
+
|
|
7
|
+
export default function EnvPage () {
|
|
8
|
+
const { state, fx } = useFx(functions)
|
|
9
|
+
|
|
10
|
+
// env
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
console.log(env)
|
|
13
|
+
}, [])
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<section className={css('EnvPage', '')}>
|
|
17
|
+
|
|
18
|
+
<br />
|
|
19
|
+
<br />
|
|
20
|
+
|
|
21
|
+
<div style={{ display: 'flex' }}>
|
|
22
|
+
<pre style={{ margin: '0 50px 0 50px' }}>
|
|
23
|
+
env = {JSON.stringify(env, undefined, 2)}
|
|
24
|
+
</pre>
|
|
25
|
+
</div>
|
|
26
|
+
</section>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.EnvPage {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import i18nFile from 'assets/i18n'
|
|
2
|
+
|
|
3
|
+
const initialState = {
|
|
4
|
+
i18n: window.localStorage.getItem('i18n') || i18nFile.defaultLocale,
|
|
5
|
+
loading: false,
|
|
6
|
+
//
|
|
7
|
+
num: 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function increment ({ state, set }) {
|
|
11
|
+
set({ num: state.num + 1 })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function decrement ({ state, set }) {
|
|
15
|
+
set({ num: state.num - 1 })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function zero ({ payload, set }) {
|
|
19
|
+
set({ num: payload.value })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
initialState,
|
|
24
|
+
increment,
|
|
25
|
+
decrement,
|
|
26
|
+
zero
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const initialState = {
|
|
2
|
+
channel: 7,
|
|
3
|
+
msg: 'https://sinuhe.dev',
|
|
4
|
+
data: { user: 'Sinuhe MB' },
|
|
5
|
+
myArray: ['A', 'B', 'C'],
|
|
6
|
+
setNameValue: 'name value',
|
|
7
|
+
form: {
|
|
8
|
+
funny: false,
|
|
9
|
+
gender: 'M',
|
|
10
|
+
name: {
|
|
11
|
+
firstName: 'Sinuhe',
|
|
12
|
+
lastName: 'Maceda'
|
|
13
|
+
},
|
|
14
|
+
year: 33,
|
|
15
|
+
moreArray: [[[50, 40, 10]]]
|
|
16
|
+
},
|
|
17
|
+
ls: {
|
|
18
|
+
users: [
|
|
19
|
+
{
|
|
20
|
+
name: 'sinuhe',
|
|
21
|
+
year: 33
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'alberto',
|
|
25
|
+
year: 20
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function increment ({ state, set }) {
|
|
32
|
+
set({ channel: state.channel + 1 })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function decrement ({ state, set }) {
|
|
36
|
+
set({ channel: state.channel - 1 })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
initialState,
|
|
41
|
+
increment,
|
|
42
|
+
decrement
|
|
43
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import './style.css'
|
|
3
|
+
import { useFx, css } from 'nextia'
|
|
4
|
+
import functions from './functions'
|
|
5
|
+
import { sum } from 'utils'
|
|
6
|
+
|
|
7
|
+
export default function HomePage () {
|
|
8
|
+
const { state, initialState, fx, context } = useFx(functions)
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
console.info(sum(10, 10))
|
|
12
|
+
}, [])
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<section className={css('HomePage', 'container')}>
|
|
16
|
+
<div>
|
|
17
|
+
<div>
|
|
18
|
+
<p>set</p>
|
|
19
|
+
<button className='' onClick={() => fx.set({ setNameValue: 'set 1 level' })}>
|
|
20
|
+
set Value
|
|
21
|
+
</button>
|
|
22
|
+
<button
|
|
23
|
+
onClick={() =>
|
|
24
|
+
fx.set({
|
|
25
|
+
form: {
|
|
26
|
+
name: {
|
|
27
|
+
firstName: 'ppppppppppp',
|
|
28
|
+
lastName: '***********'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})}
|
|
32
|
+
>
|
|
33
|
+
set Json
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div>
|
|
38
|
+
<button onClick={() => fx.set({ 'form.name.lastName': 'BOUCHAN' })}>
|
|
39
|
+
set mulit level (Value)
|
|
40
|
+
</button>
|
|
41
|
+
|
|
42
|
+
<button
|
|
43
|
+
onClick={() =>
|
|
44
|
+
fx.set({
|
|
45
|
+
'form.name': { firstName: 'SINUHE', lastName: 'MACEDA' }
|
|
46
|
+
})}
|
|
47
|
+
>
|
|
48
|
+
set mulit level (Json)
|
|
49
|
+
</button>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div>
|
|
53
|
+
<p>Show and Hide :</p>
|
|
54
|
+
<button onClick={() => fx.show('form.funny')}>show</button>
|
|
55
|
+
<button onClick={() => fx.hide('form.funny')}>hide</button>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div>
|
|
59
|
+
<p>Reset :</p>
|
|
60
|
+
<button onClick={() => fx.reset('ls')}>Reset (ls)</button>
|
|
61
|
+
<button onClick={() => fx.reset('form.name')}>
|
|
62
|
+
Reset (form.name)
|
|
63
|
+
</button>
|
|
64
|
+
<button onClick={() => fx.reset(['channel', 'msg', 'form.name'])}>
|
|
65
|
+
Reset ([channel,msg,form.name])
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div>
|
|
70
|
+
<p>Simple actions/Reducer:</p>
|
|
71
|
+
<button onClick={e => fx.increment(e)}>+</button>
|
|
72
|
+
<button onClick={e => fx.decrement(e)}>-</button>
|
|
73
|
+
|
|
74
|
+
<button
|
|
75
|
+
onClick={() =>
|
|
76
|
+
fx.set({
|
|
77
|
+
channel: 256,
|
|
78
|
+
msg: 256,
|
|
79
|
+
data: { user: 256 },
|
|
80
|
+
myArray: ['256', '256', '256'],
|
|
81
|
+
setNameValue: '256',
|
|
82
|
+
form: {
|
|
83
|
+
// funny: 256,
|
|
84
|
+
// gender: '256',
|
|
85
|
+
name: {
|
|
86
|
+
firstName: '256',
|
|
87
|
+
lastName: '256'
|
|
88
|
+
},
|
|
89
|
+
year: 256,
|
|
90
|
+
moreArray: [[[256, 256, 256]]]
|
|
91
|
+
},
|
|
92
|
+
ls: {
|
|
93
|
+
users: [
|
|
94
|
+
{
|
|
95
|
+
name: '256',
|
|
96
|
+
year: 256
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: '256',
|
|
100
|
+
year: 256
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
})}
|
|
105
|
+
>
|
|
106
|
+
256
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div>
|
|
111
|
+
<p>onChange:</p>
|
|
112
|
+
|
|
113
|
+
{/* input text */}
|
|
114
|
+
<input
|
|
115
|
+
type='text'
|
|
116
|
+
name='form.name.firstName'
|
|
117
|
+
value={state.form.name.firstName}
|
|
118
|
+
onChange={evt => fx.change(evt)}
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
{/* checkbox */}
|
|
122
|
+
<input
|
|
123
|
+
type='checkbox'
|
|
124
|
+
name='form.funny'
|
|
125
|
+
checked={state.form.funny}
|
|
126
|
+
onChange={evt => fx.change(evt)}
|
|
127
|
+
/>
|
|
128
|
+
<label htmlFor='form.funny'>Funny</label>
|
|
129
|
+
|
|
130
|
+
{/* radio */}
|
|
131
|
+
<input
|
|
132
|
+
type='radio'
|
|
133
|
+
name='form.gender'
|
|
134
|
+
value='M'
|
|
135
|
+
checked={state.form.gender === 'M'}
|
|
136
|
+
onChange={evt => fx.change(evt)}
|
|
137
|
+
/>
|
|
138
|
+
<label htmlFor='M'>M</label>
|
|
139
|
+
<input
|
|
140
|
+
type='radio'
|
|
141
|
+
name='form.gender'
|
|
142
|
+
value='F'
|
|
143
|
+
checked={state.form.gender === 'F'}
|
|
144
|
+
onChange={evt => fx.change(evt)}
|
|
145
|
+
/>
|
|
146
|
+
<label htmlFor='F'>F</label>
|
|
147
|
+
|
|
148
|
+
{/* select */}
|
|
149
|
+
<select name='form.year' onChange={evt => fx.change(evt)}>
|
|
150
|
+
<option value='20'>20</option>
|
|
151
|
+
<option value='21'>21</option>
|
|
152
|
+
<option value='22'>22</option>
|
|
153
|
+
<option value='33'>33</option>
|
|
154
|
+
</select>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div>
|
|
159
|
+
<div style={{ textAlign: 'center' }}>
|
|
160
|
+
<button onClick={() => fx.reset()}>RESET</button>
|
|
161
|
+
<button
|
|
162
|
+
onClick={() => {
|
|
163
|
+
if (context.state.loading) context.fx.hide('loading')
|
|
164
|
+
else context.fx.show('loading')
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
loading
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div style={{ display: 'flex' }}>
|
|
172
|
+
<pre style={{ margin: '0 50px 0 50px' }}>
|
|
173
|
+
state = {JSON.stringify(state, undefined, 2)}
|
|
174
|
+
</pre>
|
|
175
|
+
<pre style={{ margin: '0 50px 0 50px' }}>
|
|
176
|
+
initialState = {JSON.stringify(initialState, undefined, 2)}
|
|
177
|
+
</pre>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</section>
|
|
181
|
+
)
|
|
182
|
+
}
|