Skip to content

Commit 5811da2

Browse files
committed
Style the disable button
1 parent 9155991 commit 5811da2

3 files changed

Lines changed: 45 additions & 8 deletions

File tree

css/cloudinary.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

php/ui/component/class-crops.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ protected function make_input( $name, $value ) {
288288
'crop-size-inputs',
289289
);
290290

291-
$label = $this->get_part( 'label' );
292-
$label['attributes']['for'] = $name;
293-
$label['content'] = __( 'Disable', 'cloudinary' );
291+
// Disable toggle control.
292+
$control = $this->get_part( 'label' );
293+
$control['attributes']['class'][] = 'cld-input-on-off-control';
294+
$control['attributes']['class'][] = 'medium';
295+
$control['attributes']['for'] = $name;
294296

295297
$check = $this->get_part( 'input' );
296298
$check['attributes']['type'] = 'checkbox';
@@ -303,6 +305,17 @@ protected function make_input( $name, $value ) {
303305
$check['attributes']['checked'] = 'checked';
304306
}
305307

308+
$slider = $this->get_part( 'span' );
309+
$slider['attributes']['class'][] = 'cld-input-on-off-control-slider';
310+
$slider['render'] = true;
311+
312+
$control['children']['input'] = $check;
313+
$control['children']['slider'] = $slider;
314+
315+
$label = $this->get_part( 'span' );
316+
$label['attributes']['class'] = 'cld-input-on-off-control-label';
317+
$label['content'] = __( 'Disable', 'cloudinary' );
318+
306319
$input = $this->get_part( 'input' );
307320
$input['attributes']['type'] = 'text';
308321
$input['attributes']['name'] = $name;
@@ -316,10 +329,10 @@ protected function make_input( $name, $value ) {
316329
$clear_button['attributes']['title'] = __( 'Reset input', 'cloudinary' );
317330
$clear_button['content'] = Utils::get_inline_svg( 'css/images/undo.svg', false ) . '<span>' . __( 'Reset', 'cloudinary' ) . '</span>';
318331

319-
$wrapper['children']['input'] = $input;
320-
$wrapper['children']['button'] = $clear_button;
321-
$wrapper['children']['label'] = $label;
322-
$wrapper['children']['check'] = $check;
332+
$wrapper['children']['input'] = $input;
333+
$wrapper['children']['button'] = $clear_button;
334+
$wrapper['children']['control'] = $control;
335+
$wrapper['children']['label'] = $label;
323336

324337
return $wrapper;
325338
}

src/css/components/ui/_sizes-preview.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
align-items: center;
7979
gap: 10px;
8080
margin-bottom: 16px;
81+
max-width: 400px;
82+
flex-wrap: wrap;
8183
}
8284

8385
.cld-ui-input.regular-text {
@@ -93,6 +95,28 @@
9395
margin: 0;
9496
}
9597

98+
// Medium size toggle (between mini and standard)
99+
.cld-input-on-off-control.medium {
100+
width: 25px;
101+
height: 13px;
102+
margin-right: 0;
103+
104+
.cld-input-on-off-control-slider::before {
105+
height: 9px;
106+
width: 9px;
107+
left: 2px;
108+
bottom: 2px;
109+
}
110+
111+
input:checked + .cld-input-on-off-control-slider::before {
112+
transform: translateX(12px);
113+
}
114+
}
115+
116+
.cld-input-on-off-control-label {
117+
font-size: 12px;
118+
}
119+
96120
.button.clear-crop-input {
97121
display: inline-flex;
98122
align-items: center;

0 commit comments

Comments
 (0)