Skip to content
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

Colors moved to variables in SCSS #3026

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
111 changes: 70 additions & 41 deletions sass/chosen.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
$chosen-sprite: url('chosen-sprite.png') !default;
$chosen-sprite-retina: url('chosen-sprite@2x.png') !default;

$chosen-bg-color: #fff;
$chosen-box-shadow-color: #000;
$chosen-border-color: #aaa;
$chosen-group-name-color: #999;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of colors here. I like what you started with clarifying whether a color is background or border or box-shadow or whatever. I think we should keep that going with text colors too, so I'd recommend this be $chosen-group-name-text-color.

$chosen-highlighted-color: #3875d7;
$chosen-highlighted-second-color: #2a62bc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of using two different colors here to represent a gradient. You have gradients in variables below, so why not do the same here. Also, we could clarify that these are background colors. I'd recommend:

$chosen-highlighted-bg-color: #3875d7;
$chosen-highlighted-bg-gradient: linear-gradient(#3875d7 20%, #2a62bc 90%);


$chosen-search-choice-bg-color: #eee;
$chosen-search-choice-disabled-bg-color: #e4e4e4;
$chosen-search-choice-color: #333;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "text" comment here: $chosen-search-choice-text-color

$chosen-search-choice-bg: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend us using the word "gradient" here, and in terms of line ordering, this should be bundled with $chosen-search-choice-bg-color, since those two are next to each other in the css too.

$chosen-search-choice-bg-color: #eee;
$chosen-search-choice-bg-gradient: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);

$chosen-search-choice-disabled-color: #666;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "text" comment here: $chosen-search-choice-disabled-text-color

$chosen-search-choice-focus-bg-color: $chosen-search-choice-disabled-color;
$chosen-search-choice-disabled-border-color: #ccc;
$chosen-no-results-bg: #f4f4f4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other variable names, this should be $chosen-no-results-bg-color


$chosen-color: #222;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "text" comment here: $chosen-text-color

$chosen-border-color: #5897fb;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first actual issue I see in the code. $chosen-border-color is already being defined above. Looking at the CSS, #5897fb is only used when active/focused. So I think this should be $chosen-active-border-color. I see some other active/focused-specific variables, and I think those variables should be grouped together, and have consistent naming.

$chosen-single-color: #444;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "text" comment here: $chosen-single-text-color

