@avilang/practical-ui 0.1.5 → 0.2.1

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 (60) hide show
  1. package/dist/assets/LatoLatin-Regular.woff2 +0 -0
  2. package/dist/assets/LatoLatin-Semibold.woff2 +0 -0
  3. package/dist/index.js +8395 -0
  4. package/dist/style.css +1 -0
  5. package/index.js +13 -0
  6. package/package.json +31 -55
  7. package/.browserslistrc +0 -6
  8. package/.editorconfig +0 -15
  9. package/.eslintrc +0 -25
  10. package/.gitattributes +0 -4
  11. package/.husky/pre-commit +0 -4
  12. package/.stylelintrc.json +0 -14
  13. package/LICENSE +0 -21
  14. package/README.md +0 -3
  15. package/dist/Icon-shared.js +0 -33
  16. package/dist/button/index.js +0 -159
  17. package/dist/button/style/index.css +0 -1
  18. package/dist/checkbox/index.js +0 -61
  19. package/dist/checkbox/style/index.css +0 -1
  20. package/dist/icon/index.js +0 -4
  21. package/dist/icon/style/index.css +0 -1
  22. package/dist/index-shared.js +0 -146
  23. package/dist/style/fonts/icomoon-practical.eot +0 -0
  24. package/dist/style/fonts/icomoon-practical.svg +0 -12
  25. package/dist/style/fonts/icomoon-practical.ttf +0 -0
  26. package/dist/style/fonts/icomoon-practical.woff +0 -0
  27. package/dist/style/index.css +0 -1
  28. package/docz.config.js +0 -3
  29. package/gatsby-config.js +0 -3
  30. package/gulpfile.js +0 -48
  31. package/lib/_fonts/icomoon-practical-v1.0/Read Me.txt +0 -7
  32. package/lib/_fonts/icomoon-practical-v1.0/demo-files/demo.css +0 -152
  33. package/lib/_fonts/icomoon-practical-v1.0/demo-files/demo.js +0 -30
  34. package/lib/_fonts/icomoon-practical-v1.0/demo.html +0 -66
  35. package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.eot +0 -0
  36. package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.svg +0 -12
  37. package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.ttf +0 -0
  38. package/lib/_fonts/icomoon-practical-v1.0/fonts/icomoon-practical.woff +0 -0
  39. package/lib/_fonts/icomoon-practical-v1.0/selection.json +0 -1
  40. package/lib/_fonts/icomoon-practical-v1.0/style.css +0 -33
  41. package/lib/_variables.scss +0 -20
  42. package/lib/button/Button.js +0 -118
  43. package/lib/button/doc/button.mdx +0 -119
  44. package/lib/button/index.js +0 -1
  45. package/lib/button/style/button.scss +0 -195
  46. package/lib/checkbox/Checkbox.js +0 -46
  47. package/lib/checkbox/doc/checkbox.mdx +0 -82
  48. package/lib/checkbox/index.js +0 -1
  49. package/lib/checkbox/style/checkbox.scss +0 -127
  50. package/lib/icon/Icon.js +0 -30
  51. package/lib/icon/doc/icon.mdx +0 -45
  52. package/lib/icon/index.js +0 -1
  53. package/lib/icon/style/icon.scss +0 -20
  54. package/lib/input/Input.js +0 -3
  55. package/lib/input/index.js +0 -1
  56. package/lib/util/index.js +0 -1
  57. package/lib/util/useThrottleFn.js +0 -31
  58. package/prettier.config.js +0 -20
  59. package/rollup.config.js +0 -30
  60. package/src/gatsby-theme-docz/wrapper.js +0 -9
