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

Moved definition of colors in the cookies modal and banner colors to common darkswarm/base/colors #2735

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/assets/stylesheets/darkswarm/base/colors.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
@import 'darkswarm/branding';

$modal-background-color: #efefef;
$modal-content-background-color: #fff;
$modal-alert-link-color: #fff;
$modal-alert-link-hover-color: rgba(255, 255, 255, .7);

$cookies-banner-background-color: $dark-grey;
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 also lost with CSS color vars naming but, does this mean we'll have a var for each of $dark-grey uses we'll have? won't we end up with trillions of single-purpose vars?

Copy link
Member

Choose a reason for hiding this comment

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

@sauloperez Ideally, we'd keep in mind to extract CSS components when possible. For example, there could be just one set of color assignments in one SCSS partial for general styles used in all modals. So maybe not trillions 😉 but a hundred or so variables.

For the cookies banner though, the color assignments are quite unique, so they would be single-purpose.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

you mean having an SCSS file for each new UI component where we assign the palette vars to component vars? looks good 👍 naming colors vars seems like a very difficult problem for me. I'm struggling with my side project 😓

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, the style I suggested, which is also how @luisramos0 did it in this PR, is to assign the palette vars to component vars in a central file. Each component SCSS partial only uses the component vars.

Good luck with your side project! 😟

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
yes, that central file is this colors.scss file.
if it gets to big, we can move some parts to separate files, as you say, for example, modals_colors.scss

The new convention here is that when you set a color in your component scss, you always set it to a variable like in menu.scss:
li a { color: $menu-mobile-li-a-color; }
instead of
li a { color: rgba(0, 0, 0, 0.9); }
or
li a { color: $dark-grey; }

and then you go to colors.scss to assign this variable $menu-mobile-li-a-color = $dark-grey;

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's doc this if the rest of the team agrees.

$cookies-banner-button-background-color: $clr-turquoise;
$cookies-banner-text-color: $white;
$cookies-policy-modal-background-color: $disabled-light;
$cookies-policy-modal-border-bottom-color: $disabled-light;
$cookies-policy-modal-table-tr-even-background-color: $disabled-very-light;
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@import 'darkswarm/branding';
@import 'darkswarm/base/colors';

.cookies-banner {
background: $dark-grey;
background: $cookies-banner-background-color;
bottom: 0;
position: fixed;
top: 15% !important;
z-index: 100000;

button {
background-color: $clr-turquoise;
background-color: $cookies-banner-button-background-color;
}

p {
color: $white;
color: $cookies-banner-text-color;
font-size: .75rem;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@import 'darkswarm/branding';
@import 'darkswarm/base/colors';

.cookies-policy-modal {
background: $disabled-light;
border-bottom-color: $disabled-light;
background: $cookies-policy-modal-background-color;
border-bottom-color: $cookies-policy-modal-border-bottom-color;

table {
width: 100%;

tr:nth-of-type(even) {
background-color: $disabled-very-light;
background-color: $cookies-policy-modal-table-tr-even-background-color;
}

p {
Expand Down