-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add component primitives for the toggle switch component #309
Conversation
🦋 Changeset detectedLatest commit: 6fb5edd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/primer/primitives/EYyXmwb6pqPEejbxWVz58yuoLwQt |
Variables changed--- base/dist/scss/colors/_dark.scss 2022-03-21 17:48:44.087944166 +0000
+++ dist/scss/colors/_dark.scss 2022-03-21 17:48:33.667804850 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #ff7b72;
+ --color-switch-track-bg: #010409;
+ --color-switch-track-border: #6e7681;
+ --color-switch-track-checked-bg: rgba(31,111,235,0.35);
+ --color-switch-track-checked-hover-bg: rgba(31,111,235,0.5);
+ --color-switch-track-checked-active-bg: rgba(31,111,235,0.65);
+ --color-switch-track-checked-border: #58a6ff;
+ --color-switch-knob-checked-bg: #1f6feb;
+ --color-switch-knob-checked-disabled-bg: #484f58;
--color-fg-default: #c9d1d9;
--- base/dist/scss/colors/_dark_colorblind.scss 2022-03-21 17:48:44.107944417 +0000
+++ dist/scss/colors/_dark_colorblind.scss 2022-03-21 17:48:33.687805140 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #ec8e2c;
+ --color-switch-track-bg: #010409;
+ --color-switch-track-border: #6e7681;
+ --color-switch-track-checked-bg: rgba(31,111,235,0.35);
+ --color-switch-track-checked-hover-bg: rgba(31,111,235,0.5);
+ --color-switch-track-checked-active-bg: rgba(31,111,235,0.65);
+ --color-switch-track-checked-border: #58a6ff;
+ --color-switch-knob-checked-bg: #1f6feb;
+ --color-switch-knob-checked-disabled-bg: #484f58;
--color-fg-default: #c9d1d9;
--- base/dist/scss/colors/_dark_dimmed.scss 2022-03-21 17:48:44.095944267 +0000
+++ dist/scss/colors/_dark_dimmed.scss 2022-03-21 17:48:33.675804966 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #f47067;
+ --color-switch-track-bg: #1c2128;
+ --color-switch-track-border: #636e7b;
+ --color-switch-track-checked-bg: rgba(49,109,202,0.35);
+ --color-switch-track-checked-hover-bg: rgba(49,109,202,0.5);
+ --color-switch-track-checked-active-bg: rgba(49,109,202,0.65);
+ --color-switch-track-checked-border: #539bf5;
+ --color-switch-knob-checked-bg: #316dca;
+ --color-switch-knob-checked-disabled-bg: #545d68;
--color-fg-default: #adbac7;
--- base/dist/scss/colors/_dark_high_contrast.scss 2022-03-21 17:48:44.099944317 +0000
+++ dist/scss/colors/_dark_high_contrast.scss 2022-03-21 17:48:33.683805082 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #0a0c10;
+ --color-switch-track-bg: #010409;
+ --color-switch-track-border: #7a828e;
+ --color-switch-track-checked-bg: rgba(64,158,255,0.35);
+ --color-switch-track-checked-hover-bg: rgba(64,158,255,0.5);
+ --color-switch-track-checked-active-bg: rgba(64,158,255,0.65);
+ --color-switch-track-checked-border: #409eff;
+ --color-switch-knob-checked-bg: #409eff;
+ --color-switch-knob-checked-disabled-bg: #7a828e;
--color-fg-default: #f0f3f6;
--- base/dist/scss/colors/_light.scss 2022-03-21 17:48:44.063943864 +0000
+++ dist/scss/colors/_light.scss 2022-03-21 17:48:33.643804502 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #cf222e;
+ --color-switch-track-bg: #eaeef2;
+ --color-switch-track-border: #afb8c1;
+ --color-switch-track-checked-bg: #ddf4ff;
+ --color-switch-track-checked-hover-bg: #b6e3ff;
+ --color-switch-track-checked-active-bg: #80ccff;
+ --color-switch-track-checked-border: #54aeff;
+ --color-switch-knob-checked-bg: #0969da;
+ --color-switch-knob-checked-disabled-bg: #6e7781;
--color-fg-default: #24292f;
--- base/dist/scss/colors/_light_colorblind.scss 2022-03-21 17:48:44.083944116 +0000
+++ dist/scss/colors/_light_colorblind.scss 2022-03-21 17:48:33.663804792 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #b35900;
+ --color-switch-track-bg: #eaeef2;
+ --color-switch-track-border: #afb8c1;
+ --color-switch-track-checked-bg: #ddf4ff;
+ --color-switch-track-checked-hover-bg: #b6e3ff;
+ --color-switch-track-checked-active-bg: #80ccff;
+ --color-switch-track-checked-border: #54aeff;
+ --color-switch-knob-checked-bg: #0969da;
+ --color-switch-knob-checked-disabled-bg: #6e7781;
--color-fg-default: #24292f;
--- base/dist/scss/colors/_light_high_contrast.scss 2022-03-21 17:48:44.075944015 +0000
+++ dist/scss/colors/_light_high_contrast.scss 2022-03-21 17:48:33.651804618 +0000
@@ -272,2 +272,10 @@
--color-action-list-item-danger-hover-text: #ffffff;
+ --color-switch-track-bg: #ffffff;
+ --color-switch-track-border: #20252C;
+ --color-switch-track-checked-bg: #dff7ff;
+ --color-switch-track-checked-hover-bg: #9cd7ff;
+ --color-switch-track-checked-active-bg: #67b3fd;
+ --color-switch-track-checked-border: #0349b4;
+ --color-switch-knob-checked-bg: #0349b4;
+ --color-switch-knob-checked-disabled-bg: #66707B;
--color-fg-default: #0E1116; |
} | ||
}, | ||
|
||
switchKnob: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: How do we decide the nesting structure in primitives, are there any rules/ADRs around it?
switch: {
track: {},
knob: {}
}
vs
switchTrack: {},
switchKnob: {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not aware of any rules around this. I considered nesting switch.track
and switch.knob
too, but decided to keep it flatter.
I don't feel strongly either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have rules for the new tokens + future color tokens 😄 since there are no rules or guidelines right now, I don't think we need to be strict about naming conventions with color. We'll have some cleanup to do in the future!
} | ||
}, | ||
|
||
switchKnob: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have rules for the new tokens + future color tokens 😄 since there are no rules or guidelines right now, I don't think we need to be strict about naming conventions with color. We'll have some cleanup to do in the future!
|
||
switchTrack: { | ||
bg: get('scale.black'), | ||
border: get('scale.gray.4'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this new border color one that we want to share with all form controls? Like input
and select
? Thinking about the contrast ratio for our standard input
border..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that context! That makes sense to me as well. If you add a more generic token now without actually rolling it out to more form components or documenting it, I could see that being confusing for folks utilizing tokens in other apps. Renaming and re-mapping tokens later isn't a huge lift 😄
Will be used for this primer/react PR