close
The Wayback Machine - https://web.archive.org/web/20250923093144/https://github.com/simonwep/pickr/commit/6e5d0fef71ea819888e22d1fbfbf1fae6f6c83ea
Skip to content

Commit 6e5d0fe

Browse files
committed
Use css variables for all sorts of color propagation
1 parent 46a8f97 commit 6e5d0fe

File tree

13 files changed

+21
-21
lines changed

13 files changed

+21
-21
lines changed

 1�7dist/pickr.es5.min.js 1�7

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

 1�7dist/pickr.es5.min.js.map 1�7

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

 1�7dist/pickr.min.js 1�7

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

 1�7dist/pickr.min.js.map 1�7

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

 1�7dist/themes/classic.min.css 1�7

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

 1�7dist/themes/monolith.min.css 1�7

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

 1�7dist/themes/nano.min.css 1�7

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

 1�7src/js/pickr.js 1�7

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class Pickr {
300300
} else if (!options.useAsButton && !inst._lastColor) {
301301

302302
// Apply color to both the last and current color since the current state is cleared
303-
lastColor.style.color = cssRGBaString;
303+
lastColor.style.setProperty('--pcr-color', cssRGBaString);
304304
}
305305

306306
// Check if there's a swatch which color matches the current one
@@ -310,7 +310,7 @@ class Pickr {
310310
}
311311

312312
// Change current color
313-
currentColor.style.color = cssRGBaString;
313+
currentColor.style.setProperty('--pcr-color', cssRGBaString);
314314
}
315315
}),
316316

@@ -623,7 +623,7 @@ class Pickr {
623623

624624
// Create new swatch HTMLElement
625625
const el = _.createElementFromString(
626-
`<button type="button" style="color: ${color.toRGBA().toString(0)}" aria-label="${this._t('btn:swatch')}"/>`
626+
`<button type="button" style="--pcr-color: ${color.toRGBA().toString(0)}" aria-label="${this._t('btn:swatch')}"/>`
627627
);
628628

629629
// Append element and save swatch data
@@ -671,11 +671,11 @@ class Pickr {
671671

672672
// Change preview and current color
673673
const cssRGBaString = this._color.toRGBA().toString(0);
674-
preview.lastColor.style.color = cssRGBaString;
674+
preview.lastColor.style.setProperty('--pcr-color', cssRGBaString);
675675

676676
// Change only the button color if it isn't customized
677677
if (!this.options.useAsButton) {
678-
button.style.color = cssRGBaString;
678+
button.style.setProperty('--pcr-color', cssRGBaString);
679679
}
680680

681681
// User changed the color so remove the clear clas

 1�7src/scss/base.scss 1�7

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
height: 100%;
3737
width: 100%;
3838
transition: background 0.3s;
39-
background: currentColor;
39+
background: var(--pcr-color);
4040
border-radius: $border-radius-mid;
4141
}
4242

@@ -48,7 +48,7 @@
4848
}
4949

5050
&:focus {
51-
@include focus(currentColor);
51+
@include focus(var(--pcr-color));
5252
}
5353
}
5454

@@ -71,7 +71,7 @@
7171
button {
7272
&:focus,
7373
&.pcr-active {
74-
@include focus(currentColor);
74+
@include focus(var(--pcr-color));
7575
}
7676
}
7777

@@ -146,7 +146,7 @@
146146
left: 0;
147147
width: 100%;
148148
height: 100%;
149-
background: currentColor;
149+
background: var(--pcr-color);
150150
border: 1px solid rgba(black, 0.05);
151151
border-radius: 0.15em;
152152
box-sizing: border-box;

 1�7src/scss/themes/classic.scss 1�7

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
.pcr-last-color,
3737
.pcr-current-color {
38-
background: currentColor;
38+
background: var(--pcr-color);
3939
width: 100%;
4040
height: 50%;
4141
}

0 commit comments

Comments
 (0)