feffery_utils_components 0.1.1 → 0.1.2

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.
@@ -299,17 +299,6 @@
299
299
  "required": false,
300
300
  "description": ""
301
301
  },
302
- "width": {
303
- "type": {
304
- "name": "string"
305
- },
306
- "required": false,
307
- "description": "",
308
- "defaultValue": {
309
- "value": "'200px'",
310
- "computed": false
311
- }
312
- },
313
302
  "color": {
314
303
  "type": {
315
304
  "name": "string"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Build more utility components for Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feffery_utils_components",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Build more utility components for Plotly Dash.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,7 +3,7 @@ module FefferyUtilsComponents
3
3
  using Dash
4
4
 
5
5
  const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
6
- const version = "0.1.1"
6
+ const version = "0.1.2"
7
7
 
8
8
  include("jl/''_fefferyblockcolorpicker.jl")
9
9
  include("jl/''_fefferycirclecolorpicker.jl")
@@ -61,14 +61,14 @@ function __init__()
61
61
  [
62
62
  DashBase.Resource(
63
63
  relative_package_path = "feffery_utils_components.min.js",
64
- external_url = "https://unpkg.com/feffery_utils_components@0.1.1/feffery_utils_components/feffery_utils_components.min.js",
64
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.2/feffery_utils_components/feffery_utils_components.min.js",
65
65
  dynamic = nothing,
66
66
  async = nothing,
67
67
  type = :js
68
68
  ),
69
69
  DashBase.Resource(
70
70
  relative_package_path = "feffery_utils_components.min.js.map",
71
- external_url = "https://unpkg.com/feffery_utils_components@0.1.1/feffery_utils_components/feffery_utils_components.min.js.map",
71
+ external_url = "https://unpkg.com/feffery_utils_components@0.1.2/feffery_utils_components/feffery_utils_components.min.js.map",
72
72
  dynamic = true,
73
73
  async = nothing,
74
74
  type = :js
@@ -19,10 +19,9 @@ Those elements have the following types:
19
19
  - `component_name` (String; optional): Holds the name of the component that is loading
20
20
  - `style` (Dict; optional)
21
21
  - `triangle` (a value equal to: 'hide', 'top-left', 'top-right'; optional)
22
- - `width` (String; optional)
23
22
  """
24
23
  function ''_fefferygithubcolorpicker(; kwargs...)
25
- available_props = Symbol[:id, :className, :color, :colors, :loading_state, :style, :triangle, :width]
24
+ available_props = Symbol[:id, :className, :color, :colors, :loading_state, :style, :triangle]
26
25
  wild_props = Symbol[]
27
26
  return Component("''_fefferygithubcolorpicker", "FefferyGithubColorPicker", "feffery_utils_components", available_props, wild_props; kwargs...)
28
27
  end
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { BlockPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -17,6 +18,15 @@ const FefferyBlockColorPicker = (props) => {
17
18
  loading_state
18
19
  } = props;
19
20
 
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <BlockPicker id={id}
22
32
  className={className}
@@ -43,7 +53,7 @@ FefferyBlockColorPicker.propTypes = {
43
53
  // 自定义css字典
44
54
  style: PropTypes.object,
45
55
 
46
- // 设置组件整体宽度,默认为'276px'
56
+ // 设置组件整体宽度,默认为'170px'
47
57
  width: PropTypes.string,
48
58
 
49
59
  // 对应当前选中的16进制色彩字符串
@@ -78,4 +88,4 @@ FefferyBlockColorPicker.defaultProps = {
78
88
  colors: ['#D9E3F0', '#F47373', '#697689', '#37D67A', '#2CCCE4', '#555555', '#dce775', '#ff8a65', '#ba68c8']
79
89
  }
80
90
 
81
- export default FefferyBlockColorPicker;
91
+ export default React.memo(FefferyBlockColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { CirclePicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -18,6 +19,15 @@ const FefferyCircleColorPicker = (props) => {
18
19
  loading_state
19
20
  } = props;
20
21
 
22
+ useEffect(() => {
23
+ if (colors && !color) {
24
+ // 默认缺省选中色为colors中第0个色彩
25
+ setProps({
26
+ color: colors[0]
27
+ })
28
+ }
29
+ }, [])
30
+
21
31
  return (
22
32
  <CirclePicker id={id}
23
33
  className={className}
@@ -84,4 +94,4 @@ FefferyCircleColorPicker.defaultProps = {
84
94
  colors: ["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#cddc39", "#ffeb3b", "#ffc107", "#ff9800", "#ff5722", "#795548", "#607d8b"]
85
95
  }
86
96
 
87
- export default FefferyCircleColorPicker;
97
+ export default React.memo(FefferyCircleColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { GithubPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -9,7 +10,6 @@ const FefferyGithubColorPicker = (props) => {
9
10
  id,
10
11
  className,
11
12
  style,
12
- width,
13
13
  color,
14
14
  colors,
15
15
  triangle,
@@ -17,13 +17,22 @@ const FefferyGithubColorPicker = (props) => {
17
17
  loading_state
18
18
  } = props;
19
19
 
20
+
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <GithubPicker id={id}
22
32
  className={className}
23
33
  style={style}
24
34
  color={color}
25
35
  colors={colors}
26
- width={width}
27
36
  triangle={triangle}
28
37
  onChangeComplete={(c, e) => setProps({ color: c.hex })}
29
38
  data-dash-is-loading={
@@ -43,9 +52,6 @@ FefferyGithubColorPicker.propTypes = {
43
52
  // 自定义css字典
44
53
  style: PropTypes.object,
45
54
 
46
- // 设置组件整体宽度,默认为'200px'
47
- width: PropTypes.string,
48
-
49
55
  // 对应当前选中的16进制色彩字符串
50
56
  color: PropTypes.string,
51
57
 
@@ -74,8 +80,7 @@ FefferyGithubColorPicker.propTypes = {
74
80
  // 设置默认参数
75
81
  FefferyGithubColorPicker.defaultProps = {
76
82
  triangle: 'top-left',
77
- width: '200px',
78
83
  colors: ['#B80000', '#DB3E00', '#FCCB00', '#008B02', '#006B76', '#1273DE', '#004DCF', '#5300EB', '#EB9694', '#FAD0C3', '#FEF3BD', '#C1E1C5', '#BEDADC', '#C4DEF6', '#BED3F3', '#D4C4FB']
79
84
  }
80
85
 
81
- export default FefferyGithubColorPicker;
86
+ export default React.memo(FefferyGithubColorPicker);
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from 'react';
1
2
  import { TwitterPicker } from 'react-color';
2
3
  import PropTypes from 'prop-types';
3
4
  import '../styles.css';
@@ -17,6 +18,15 @@ const FefferyTwitterColorPicker = (props) => {
17
18
  loading_state
18
19
  } = props;
19
20
 
21
+ useEffect(() => {
22
+ if (colors && !color) {
23
+ // 默认缺省选中色为colors中第0个色彩
24
+ setProps({
25
+ color: colors[0]
26
+ })
27
+ }
28
+ }, [])
29
+
20
30
  return (
21
31
  <TwitterPicker id={id}
22
32
  className={className}
@@ -78,4 +88,4 @@ FefferyTwitterColorPicker.defaultProps = {
78
88
  colors: ['#FF6900', '#FCB900', '#7BDCB5', '#00D084', '#8ED1FC', '#0693E3', '#ABB8C3', '#EB144C', '#F78DA7', '#9900EF']
79
89
  }
80
90
 
81
- export default FefferyTwitterColorPicker;
91
+ export default React.memo(FefferyTwitterColorPicker);
@@ -111,3 +111,7 @@
111
111
  box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
112
112
  transition: box-shadow 0.3s ease-in-out;
113
113
  }
114
+
115
+ .github-picker {
116
+ box-sizing: content-box;
117
+ }
package/usage.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import dash
2
- from dash import html
3
- import feffery_antd_components as fac
2
+ from dash import html, dcc
4
3
  import feffery_utils_components as fuc
5
4
  from dash.dependencies import Input, Output, State
6
5
 
@@ -8,59 +7,32 @@ app = dash.Dash(__name__)
8
7
 
9
8
  app.layout = html.Div(
10
9
  [
11
- fac.AntdSpace(
12
- [
13
- fac.AntdSwitch(
14
- id='css-var-demo',
15
- checked=False,
16
- unCheckedChildren='🌞',
17
- checkedChildren='🌛'
18
- ),
19
-
20
- fuc.FefferyCssVar(
21
- id='css-var-demo-output'
22
- ),
23
-
24
- html.Div(
25
- 'FefferyCssVar示例',
26
- style={
27
- 'background': 'var(--demo-bg-color)',
28
- 'color': 'var(--demo-color)',
29
- 'display': 'flex',
30
- 'justifyContent': 'center',
31
- 'alignItems': 'center',
32
- 'fontSize': '28px',
33
- 'transition': '0.2s',
34
- 'padding': '100px 150px'
35
- }
36
- )
37
- ],
38
- direction='vertical'
39
- )
10
+ fuc.FefferyDiv(
11
+ id='div-demo',
12
+ style={
13
+ 'width': '400px',
14
+ 'height': '300px',
15
+ 'border': '1px solid #d9d9d9'
16
+ }
17
+ ),
18
+ html.Span(id='output')
40
19
  ],
41
20
  style={
42
- 'padding': '100px'
21
+ 'padding': '50px'
43
22
  }
44
23
  )
45
24
 
46
25
  @app.callback(
47
- Output('css-var-demo-output', 'cssVars'),
48
- Input('css-var-demo', 'checked')
26
+ Output('output', 'children'),
27
+ [Input('div-demo', '_width'),
28
+ Input('div-demo', '_height')],
29
+ prevent_initial_call=True
49
30
  )
50
- def css_var_demo(checked):
31
+ def demo(_width, _height):
51
32
 
52
- print(checked)
33
+ print(_width, _height)
53
34
 
54
- if checked:
55
- return {
56
- '--demo-bg-color': 'black',
57
- '--demo-color': 'white'
58
- }
59
-
60
- return {
61
- '--demo-bg-color': 'white',
62
- '--demo-color': 'black'
63
- }
35
+ return f'{_width}, {_height}'
64
36
 
65
37
  if __name__ == '__main__':
66
- app.run(debug=True)
38
+ app.run(debug=True)