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

Sass guidelines #1257

Merged
merged 27 commits into from
Oct 31, 2018
Merged

Sass guidelines #1257

merged 27 commits into from
Oct 31, 2018

Conversation

snide
Copy link
Contributor

@snide snide commented Oct 23, 2018

Summary

Adds guidelines for our Sass layer with some examples of what the output is.

image

Checklist

- [ ] This was checked in mobile
- [ ] This was checked in IE11
- [ ] This was checked in dark mode Has a similar issue to color guidelines where the colors don't appear correctly with theme.
- [ ] Any props added have proper autodocs

  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
    - [ ] This was checked for breaking changes and labeled appropriately
    - [ ] Jest tests were updated or added to match the most common scenarios
    - [ ] This was checked against keyboard-only and screenreader scenarios

@snide snide force-pushed the guidelines/sass branch 2 times, most recently from 8a9e56a to a8ffb2a Compare October 25, 2018 23:49
<EuiDescriptionList>
<EuiDescriptionListTitle>
<EuiDescriptionList compressed>
<EuiDescriptionListTitle className="guidelineColor__title">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a small fix for the tooltip popup on the color page while i was in the guidelines.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

The main thing that bugs me about the presentation of this section is that you have to hover to see the namings of the combinations. I'd really like to see the "Text" actually say the color name and then put a header before each section with the background color name and just leave the tooltip to show the contrast level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prolly outside the scope of this PR, but if you want to give it a shot, go for it.

@@ -51,3 +51,9 @@ $fractions: (
}
}
}
@include euiBreakpoint('xs','s') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noticed a bug where the negative margins from EuiFlexGrid was messing up mobile.

@@ -43,7 +43,7 @@ $euiColorVis9: #920000 !default;

// Code

$euiCodeBlockBackgroundColor: $euiColorLightestShade !default;
$euiCodeBlockBackgroundColor: rgba(0,0,0,.05) !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved our code background color to an opacity. It fixes the issue where these things showed up ugly on things like callouts.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that enough and does it work in dark mode?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or in a tooltip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but i'll fix. I think I'll just remove this from the PR so it can be tackled separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I had a solution for this with opacities, but it was a little hacky. I'm instead reverting the color change so I can merge this (but keeping some of the more general bugs we had with inline code in EuiText). I'll discuss my hacky solution with you another time. :)

@@ -0,0 +1,712 @@
import React from 'react';
import lightColors from '!!sass-vars-to-js-loader?preserveKeys=true!../../../../src/global_styling/variables/_colors.scss';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chandlerprall Is there any way I can get the theme context in the lower level pages. To make this stuff work in dark mode I'd need to know what theme this page is viewing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This issue is the same problem as #605 so I'm going to leave it for now. We can address it in a later PR.

@snide
Copy link
Contributor Author

snide commented Oct 29, 2018

@daveyholler and @ryankeairns ^^ do you mind taking a look at this from a content perspective? This kind of doc is aimed at people who are writing Sass but not super familiar with what all the variables and mixins are.

Hopefully this should make clear the following.

  1. How to format and namespace your Sass.
  2. How light dark theming works
  3. Some color functions available for contrast and theming
  4. The variables and mixins needed for the global scope

If there's anything you have questions on, ask them, and I'll make sure to include it.

@daveyholler
Copy link
Contributor

@snide Here are my suggestions:

  • Give some overview as to how to use sizing
    • Should we avoid using pixel values wherever possible?
    • Are they based on rems
  • Grammar error in second paragraph on Theming patterns
    • ... traditional color function functions don't give enough...
  • I'm not sure what the graphic for Shadows hide overflowing content is conveying 😁
  • Maybe some explanation on when to and when not to use colors on shadows?
  • I'd recommend a link to the BEM principal for the uninitiated

@ryankeairns
Copy link
Contributor

ryankeairns commented Oct 29, 2018

  • In the comment above the tintOrShade function, describe what the parameters of the function are // tintOrShade(color, tint value, shade value) will tint...

@ryankeairns
Copy link
Contributor

ryankeairns commented Oct 29, 2018

The example callouts appear to use $euiColorPrimary, but this code block says $euiColorSecondary :

.themedBox {
  background-color: tintOrShade($euiColorSecondary, 90%, 70%);
  border-left: $euiBorderThick;
  border-color: $euiColorSecondary;
  padding: $euiSize;
  color: $euiTextColor;
}```

@ryankeairns
Copy link
Contributor

Where it shows the two different values for $euiColorPrimary, is that telling me that the two values happen automatically based upon the current theme or that I have to use the tintOrShade mixin to achieve that result? (I think it happens automatically and all I need to do is use $euiPrimaryColor, but this made me feel less sure)

@ryankeairns
Copy link
Contributor

ryankeairns commented Oct 29, 2018

It might be helpful to denote which of these is the default text color... is it $euiTextColor or $euiColorDarkShade? Simply adding (default) after the color variable name would do the trick.

Text colors
$euiTextColor
$euiColorDarkShade
$euiLinkColor

Same for the text sizes, which of these is the default/base K7 font size? is it $euiFontSize ?

@ryankeairns
Copy link
Contributor

ryankeairns commented Oct 29, 2018

Misspell on the variable name here (missing the 'k'):
Breakpoints in EUI are provided through the use of a sass mixin @include euiBreapoint() that accepts an array of sizes

@ryankeairns
Copy link
Contributor

Should this be Target tablets and up not just tablet only? The word only made me think it targeted a fixed range between two pixel widths (which I don't think is the case):

Target tablets only

@include euiBreakpoint('m') {...}

@ryankeairns
Copy link
Contributor

Perhaps toss the border variables into this bullet list? It's the only section of this page not reflected in the bullet points :)

Writing Sass the EUI way
In general, when writing new SCSS in a project that installs EUI as a dependency ry to follow these best practices:

- Utilize color variables and functions rather than hard-coded values
- Utilize the sizing variables for padding and margins
- Utilize the animation variables for animations when possible
- Utilize the responsive mixins for all screen width calculations
- Utilize the typography mixins and variables for all font family, weight and sizing
- Utilize the shadow mixins and z-index variables to manage depth
- Minimize your overwrites and try to make new Sass additive in nature

@ryankeairns
Copy link
Contributor

This is really helpful, thanks for putting it together. This will save me from searching through code in VSCode for the actual values!

@snide
Copy link
Contributor Author

snide commented Oct 30, 2018

Should this be Target tablets and up not just tablet only? The word only made me think it targeted a fixed range between two pixel widths (which I don't think is the case):

Target tablets only

@include euiBreakpoint('m') {...}

It is the case!

@snide snide changed the title [WIP] Sass guidelines Sass guidelines Oct 31, 2018
@snide
Copy link
Contributor Author

snide commented Oct 31, 2018

OK. Feedback addressed. Gonna wait to merge till morning. Think there might be something goofy going on with the yarn.lock file and wanna consult with @chandlerprall

@snide snide merged commit 8902d68 into elastic:master Oct 31, 2018
@snide snide deleted the guidelines/sass branch October 31, 2018 20:11
@snide
Copy link
Contributor Author

snide commented Oct 31, 2018

@chandlerprall did a check on this. merging down now that feedback is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants