Skip to content

Commit 1e0cc8b

Browse files
committed
Improve UX of activation switch.
1 parent fefdaf2 commit 1e0cc8b

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

src/css/common/_switch.scss

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
@use 'theme';
22

3+
$off-color: #789;
4+
35
.snippet-execution-button,
46
.snippet-activation-switch,
5-
input[type="checkbox"].switch {
7+
input[type='checkbox'].switch {
68
display: block;
79
position: relative;
810
}
911

1012
.snippet-activation-switch,
11-
input[type="checkbox"].switch {
13+
input[type='checkbox'].switch {
1214
appearance: none;
1315
outline: 0;
1416
cursor: pointer;
@@ -17,23 +19,23 @@ input[type="checkbox"].switch {
1719
block-size: 19px;
1820
border-radius: 34px;
1921
text-align: start;
20-
border: 1px solid theme.$accent;
22+
border: 1px solid $off-color;
2123
box-sizing: border-box;
2224

2325
&::before {
24-
transition: all .4s;
26+
transition: all .1s;
2527
content: '';
2628
block-size: 13px;
2729
inline-size: 13px;
2830
display: inline-block;
29-
background-color: theme.$accent;
31+
background-color: $off-color;
3032
border-radius: 50%;
3133
margin: 2px;
3234
}
3335
}
3436

3537
.active-snippet .snippet-activation-switch,
36-
input[type="checkbox"].switch:checked {
38+
input[type='checkbox'].switch:checked {
3739
background-color: #0073aa;
3840

3941
&::before {

src/css/edit/_sidebar.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ p.submit {
102102
padding-block-start: 0;
103103
}
104104

105+
.activation-switch-container label {
106+
display: flex;
107+
flex-flow: row;
108+
gap: 5px;
109+
justify-content: center;
110+
}
111+
105112
.shortcode-tag-wrapper {
106113
background: #fff;
107114
min-block-size: 54px;

src/js/components/EditorSidebar/actions/ShortcodeInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const ShortcodeInfo: React.FC = () => {
131131
? <div className="inline-form-field">
132132
<h4>{__('Shortcode', 'code-snippets')}</h4>
133133
<Button onClick={() => setIsModalOpen(true)} disabled={isReadOnly}>
134-
{__('See Options', 'code-snippets')}
134+
{__('See options', 'code-snippets')}
135135
</Button>
136136

137137
{isModalOpen

src/js/components/EditorSidebar/controls/ActivationSwitch.tsx

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,29 @@ export const ActivationSwitch = () => {
99
const { submitSnippet } = useSubmitSnippet()
1010

1111
return (
12-
<div className="inline-form-field">
13-
<h4>
14-
<label htmlFor="activation-switch">
15-
{snippet.active
16-
? __('Deactivate snippet', 'code-snippets')
17-
: __('Activate snippet', 'code-snippets')}
18-
</label>
19-
</h4>
12+
<div className="inline-form-field activation-switch-container">
13+
<h4>{__('Status')}</h4>
2014

21-
<input
22-
id="activation-switch"
23-
type="checkbox"
24-
checked={snippet.active}
25-
disabled={isWorking || !!snippet.shared_network}
26-
className="switch"
27-
title={snippet.active
28-
? __('Deactivate', 'code-snippets')
29-
: __('Activate', 'code-snippets')}
30-
onChange={() => {
31-
submitSnippet(snippet.active
32-
? SubmitSnippetAction.SAVE_AND_DEACTIVATE
33-
: SubmitSnippetAction.SAVE_AND_ACTIVATE)
34-
.then(() => undefined)
35-
.catch(handleUnknownError)
36-
}}
37-
/>
15+
<label>
16+
{snippet.active
17+
? __('Active', 'code-snippets')
18+
: __('Inactive', 'code-snippets')}
19+
20+
<input
21+
id="activation-switch"
22+
type="checkbox"
23+
checked={snippet.active}
24+
disabled={isWorking || !!snippet.shared_network}
25+
className="switch"
26+
onChange={() => {
27+
submitSnippet(snippet.active
28+
? SubmitSnippetAction.SAVE_AND_DEACTIVATE
29+
: SubmitSnippetAction.SAVE_AND_ACTIVATE)
30+
.then(() => undefined)
31+
.catch(handleUnknownError)
32+
}}
33+
/>
34+
</label>
3835
</div>
3936
)
4037
}

0 commit comments

Comments
 (0)