@@ -117,53 +117,71 @@ export const SemanticGrid = () => {
117
117
}
118
118
119
119
export const SemanticForm = ( ) => {
120
- const [ value , setValue ] = useState < number > ( 40 )
120
+ const [ valueSingle , setValueSingle ] = useState < number > ( 40 )
121
+ const [ [ minValue , maxValue ] , setValuesMulti ] = useState < [ number , number ] > ( [ 30 , 80 ] )
121
122
122
123
/**
123
- * Handles changes.
124
+ * Handles changes on single range sliders .
124
125
*
125
126
* @param newValue - New value.
126
127
*/
127
- function handleChange ( newValue : number ) {
128
- setValue ( newValue )
128
+ function handleChangeOnSingle ( newValue : number ) {
129
+ setValueSingle ( newValue )
130
+ }
131
+
132
+ /**
133
+ * Handles changes on multi range sliders.
134
+ *
135
+ * @param newMinValue - New min value.
136
+ * @param newMaxValue - New max value.
137
+ */
138
+ function handleChangeOnMulti ( newMinValue : number , newMaxValue : number ) {
139
+ setValuesMulti ( [ newMinValue , newMaxValue ] )
129
140
}
130
141
131
142
return (
132
143
< Container >
133
144
< Grid >
145
+ < Grid . Row columns = { 1 } >
146
+ < Grid . Column >
147
+ < h2 > You can use Sliders inside < a href = 'https://react.semantic-ui.com/collections/form/' target = '_blank' rel = 'noreferrer' > Semantic-UI forms</ a > </ h2 >
148
+ </ Grid . Column >
149
+ </ Grid . Row >
150
+
134
151
< Grid . Row columns = { 1 } >
135
152
< Grid . Column >
136
153
< Form >
137
- < Form . Group widths = 'equal' >
154
+ < Form . Group widths = { 4 } >
138
155
< Form . Input fluid label = 'First name' placeholder = 'First name' />
139
156
< Form . Input fluid label = 'Last name' placeholder = 'Last name' />
140
157
</ Form . Group >
141
- < Form . Group inline >
142
- < label > Size</ label >
143
- < Form . Radio
144
- label = 'Small'
145
- value = 'sm'
146
- checked
147
- />
148
- < Form . Radio
149
- label = 'Medium'
150
- value = 'md'
151
- />
152
- < Form . Radio
153
- label = 'Large'
154
- value = 'lg'
155
- />
156
- </ Form . Group >
157
158
< Form . Group >
158
- < SingleRangeSlider
159
- defaultMinValue = { 0 }
160
- defaultMaxValue = { 100 }
161
- value = { value }
162
- color = 'red'
163
- onChange = { handleChange }
164
- />
159
+ < Form . Field width = { 4 } >
160
+ < label > Happiness</ label >
161
+ < SingleRangeSlider
162
+ style = { { marginTop : '5%' , marginBottom : '5%' } }
163
+ defaultMinValue = { 0 }
164
+ defaultMaxValue = { 100 }
165
+ value = { valueSingle }
166
+ color = 'green'
167
+ onChange = { handleChangeOnSingle }
168
+ />
169
+ </ Form . Field >
170
+
171
+ < Form . Field width = { 4 } >
172
+ < label > Earning range</ label >
173
+ < MultiRangeSlider
174
+ style = { { marginTop : '5%' , marginBottom : '5%' } }
175
+ defaultMinValue = { 0 }
176
+ defaultMaxValue = { 100 }
177
+ minValue = { minValue }
178
+ maxValue = { maxValue }
179
+ color = 'violet'
180
+ showLabels
181
+ onChange = { handleChangeOnMulti }
182
+ />
183
+ </ Form . Field >
165
184
</ Form . Group >
166
- < Form . Checkbox label = 'I agree to the Terms and Conditions' />
167
185
< Form . Button > Submit</ Form . Button >
168
186
</ Form >
169
187
</ Grid . Column >
0 commit comments