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
[WIP] Separate Foundation Palette #9683
Conversation
…sign the colors to states
I just pulled it .... i am sorry but docs is not working bro .... did you tested your code before pushing ? |
scss/_global.scss
Outdated
success: #3adb76, | ||
warning: #ffae00, | ||
alert: #cc4b37, | ||
$foundation-colors: ( |
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 don't know if _global.scss
is the best place for this. We should rather put it in util/_color.scss
.
Edit: Should it be the same for $foundation-states
?
Also, it makes me think we should separate the utils of Foundation (private variables/mixins/functions) from the utils for the user (real Sass utilities).
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 agree with moving the states as well.
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.
Actually, if we were to move this, the variables would need to be declared in the middle of the file. _global.scss
may be the best place for now.
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.
the variables would need to be declared in the middle of the file
Why ?
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.
The state color assignments are dependent on get-color
which is declared further down the file.
scss/_global.scss
Outdated
@@ -20,35 +20,50 @@ $global-width: rem-calc(1200) !default; | |||
/// @type Number | |||
$global-lineheight: 1.5 !default; | |||
|
|||
/// Colors used for buttons, callouts, links, etc. There must always be a color called `primary`. | |||
/// Colors available by using `get-color()`. |
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.
Please precise that unline the previous get-color
, it these colors should not be used inside components.
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.
@ncoden, can you elaborate on this?
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 mean: Please precise that unlike the previous get-color, these colors (red
, blue
) should not be used inside components, because component should be customizable and rely on any color (so on semantic colors).
scss/_global.scss
Outdated
@if not map-has-key($foundation-palette, primary) { | ||
@error 'In $foundation-palette, you must have a color named "primary".'; | ||
@if not map-has-key($foundation-states, primary) { | ||
@error 'In $foundation-states, you must have a color named "primary".'; |
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.
In $foundation-states, you must have a state color named "primary".
scss/settings/_settings.scss
Outdated
success: #3adb76, | ||
warning: #ffae00, | ||
alert: #cc4b37, | ||
$foundation-colors: ( |
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.
scss/settings/_settings.scss
is automatically generated. You do not have to update it.
scss/util/_color.scss
Outdated
/// @param {key} state key from foundation-states | ||
/// | ||
/// @returns {Color} color from foundation-states | ||
@function get-state($key) { |
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.
You can use @function map-safe-get()
now.
@ncoden, the builds are failing when calling |
@natewiebe13 In Sass, when a called function is not found, it is considered as text. This is the way Sass prevent to execute CSS functions like I agree, that's dirty. So it means you called Did you built Foundation with |
scss/util/_color.scss
Outdated
@@ -4,7 +4,7 @@ | |||
|
|||
@import 'math'; | |||
|
|||
/// Colors available by using `get-color()`. | |||
/// Colors available by using `get-color()`. These should not be used directly within components, variables should be used instead to make components customizable. |
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.
get-state() and settings should be used instead to make components customizable.
Could you update docs and add unit tests ? |
@ncoden, what parts would you like unit tests for? (What should be tested) |
At least for every function you added/modified. So |
test/sass/_color.scss
Outdated
|
||
@include test('Get Color (Blue) [function]') { | ||
$test: get-color('blue'); | ||
$expect: #1779ba; |
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 do not expect always #1779ba
, but only the color for blue from the color map. So please set $foundation-color: (blue: #1779ba);
. Same for get-state
.
test/sass/_color.scss
Outdated
$expect: #1779ba; | ||
$foundation-colors: ('blue': $expect); | ||
$foundation-states: (primary: get-color('blue')); |
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.
Do not rely on other functions within tests. You can simply use $expect
instead of get-color('blue')
here.
Also, I think you must set !global
. Did you run the tests ?
Tagging @DaSchTour for his views, reviews and #9646 ...... |
Well. Now I would just add one additional feature, that allows activating states per component without redeclaration of color and it would be nearly exact what I proposed. |
scss/util/_color.scss
Outdated
/// @param {key} state key from foundation-states | ||
/// | ||
/// @returns {Color} color from foundation-states | ||
@function get-state($key) { |
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 would suggest to make this internal -zf-get-state
and wrap generation of states for components. Otherwise I'm sure this will cause a lot of confusion why get-color(green)
is equal to get-state(primary)
and why both returns a color. Or it should be get-state-color
to be sure, that nobody expects something else than a color.
success: #3adb76, | ||
warning: #ffae00, | ||
alert: #cc4b37, | ||
$foundation-states: ( |
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 would suggest that we don't have to use get-color here but to enforce that colors used here need to be declared in $foundation-colors
this way it is possible to introduce colors "from the side" which may cause confusion, because generated elements suddenly get colors not globally defined.
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.
Can you elaborate here? Do you mean instead of using the get-color function, we would specify the key that would be used for the get-color()
function, then return the value using get-color()
while calling get-state()
?
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.
Exactly
@DaSchTour ...... and dear sir what about Rainbow ( #9608 ) 😈 ? |
@natewiebe13 well, while talking about it and taking a deeper look on this I get that this is getting in the right direction. Still I would suggest a last change, that we reduce to have only |
Hii Guys, While creating Building Blocks if there is anything i have noticed is that there is a social button/icon for every second ( if not every single ) component. Currently within the building blocks same variables are getting used again and again which is a bloat ...so i would suggest defining these variables within the framework .... See Gist Yup you might consider my suggestion as a bloat .... but believe me.... what's happening currently is a much bigger bloat! What's your thoughts @kball @natewiebe13 @DaSchTour ?? |
I think @IamManchanda raises a potentially interesting question... The intent of this PR if I'm understanding correctly is to create a distinct abstraction for the color palette and the choice of which states map to which colors. Does it make sense to take that further, and allow the use of multiple palettes, allowing you to e.g. import palettes, or have different palettes for different portions of a site that are logically separated within the scss? |
@kball I think this could only be achieved in an manageable way if using a map of maps. I think in this case we absolutely should have only one function to retrieve colors. On the other hand maybe there should be only one map with colors, although it might have a lot of them and than a mapping for buttons etc. |
@DaSchTour => Are you relating with your this comment |
@IamManchanda yes and also the following comments. I made several suggestions. |
Hmmn....
|
@joeworkman I think this may lead to a more general form of what you're proposing in emails for foundation/foundation-emails#754 Would be interested in making sure this functionality works for the usecase of having 2 alternate palettes. Joe do you have thoughts on this approach and if something like this would achieve what you're looking for in emails? (cc @tdhartwick @rafibomb) |
@kball In my Foundation for Sites product, I actually implemented this alt color scheme as well. This is where I got the idea for Email. Its been really popular with my community of designers. When I update to use F6 later this year, this was on my list of things to submit a pull request for. |
@DaSchTour Assigning you together with @natewiebe13 As discussed, daniel can you modify the code within this PR ??
but what is more required is external color pallete's (enabled/disabled) .... For building blocks i add all these colors again and again .... |
@natewiebe13 @DaSchTour @IamManchanda It seems like we're trying to do a few things here
Are there any additional constraints I'm missing? Looking through the conversation, it seems like keeping separate maps makes sense... what I'm not sure is if it makes sense to have the indirection from state to color palettes, especially when we start talking about alternate palettes, some arbitrary number of which may be state based. (e.g. imagine having state palette, alternate palette, social media palette, and possibly some accent colors) I may be totally off base here, but lets walk down a thought experiment... The states matter because we use them to generate classes... so what if we instead just have an arbitrary number of palettes, and then we specify which ones create classes and which don't? In pseudocode I'm thinking something like...
We could take this to
Such that when Thoughts? |
Any updates Guys ... I think we should surely get this in for 6.5 ?? Poke @natewiebe13 @DaSchTour |
I have the feeling that we are forgetting and refinding/repeating a lot if ideas we already discussed in the issue: #9671. Please take a look at the piece of code we discussed before, they are already following the 3 points @kball given. |
I think that point 1 and 2 are somehow conflicting. I think we should abandon the concept of state-colors as it always didn't feel right. I think the best would be to have one single point to define colors, a color palette including such things as 'facebook-blue' and than mappings to components. Somethink that tells the button component that it should use facebook-blue for a button with the class facebook. |
You miswritten "custom component state". ;) |
@ncoden well the problem with the term state is, that state is often something that changes and is part of a defined flow which describes the change between different states. I don't see how primary is a state. It's more of a characteristic that is set once and that is constant. |
@DaSchTour I agree with you on this point. In a clear CSS architecture, a Generally in BEM+SMACSS, we use the declaration order to give a modifier ( In our current Beside that, we also need a set of colors we can use (or not) freely inside components, without generating new dedicated classes. So finally, we have "modifier", "state" and "color". We need three maps for each component, inherited from three maps at the global level (see my code examples in #9671), and an unique set of mixins the manage all of this easily without code duplication ! Also, I don't see how @kball's 1st and 2nd points are conflicting. We can add palettes globally or locally (from the config, function parameters...) by merging them into three different kind of internal palette in which we search for colors and states. |
bump @ncoden @DaSchTour @natewiebe13 @IamManchanda anyone interested in picking this back up and carrying it across the finish line? |
@kball I really have no idea which direction this should be carried. There are so many ideas for this topic and all of them somehow feel bad. While working on my current project I also see, that the concept of colors named with color names (blue, red and so on) as used in |
Closing this as old WIP |
Goal: To separate the Foundation palette into having a map that lists possible colors, and a map that assigns a color to a state.
TODO: Update documentation. (This should be done after functionality is finalized)
Fixes: #9671