1
- import { BoolCodeControl , NumberControl } from '../../controls/codeControl' ;
2
- import { LabelControl } from '../../controls/labelControl' ;
3
- import { withDefault } from '../../generators' ;
4
- import { ChangeEventHandlerControl } from '../../controls/eventHandlerControl' ;
5
- import { Section , sectionNames } from 'lowcoder-design' ;
6
- import { RecordConstructorToComp } from 'lowcoder-core' ;
7
- import { styleControl } from 'comps/controls/styleControl' ;
8
- import {
9
- AnimationStyle ,
10
- InputFieldStyle ,
11
- LabelStyle ,
12
- SliderStyle ,
13
- SliderStyleType ,
14
- heightCalculator ,
15
- widthCalculator ,
16
- } from 'comps/controls/styleControlConstants' ;
17
- import styled , { css } from 'styled-components' ;
18
- import { default as Slider } from 'antd/es/slider' ;
19
- import { darkenColor , fadeColor } from 'lowcoder-design' ;
20
- import {
21
- disabledPropertyView ,
22
- hiddenPropertyView ,
23
- } from 'comps/utils/propertyUtils' ;
24
- import { IconControl } from 'comps/controls/iconControl' ;
25
- import { trans } from 'i18n' ;
1
+ import { BoolCodeControl , NumberControl } from "../../controls/codeControl" ;
2
+ import { LabelControl } from "../../controls/labelControl" ;
3
+ import { withDefault } from "../../generators" ;
4
+ import { ChangeEventHandlerControl } from "../../controls/eventHandlerControl" ;
5
+ import { Section , sectionNames } from "lowcoder-design" ;
6
+ import { RecordConstructorToComp } from "lowcoder-core" ;
7
+ import { styleControl } from "comps/controls/styleControl" ;
8
+ import { AnimationStyle , InputFieldStyle , LabelStyle , SliderStyle , SliderStyleType , heightCalculator , widthCalculator } from "comps/controls/styleControlConstants" ;
9
+ import styled , { css } from "styled-components" ;
10
+ import { default as Slider } from "antd/es/slider" ;
11
+ import { darkenColor , fadeColor } from "lowcoder-design" ;
12
+ import { disabledPropertyView , hiddenPropertyView } from "comps/utils/propertyUtils" ;
13
+ import { IconControl } from "comps/controls/iconControl" ;
14
+ import { trans } from "i18n" ;
26
15
27
- import { useContext } from ' react' ;
28
- import { EditorContext } from ' comps/editorState' ;
16
+ import { useContext } from " react" ;
17
+ import { EditorContext } from " comps/editorState" ;
29
18
30
19
const getStyle = ( style : SliderStyleType , vertical : boolean ) => {
31
- console . log ( '🚀 ~ getStyle ~ style:' , style ) ;
32
20
return css `
33
21
& .ant-slider : not (.ant-slider-disabled ) {
34
22
& ,
@@ -51,87 +39,67 @@ const getStyle = (style: SliderStyleType, vertical: boolean) => {
51
39
}
52
40
}
53
41
.ant-slider-handle : focus {
54
- box-shadow : 0 0 0 5px
55
- ${ fadeColor ( darkenColor ( style . thumbBorder , 0.08 ) , 0.12 ) } ;
42
+ box-shadow : 0 0 0 5px ${ fadeColor ( darkenColor ( style . thumbBorder , 0.08 ) , 0.12 ) } ;
56
43
}
57
- ${ vertical &&
58
- css `
59
- width : auto;
44
+ ${ vertical && css `
45
+ width : auto;
60
46
min-height : calc (300px - ${ style . margin } );
61
47
margin : ${ style . margin } auto !important ;
62
48
` }
63
49
}
64
50
` ;
65
51
} ;
66
52
67
- export const SliderStyled = styled ( Slider ) < {
68
- $style : SliderStyleType ;
69
- vertical : boolean ;
70
- } > `
53
+ export const SliderStyled = styled ( Slider ) < { $style : SliderStyleType , vertical : boolean } > `
71
54
${ ( props ) => props . $style && getStyle ( props . $style , props . vertical ) }
72
55
` ;
73
56
74
- export const SliderWrapper = styled . div < {
75
- $style ?: SliderStyleType ;
76
- vertical : boolean ;
77
- } > `
57
+ export const SliderWrapper = styled . div < { vertical : boolean } > `
78
58
width: 100%;
79
59
display: inline-flex;
80
60
align-items: center;
81
61
justify-content: center;
82
62
.ant-slider {
83
63
width: 100%;
84
- rotate: ${ ( props ) => props ?. $style ?. rotation } ;
85
64
}
86
- ` ;
65
+ `
87
66
88
67
export const SliderChildren = {
89
- max : withDefault ( NumberControl , ' 100' ) ,
90
- min : withDefault ( NumberControl , '0' ) ,
91
- step : withDefault ( NumberControl , '1' ) ,
68
+ max : withDefault ( NumberControl , " 100" ) ,
69
+ min : withDefault ( NumberControl , "0" ) ,
70
+ step : withDefault ( NumberControl , "1" ) ,
92
71
label : LabelControl ,
93
72
disabled : BoolCodeControl ,
94
73
onEvent : ChangeEventHandlerControl ,
95
74
style : withDefault ( styleControl ( InputFieldStyle ) , { borderWidth : '1px' } ) ,
96
- labelStyle : styleControl (
97
- LabelStyle . filter (
98
- ( style ) => [ 'accent' , 'validate' ] . includes ( style . name ) === false
99
- )
100
- ) ,
75
+ labelStyle :styleControl ( LabelStyle . filter ( ( style ) => [ 'accent' , 'validate' ] . includes ( style . name ) === false ) ) ,
101
76
prefixIcon : IconControl ,
102
77
suffixIcon : IconControl ,
103
- inputFieldStyle : styleControl ( SliderStyle ) ,
104
- animationStyle : styleControl ( AnimationStyle ) ,
78
+ inputFieldStyle :styleControl ( SliderStyle ) ,
79
+ animationStyle :styleControl ( AnimationStyle )
105
80
} ;
106
81
107
82
export const SliderPropertyView = (
108
- children : RecordConstructorToComp <
109
- typeof SliderChildren & { hidden : typeof BoolCodeControl }
110
- >
83
+ children : RecordConstructorToComp < typeof SliderChildren & { hidden : typeof BoolCodeControl } >
111
84
) => (
112
85
< >
113
- { [ 'logic' , 'both' ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
86
+
87
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
114
88
< Section name = { sectionNames . interaction } >
115
89
{ children . onEvent . getPropertyView ( ) }
116
90
{ disabledPropertyView ( children ) }
117
91
{ hiddenPropertyView ( children ) }
118
92
</ Section >
119
93
) }
120
94
121
- { [ 'layout' , 'both' ] . includes ( useContext ( EditorContext ) . editorModeStatus ) &&
122
- children . label . getPropertyView ( ) }
95
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
96
+ children . label . getPropertyView ( )
97
+ ) }
123
98
124
- { [ 'layout' , 'both' ] . includes (
125
- useContext ( EditorContext ) . editorModeStatus
126
- ) && (
127
- < >
128
- < Section name = { sectionNames . layout } >
129
- { children . prefixIcon . propertyView ( {
130
- label : trans ( 'button.prefixIcon' ) ,
131
- } ) }
132
- { children . suffixIcon . propertyView ( {
133
- label : trans ( 'button.suffixIcon' ) ,
134
- } ) }
99
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
100
+ < > < Section name = { sectionNames . layout } >
101
+ { children . prefixIcon . propertyView ( { label : trans ( "button.prefixIcon" ) } ) }
102
+ { children . suffixIcon . propertyView ( { label : trans ( "button.suffixIcon" ) } ) }
135
103
</ Section >
136
104
< Section name = { sectionNames . style } >
137
105
{ children . style . getPropertyView ( ) }
0 commit comments