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

Card: Improving styling and adding compact Card styling and examples #8247

Merged
merged 39 commits into from
Mar 29, 2019

Conversation

khmakoto
Copy link
Member

@khmakoto khmakoto commented Mar 8, 2019

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ 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 compact Cards and adds an example of it to the component page. Finally, this PR also adds a basic and a compact Card 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

@size-auditor
Copy link

size-auditor bot commented Mar 8, 2019

Bundle test Size (minified) Diff from master
Stack 42.265 kB ExceedsBaseline     69 bytes
Foundation 49.857 kB ExceedsBaseline     18 bytes
Text 39.131 kB ExceedsBaseline     18 bytes

ExceedsTolerance  Exceeds Tolerance     ExceedsBaseline  Exceeds Baseline     BelowBaseline  Below Baseline     1 kB = 1000 bytes

</Card>

<Card compact={true} gap={12} tokens={{ padding: 12 }} onClick={alertClicked}>
<Card.Item tokens={{ margin: '-12px 0 -12px -12px' }}>
Copy link
Member

@dzearing dzearing Mar 13, 2019

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.

Copy link
Member Author

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.

@khmakoto khmakoto requested a review from kkjeer as a code owner March 13, 2019 19:45
/**
* Defines the spacing between Card children.
*/
gap?: number | string;
Copy link
Member

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......

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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?

@leddie24
Copy link
Collaborator

@kkjeer , looks like this still needs your approval as a code owner; can you take a look at your earliest convenience please?

@leddie24
Copy link
Collaborator

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.
Copy link
Member

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...

Copy link
Member

Choose a reason for hiding this comment

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

@khmakoto khmakoto requested a review from JasonGore March 28, 2019 20:36
<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}>
Copy link
Member

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>

Copy link
Member

@JasonGore JasonGore left a 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'),
Copy link
Member

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.

@JasonGore JasonGore merged commit df35977 into microsoft:master Mar 29, 2019
@khmakoto khmakoto deleted the cardApi branch March 29, 2019 21:28
@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@micahgodbolt micahgodbolt mentioned this pull request Apr 2, 2019
12 tasks
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants