-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[UI Framework] [K7] Add KuiCallOut and KuiVerticalRhythm components. #13306
[UI Framework] [K7] Add KuiCallOut and KuiVerticalRhythm components. #13306
Conversation
- Add verticalRhythm prop to Typography components. - Add kuiIcon--basic class.
2914894
to
d5508dd
Compare
@@ -80,7 +80,7 @@ export default () => ( | |||
|
|||
<KuiButton | |||
iconReverse | |||
icon="arrowRight" | |||
iconType="arrowRight" |
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.
Let's use this pattern of putting "type" in a prop name when we're passing in a string reference to a type.
.kuiCallOut { | ||
padding: $kuiSizeM $kuiSizeL; | ||
border-left: 4px solid $kuiColorPrimary; | ||
background-color: rgba($kuiColorPrimary, 0.1); /* 1 */ |
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 think we should change our approach here so that components with modifiers require a modifier to take on an appearance. In other words, we'd remove these default values and add an info
definition to $callOutTypes
, below (and do something similar with KuiButton
and KuiIcon
).
I kept running into cascade problems with KuiIcon because of its default fill
, and this approach avoids that problem. It also makes it easier to scan the modifiers and know exactly what kind of use cases a component addresses.
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.
Again, this is where I why I think modifiers should use &.
. Modifiers modify something. Makes perfect sense to use CSS this 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.
It also makes it easier to scan the modifiers and know exactly what kind of use cases a component addresses.
Nesting modifiers to introduce more specificity is definitely an option (which I'm not opposed to), but another benefit of my suggestion is improved maintainability.
export const SIZES = Object.keys(sizeToClassNameMap); | ||
const titleSizeToVerticalRhythmClassNameMap = { | ||
small: 'kuiVerticalRhythm', | ||
large: 'kuiVerticalRhythm--xLarge', |
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.
Weird mappings.
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.
Agree. I don't have a solution, but think this is the best way to "solve" it. Basically that component sizing and CSS global sizing are somewhat distanced to make React components more usable.
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.
Minor changes on the callouts themselves. I can prolly clean it up in a separate PR. Little confused by the margin mixins and the react component. Let's chat it out over zoom.
} | ||
|
||
.kuiCallOutHeader__title { | ||
font-weight: $kuiFontWeightMedium; |
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.
Oh, I actually thought the design had a heavier weight on it. Take a look at these screenshots with the regular weight:
It looks much lighter than the design to my eyes. To be honest, I think the heaver weight improves readability significantly since the text is the same color as the background, just darker.
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 just checked the color contrast, and the colors do fail at both AA and AAA. I'll make the tint/shade change and take another look.
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 like the unbolded fwiw. Doesn't feel like it's screaming at me, which alerts can sometimes feel.
@@ -87,3 +88,7 @@ KuiIcon.propTypes = { | |||
size: PropTypes.oneOf(SIZES), | |||
title: PropTypes.string, | |||
}; | |||
|
|||
KuiIcon.defaultProps = { | |||
className: 'kuiIcon--basic', |
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 ok with this in the React sense and it totally makes sense. I'm a little worried in the HTML/CSS sense where suddenly default settings of css components are "broken". For example, what's the version of this for .kuiButton
? Does that component not usable on its own? Seems so easy to just solve with .kuiIcon.modifier
.
Just something to think about.
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.
Yeah, I was thinking that kuiButton
by itself wouldn't be usable without a modifier. Bootstrap is kind of the same way, in that the default button just looks like a weird link.
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.
If you think it's the right call I'll go with it! We should probably switch buttons then too.
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.
Cool thanks man!
.kuiText--small { | ||
@include kuiFontSizeS; | ||
color: $kuiTextColor; | ||
font-weight: $kuiFontWeightRegular; |
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.
Does font weight need to be on here?
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.
Good catch!
export const SIZES = Object.keys(sizeToClassNameMap); | ||
const titleSizeToVerticalRhythmClassNameMap = { | ||
small: 'kuiVerticalRhythm', | ||
large: 'kuiVerticalRhythm--xLarge', |
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.
Agree. I don't have a solution, but think this is the best way to "solve" it. Basically that component sizing and CSS global sizing are somewhat distanced to make React components more usable.
$kuiLineHeightS: $kuiLineHeight * 0.75; | ||
$kuiLineHeightM: $kuiLineHeight; | ||
$kuiLineHeightL: $kuiLineHeight * 1.5; | ||
$kuiLineHeightXL: $kuiLineHeight * 2; |
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'll need to tweak this stuff separately. Some of it's too fat. I'll do it in another PR.
@@ -0,0 +1,23 @@ | |||
.kuiVerticalRhythm { |
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.
What do these mixins do that the variables themselves don't already provide? When would we ever swap the content inside of them, versus just changing the value of the variable?
As a react component when is it ever a good idea to use <KuiVerticalRhythm size="whatever">
versus just passing it onto the element?
If we did use something like this, it should be called BottomMargin
I think? Vertical Rhythm is most often associated with a holistic system to space bodies of text. It's usually a mix of lots of different values, not just spacing, but size, line-height...etc.
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.
OK, I'll remove the mixins and components for now, and rename the terminology to bottomMargin
.
.kuiCallOut { | ||
padding: $kuiSizeM $kuiSizeL; | ||
border-left: 4px solid $kuiColorPrimary; | ||
background-color: rgba($kuiColorPrimary, 0.1); /* 1 */ |
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'd prefer if we avoid opacity in places where we can use flat values (tintOrShade works perfectly fine here). I know opacity is easy for theming, but I'd like to avoid the render problems that opacity can aggravate. Anything that we can do to help the slowdowns that K6 suffers from (think of the slowness around resizing the discover page) I think we should try to do. tintOrShade also lets us be more specific and apply separate values.
Opacity is great for animations and shadows. If it's just defining a color, lets use a color.
@snide Could you take another look? I'm going to make the change to remove the default component styles for Button and CallOut in a separate PR. I wasn't sure what to rename the vertical rhythm classes in a way that didn't create confusion with the utility classes we have (e.g. I addressed your other feedback and created an additional function for helping us solve color contrast problems. The color contrast level is now AA compliant: |
This looks great man! |
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.
All good.
* Add KuiCallOut component. - Add verticalRhythm prop to Typography components. - Add kuiIcon--basic class.
* Add KuiCallOut component. - Add verticalRhythm prop to Typography components. - Add kuiIcon--basic class.
* Add KuiCallOut component. - Add verticalRhythm prop to Typography components. - Add kuiIcon--basic class.
@snide The only thing I'm not completely happy with is the vertical rhythm system. The sizes map strangely to our typography. Maybe we should rename them to mirror our typographic terms, e.g.
kuiVerticalRhythm--title
. Or maybe we should convert them into typographic modifiers, e.g.kuiTitle--verticalRhythm
.