$chosen-bg: linear-gradient($chosen-bg-color 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%);
$chosen-single-bg: linear-gradient(#eee 20%, $chosen-bg-color 80%);
$chosen-default-color: $chosen-group-name-color;
$chosen-container-color: $chosen-single-color;
$chosen-container-disabled-color: $chosen-search-choice-disabled-border-color;
$chosen-container-no-results-color: #777;
$chosen-choices-color: #999;
$chosen-choices-bg: linear-gradient($chosen-search-choice-bg-color 1%, $chosen-bg-color 15%);
$chosen-drop-result-selected: $chosen-search-choice-disabled-border-color;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about using a variable inside the definition of another variable. Normally I'd be all for it, but in this case (and a few other cases I see in this file), the variables are completely unrelated. For instance, $chosen-drop-result-selected has absolutely nothing to do with $chosen-search-choice-disabled-border-color (other than being a similar hex color), and by making the former defined by the latter, the code is making the two seem related in some way. I'll let another dev make a call on that (cc @stof)


/* @group Base */
.chosen-container {
position: relative;
Expand All @@ -16,10 +45,10 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
top: 100%;
z-index: 1010;
width: 100%;
border: 1px solid #aaa;
border: 1px solid $chosen-border-color;
border-top: 0;
background: #fff;
box-shadow: 0 4px 5px rgba(#000,.15);
background: $chosen-bg-color;
box-shadow: 0 4px 5px rgba($chosen-box-shadow-color,.15);
clip: rect(0,0,0,0);
clip-path: inset(100% 100%);
}
Expand All @@ -38,7 +67,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
white-space: nowrap;
text-overflow: ellipsis;
font-weight: normal;
color: #999999;
color: $chosen-group-name-color;
&:after {
content: ":";
padding-left: 2px;
Expand All @@ -57,19 +86,19 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
overflow: hidden;
padding: 0 0 0 8px;
height: 25px;
border: 1px solid #aaa;
border: 1px solid $chosen-border-color;
border-radius: 5px;
background-color: #fff;
background: linear-gradient(#fff 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%);
background-color: $chosen-bg-color;
background: $chosen-bg;
background-clip: padding-box;
box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(#000,.1);
color: #444;
box-shadow: 0 0 3px $chosen-bg-color inset, 0 1px 1px rgba($chosen-box-shadow-color,.1);
color: $chosen-single-color;
text-decoration: none;
white-space: nowrap;
line-height: 24px;
}
.chosen-default {
color: #999;
color: $chosen-default-color;
}
.chosen-single span {
display: block;
Expand Down Expand Up @@ -124,7 +153,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
width: 100%;
height: auto;
outline: 0;
border: 1px solid #aaa;
border: 1px solid $chosen-border-color;
background: $chosen-sprite no-repeat 100% -20px;
font-size: 1em;
font-family: sans-serif;
Expand All @@ -147,7 +176,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;

/* @group Results */
.chosen-container .chosen-results {
color: #444;
color: $chosen-container-color;
position: relative;
overflow-x: hidden;
overflow-y: auto;
Expand All @@ -169,18 +198,18 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
}
&.disabled-result {
display: list-item;
color: #ccc;
color: $chosen-container-disabled-color;
cursor: default;
}
&.highlighted {
background-color: #3875d7;
background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
color: #fff;
background-color: $chosen-highlighted-color;
background-image: linear-gradient($chosen-highlighted-color 20%, $chosen-highlighted-second-color 90%);
color: $chosen-bg-color;
}
&.no-results {
color: #777;
color: $chosen-container-no-results-color;
display: list-item;
background: #f4f4f4;
background: $chosen-no-results-bg;
}
&.group-result {
display: list-item;
Expand All @@ -207,9 +236,9 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
padding: 0 5px;
width: 100%;
height: auto;
border: 1px solid #aaa;
background-color: #fff;
background-image: linear-gradient(#eee 1%, #fff 15%);
border: 1px solid $chosen-border-color;
background-color: $chosen-bg-color;
background-image: $chosen-choices-bg;
cursor: text;
}
.chosen-choices li {
Expand All @@ -227,7 +256,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
border: 0 !important;
background: transparent !important;
box-shadow: none;
color: #999;
color: $chosen-choices-color;
font-size: 100%;
font-family: sans-serif;
line-height: normal;
Expand All @@ -239,16 +268,16 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
position: relative;
margin: 3px 5px 3px 0;
padding: 3px 20px 3px 5px;
border: 1px solid #aaa;
border: 1px solid $chosen-border-color;
max-width: 100%;
border-radius: 3px;
background-color: #eeeeee;
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-color: $chosen-search-choice-bg-color;
background-image: $chosen-search-choice-bg;
background-size: 100% 19px;
background-repeat: repeat-x;
background-clip: padding-box;
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(#000,.05);
color: #333;
box-shadow: 0 0 2px $chosen-bg-color inset, 0 1px 0 rgba($chosen-box-shadow-color,.05);
color: $chosen-search-choice-color;
line-height: 13px;
cursor: default;
span {
Expand All @@ -270,13 +299,13 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
}
&.search-choice-disabled {
padding-right: 5px;
border: 1px solid #ccc;
background-color: #e4e4e4;
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
color: #666;
border: 1px solid $chosen-search-choice-disabled-border-color;
background-color: $chosen-search-choice-disabled-bg-color;
background-image: $chosen-search-choice-bg;
color: $chosen-search-choice-disabled-color;
}
&.search-choice-focus {
background: #d4d4d4;
background: $chosen-search-choice-focus-bg-color;
.search-choice-close {
background-position: -42px -10px;
}
Expand All @@ -288,7 +317,7 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
}
.chosen-drop .result-selected {
display: list-item;
color: #ccc;
color: $chosen-drop-result-selected;
cursor: default;
}
}
Expand All @@ -297,18 +326,18 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
/* @group Active */
.chosen-container-active{
.chosen-single {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(#000,.3);
border: 1px solid $chosen-border-color;
box-shadow: 0 0 5px rgba($chosen-box-shadow-color,.3);
}
&.chosen-with-drop{
.chosen-single {
border: 1px solid #aaa;
border: 1px solid $chosen-border-color;
-moz-border-radius-bottomright: 0;
border-bottom-right-radius: 0;
-moz-border-radius-bottomleft: 0;
border-bottom-left-radius: 0;
background-image: linear-gradient(#eee 20%, #fff 80%);
box-shadow: 0 1px 0 #fff inset;
background-image: $chosen-single-bg;
box-shadow: 0 1px 0 $chosen-bg-color inset;
}
.chosen-single div {
border-left: none;
Expand All @@ -319,10 +348,10 @@ $chosen-sprite-retina: url('chosen-sprite@2x.png') !default;
}
}
.chosen-choices {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(#000,.3);
border: 1px solid $chosen-border-color;
box-shadow: 0 0 5px rgba($chosen-box-shadow-color,.3);
li.search-field input[type="text"] {
color: #222 !important;
color: $chosen-color !important;
}
}
}
Expand Down