-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3850 from owid/extract-labeled-switch
🔨 extract `LabeledSwitch` into components library
- Loading branch information
Showing
11 changed files
with
106 additions
and
108 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
packages/@ourworldindata/components/src/LabeledSwitch/LabeledSwitch.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
$dark-text: #5b5b5b; | ||
$light-text: #858585; | ||
$light-fill: #dadada; | ||
$active-fill: #dbe5f0; | ||
|
||
$info-icon: #a1a1a1; | ||
$active-switch: #6e87a2; | ||
|
||
$medium: 400; | ||
$lato: $sans-serif-font-stack; | ||
|
||
// on/off switch with label written to the right | ||
.labeled-switch { | ||
// keep in sync with TableFilterToggle.tsx | ||
// where the width of a labeled switch is calculated | ||
|
||
display: flex; | ||
color: $light-text; | ||
font: $medium 13px/16px $lato; | ||
letter-spacing: 0.01em; | ||
|
||
position: relative; | ||
margin: 8px 0; | ||
-webkit-user-select: none; | ||
user-select: none; | ||
|
||
label { | ||
color: $dark-text; | ||
padding-left: 35px; | ||
white-space: nowrap; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
|
||
svg { | ||
color: $info-icon; | ||
height: 13px; | ||
padding: 0 0.333em; | ||
} | ||
} | ||
|
||
.labeled-switch-subtitle { | ||
// only show subtitle in settings menu, otherwise use icon + tooltip | ||
display: none; | ||
} | ||
|
||
input { | ||
position: absolute; | ||
opacity: 0; | ||
left: 0; | ||
} | ||
|
||
.outer { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
content: " "; | ||
width: 29px; | ||
height: 16px; | ||
background: $light-fill; | ||
border-radius: 8px; | ||
pointer-events: none; | ||
.inner { | ||
position: relative; | ||
content: " "; | ||
width: 10px; | ||
height: 10px; | ||
background: $light-text; | ||
border-radius: 5px; | ||
top: 3px; | ||
left: 3px; | ||
pointer-events: none; | ||
transition: transform 333ms; | ||
} | ||
} | ||
|
||
&:hover { | ||
.outer .inner { | ||
background: $dark-text; | ||
} | ||
} | ||
|
||
input:focus-visible + .outer { | ||
outline: 2px solid $controls-color; | ||
} | ||
|
||
input:checked + .outer { | ||
background: $active-fill; | ||
.inner { | ||
background: $active-switch; | ||
transform: translate(13px, 0); | ||
} | ||
} | ||
&:hover input:checked + .outer .inner { | ||
background: darken($active-switch, 13%); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
packages/@ourworldindata/grapher/src/controls/LabeledSwitch.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/@ourworldindata/grapher/src/controls/settings/NoDataAreaToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/@ourworldindata/grapher/src/controls/settings/ZoomToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters