-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Card: Improving styling and adding compact Card styling and examples #8247
Conversation
packages/react-cards/src/components/Card/CardItem/CardItem.types.ts
Outdated
Show resolved
Hide resolved
packages/react-cards/src/components/Card/CardItem/CardItem.types.ts
Outdated
Show resolved
Hide resolved
</Card> | ||
|
||
<Card compact={true} gap={12} tokens={{ padding: 12 }} onClick={alertClicked}> | ||
<Card.Item tokens={{ margin: '-12px 0 -12px -12px' }}> |
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.
Not for change now, but I would like to see no hardcoded gap sizes or paddings in any of the docs.
Allowing or encouraging hardcoded sizes like this in the code I think will have some bad consequences. People will have opinions which will create inconsistency.
It also makes the implementation messy.
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 removed both gap
and padding
hardcoded sizes for the Card
usage in the examples. Sadly, I didn't remove the margins
in Card.Item
because it would break some inner styling right now.
packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.styles.ts
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.styles.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Defines the spacing between Card children. | ||
*/ | ||
gap?: number | string; |
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.
David and I have talked previously about how this is something that should be accessible via theming. This is fairly awkward to have to specify as a standalone prop in every component instance. I wonder if gap
is actually a token
idea that needs a better name. Maybe contentPadding
? Hmmmmmmm......
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.
Should we consider this as part of this PR or does this need further discussion? In any case, if we actually change gap
to something else we will have to consider that changing gap
in Stack
is a breaking change.
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.
Is react-cards still in experimental state? If not, I'd rather consider this as part of this PR rather than set gap
in stone for Card.
Regarding Stack, I don't think it would have to be a breaking change. Could we not support both and deprecate gap
?
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 can do it in this PR, I was just asking. And yeah, I suppose we can deprecate gap
and support the other approach.
Do you want contentPadding
to be the token name? Or should we do more brainstorming on the name?
@kkjeer , looks like this still needs your approval as a code owner; can you take a look at your earliest convenience please? |
Just pinged @khmakoto on this, he's still adding changes to the PR, but will merge when ready. |
@@ -84,6 +84,7 @@ export interface IStackProps | |||
* Defines the spacing between Stack children. | |||
* The property is specified as a value for 'row gap', followed optionally by a value for 'column gap'. | |||
* If 'column gap' is omitted, it's set to the same value as 'row gap'. | |||
* @deprecated Use `childrenGap` token instead. |
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 should add a warnDeprecations
call for this too. I'm not sure how difficult that is since we're not using BaseComponent
, but maybe there's an underlying utility function we can call directly...
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.
<Stack horizontal disableShrink horizontalAlign="space-between"> | ||
<Stack> | ||
<span>Numerical spacing</span> | ||
<Stack horizontal className={styles.root} gap={10} padding={10}> | ||
<Stack horizontal className={styles.root} tokens={tokens.numericalSpacing} padding={10}> |
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's still a lot of duplication going on. Once we get extendsComponent
in we can do something like:
const NumberStack = extendComponent(Stack, { horizontal: true, styles: { }, padding: 10, tokens: { childrenGap: 10 } });
Then just use:
<NumberStack>
<span>1</span>
<span>2</span>
<span>3</span>
</NumberStack>
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 can improve this further and remove duplication once we have extendComponent
.
@@ -18,9 +15,17 @@ module.exports = resources.createServeConfig({ | |||
|
|||
resolve: { | |||
alias: { | |||
'@uifabric/example-app-base$': path.join(__dirname, '../../packages/example-app-base/src'), |
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.
These should probably use path.resolve not path.join.
🎉 Handy links: |
🎉 Handy links: |
🎉 Handy links: |
🎉 Handy links: |
🎉 Handy links: |
Pull request checklist
$ npm run change
Description of changes
This PR improves styling in the
Card
component by aligning it closer to the examples shown by design. It also adds styling for compactCards
and adds an example of it to the component page. Finally, this PR also adds a basic and a compactCard
with no content in it aside from text to show that the component refers to the container and not its inner components.Focus areas to test
(optional)
Microsoft Reviewers: Open in CodeFlow