@zuzjs/ui 0.3.3 → 0.3.5

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 (78) 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 +679 -0
  5. package/jest.config.js +0 -0
  6. package/package.json +17 -18
  7. package/rollup.config.js +30 -47
  8. package/tsconfig.json +0 -0
  9. package/tsconfig.lib.json +0 -0
  10. package/tsconfig.spec.json +0 -0
  11. package/dist/index.js +0 -1879
  12. package/src/actions/addForm.tsx +0 -0
  13. package/src/actions/index.tsx +0 -29
  14. package/src/actions/redo.tsx +0 -1
  15. package/src/actions/reset.tsx +0 -1
  16. package/src/actions/undo.tsx +0 -1
  17. package/src/comps/app.tsx +0 -34
  18. package/src/comps/box.tsx +0 -28
  19. package/src/comps/button.tsx +0 -47
  20. package/src/comps/checkbox.tsx +0 -74
  21. package/src/comps/component.tsx +0 -32
  22. package/src/comps/contextmenu.tsx +0 -60
  23. package/src/comps/cover.tsx +0 -34
  24. package/src/comps/form.tsx +0 -89
  25. package/src/comps/heading.tsx +0 -31
  26. package/src/comps/icon.tsx +0 -36
  27. package/src/comps/image.tsx +0 -34
  28. package/src/comps/input.tsx +0 -224
  29. package/src/comps/masonry.tsx +0 -192
  30. package/src/comps/mediaplayer.tsx +0 -12
  31. package/src/comps/placeholder.tsx +0 -58
  32. package/src/comps/root.tsx +0 -32
  33. package/src/comps/select.tsx +0 -63
  34. package/src/comps/spacer.tsx +0 -20
  35. package/src/comps/spinner.tsx +0 -36
  36. package/src/comps/text.tsx +0 -27
  37. package/src/comps/toaster.tsx +0 -123
  38. package/src/comps/tweet.tsx +0 -48
  39. package/src/context/AppContext.tsx +0 -3
  40. package/src/context/AppProvider.tsx +0 -106
  41. package/src/context/_AppProvider.tsx +0 -116
  42. package/src/context/combineReducers.tsx +0 -47
  43. package/src/context/combineState.tsx +0 -14
  44. package/src/context/createSlice.tsx +0 -40
  45. package/src/context/index.tsx +0 -6
  46. package/src/context/reduceReducers.tsx +0 -6
  47. package/src/context/store/appbase.tsx +0 -19
  48. package/src/context/store/lang.tsx +0 -26
  49. package/src/context/store/theme.tsx +0 -54
  50. package/src/core/extractCurrentDesignState.tsx +0 -0
  51. package/src/core/index.ts +0 -431
  52. package/src/core/router.ts +0 -86
  53. package/src/core/styles.ts +0 -372
  54. package/src/hooks/index.tsx +0 -10
  55. package/src/hooks/useAppReducer.tsx +0 -40
  56. package/src/hooks/useChooseEffect.tsx +0 -6
  57. package/src/hooks/useContextMenu.tsx +0 -123
  58. package/src/hooks/useDevice.tsx +0 -168
  59. package/src/hooks/useDispatch.tsx +0 -37
  60. package/src/hooks/useImage.tsx +0 -84
  61. package/src/hooks/useLang.tsx +0 -9
  62. package/src/hooks/useMediaPlayer.tsx +0 -27
  63. package/src/hooks/useNavigator.tsx +0 -6
  64. package/src/hooks/useRender.tsx +0 -29
  65. package/src/hooks/useResizeObserver.tsx +0 -84
  66. package/src/hooks/useRouter.tsx +0 -45
  67. package/src/hooks/useSelector.tsx +0 -9
  68. package/src/hooks/useStore.tsx +0 -27
  69. package/src/hooks/useTheme.tsx +0 -9
  70. package/src/hooks/useToast.tsx +0 -11
  71. package/src/index.tsx +0 -33
  72. package/src/kit/Builder.tsx +0 -18
  73. package/src/kit/Component.tsx +0 -32
  74. package/src/kit/Header.tsx +0 -21
  75. package/src/scss/constants.scss +0 -4
  76. package/src/scss/mixins.scss +0 -3
  77. package/src/scss/props.scss +0 -70
  78. package/src/scss/style.scss +0 -133
