Skip to content

Commit ed022fd

Browse files
committed
Tokenize toggle style, so it can be easily overridden
1 parent a32ff81 commit ed022fd

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.64.10 (2024-03-15)
2+
3+
### Improvements
4+
5+
- **Toggle**: tokenize toggle style, so it can be easily overridden
6+
17
# 2.64.9 (2024-03-11)
28

39
### Improvements

projects/pastanaga-angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@guillotinaweb/pastanaga-angular",
33
"description": "Provides Pastanaga UI elements as Angular components",
4-
"version": "2.64.9",
4+
"version": "2.64.10",
55
"license": "MIT",
66
"keywords": [
77
"angular",

projects/pastanaga-angular/src/lib/controls/toggles/toggle/toggle.component.scss

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
@use 'sass:math';
22
@import '../../../../styles/variables';
33

4-
$toggle-full-width: rhythm(6);
5-
$toggle-full-mid-width: math.div($toggle-full-width, 2);
6-
$toggle-full-height: rhythm(3);
7-
$toggle-slider-padding: rhythm(0.25);
4+
$toggle-mid-width: math.div($width-toggle, 2);
85
$toggle-transition-duration: $duration-fast;
96

107
.pa-field {
@@ -52,9 +49,9 @@ $toggle-transition-duration: $duration-fast;
5249

5350
.pa-toggle-container {
5451
position: relative;
55-
width: $toggle-full-width;
56-
min-width: $toggle-full-width;
57-
height: $toggle-full-height;
52+
width: $width-toggle;
53+
min-width: $width-toggle;
54+
height: $height-toggle;
5855
box-sizing: border-box;
5956

6057
input {
@@ -63,8 +60,8 @@ $toggle-transition-duration: $duration-fast;
6360
}
6461

6562
.pa-toggle-checkbox {
66-
width: $toggle-full-width;
67-
height: $toggle-full-height;
63+
width: $width-toggle;
64+
height: $height-toggle;
6865
opacity: 0;
6966
}
7067
.pa-toggle-slider {
@@ -74,28 +71,28 @@ $toggle-transition-duration: $duration-fast;
7471
bottom: 0;
7572
left: 0;
7673
transition: $toggle-transition-duration;
77-
border-radius: $toggle-full-height;
78-
background: $color-neutral-lighter;
74+
border-radius: $height-toggle;
75+
background: $color-background-toggle-slider;
7976
cursor: pointer;
8077
&:before {
8178
content: '';
8279
position: absolute;
8380
border-radius: 50%;
8481
transition: $toggle-transition-duration;
85-
top: $toggle-slider-padding;
86-
right: $toggle-full-mid-width + $toggle-slider-padding;
87-
bottom: $toggle-slider-padding;
88-
left: $toggle-slider-padding;
82+
top: $padding-toggle-slider;
83+
right: $toggle-mid-width + $padding-toggle-slider;
84+
bottom: $padding-toggle-slider;
85+
left: $padding-toggle-slider;
8986
box-shadow: 0 rhythm(0.25) rhythm(0.5) rgba(0, 0, 0, 0.15);
90-
background-color: $color-light-stronger;
87+
background-color: $color-background-toggle-button;
9188
}
9289
}
9390

9491
&.pa-checked {
9592
.pa-toggle-slider {
96-
background: $color-primary-regular;
93+
background: $color-background-toggle-slider-selected;
9794
&:before {
98-
transform: translateX($toggle-full-mid-width);
95+
transform: translateX($toggle-mid-width);
9996
}
10097
}
10198
}
@@ -107,9 +104,9 @@ $toggle-transition-duration: $duration-fast;
107104
&.pa-disable {
108105
.pa-toggle-slider {
109106
cursor: default;
110-
background: $color-neutral-light;
107+
background: $color-background-toggle-slider-disabled;
111108
&:before {
112-
background-color: $color-neutral-lighter;
109+
background-color: $color-background-toggle-button-disabled;
113110
}
114111
}
115112
}

projects/pastanaga-angular/src/styles/theme/_toggle.tokens.scss

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
// COLORS
77
//=====================================
88

9-
// Background
9+
// Background checkbox/radio
1010
$color-background-toggle-selected: $color-primary-regular !default;
1111
$color-background-toggle-selected-hover: $color-primary-strong !default;
1212
$color-background-toggle-disabled: $color-neutral-lightest !default;
1313
$color-background-toggle-unselected-disabled: $color-neutral-lightest !default;
1414

15+
// Background toggle
16+
$color-background-toggle-button: $color-light-stronger !default;
17+
$color-background-toggle-slider: $color-neutral-lighter !default;
18+
$color-background-toggle-slider-selected: $color-primary-regular !default;
19+
$color-background-toggle-slider-disabled: $color-neutral-light !default;
20+
$color-background-toggle-button-disabled: $color-neutral-lighter !default;
21+
1522
// Border
1623
$color-border-toggle-selected: $color-background-toggle-selected !default;
1724
$color-border-toggle-selected-hover: $color-background-toggle-selected-hover !default;
@@ -31,6 +38,10 @@ $color-check-toggle-disabled: $color-neutral-light !default;
3138
$size-toggle-checkbox: calc(#{rhythm(2)} - #{rhythm(0.25)}) !default;
3239
$gap-radio-group: rhythm(1) !default;
3340

41+
$height-toggle: rhythm(3) !default;
42+
$width-toggle: rhythm(6) !default;
43+
$padding-toggle-slider: rhythm(0.25) !default;
44+
3445
//=====================================
3546
// TYPOGRAPHY
3647
//=====================================

0 commit comments

Comments
 (0)