@zuzjs/ui 0.3.2 → 0.3.4

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.
Files changed (88) hide show
  1. package/README.md +0 -0
  2. package/dist/hooks.js +89 -0
  3. package/dist/styles.css +37 -62
  4. package/dist/ui.js +665 -0
  5. package/jest.config.js +0 -0
  6. package/package.json +16 -18
  7. package/rollup.config.js +30 -47
  8. package/src/comps/box.tsx +24 -28
  9. package/src/comps/button.tsx +23 -47
  10. package/src/comps/crumb.tsx +9 -0
  11. package/src/comps/form.tsx +57 -88
  12. package/src/comps/heading.tsx +25 -31
  13. package/src/comps/icon.tsx +24 -36
  14. package/src/comps/input.tsx +24 -224
  15. package/src/comps/select.tsx +23 -63
  16. package/src/comps/spinner.tsx +23 -35
  17. package/src/comps/stylesheet.tsx +5 -0
  18. package/src/context/AppContext.tsx +2 -2
  19. package/src/context/AppProvider.tsx +68 -105
  20. package/src/context/createSlice.tsx +15 -39
  21. package/src/context/index.tsx +4 -5
  22. package/src/core/css.ts +1 -0
  23. package/src/core/index.tsx +241 -0
  24. package/src/core/styles.ts +378 -371
  25. package/src/hooks/index.tsx +2 -10
  26. package/src/hooks/useDispatch.tsx +36 -36
  27. package/src/hooks/useStore.tsx +24 -26
  28. package/src/hooks.tsx +8 -0
  29. package/src/scss/mixins.scss +2 -2
  30. package/src/scss/props.scss +91 -69
  31. package/src/scss/{style.scss → styles.scss} +102 -132
  32. package/src/ui.tsx +13 -0
  33. package/tsconfig.json +0 -0
  34. package/tsconfig.lib.json +0 -0
  35. package/tsconfig.spec.json +0 -0
  36. package/dist/index.js +0 -1868
  37. package/src/actions/addForm.tsx +0 -0
  38. package/src/actions/index.tsx +0 -29
  39. package/src/actions/redo.tsx +0 -1
  40. package/src/actions/reset.tsx +0 -1
  41. package/src/actions/undo.tsx +0 -1
  42. package/src/comps/app.tsx +0 -34
  43. package/src/comps/checkbox.tsx +0 -74
  44. package/src/comps/component.tsx +0 -32
  45. package/src/comps/contextmenu.tsx +0 -60
  46. package/src/comps/cover.tsx +0 -34
  47. package/src/comps/image.tsx +0 -34
  48. package/src/comps/masonry.tsx +0 -192
  49. package/src/comps/mediaplayer.tsx +0 -12
  50. package/src/comps/placeholder.tsx +0 -58
  51. package/src/comps/root.tsx +0 -32
  52. package/src/comps/spacer.tsx +0 -20
  53. package/src/comps/text.tsx +0 -27
  54. package/src/comps/toaster.tsx +0 -117
  55. package/src/comps/tweet.tsx +0 -48
  56. package/src/context/_AppProvider.tsx +0 -116
  57. package/src/context/combineReducers.tsx +0 -47
  58. package/src/context/combineState.tsx +0 -14
  59. package/src/context/reduceReducers.tsx +0 -6
  60. package/src/context/store/appbase.tsx +0 -19
  61. package/src/context/store/lang.tsx +0 -26
  62. package/src/context/store/theme.tsx +0 -54
  63. package/src/core/defaultTheme.ts +0 -90
  64. package/src/core/extractCurrentDesignState.tsx +0 -0
  65. package/src/core/index.ts +0 -431
  66. package/src/core/router.ts +0 -86
  67. package/src/hooks/useAppReducer.tsx +0 -40
  68. package/src/hooks/useChooseEffect.tsx +0 -6
  69. package/src/hooks/useContextMenu.tsx +0 -123
  70. package/src/hooks/useDevice.tsx +0 -164
  71. package/src/hooks/useImage.tsx +0 -84
  72. package/src/hooks/useLang.tsx +0 -9
  73. package/src/hooks/useMediaPlayer.tsx +0 -27
  74. package/src/hooks/useNavigator.tsx +0 -6
  75. package/src/hooks/useRender.tsx +0 -29
  76. package/src/hooks/useResizeObserver.tsx +0 -84
  77. package/src/hooks/useRouter.tsx +0 -45
  78. package/src/hooks/useSelector.tsx +0 -9
  79. package/src/hooks/useTheme.tsx +0 -9
  80. package/src/hooks/useToast.tsx +0 -11
  81. package/src/index.tsx +0 -35
  82. package/src/kit/Builder.tsx +0 -18
  83. package/src/kit/Component.tsx +0 -32
  84. package/src/kit/Header.tsx +0 -21
  85. package/src/redux/slices/app.js +0 -26
  86. package/src/redux/slices/form.js +0 -46
  87. package/src/redux/store.js +0 -33
  88. package/src/scss/constants.scss +0 -4