@@ -1,195 +0,0 @@
1
- @import '../../variables';
2
-
3
- .#{$prefix}-button-reset {
4
- margin: 0;
5
- overflow: visible;
6
- text-transform: none;
7
- appearance: button;
8
-
9
- &::-moz-focus-inner {
10
- padding: 0;
11
- border-style: none;
12
- }
13
-
14
- &:-moz-focusring {
15
- outline: 1px dotted ButtonText;
16
- }
17
- }
18
-
19
- .#{$prefix}-button-default {
20
- box-sizing: border-box;
21
- display: inline-block;
22
- height: 34px;
23
- padding: 5px 12px;
24
- font-family: inherit;
25
- font-size: 14px;
26
- font-weight: 400;
27
- line-height: $line-height;
28
- color: $primary-text;
29
- text-align: center;
30
- touch-action: manipulation;
31
- cursor: pointer;
32
- user-select: none;
33
- background-color: #fff;
34
- border-color: $border-color;
35
- border-style: solid;
36
- border-width: 1px;
37
- border-radius: 2px;
38
- outline: none;
39
- transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
40
-
41
- &,
42
- &:active,
43
- &:focus {
44
- outline: 0;
45
- }
46
-
47
- &:hover {
48
- color: $blue-6;
49
- border-color: $blue-6;
50
- }
51
-
52
- & > span {
53
- display: inline-block;
54
- margin-top: 1px;
55
- }
56
-
57
- &.#{$prefix}-button-block {
58
- width: 100%;
59
- }
60
-
61
- &.#{$prefix}-button-primary {
62
- color: #fff;
63
- background-color: $blue-6;
64
- border-color: $blue-6;
65
-
66
- &:hover {
67
- background-color: $blue-5;
68
- border-color: $blue-5;
69
- }
70
- }
71
-
72
- &.#{$prefix}-button-secondary {
73
- color: #fff;
74
- background-color: $green-6;
75
- border-color: $green-6;
76
-
77
- &:hover {
78
- background-color: $green-5;
79
- border-color: $green-5;
80
- }
81
- }
82
-
83
- &.#{$prefix}-button-dashed {
84
- border-style: dashed;
85
- }
86
-
87
- &.#{$prefix}-button-danger {
88
- color: $red-6;
89
- border-color: $red-6;
90
-
91
- &:hover {
92
- opacity: 0.7;
93
- }
94
- }
95
-
96
- &.#{$prefix}-button-primary.#{$prefix}-button-danger,
97
- &.#{$prefix}-button-secondary.#{$prefix}-button-danger {
98
- color: #fff;
99
- background-color: $red-6;
100
- border-color: $red-6;
101
- }
102
-
103
- &.#{$prefix}-button-text {
104
- height: auto;
105
- padding: 0;
106
- background-color: transparent;
107
- border-color: transparent;
108
- border-width: 0;
109
-
110
- & > span {
111
- margin-top: 0;
112
- }
113
-
114
- &:hover {
115
- color: $primary-text;
116
- background-color: transparent;
117
- border-color: transparent;
118
- opacity: 1;
119
-
120
- & > span {
121
- text-decoration: underline;
122
- }
123
- }
124
-
125
- &.#{$prefix}-button-primary {
126
- color: $blue-6;
127
- }
128
- &.#{$prefix}-button-secondary {
129
- color: $green-6;
130
- }
131
- &.#{$prefix}-button-danger {
132
- color: $red-6;
133
- }
134
-
135
- &.#{$prefix}-button-primary.#{$prefix}-button-danger,
136
- &.#{$prefix}-button-secondary.#{$prefix}-button-danger {
137
- color: $red-6;
138
- background-color: transparent;
139
- border-color: transparent;
140
- }
141
- }
142
-
143
- &[disabled] {
144
- &,
145
- &:hover,
146
- &:focus,
147
- &:active,
148
- &.#{$prefix}-button-danger {
149
- color: $disable-text;
150
- cursor: not-allowed;
151
- background-color: $background-color;
152
- border-color: $border-color;
153
-
154
- &:hover {
155
- opacity: 1;
156
- }
157
- }
158
-
159
- &.#{$prefix}-button-text,
160
- &.#{$prefix}-button-danger.#{$prefix}-button-text {
161
- color: $disable-text;
162
- cursor: not-allowed;
163
- background-color: transparent;
164
- border-color: transparent;
165
- }
166
-
167
- &.#{$prefix}-button-text:hover {
168
- opacity: 1;
169
-
170
- & > span {
171
- text-decoration: none;
172
- }
173
- }
174
- }
175
-
176
- &.#{$prefix}-button-loading {
177
- position: relative;
178
- pointer-events: none;
179
-
180
- &::before {
181
- position: absolute;
182
- top: -1px;
183
- right: -1px;
184
- bottom: -1px;
185
- left: -1px;
186
- z-index: 1;
187
- pointer-events: none;
188
- content: '';
189
- background: #fff;
190
- border-radius: inherit;
191
- opacity: 0.35;
192
- transition: opacity 0.2s;
193
- }
194
- }
195
- }
@@ -1,46 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import classNames from 'classnames';
4
- import './style/checkbox.scss';
5
-
6
- function Checkbox(props) {
7
- const { children, checked, indeterminate, disabled, onChange, ...rest } = props;
8
- const classes = classNames('practical-checkbox', {
9
- 'practical-checkbox-checked': checked,
10
- 'practical-checkbox-disabled': disabled,
11
- 'practical-checkbox-indeterminate': checked === false && indeterminate
12
- });
13
- const handleChange = (e) => {
14
- if (disabled) return;
15
- onChange && onChange(e, e.target.checked);
16
- };
17
-
18
- return (
19
- // eslint-disable-next-line jsx-a11y/label-has-associated-control
20
- <label className={classes} {...rest}>
21
- <span className="practical-checkbox-sign">
22
- <input type="checkbox" checked={checked} onChange={handleChange} />
23
- </span>
24
- {children && <span className="practical-checkbox-text">{children}</span>}
25
- </label>
26
- );
27
- }
28
-
29
- Checkbox.displayName = 'PracticalUi.Checkbox';
30
- Checkbox.defaultProps = {
31
- checked: false,
32
- disabled: false,
33
- indeterminate: false
34
- };
35
- Checkbox.propTypes = {
36
- /** 指定当前是否选中 */
37
- checked: PropTypes.bool,
38
- /** 失效状态 */
39
- disabled: PropTypes.bool,
40
- /** 设置 indeterminate 状态,只负责样式控制 */
41
- indeterminate: PropTypes.bool,
42
- /** 变化时回调函数 | (event, checked) => void | checked 参数为 checkbox 的 checked 状态值 */
43
- onChange: PropTypes.func
44
- };
45
-
46
- export default Checkbox;
@@ -1,82 +0,0 @@
1
- ---
2
- name: Checkbox 多选框
3
- route: /checkbox
4
- ---
5
-
6
- import { Playground, Props } from 'docz';
7
- import { Checkbox } from '../index';
8
-
9
- # Checkbox 多选框
10
-
11
- ## 基本用法
12
-
13
- <Playground>
14
- {() => {
15
- const [checked, setChecked] = React.useState(true);
16
- return (
17
- <>
18
- <Checkbox
19
- checked={checked}
20
- onChange={(e, status) => {
21
- setChecked(status);
22
- }}
23
- >
24
- 苹果
25
- </Checkbox>
26
- <Checkbox style={{ marginLeft: 16 }}>香蕉</Checkbox>
27
- <Checkbox style={{ marginLeft: 16 }} />
28
- </>
29
- );
30
- }}
31
- </Playground>
32
-
33
- ## 不可用
34
-
35
- <Playground>
36
- <Checkbox checked disabled>
37
- 香蕉
38
- </Checkbox>
39
- <Checkbox style={{ marginLeft: 16 }} disabled>
40
- 雪梨
41
- </Checkbox>
42
- </Playground>
43
-
44
- ## 全选
45
-
46
- 在实现全选效果时,你可能会用到 indeterminate 属性。
47
-
48
- <Playground>
49
- {() => {
50
- const [checkedA, setCheckedA] = React.useState(true);
51
- const [checkedB, setCheckedB] = React.useState(false);
52
- return (
53
- <>
54
- <Checkbox indeterminate={checkedA || checkedB} checked={checkedA && checkedB}>
55
- 全部
56
- </Checkbox>
57
- <Checkbox
58
- style={{ marginLeft: 16 }}
59
- checked={checkedB}
60
- onChange={(e, status) => {
61
- setCheckedB(status);
62
- }}
63
- >
64
- 菠萝
65
- </Checkbox>
66
- <Checkbox
67
- style={{ marginLeft: 16 }}
68
- checked={checkedA}
69
- onChange={(e, status) => {
70
- setCheckedA(status);
71
- }}
72
- >
73
- 西瓜
74
- </Checkbox>
75
- </>
76
- );
77
- }}
78
- </Playground>
79
-
80
- ## API
81
-
82
- <Props of={Checkbox} />
@@ -1 +0,0 @@
1
- export { default as Checkbox } from './Checkbox';
@@ -1,127 +0,0 @@
1
- @import '../../variables';
2
-
3
- .#{$prefix}-checkbox {
4
- box-sizing: border-box;
5
- display: inline-block;
6
- padding: 0;
7
- margin: 0;
8
- font-size: 14px;
9
- line-height: $line-height;
10
- color: $primary-text;
11
- list-style: none;
12
- touch-action: manipulation;
13
- cursor: pointer;
14
-
15
- & > span {
16
- vertical-align: middle;
17
- }
18
-
19
- &:hover {
20
- .#{$prefix}-checkbox-sign {
21
- border-color: $blue-6;
22
- }
23
- }
24
- }
25
-
26
- .#{$prefix}-checkbox-checked {
27
- .#{$prefix}-checkbox-sign {
28
- background-color: $blue-6;
29
- border-color: $blue-6;
30
-
31
- &::after {
32
- position: absolute;
33
- top: 50%;
34
- left: 22%;
35
- box-sizing: border-box;
36
- display: table;
37
- width: 5.71428571px;
38
- height: 9.14285714px;
39
- content: ' ';
40
- border: 2px solid #fff;
41
- border-top: 0;
42
- border-left: 0;
43
- opacity: 1;
44
- transition: all 0.2s cubic-bezier(0.12, 0.4, 0.29, 1.46) 0.1s;
45
- transform: rotate(45deg) scale(1) translate(-50%, -50%);
46
- }
47
- }
48
- }
49
-
50
- .#{$prefix}-checkbox-indeterminate {
51
- .#{$prefix}-checkbox-sign {
52
- &::after {
53
- position: absolute;
54
- top: 50%;
55
- left: 50%;
56
- box-sizing: border-box;
57
- display: table;
58
- width: 8px;
59
- height: 8px;
60
- content: ' ';
61
- background-color: $blue-6;
62
- border: 0;
63
- border-radius: 2px;
64
- opacity: 1;
65
- transition: all 0.1s cubic-bezier(0.71, -0.46, 0.88, 0.6), opacity 0.1s;
66
- transform: translate(-50%, -50%) scale(1);
67
- }
68
- }
69
- }
70
-
71
- .#{$prefix}-checkbox-disabled {
72
- color: $disable-text;
73
- cursor: not-allowed;
74
-
75
- .#{$prefix}-checkbox-sign {
76
- background-color: $background-color;
77
- border-color: $border-color;
78
-
79
- &::after {
80
- border-color: rgba(0, 0, 0, 0.25);
81
- }
82
- }
83
-
84
- &:hover {
85
- .#{$prefix}-checkbox-sign {
86
- border-color: $border-color;
87
- }
88
- }
89
-
90
- &.#{$prefix}-checkbox-indeterminate {
91
- .#{$prefix}-checkbox-sign {
92
- &::after {
93
- background-color: rgba(0, 0, 0, 0.25);
94
- }
95
- }
96
- }
97
- }
98
-
99
- .#{$prefix}-checkbox-sign {
100
- position: relative;
101
- top: -1px;
102
- box-sizing: border-box;
103
- display: inline-block;
104
- width: 16px;
105
- height: 16px;
106
- overflow: hidden;
107
- background-color: #fff;
108
- border: 1px solid $border-color;
109
- border-radius: 2px;
110
- transition: all 0.3s;
111
-
112
- & > input {
113
- position: absolute;
114
- top: 0;
115
- left: -18px;
116
- padding: 0;
117
- margin: 0;
118
- overflow: visible;
119
- outline: none;
120
- opacity: 0;
121
- appearance: auto;
122
- }
123
- }
124
-
125
- .#{$prefix}-checkbox-text {
126
- padding-left: 4px;
127
- }
package/lib/icon/Icon.js DELETED
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import '../_fonts/icomoon-practical-v1.0/style.css';
5
- import './style/icon.scss';
6
-
7
- function Icon(props) {
8
- const { type, style, spin } = props;
9
- const classes = classNames('practical-sign', {
10
- [`practical-icon-${type}`]: true,
11
- 'practical-sign-spin': spin
12
- });
13
-
14
- return <span className={classes} style={style} />;
15
- }
16
-
17
- Icon.displayName = 'PracticalUi.Icon';
18
- Icon.defaultProps = {
19
- style: {},
20
- spin: false
21
- };
22
- Icon.propTypes = {
23
- type: PropTypes.string.isRequired,
24
- /** 设置图标的样式,例如 fontSize 和 color */
25
- style: PropTypes.object,
26
- /** 是否有旋转动画 */
27
- spin: PropTypes.bool
28
- };
29
-
30
- export default Icon;
@@ -1,45 +0,0 @@
1
- ---
2
- name: Icon 图标
3
- route: /icon
4
- ---
5
-
6
- import { Playground, Props } from 'docz';
7
- import { Icon } from '../index';
8
-
9
- export const inlineStyleForIconWrap = {
10
- display: 'inline-block',
11
- textAlign: 'center',
12
- marginRight: 20
13
- };
14
- export const inlineStyleForIconBox = {
15
- width: 30,
16
- height: 30,
17
- border: '1px solid #ccc',
18
- borderRadius: '3px',
19
- boxSizing: 'border-box',
20
- display: 'inline-block'
21
- };
22
- export const inlineStyleForIconText = { display: 'block', fontSize: 14 };
23
-
24
- # Icon 图标
25
-
26
- ## 图标类型
27
-
28
- <Playground>
29
- <div style={inlineStyleForIconWrap}>
30
- <div style={inlineStyleForIconBox}>
31
- <Icon type="loading" spin />
32
- </div>
33
- <span style={inlineStyleForIconText}>loading</span>
34
- </div>
35
- <div style={inlineStyleForIconWrap}>
36
- <div style={inlineStyleForIconBox}>
37
- <Icon type="search" style={{ color: 'red' }} />
38
- </div>
39
- <span style={inlineStyleForIconText}>search</span>
40
- </div>
41
- </Playground>
42
-
43
- ## API
44
-
45
- <Props of={Icon} />
package/lib/icon/index.js DELETED
@@ -1 +0,0 @@
1
- export { default as Icon } from './Icon';
@@ -1,20 +0,0 @@
1
- @import '../../variables';
2
-
3
- @keyframes iconLoadingCircle {
4
- to {
5
- transform: rotate(1turn);
6
- }
7
- }
8
-
9
- .#{$prefix}-sign {
10
- display: inline-block;
11
- font-style: normal;
12
- -webkit-font-smoothing: antialiased;
13
- line-height: 0;
14
- text-transform: none;
15
- text-rendering: optimizeLegibility;
16
- }
17
-
18
- .#{$prefix}-sign-spin {
19
- animation: iconLoadingCircle 1s linear infinite;
20
- }
@@ -1,3 +0,0 @@
1
- function Input() {}
2
-
3
- export default Input;
@@ -1 +0,0 @@
1
- export { default as Input } from './Input';
package/lib/util/index.js DELETED
@@ -1 +0,0 @@
1
- export { default as useThrottleFn } from './useThrottleFn';
@@ -1,31 +0,0 @@
1
- import { useRef, useEffect, useCallback } from 'react';
2
-
3
- function useThrottleFn(fn, delay) {
4
- const { current } = useRef({ fn, timer: null });
5
- useEffect(
6
- function () {
7
- current.fn = fn;
8
- },
9
- [fn]
10
- );
11
-
12
- useEffect(() => {
13
- return () => {
14
- if (current.timer) {
15
- clearTimeout(current.timer);
16
- current.timer = null;
17
- }
18
- };
19
- }, []);
20
-
21
- return useCallback(function (...args) {
22
- if (!current.timer) {
23
- current.timer = setTimeout(() => {
24
- current.timer = null;
25
- }, delay);
26
- current.fn.call(this, ...args);
27
- }
28
- }, []);
29
- }
30
-
31
- export default useThrottleFn;
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- printWidth: 100,
3
- tabWidth: 2,
4
- useTabs: false,
5
- semi: true,
6
- singleQuote: true,
7
- quoteProps: 'as-needed',
8
- jsxSingleQuote: false,
9
- trailingComma: 'none',
10
- bracketSpacing: true,
11
- jsxBracketSameLine: false,
12
- arrowParens: 'always',
13
- rangeStart: 0,
14
- rangeEnd: Infinity,
15
- requirePragma: false,
16
- insertPragma: false,
17
- proseWrap: 'preserve',
18
- htmlWhitespaceSensitivity: 'css',
19
- endOfLine: 'auto'
20
- };
package/rollup.config.js DELETED
@@ -1,30 +0,0 @@
1
- import { babel } from '@rollup/plugin-babel';
2
- import { nodeResolve } from '@rollup/plugin-node-resolve';
3
- import postcss from 'rollup-plugin-postcss';
4
- import commonjs from '@rollup/plugin-commonjs';
5
-
6
- export default {
7
- input: {
8
- button: 'lib/button/index.js',
9
- icon: 'lib/icon/index.js',
10
- checkbox: 'lib/checkbox/index.js'
11
- },
12
- output: {
13
- dir: 'dist',
14
- entryFileNames: '[name]/index.js',
15
- chunkFileNames: '[name]-shared.js',
16
- format: 'es'
17
- },
18
- plugins: [
19
- nodeResolve(),
20
- commonjs({ include: /node_modules/ }),
21
- postcss({ extract: 'index.css' }),
22
- babel({
23
- babelHelpers: 'bundled',
24
- presets: ['@babel/preset-env', '@babel/preset-react'],
25
- exclude: 'node_modules/**'
26
- // plugins: ['@babel/plugin-transform-runtime']
27
- })
28
- ],
29
- external: ['react', 'prop-types']
30
- };
@@ -1,9 +0,0 @@
1
- export default ({ children }) => (
2
- <div
3
- style={{
4
- fontFamily: 'tahoma,arial,Microsoft YaHei,Hiragino Sans GB,"\u5b8b\u4f53",sans-serif'
5
- }}
6
- >
7
- {children}
8
- </div>
9
- );