@@ -1,224 +0,0 @@
1
- import {
2
- FC,
3
- Ref,
4
- LegacyRef,
5
- forwardRef,
6
- useRef,
7
- SyntheticEvent,
8
- useEffect,
9
- memo,
10
- } from 'react';
11
- import { ClassNames } from '@emotion/react'
12
- import { nanoid } from 'nanoid';
13
- import { cleanProps, buildCSS } from '../core'
14
- import { STORE_FORM_KEY } from '../context/AppProvider'
15
- import useDispatch from '../hooks/useDispatch'
16
- import useStore from '../hooks/useStore'
17
- import {
18
- UPDATE_FORM_FIELD
19
- } from '../actions'
20
-
21
- const SIZING_STYLE = [
22
- 'borderBottomWidth',
23
- 'borderLeftWidth',
24
- 'borderRightWidth',
25
- 'borderTopWidth',
26
- 'boxSizing',
27
- 'fontFamily',
28
- 'fontSize',
29
- 'fontStyle',
30
- 'fontWeight',
31
- 'letterSpacing',
32
- 'lineHeight',
33
- 'paddingBottom',
34
- 'paddingLeft',
35
- 'paddingRight',
36
- 'paddingTop',
37
- // non-standard
38
- 'tabSize',
39
- 'textIndent',
40
- // non-standard
41
- 'textRendering',
42
- 'textTransform',
43
- 'width',
44
- 'wordBreak',
45
- ] as const;
46
- type SizingProps = Extract<
47
- (typeof SIZING_STYLE)[number],
48
- keyof CSSStyleDeclaration
49
- >;
50
-
51
- export const noop = () => {};
52
-
53
- const pick = <Obj extends { [key: string]: any }, Key extends keyof Obj>(
54
- props: Key[],
55
- obj: Obj,
56
- ): Pick<Obj, Key> =>
57
- props.reduce((acc, prop) => {
58
- acc[prop] = obj[prop];
59
- return acc;
60
- }, {} as Pick<Obj, Key>);
61
-
62
- type SizingStyle = Pick<CSSStyleDeclaration, SizingProps>;
63
-
64
- export type SizingData = {
65
- sizingStyle: SizingStyle;
66
- paddingSize: number;
67
- borderSize: number;
68
- };
69
-
70
- const isIE = typeof window !== "undefined" && !!(document.documentElement as any).currentStyle
71
-
72
- const getSizingData = (node: HTMLElement): SizingData | null => {
73
-
74
- const style = window.getComputedStyle(node);
75
-
76
- if (style === null) {
77
- return null;
78
- }
79
-
80
- const sizingStyle = pick(SIZING_STYLE as unknown as SizingProps[], style);
81
- const { boxSizing } = sizingStyle;
82
-
83
- // probably node is detached from DOM, can't read computed dimensions
84
- if (boxSizing === '') {
85
- return null;
86
- }
87
-
88
- // IE (Edge has already correct behaviour) returns content width as computed width
89
- // so we need to add manually padding and border widths
90
- if (isIE && boxSizing === 'border-box') {
91
- sizingStyle.width =
92
- parseFloat(sizingStyle.width!) +
93
- parseFloat(sizingStyle.borderRightWidth!) +
94
- parseFloat(sizingStyle.borderLeftWidth!) +
95
- parseFloat(sizingStyle.paddingRight!) +
96
- parseFloat(sizingStyle.paddingLeft!) +
97
- 'px';
98
- }
99
-
100
- const paddingSize =
101
- parseFloat(sizingStyle.paddingBottom!) +
102
- parseFloat(sizingStyle.paddingTop!);
103
-
104
- const borderSize =
105
- parseFloat(sizingStyle.borderBottomWidth!) +
106
- parseFloat(sizingStyle.borderTopWidth!);
107
-
108
- return {
109
- sizingStyle,
110
- paddingSize,
111
- borderSize,
112
- };
113
-
114
- }
115
-
116
- const Input = forwardRef((props : { [ key: string ] : any }, ref : Ref<HTMLTextAreaElement|HTMLInputElement>) => {
117
-
118
- const {
119
- as,
120
- accept,
121
- multiple,
122
- onChange,
123
- onKeyUp,
124
- onClick,
125
- onBlur,
126
- onFocus,
127
- readOnly,
128
- type,
129
- tag,
130
- placeholder,
131
- name,
132
- form,
133
- touched,
134
- onSubmit,
135
- value,
136
- defaultValue,
137
- fref,
138
- autoComplete,
139
- elastic,
140
- minRows,
141
- maxRows
142
- } = props;
143
-
144
- const dispatch = useDispatch(STORE_FORM_KEY)
145
- const { forms } = useStore(state => state[STORE_FORM_KEY], false)
146
-
147
- let Tag : string = tag || 'input';
148
- const El = Tag as `textarea` | `input`
149
- const _ref = fref || useRef();
150
-
151
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
152
-
153
- const isControlled = props.value !== undefined;
154
- const measurementsCacheRef = useRef<SizingData>();
155
-
156
- const handleElastic = () => {
157
- const node = _ref.current!
158
- const nodeSizingData = measurementsCacheRef.current
159
- ? measurementsCacheRef.current : getSizingData(node)
160
- if (!nodeSizingData) {
161
- return;
162
- }
163
- measurementsCacheRef.current = nodeSizingData;
164
-
165
- // const [height, rowHeight] = calculateNodeHeight(
166
- // nodeSizingData,
167
- // node.value || node.placeholder || 'x',
168
- // minRows || 6,
169
- // maxRows || 6,
170
- // );
171
-
172
- }
173
-
174
- useEffect(() => {}, [])
175
-
176
- return (
177
- <ClassNames>
178
- {({ css, cx }) => <El
179
- {...cleanProps(props)}
180
- type={type || `text`}
181
- placeholder={placeholder || undefined}
182
- autoComplete={autoComplete || undefined}
183
- name={name || nanoid()}
184
- multiple={type == 'file' ? multiple : undefined}
185
- accept={accept || `*`}
186
- className={`${as ? `${as} ` : ``}f ${cx(css`${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}} &:focus {${buildCSS(props.focus || {})}}`)}`}
187
- ref={_ref}
188
- value={value || undefined}
189
- defaultValue={defaultValue || ``}
190
- onKeyUp={(e : SyntheticEvent) => {
191
- let k = e['keyCode'] || ['which'];
192
- if(form && onSubmit && El != 'textarea' && k == 13){
193
- onSubmit(forms[form]);
194
- }else{
195
- if(onKeyUp) onKeyUp(e)
196
- }
197
-
198
- }}
199
- onChange={e => {
200
- let val = type == 'file' ?
201
- e.currentTarget.files
202
- : e.currentTarget.value;
203
- if(form) dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, val == "" ? null : val, forms ) ) );
204
- // if(El == `textarea` && elastic) handleElastic()
205
- onChange && onChange(val == "" ? null : val)
206
- }}
207
- onClick={onClick ? onClick : () => {}}
208
- readOnly={readOnly || false}
209
- onBlur={e => {
210
- if(onBlur) onBlur(e)
211
- if(touched){}
212
- }}
213
- onFocus={ e => {
214
- if(touched == false)dispatch( UPDATE_FORM_FIELD( form || 'orphan', `touched`, true, forms ) )
215
- if(onFocus) onFocus(e)
216
- }}
217
- />}
218
- </ClassNames>
219
- )
220
-
221
-
222
- })
223
-
224
- export default Input
@@ -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,63 +0,0 @@
1
- import {
2
- FC,
3
- LegacyRef,
4
- forwardRef,
5
- useRef,
6
- useEffect
7
- } from 'react';
8
- import { ClassNames } from '@emotion/react'
9
- import { buildCSS } from '../core'
10
- import { nanoid } from 'nanoid';
11
- import useStore from "../hooks/useStore";
12
- import useDispatch from "../hooks/useDispatch";
13
- import {
14
- UPDATE_FORM_FIELD
15
- } from '../actions'
16
- import { STORE_FORM_KEY } from '../context/AppProvider'
17
-
18
- const Select = forwardRef((props : { [ key: string ] : any }, ref : LegacyRef<HTMLHeadingElement>) => {
19
-
20
- const {
21
- as,
22
- onChange,
23
- name,
24
- form,
25
- touched,
26
- options,
27
- defaultValue
28
- } = props;
29
-
30
- const _ref = useRef();
31
- const dispatch = useDispatch(STORE_FORM_KEY)
32
- const { forms } = useStore(state => state[STORE_FORM_KEY], false)
33
-
34
- const _defaultCSS = `width: 100%;border-radius: var(--radius-base);padding-left: 4px;padding-right: 4px;border-style: solid;border-width: 1px;border-color: var(--colors-gray-200);`;
35
-
36
- useEffect(() => {
37
- dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name,
38
- defaultValue && defaultValue != null && defaultValue != "" && defaultValue != undefined ? defaultValue : options[0]?.value || '-1',
39
- forms ) ) );
40
- }, [])
41
-
42
- return (
43
- <ClassNames>
44
- {({ css, cx }) => <select
45
- onChange={e => {
46
- let val = e.currentTarget.value;
47
- dispatch( dispatch( UPDATE_FORM_FIELD( form || 'orphan', name, val, forms ) ) );
48
- onChange && onChange(val)
49
- }}
50
- onFocus={ e => touched == false && dispatch( UPDATE_FORM_FIELD( form || 'orphan', `touched`, true, forms ) ) }
51
- onBlur={e => {
52
- if(touched){}
53
- }}
54
- name={name || nanoid()}
55
- className={`${as ? as : ``} ${cx(css`${_defaultCSS}${buildCSS(props)}&:hover {${buildCSS(props.hover || {})}}`)}`}
56
- ref={_ref}>{options?.map(o => <option key={`select-${name}-option-${o.value}`} value={o.value}>{o.label}</option>)}</select>}
57
- </ClassNames>
58
- )
59
-
60
-
61
- })
62
-
63
- export default Select
@@ -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,36 +0,0 @@
1
- import React from 'react';
2
- import Box from './box'
3
- import PropTypes from 'prop-types'
4
-
5
- const Spinner = (props : any) => {
6
-
7
- return (
8
- <Box
9
- rel
10
- w={props.size}
11
- h={props.size}
12
- zIndex={`1`}
13
- useSelect={`none`}>
14
- <Box abs as={`spinner rotating`} animationDirection={`reverse`} animationDuration={typeof props.s1 == `string` ? props.s1 : `${props.s1}s`} w={props.size} r={props.radius} h={props.size} bg={props.color} opacity={0.2} />
15
- <Box abs as={`spinner rotating`} animationDuration={typeof props.s2 == `string` ? props.s2 : `${props.s2}s`} w={props.size} r={props.radius} h={props.size} bg={props.color} opacity={0.5} />
16
- </Box>
17
- );
18
- }
19
-
20
- Spinner.defaultProps = {
21
- size: 30,
22
- radius: 4,
23
- color: `black`,
24
- s1: `5s`,
25
- s2: `1s`
26
- }
27
-
28
- Spinner.propTypes = {
29
- size: PropTypes.number.isRequired,
30
- color: PropTypes.string,
31
- radius: PropTypes.number,
32
- s1: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
33
- s2: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
34
- }
35
-
36
- export default Spinner;
@@ -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;