feat(tile): add tile component - #3229
Conversation
|
Preview: https://patternfly-pr-3229.surge.sh A11y report: https://patternfly-pr-3229-coverage.surge.sh |
|
@mcarrano initial design specs request using all-black variant of logos on default and disabled, then switch to the full-color logo variant on hover and selected, but seeing this implemented with the full-color logo always used, I think that this still provides enough differentiation between the different states and I would support this as well, what do you think (before I approve this) |
maryshak1996
left a comment
There was a problem hiding this comment.
@christiemolloy you'll see I posed a question for Matt as well, but the only thing missing here is that this large stacked title needs to swap to blue for the icon on hover and selected (see here it's black still)

mcarrano
left a comment
There was a problem hiding this comment.
@maryshak1996 I agree with you that allowing the logo to remain full-color in some cases is fine. I can see instances where changing a logotype to all black might to work. I'll defer to you on other issues. But looks good to me.
|
@maryshak1996 I actually saw this in the Marvel mock up so I thought that the larger tiles had a black icon for all states: Also I didn't update the image color on different states, because that would require having that image as a background image, and i think the switch in images would be better solved in React but I can definitely try to achieve that if thats what we still want? |
|
@christiemolloy ahhh my bad there! Looks great now! |
mattnolting
left a comment
There was a problem hiding this comment.
Looking great, left a few comments.
| --pf-c-tile__icon--FontSize: var(--pf-c-tile__title--m-stacked__icon--FontSize); | ||
| --pf-c-tile__icon--Color: var(--pf-c-tile__title--m-stacked__icon--Color); | ||
|
|
||
| &.pf-m-large { |
There was a problem hiding this comment.
Should we use .pf-m-lg or .pf-m-display-lg here?
| --pf-c-tile--disabled__subtext--Color: var(--pf-global--disabled-color--100); | ||
|
|
||
| position: relative; | ||
| display: inline-block; |
There was a problem hiding this comment.
I think I'd use display: inline-grid here, then apply a row-gap. That way, in the future, if we want to use subgrid to manage row height in the title or text when tiles are adjacent, we could do that.
| text-align: center; | ||
| background-color: var(--pf-c-tile--BackgroundColor); | ||
|
|
||
| &::after { |
There was a problem hiding this comment.
| &::after { | |
| &::before { |
We should try to use ::before first before using the ::after pseudo, as ::after always render above the element's content and ::before will naturally render behind content.
| --pf-c-tile__title--m-stacked__icon--m-large--FontSize: var(--pf-global--icon--FontSize--xl); | ||
| --pf-c-tile__title--m-stacked__icon--m-large--Width: var(--pf-c-tile__title--m-stacked__icon--m-large--FontSize); | ||
| --pf-c-tile__title--m-stacked__icon--m-large--Height: var(--pf-c-tile__title--m-stacked__icon--m-large--Width); |
There was a problem hiding this comment.
Probably should use .pf-m-lg or .pf-m-display-lg to conform to existing patterns.
| --pf-c-tile__title--Color: var(--pf-c-tile--disabled__title--Color); | ||
| --pf-c-tile__subtext--Color: var(--pf-c-tile--disabled__subtext--Color); | ||
|
|
||
| &::after { |
There was a problem hiding this comment.
| &::after { | |
| &::before { |
| &::after { | ||
| --pf-c-tile--BorderWidth: var(--pf-c-tile--m-selected--BorderWidth); | ||
| --pf-c-tile--BorderColor: var(--pf-c-tile--m-selected--BorderColor); | ||
| } |
There was a problem hiding this comment.
| &::after { | |
| --pf-c-tile--BorderWidth: var(--pf-c-tile--m-selected--BorderWidth); | |
| --pf-c-tile--BorderColor: var(--pf-c-tile--m-selected--BorderColor); | |
| } | |
| &::before { | |
| --pf-c-tile--before--BorderWidth: var(--pf-c-tile--m-selected--before--BorderWidth); | |
| --pf-c-tile--before--BorderColor: var(--pf-c-tile--m-selected--before--BorderColor); | |
| } |
| --pf-c-tile--BorderColor: var(--pf-global--BorderColor--100); | ||
| --pf-c-tile--BorderWidth: var(--pf-global--BorderWidth--sm); | ||
| --pf-c-tile--BorderRadius: var(--pf-global--BorderRadius--sm); | ||
| --pf-c-tile--hover--BorderColor: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--m-selected--BorderWidth: var(--pf-global--BorderWidth--md); | ||
| --pf-c-tile--m-selected--BorderColor: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--disabled--BackgroundColor: var(--pf-global--disabled-color--300); |
There was a problem hiding this comment.
| --pf-c-tile--BorderColor: var(--pf-global--BorderColor--100); | |
| --pf-c-tile--BorderWidth: var(--pf-global--BorderWidth--sm); | |
| --pf-c-tile--BorderRadius: var(--pf-global--BorderRadius--sm); | |
| --pf-c-tile--hover--BorderColor: var(--pf-global--primary-color--100); | |
| --pf-c-tile--m-selected--BorderWidth: var(--pf-global--BorderWidth--md); | |
| --pf-c-tile--m-selected--BorderColor: var(--pf-global--primary-color--100); | |
| --pf-c-tile--disabled--BackgroundColor: var(--pf-global--disabled-color--300); | |
| --pf-c-tile--before--BorderColor: var(--pf-global--BorderColor--100); | |
| --pf-c-tile--before--BorderWidth: var(--pf-global--BorderWidth--sm); | |
| --pf-c-tile--before--BorderRadius: var(--pf-global--BorderRadius--sm); | |
| --pf-c-tile--hover--before--BorderColor: var(--pf-global--primary-color--100); | |
| --pf-c-tile--m-selected--before--BorderWidth: var(--pf-global--BorderWidth--md); | |
| --pf-c-tile--m-selected--before--BorderColor: var(--pf-global--primary-color--100); | |
| --pf-c-tile--disabled--before--BackgroundColor: var(--pf-global--disabled-color--300); | |
| --pf-c-tile--disabled--before--BorderWidth: 0; |
| &::after { | ||
| --pf-c-tile--BorderColor: var(--pf-c-tile--hover--BorderColor); | ||
| } |
There was a problem hiding this comment.
| &::after { | |
| --pf-c-tile--BorderColor: var(--pf-c-tile--hover--BorderColor); | |
| } | |
| &::before { | |
| --pf-c-tile--before--BorderColor: var(--pf-c-tile--hover--before--BorderColor); | |
| } |
| left: 0; | ||
| content: ""; | ||
| border: var(--pf-c-tile--BorderWidth) solid var(--pf-c-tile--BorderColor); | ||
| border-radius: var(--pf-c-tile--BorderRadius); |
| } | ||
|
|
||
| // stylelint-disable | ||
| &[disabled] { |
There was a problem hiding this comment.
disabled isn't valid on a div - needs to be .pf-m-disabled
| pointer-events: none; | ||
| cursor: not-allowed; | ||
|
|
||
| --pf-c-tile--BackgroundColor: var(--pf-c-tile--disabled--BackgroundColor); |
There was a problem hiding this comment.
can you move the vars to the beginning of the block? We usually list it in the order of vars -> properties -> selectors
| --pf-c-tile__body--Color: var(--pf-c-tile--disabled__body--Color); | ||
|
|
||
| &::before { | ||
| border: 0; |
There was a problem hiding this comment.
you could just set --pf-c-tile--before--BorderWidth: 0; on the disabled (or .pf-m-disabled) selector
| } | ||
|
|
||
| &:hover { | ||
| &::before { |
There was a problem hiding this comment.
do you need this selector? Could you just assign the var under &:hover?
|
|
||
| cursor: pointer; | ||
|
|
||
| --pf-c-tile__title--Color: var(--pf-c-tile--hover__title--Color); |
There was a problem hiding this comment.
can you move the vars to the beginning of the block?
|
|
||
| img { | ||
| width: 100%; | ||
| height: 100%; |
There was a problem hiding this comment.
this can create a skewed image, should be max-width/height, but what if it's an svg? We could just start with supporting icon fonts and react-icons SVGs, which will accept the font-size declaration, then create a follow-up to investigate other image formats.
|
|
||
| .pf-c-tile__header { | ||
| display: flex; | ||
| flex-direction: row; |
There was a problem hiding this comment.
shouldn't need this since it's the default.
| .pf-c-tile__header { | ||
| display: flex; | ||
| flex-direction: row; | ||
| align-items: center; |
There was a problem hiding this comment.
ill need to follow-up with design on this
| &.pf-m-selected, | ||
| &:focus { | ||
| &::before { | ||
| --pf-c-tile--before--BorderWidth: var(--pf-c-tile--before--m-selected--BorderWidth); |
There was a problem hiding this comment.
vars should be title--m-selected--before--
| } | ||
|
|
||
| .pf-c-tile__header.pf-m-stacked .pf-c-tile__icon { | ||
| --pf-c-tile__icon--Color: var(--pf-c-tile--disabled__header--m-stacked__icon--Color); |
There was a problem hiding this comment.
does this need to be set on .pf-c-tile__header.pf-m-stacked .pf-c-tile__icon or could we just set it under .pf-m-disabled as --pf-c-tile__icon--Color: var(--pf-c-tile--m-disabled__header__icon--Color);
| --pf-c-tile--before--BorderWidth: var(--pf-c-tile--m-selected--before--BorderWidth); | ||
| --pf-c-tile--before--BorderColor: var(--pf-c-tile--m-selected--before--BorderColor); | ||
|
|
||
| cursor: pointer; |
There was a problem hiding this comment.
could cursor: pointer just be set on the entire component? The card sets .pf-m-selectable { cursor: pointer; }
| | `.pf-c-tile__body` | `<div>` | Initiates the tile body. | | ||
| | `.pf-m-selected` | `.pf-c-tile` | Modifies the tile for the selected state. | | ||
| | `.pf-m-stacked` | `.pf-c-tile__header` | Modifies the tile header to be stacked vertically. | | ||
| | `.pf-m-display-lg` | `.pf-c-tile` | Modifies the tile to have large display styling. | |
| --pf-c-tile--before--m-selected--BorderWidth: var(--pf-global--BorderWidth--md); | ||
| --pf-c-tile--before--m-selected--BorderColor: var(--pf-global--primary-color--100); |
There was a problem hiding this comment.
| --pf-c-tile--before--m-selected--BorderWidth: var(--pf-global--BorderWidth--md); | |
| --pf-c-tile--before--m-selected--BorderColor: var(--pf-global--primary-color--100); | |
| --pf-c-tile--m-selected--before--BorderWidth: var(--pf-global--BorderWidth--md); | |
| --pf-c-tile--m-selected--before--BorderColor: var(--pf-global--primary-color--100); |
| --pf-c-tile__title--Color: var(--pf-global--Color--100); | ||
| --pf-c-tile--hover__title--Color: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--m-selected__title--Color: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--disabled__title--Color: var(--pf-global--disabled-color--100); |
There was a problem hiding this comment.
| --pf-c-tile--disabled__title--Color: var(--pf-global--disabled-color--100); | |
| --pf-c-tile--m-disabled__title--Color: var(--pf-global--disabled-color--100); |
| --pf-c-tile__header--m-stacked__icon--Color: var(--pf-global--Color--100); | ||
| --pf-c-tile--hover__header--m-stacked__icon--Color: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--m-selected__header--m-stacked__icon--Color: var(--pf-global--primary-color--100); | ||
| --pf-c-tile--disabled__header--m-stacked__icon--Color: var(--pf-global--Color--200); |
There was a problem hiding this comment.
| --pf-c-tile--disabled__header--m-stacked__icon--Color: var(--pf-global--Color--200); | |
| --pf-c-tile--m-disabled__header--m-stacked__icon--Color: var(--pf-global--Color--200); |
| // body | ||
| --pf-c-tile__body--Color: var(--pf-global--Color--100); | ||
| --pf-c-tile__body--FontSize: var(--pf-global--FontSize--xs); | ||
| --pf-c-tile--disabled__body--Color: var(--pf-global--disabled-color--100); |
There was a problem hiding this comment.
| --pf-c-tile--disabled__body--Color: var(--pf-global--disabled-color--100); | |
| --pf-c-tile--m-disabled__body--Color: var(--pf-global--disabled-color--100); |
| pointer-events: none; | ||
| cursor: not-allowed; | ||
|
|
||
| --pf-c-tile--BackgroundColor: var(--pf-c-tile--disabled--BackgroundColor); |
There was a problem hiding this comment.
| --pf-c-tile--BackgroundColor: var(--pf-c-tile--disabled--BackgroundColor); | |
| --pf-c-tile--BackgroundColor: var(--pf-c-tile--m-disabled--BackgroundColor); |
| --pf-c-tile__title--Color: var(--pf-c-tile--disabled__title--Color); | ||
| --pf-c-tile__body--Color: var(--pf-c-tile--disabled__body--Color); |
There was a problem hiding this comment.
| --pf-c-tile__title--Color: var(--pf-c-tile--disabled__title--Color); | |
| --pf-c-tile__body--Color: var(--pf-c-tile--disabled__body--Color); | |
| --pf-c-tile__title--Color: var(--pf-c-tile--m-disabled__title--Color); | |
| --pf-c-tile__body--Color: var(--pf-c-tile--m-disabled__body--Color); |
| } | ||
|
|
||
| .pf-c-tile__header.pf-m-stacked .pf-c-tile__icon { | ||
| --pf-c-tile__icon--Color: var(--pf-c-tile--disabled__header--m-stacked__icon--Color); |
There was a problem hiding this comment.
| --pf-c-tile__icon--Color: var(--pf-c-tile--disabled__header--m-stacked__icon--Color); | |
| --pf-c-tile__icon--Color: var(--pf-c-tile--m-disabled__header--m-stacked__icon--Color); |
| flex-direction: column; | ||
| justify-content: initial; | ||
|
|
||
| .pf-c-tile__icon { |
There was a problem hiding this comment.
Should you use the same pattern we use w/button in pf-m-start/end?
There was a problem hiding this comment.
I think design only calls for it to be on the left
| --pf-c-tile__icon--Color: var(--pf-c-tile__header--m-stacked__icon--Color); | ||
|
|
||
| display: flex; | ||
| justify-content: center; |
There was a problem hiding this comment.
you probably want to add align-items: center; here, or at least on the display-lg.stacked icon selector since that has a defined height and the image may be shorter than the height
| --pf-c-tile__title--Color: var(--pf-c-tile--m-disabled__title--Color); | ||
| --pf-c-tile__body--Color: var(--pf-c-tile--m-disabled__body--Color); | ||
| --pf-c-tile--before--BorderWidth: 0; | ||
| --pf-c-tile__icon--Color: var(--pf-c-tile--m-disabled__header--m-stacked__icon--Color); |
There was a problem hiding this comment.
could this be renamed?
| --pf-c-tile__icon--Color: var(--pf-c-tile--m-disabled__header--m-stacked__icon--Color); | |
| --pf-c-tile__icon--Color: var(--pf-c-tile--m-disabled__icon--Color); |
mattnolting
left a comment
There was a problem hiding this comment.
It's pretty much perfect!




closes #3100