-
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
feat(react-card): add orientation
prop
#23037
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 203dbb6:
|
📊 Bundle size reportUnchanged fixtures
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 143f4ac9fb4eef165e4975bcf3b113bc00680e03 (build) |
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 883 | 900 | 5000 | |
Button | mount | 566 | 569 | 5000 | |
FluentProvider | mount | 1847 | 1861 | 5000 | |
FluentProviderWithTheme | mount | 256 | 292 | 10 | |
FluentProviderWithTheme | virtual-rerender | 222 | 232 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 304 | 305 | 10 | |
MakeStyles | mount | 1605 | 1593 | 50000 |
marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`, | ||
marginBottom: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`, | ||
}, | ||
[`> :not([aria-hidden="true"]):first-of-type.${cardPreviewClassNames.root}`]: { |
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.
Unfortunate necessity due to Tabster's injected elements
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.
Im usually against adding comments to codebase, but I think this is the exception. can we document this pls?
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 that's warranted 😓 Will do 👍🏻
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 went ahead and added a little explanation to the other styles too. Let me know if you would change something.
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 lets get this in!
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 don't have any concrete numbers I can share here or guidance on what to do instead but I want to share some potential issues with this selector.
Attribute selectors and pseudo-classes are some of the slowest selectors: source. Sadly it's difficult to substantiate this with numbers as devtools have dropped CSS selector profilers :(
Is it at all possible to refactor this selector to, say, drop the attribute selector? Does Tabster apply classes to its hidden elements? Could it be updated to if not?
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.
thanks for reaching out @spmonahan ! The thing with Tabster DOM insertions is it can break at any time (which happened already). IMO would be best if tabster could expose a hook (css selector?) as part of its public API to give use solid contract. Can we reach out to folks @andrefcdias ? WDYT
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.
Thank you for sharing your concerns, @spmonahan. I agree that this approach is not ideal, but please keep in mind that there will be some work put into optimization after all implementation is finished as not to keep delaying the implementation.
As @Hotell said, Tabster updates tends to be breaking and this was the lesser evil approach.
I'll keep this in mind for the future before finalizing Card.
[`> .${cardHeaderClassNames.root}, > .${cardFooterClassNames.root}`]: { | ||
flexShrink: 0, | ||
}, |
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.
Ensuring header and footer won't go below the required sizes.
[`> :not(.${cardPreviewClassNames.root}):not(.${cardHeaderClassNames.root}):not(.${cardFooterClassNames.root})`]: { | ||
flexGrow: 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.
Allow content to grow before Card components.
@@ -16,6 +16,7 @@ const useStyles = makeStyles({ | |||
|
|||
'> *': { | |||
display: 'block', | |||
height: '100%', |
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.
Now necessary to adjust CardPreview's content for horizontal cards.
<Card size="small" orientation="horizontal"> | ||
<CardPreview className={styles.horizontalPreview}> | ||
<img src={Logo} alt="company logo template" /> | ||
</CardPreview> | ||
<CardHeader | ||
image={<Avatar badge={{ status: 'available' }} image={{ src: avatarElviaURL }} />} | ||
header={ | ||
<Body1> | ||
<b>Strategy 2021</b> | ||
</Body1> | ||
} | ||
description={<Caption1>https://aka.ms/fluentui</Caption1>} | ||
action={<Button appearance="transparent" icon={<MoreHorizontal24Regular />} />} | ||
/> | ||
</Card> |
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.
Custom example that fits better the horizontal use case. Will start reusing more of design's templates going forward.
@@ -14,8 +14,9 @@ const useStyles = makeStyles({ | |||
root: { | |||
position: 'relative', | |||
|
|||
'> *': { | |||
[`> :not(.${cardPreviewClassNames.logo})`]: { |
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.
Previously wrongfully applying to any child element, which would include the floating logo slot.
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.
also improves paint perf, nice catch
@@ -38,7 +38,7 @@ const SampleCardContent = () => ( | |||
storiesOf('Card Converged', module) | |||
.addDecorator(story => ( | |||
<Screener steps={new Screener.Steps().snapshot('normal', { cropTo: '.testWrapper' }).end()}> | |||
<div className="testWrapper" style={{ width: '300px' }}> | |||
<div className="testWrapper" style={{ width: '600px' }}> |
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.
300px
crops the horizontal example.
marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`, | ||
marginBottom: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`, | ||
}, | ||
[`> :not([aria-hidden="true"]):first-of-type.${cardPreviewClassNames.root}`]: { |
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.
Im usually against adding comments to codebase, but I think this is the exception. can we document this pls?
@@ -14,8 +14,9 @@ const useStyles = makeStyles({ | |||
root: { | |||
position: 'relative', | |||
|
|||
'> *': { | |||
[`> :not(.${cardPreviewClassNames.logo})`]: { |
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.
also improves paint perf, nice catch
New Behavior
Added the
orientation
property which will control:The 6 changes in Screener are due to the change in the viewport size, so they're expected.
#23037 (comment)
I plan on refactoring these stories in the future to use design templates, so for now I'm keeping changes simple to facilitate reviews.
Related Issue(s)
#19336