File without changes
@@ -1,29 +0,0 @@
1
- import { UNDO } from './undo'
2
- import { REDO } from './redo'
3
- import { RESET } from './reset'
4
-
5
- export const ADD_FORM = (name, fields, forms) => ({
6
- forms: {
7
- ...forms,
8
- [name] : { touched: false, loading: false, ...fields }
9
- }
10
- })
11
-
12
- export const UPDATE_FORM_FIELD = (formName, field, value, forms) => {
13
- if(forms[formName]){
14
- let _forms = {
15
- ...forms
16
- }
17
- _forms[formName][field] = value;
18
- return {
19
- forms: _forms
20
- }
21
- }
22
- return {}
23
- }
24
-
25
- export {
26
- UNDO,
27
- REDO,
28
- RESET
29
- }
@@ -1 +0,0 @@
1
- export const REDO = 'REDO';
@@ -1 +0,0 @@
1
- export const RESET = 'RESET';
@@ -1 +0,0 @@
1
- export const UNDO = 'UNDO';
package/src/comps/app.tsx DELETED
@@ -1,34 +0,0 @@
1
- import {
2
- forwardRef,
3
- useEffect
4
- } from 'react';
5
- import { setCSSVar, buildCSS } from '../core'
6
- import { Provider } from '../context'
7
- import { ClassNames } from '@emotion/react'
8
- import { useStore } from '../hooks'
9
-
10
- const AppMain = forwardRef((props : { [ key: string ] : any }, ref) => {
11
-
12
- // const { dispatch } = useStore()
13
-
14
- // if("theme" in props && !theme){
15
- // dispatch(setTheme(props.theme));
16
- // }
17
-
18
- return (
19
- <ClassNames>
20
- {({ css, cx }) => <main className={`${props.as ? props.as : `zuz-app`} ${cx(css`${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`}>{props.children}</main>}
21
- </ClassNames>
22
- )
23
- })
24
-
25
- const App = forwardRef((props : { [ key: string ] : any }, ref) => {
26
-
27
- return (
28
- <Provider>
29
- <AppMain />
30
- </Provider>
31
- )
32
- })
33
-
34
- export default App
@@ -1,74 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
- import PropTypes from 'prop-types'
3
- import { nanoid } from 'nanoid'
4
- import Box from './box'
5
- import Button from './button'
6
- import useTheme from '../hooks/useTheme'
7
- import useDispatch from '../hooks/useDispatch'
8
- import useStore from '../hooks/useStore'
9
- import { STORE_FORM_KEY } from '../context/AppProvider'
10
- import {
11
- UPDATE_FORM_FIELD
12
- } from '../actions'
13
- import { ClassNames } from '@emotion/react'
14
-
15
- function Checkbox(props) {
16
-
17
- const {
18
- checked,
19
- as,
20
- name,
21
- form,
22
- touched,
23
- onChange
24
- } = props;
25
-
26
- const [_checked, setChecked] = useState(checked || false)
27
- const theme = useTheme();
28
-
29
- const dispatch = useDispatch(STORE_FORM_KEY)
30
- const { forms } = useStore(state => state[STORE_FORM_KEY], false)
31
-
32
- const switchCheck = useCallback(() => {
33
- let nextVal = !_checked;
34
- onChange && onChange(nextVal)
35
- setChecked(nextVal)
36
- dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, nextVal, forms ) ) );
37
- }, [_checked])
38
-
39
- const defaultCSS = `cursor: pointer;&:before {
40
- background: ${!_checked ? `transparent` : theme.color} !important;
41
- }`
42
-
43
- const _name = useMemo(() => name || nanoid(), [name])
44
-
45
- return (
46
- <ClassNames>
47
- {({ css, cx }) => <>
48
- <input
49
- onChange={switchCheck}
50
- id={`zuz${_name}`}
51
- // className={`${_checked ? 'y' : 'n'} ${as ? ` ${as} ` : ``}f ${cx(css`opacity: 0;position: absolute;&:checked {${defaultCSSChecked}}`)}`}
52
- className={`zuz-checkbox`}
53
- name={_name}
54
- type={`checkbox`}
55
- value={`checked`}
56
- />
57
- <label
58
- className={`${as ? `${as} ` : ``}f ${cx(css`${defaultCSS}`)}`}
59
- htmlFor={`zuz${_name}`} />
60
- </>}
61
- </ClassNames>
62
- // <Button
63
- // overflow={`hidden`}
64
- // name={name || nanoid()}
65
- // onClick={switchCheck}
66
- // w={38} h={22} r={20} bg={`#ddd`} rel>
67
- // <Box w={38} h={22} anim={`0.2`} abs top={0} r={20} left={0} transform={`translateX(${_checked ? 0 : -16}px)`} bg={theme.color}>
68
- // <Box w={18} h={18} abs right={2} top={2} bg={`#fff`} r={20} boxShadow={`0px 0px 0px 5px ${_checked ? theme.color : `#ddd`}`} />
69
- // </Box>
70
- // </Button>
71
- );
72
- }
73
-
74
- export default Checkbox;
@@ -1,32 +0,0 @@
1
- import React, {
2
- forwardRef
3
- } from 'react';
4
- import styled from '@emotion/styled'
5
- import { css } from '@emotion/react'
6
- import {
7
- buildCSS,
8
- filterHTMLProps
9
- } from '../core'
10
-
11
- // const CoreBlock = styled.section`display: block;`
12
- // const buildComponent = (props: any) => Block.withComponent(props.for || `div`)`${buildCSS(props)}`
13
-
14
- const Component = forwardRef((props: any, ref: any) => {
15
-
16
- const Tag = props.for;
17
- const Block = (
18
- typeof props.for == 'string' ?
19
- styled[props.for || `div`] : Tag
20
- )`${buildCSS(props)}`;
21
- // const Block = styled.`${buildCSS(props)}`;
22
- // const Block = CoreBlock.withComponent(props.for)`background: red`
23
- // console.log(props)
24
- // console.log(Styles)
25
-
26
-
27
- // return <button>{props.children}</button>
28
- return <Block className={props.as || ``} {...filterHTMLProps(props)} />
29
-
30
- })
31
-
32
- export default Component;
@@ -1,60 +0,0 @@
1
- import {
2
- FC,
3
- LegacyRef,
4
- forwardRef,
5
- useRef,
6
- useState,
7
- useEffect,
8
- } from 'react';
9
- import Box from './box'
10
- import Button from './button'
11
-
12
- const ContextMenu = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
13
-
14
- const { ID, p, items, hide } = props;
15
- // const [p, setP] = useState(p)
16
- const nodeRef = useRef(null);
17
-
18
- const checkBoundaries = () => {
19
-
20
- let x = p.x
21
- let y = p.y
22
-
23
- if (nodeRef.current) {
24
- const { innerWidth, innerHeight } = window;
25
- const { offsetWidth, offsetHeight } = nodeRef.current;
26
-
27
- if (x + offsetWidth > innerWidth) x -= x + offsetWidth - innerWidth;
28
-
29
- if (y + offsetHeight > innerHeight) y -= y + offsetHeight - innerHeight;
30
- }
31
- // setP({x: x, y: y})
32
- }
33
-
34
- useEffect(() => {
35
- // checkBoundaries();
36
- }, [])
37
-
38
- return (
39
- <Box
40
- bref={nodeRef}
41
- flex dir={`cols`}
42
- fixed
43
- top={p.x}
44
- left={p.y}
45
- as={`zuz-contextmenu ${ID}`}>
46
- {items && items.map((m, i) => m.id == `line` ? <Box as={`line`} key={`line-${i}-${m.id}`} /> : <button
47
- key={`cm-${i}-${m.id}`}
48
- onClick={ev => {
49
- if(m.onClick){
50
- m.onClick(ev, m)
51
- }else{
52
- console.log(`No onClick eventFound`)
53
- }
54
- hide()
55
- }}>{m.label}</button>)}
56
- </Box>
57
- )
58
- })
59
-
60
- export default ContextMenu;
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import Box from './box'
3
- import Spinner from './spinner'
4
- import Heading from './heading'
5
- import PropTypes from 'prop-types'
6
-
7
- const Cover = (props) => {
8
-
9
- return (
10
- <Box key={`cover-cloud`} abs fill
11
- bgFilter={props.backdrop ? `saturate(${props.backdrop.saturate}%) blur(${props.backdrop.blur}px)` : undefined}
12
- zIndex={`2`}
13
- bg={props.bg}>
14
- <Box key={`cover-shadow`} abs abc aic jcc flex dir={`cols`} gap={20}>
15
- <Spinner key={`cover-spinner`} />
16
- {props.label && <Heading key={`cover-label`} size={16} as={`f`} opacity={0.7}>{props.label}</Heading>}
17
- </Box>
18
- </Box>
19
- );
20
- }
21
-
22
- Cover.defaultProps = {
23
- bg: `rgba(0,0,0,0.5)`,
24
- backdrop: { saturate: 80, blur: 10 },
25
- label: null
26
- }
27
-
28
- Cover.propTypes = {
29
- bg: PropTypes.string,
30
- backdrop: PropTypes.object,
31
- label: PropTypes.string,
32
- }
33
-
34
- export default Cover;
@@ -1,34 +0,0 @@
1
- import {
2
- forwardRef,
3
- LegacyRef
4
- } from 'react'
5
- import { ClassNames } from '@emotion/react'
6
- import { buildCSS } from '../core'
7
- import useImage from '../hooks/useImage'
8
- import Box from './box'
9
-
10
- const Image = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLImageElement>) => {
11
-
12
- const { src, isLoading, error } = useImage({ srcList: props.src, useSuspense: false });
13
-
14
- return (
15
- <ClassNames>
16
- {({ css, cx }) => <>
17
- {isLoading && <Box className={`${props.as ? `${props.as} ` : ``}${cx(css`background: #eee;${buildCSS(props)}`)}`} />}
18
- {!isLoading && <img src={src}
19
- className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
20
- ref={ref} />}
21
- </>}
22
- </ClassNames>
23
- // <ClassNames>
24
- // {({ css, cx }) => <picture className={cx(css`${buildCSS({ flex: true })}`)}>
25
- // {status == 'loading' && <Box className={`${props.as ? `${props.as} ` : ``}${cx(css`background: #eee;${buildCSS(props)}`)}`} />}
26
- // {status == 'loaded' && <img src={props.src}
27
- // className={`${props.as ? `${props.as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
28
- // ref={ref} />}
29
- // </picture>}
30
- // </ClassNames>
31
- )
32
- })
33
-
34
- export default Image;
@@ -1,192 +0,0 @@
1
- import { Component, Children } from "react"
2
- import PropTypes from 'prop-types'
3
-
4
- const DEFAULT_COLUMNS = 2;
5
-
6
- class Masonry extends Component<any, any> {
7
-
8
- constructor(props : { [ key: string ] : any }) {
9
- super(props);
10
- // Correct scope for when methods are accessed externally
11
- this.reCalculateColumnCount = this.reCalculateColumnCount.bind(this);
12
- this.reCalculateColumnCountDebounce = this.reCalculateColumnCountDebounce.bind(this);
13
- // default state
14
- let columnCount
15
- if (this.props && this.props.breakpointCols.default) {
16
- columnCount = this.props.breakpointCols.default
17
- } else {
18
- columnCount = parseInt(this.props.breakpointCols) || DEFAULT_COLUMNS
19
- }
20
- this.state = {
21
- columnCount
22
- };
23
- }
24
-
25
- componentDidMount() {
26
- this.reCalculateColumnCount();
27
- // window may not be available in some environments
28
- if(window) {
29
- window.addEventListener('resize', this.reCalculateColumnCountDebounce);
30
- }
31
- }
32
-
33
- componentDidUpdate() {
34
- this.reCalculateColumnCount();
35
- }
36
-
37
- componentWillUnmount() {
38
- if(window) {
39
- window.removeEventListener('resize', this.reCalculateColumnCountDebounce);
40
- }
41
- }
42
-
43
- reCalculateColumnCountDebounce() {
44
- if(!window || !window.requestAnimationFrame) { // IE10+
45
- this.reCalculateColumnCount();
46
- return;
47
- }
48
-
49
- if(window.cancelAnimationFrame) { // IE10+
50
- window.cancelAnimationFrame(this._lastRecalculateAnimationFrame);
51
- }
52
-
53
- }
54
-
55
- _lastRecalculateAnimationFrame = window.requestAnimationFrame(() => {
56
- this.reCalculateColumnCount();
57
- });
58
-
59
- reCalculateColumnCount() {
60
- const windowWidth = window && window.innerWidth || Infinity;
61
- let breakpointColsObject = this.props.breakpointCols;
62
-
63
- // Allow passing a single number to `breakpointCols` instead of an object
64
- if(typeof breakpointColsObject !== 'object') {
65
- breakpointColsObject = {
66
- default: parseInt(breakpointColsObject) || DEFAULT_COLUMNS
67
- }
68
- }
69
-
70
- let matchedBreakpoint = Infinity;
71
- let columns = breakpointColsObject.default || DEFAULT_COLUMNS;
72
-
73
- for(let breakpoint in breakpointColsObject) {
74
- const optBreakpoint = parseInt(breakpoint);
75
- const isCurrentBreakpoint = optBreakpoint > 0 && windowWidth <= optBreakpoint;
76
-
77
- if(isCurrentBreakpoint && optBreakpoint < matchedBreakpoint) {
78
- matchedBreakpoint = optBreakpoint;
79
- columns = breakpointColsObject[breakpoint];
80
- }
81
- }
82
-
83
- columns = Math.max(1, parseInt(columns) || 1);
84
-
85
- if(this.state.columnCount !== columns) {
86
- this.setState({
87
- columnCount: columns
88
- });
89
- this.props.onChange && this.props.onChange({ columns: columns });
90
- }
91
- }
92
-
93
- itemsInColumns() {
94
- const currentColumnCount = this.state.columnCount;
95
- const itemsInColumns = new Array(currentColumnCount);
96
-
97
- // Force children to be handled as an array
98
- const items = Children.toArray(this.props.children)
99
-
100
- for (let i = 0; i < items.length; i++) {
101
- const columnIndex = i % currentColumnCount;
102
-
103
- if(!itemsInColumns[columnIndex]) {
104
- itemsInColumns[columnIndex] = [];
105
- }
106
-
107
- itemsInColumns[columnIndex].push(items[i]);
108
- }
109
-
110
- return itemsInColumns;
111
- }
112
-
113
- renderColumns() {
114
- const { column, columnAttrs = {}, columnClassName } = this.props;
115
- const childrenInColumns = this.itemsInColumns();
116
- const columnWidth = `${100 / childrenInColumns.length}%`;
117
- let className = columnClassName;
118
-
119
- if(className && typeof className !== 'string') {
120
- this.logDeprecated('The property "columnClassName" requires a string');
121
-
122
- // This is a deprecated default and will be removed soon.
123
- if(typeof className === 'undefined') {
124
- className = 'my-masonry-grid_column';
125
- }
126
- }
127
-
128
- const columnAttributes = {
129
- // NOTE: the column property is undocumented and considered deprecated.
130
- // It is an alias of the `columnAttrs` property
131
- ...column,
132
- ...columnAttrs,
133
- style: {
134
- ...columnAttrs.style,
135
- width: columnWidth
136
- },
137
- className
138
- };
139
-
140
- return childrenInColumns.map((items, i) => {
141
- return <div
142
- {...columnAttributes}
143
-
144
- key={i}
145
- >
146
- {items}
147
- </div>;
148
- });
149
- }
150
-
151
- logDeprecated(message) {
152
- console.error('[Masonry]', message);
153
- }
154
-
155
- render() {
156
- const {
157
- // ignored
158
- children,
159
- breakpointCols,
160
- columnClassName,
161
- columnAttrs,
162
- column,
163
-
164
- // used
165
- className,
166
-
167
- ...rest
168
- } = this.props;
169
-
170
- let classNameOutput = className;
171
-
172
- if(typeof className !== 'string') {
173
- this.logDeprecated('The property "className" requires a string');
174
-
175
- // This is a deprecated default and will be removed soon.
176
- if(typeof className === 'undefined') {
177
- classNameOutput = 'my-masonry-grid';
178
- }
179
- }
180
-
181
- return (
182
- <div
183
- {...rest}
184
- className={classNameOutput}
185
- >
186
- {this.renderColumns()}
187
- </div>
188
- );
189
- }
190
- }
191
-
192
- export default Masonry;
@@ -1,12 +0,0 @@
1
- import {
2
- forwardRef,
3
- LegacyRef
4
- } from 'react'
5
- import { ClassNames } from '@emotion/react'
6
- import { buildCSS } from '../core'
7
-
8
- const MediaPlayer = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLImageElement>) => {
9
-
10
- })
11
-
12
- export default MediaPlayer;
@@ -1,58 +0,0 @@
1
- import {
2
- forwardRef
3
- } from 'react';
4
- import PropTypes from 'prop-types'
5
- import Box from './box'
6
-
7
- export interface PlaceholderProps {
8
- width: number|string,
9
- height: number|string,
10
- duration?: number,
11
- bg?: string,
12
- bgFrom?: string,
13
- bgTo?: string
14
- }
15
-
16
- const calcPlaceholderStyle = (
17
- width: number|string,
18
- height: number|string,
19
- duration = 1600
20
- ) => ({
21
- backgroundSize: `${parseInt(width.toString()) * 10}px ${height}px`,
22
- animationDuration: `${(duration / 1000).toFixed(1)}s`,
23
- });
24
-
25
- const Placeholder = forwardRef(({
26
- width,
27
- height,
28
- duration,
29
- bg,
30
- bgFrom,
31
- bgTo
32
- } : PlaceholderProps, ref) => {
33
-
34
- const placeholderStyle = calcPlaceholderStyle(width, height, duration);
35
-
36
- return (
37
- <Box
38
- as={`shimmer`}
39
- w={width}
40
- h={height}
41
- bg={bg || `#f6f7f8`}
42
- backgroundImage={`linear-gradient(to right, ${bgFrom || `rgb(238, 238, 238)`} 8%, ${bgTo || `rgb(203, 203, 203)`} 18%, ${bgFrom || `rgb(238, 238, 238)`} 33%);`}
43
- backgroundSize={placeholderStyle.backgroundSize}
44
- animationDuration={placeholderStyle.animationDuration}
45
- />
46
- )
47
- })
48
-
49
- Placeholder.propTypes = {
50
- width: PropTypes.oneOfType([ PropTypes.number, PropTypes.string ]).isRequired,
51
- height: PropTypes.oneOfType([ PropTypes.number, PropTypes.string ]).isRequired,
52
- duration: PropTypes.number,
53
- bg: PropTypes.string,
54
- bgFrom: PropTypes.string,
55
- bgTo: PropTypes.string
56
- }
57
-
58
- export default Placeholder;
@@ -1,32 +0,0 @@
1
- import {
2
- forwardRef,
3
- useEffect
4
- } from 'react';
5
- import {
6
- Provider
7
- } from 'react-redux'
8
- import appstore from '../redux/store'
9
- import { setCSSVar, buildCSS } from '../core'
10
- import { ClassNames } from '@emotion/react'
11
-
12
- const AppRoot = forwardRef((props : { [ key: string ] : any }, ref) => {
13
-
14
- if("reducers" in props){
15
- props.reducers.map(r => appstore['injectReducer'](r.id, r.reducer));
16
- }
17
-
18
- useEffect(() => {
19
- if('primaryColor' in props) setCSSVar('primary-color', props.primaryColor);
20
- if('primaryFont' in props) setCSSVar('primary-font', props.primaryFont);
21
- }, [])
22
-
23
- return (
24
- <Provider store={appstore}>
25
- <ClassNames>
26
- {({ css, cx }) => <main className={`${props.as ? props.as : `zuz-app`} ${cx(css`${buildCSS(props)} &:hover {${buildCSS(props.hover || {})}} &:active {${buildCSS(props.active || {})}}`)}`}>{props.children}</main>}
27
- </ClassNames>
28
- </Provider>
29
- )
30
- })
31
-
32
- export default AppRoot;
@@ -1,20 +0,0 @@
1
- import {
2
- FC,
3
- forwardRef
4
- } from 'react';
5
- import Box from './box'
6
-
7
- interface Props {
8
- w?: string|number,
9
- h?: string|number
10
- }
11
-
12
- const Spacer : FC<Props> = ({
13
- w, h
14
- }) => {
15
- return (
16
- <Box as={`spacer`} w={w || 0} h={h || 0} />
17
- )
18
- }
19
-
20
- export default Spacer;
@@ -1,27 +0,0 @@
1
- import {
2
- FC,
3
- LegacyRef,
4
- forwardRef,
5
- HTMLAttributes
6
- } from 'react';
7
- import { ClassNames } from '@emotion/react'
8
- import { buildCSS } from '../core'
9
-
10
- const Text = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLParagraphElement>) => {
11
-
12
- const {
13
- children,
14
- as
15
- } = props;
16
-
17
- return (
18
- <ClassNames>
19
- {({ css, cx }) => <p
20
- className={`${as ? `${as} ` : ``}${cx(css`${buildCSS(props)}`)}`}
21
- ref={ref}
22
- >{props.html ? <span dangerouslySetInnerHTML={{ __html: props.html }} /> : children}</p>}
23
- </ClassNames>
24
- )
25
- })
26
-
27
- export default Text;