Skip to content

react-card - CardPreview top padding fix#20030

Merged
theerebuss merged 4 commits into
microsoft:masterfrom
theerebuss:card-preview-padding
Oct 4, 2021
Merged

react-card - CardPreview top padding fix#20030
theerebuss merged 4 commits into
microsoft:masterfrom
theerebuss:card-preview-padding

Conversation

@theerebuss

Copy link
Copy Markdown
Contributor

Description of changes

CardPreview was not removing the margin added by the Card when it was the first element of a Card component.
Added a fixed className for CardPreview to control the padding in the parent.
Given that #19937 is still pending discussion, I opted to go with a unique name that can later on be changed once we reach a consensus.
Linking this PR there for tracking purposes.

@theerebuss theerebuss requested review from a team and layershifter September 29, 2021 14:44
@theerebuss theerebuss changed the title Card preview padding react-card - CardPreview top padding fix Sep 29, 2021
@codesandbox-ci

codesandbox-ci Bot commented Sep 29, 2021

Copy link
Copy Markdown

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 7cf0fda:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam

fabricteam commented Sep 29, 2021

Copy link
Copy Markdown
Collaborator

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-card
Card - All
0 B
0 B
13.471 kB
5.068 kB
🆕 New entry
react-card
Card
0 B
0 B
9.317 kB
3.925 kB
🆕 New entry
react-card
CardFooter
0 B
0 B
8.468 kB
3.557 kB
🆕 New entry
react-card
CardHeader
0 B
0 B
9.695 kB
3.99 kB
🆕 New entry
react-card
CardPreview
0 B
0 B
8.783 kB
3.741 kB
🆕 New entry
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
161.95 kB
46.181 kB
react-components
react-components: FluentProvider & webLightTheme
32.188 kB
10.658 kB
🤖 This report was generated against 8f6caa6059441154c40417de2bac428066552d73

@theerebuss theerebuss mentioned this pull request Sep 29, 2021
37 tasks
@size-auditor

size-auditor Bot commented Sep 29, 2021

Copy link
Copy Markdown

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 59c5d0e1ad36d03bd9cb5ee3d44b97186ef0456c (build)

@fabricteam

fabricteam commented Sep 29, 2021

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 992 955 5000
BaseButton mount 920 962 5000
Breadcrumb mount 2695 2658 1000
ButtonNext mount 510 510 5000
Checkbox mount 1551 1541 5000
CheckboxBase mount 1376 1356 5000
ChoiceGroup mount 5012 4778 5000
ComboBox mount 994 1007 1000
CommandBar mount 10368 10375 1000
ContextualMenu mount 6361 6387 1000
DefaultButton mount 1147 1153 5000
DetailsRow mount 3701 3744 5000
DetailsRowFast mount 3786 3756 5000
DetailsRowNoStyles mount 3608 3695 5000
Dialog mount 2552 2492 1000
DocumentCardTitle mount 175 174 1000
Dropdown mount 3311 3240 5000
FluentProviderNext mount 3450 3481 5000
FluentProviderWithTheme mount 206 207 10
FluentProviderWithTheme virtual-rerender 106 101 10
FluentProviderWithTheme virtual-rerender-with-unmount 239 244 10
FocusTrapZone mount 1830 1846 5000
FocusZone mount 1803 1900 5000
IconButton mount 1773 1767 5000
Label mount 358 373 5000
Layer mount 3017 3023 5000
Link mount 484 506 5000
MakeStyles mount 1952 1881 50000
MenuButton mount 1468 1503 5000
MessageBar mount 2025 2037 5000
Nav mount 3416 3319 1000
OverflowSet mount 1126 1130 5000
Panel mount 2424 2417 1000
Persona mount 859 850 1000
Pivot mount 1444 1459 1000
PrimaryButton mount 1315 1323 5000
Rating mount 7827 7845 5000
SearchBox mount 1344 1351 5000
Shimmer mount 2555 2533 5000
Slider mount 1981 1985 5000
SpinButton mount 5126 5206 5000
Spinner mount 451 454 5000
SplitButton mount 3192 3184 5000
Stack mount 533 530 5000
StackWithIntrinsicChildren mount 1748 1743 5000
StackWithTextChildren mount 4822 4797 5000
SwatchColorPicker mount 10702 10699 5000
Tabs mount 1451 1438 1000
TagPicker mount 2665 2673 5000
TeachingBubble mount 13073 13117 5000
Text mount 431 454 5000
TextField mount 1378 1409 5000
ThemeProvider mount 1222 1239 5000
ThemeProvider virtual-rerender 635 644 5000
ThemeProvider virtual-rerender-with-unmount 1943 1918 5000
Toggle mount 859 860 5000
buttonNative mount 143 146 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AttachmentMinimalPerf.default 176 154 1.14:1
AvatarMinimalPerf.default 210 197 1.07:1
FlexMinimalPerf.default 304 285 1.07:1
LayoutMinimalPerf.default 386 361 1.07:1
HeaderMinimalPerf.default 382 362 1.06:1
TextMinimalPerf.default 366 345 1.06:1
TreeWith60ListItems.default 189 179 1.06:1
AnimationMinimalPerf.default 437 416 1.05:1
ButtonMinimalPerf.default 183 174 1.05:1
CarouselMinimalPerf.default 488 464 1.05:1
ReactionMinimalPerf.default 387 370 1.05:1
FormMinimalPerf.default 420 403 1.04:1
ImageMinimalPerf.default 390 374 1.04:1
LoaderMinimalPerf.default 748 717 1.04:1
RadioGroupMinimalPerf.default 462 443 1.04:1
IconMinimalPerf.default 616 590 1.04:1
BoxMinimalPerf.default 366 355 1.03:1
DividerMinimalPerf.default 370 359 1.03:1
DropdownManyItemsPerf.default 709 688 1.03:1
ListMinimalPerf.default 526 512 1.03:1
MenuMinimalPerf.default 879 850 1.03:1
ButtonOverridesMissPerf.default 1839 1796 1.02:1
CardMinimalPerf.default 557 548 1.02:1
ChatWithPopoverPerf.default 377 369 1.02:1
DialogMinimalPerf.default 766 753 1.02:1
LabelMinimalPerf.default 408 399 1.02:1
ListNestedPerf.default 566 555 1.02:1
MenuButtonMinimalPerf.default 1710 1676 1.02:1
StatusMinimalPerf.default 711 698 1.02:1
TableManyItemsPerf.default 1932 1888 1.02:1
TreeMinimalPerf.default 824 806 1.02:1
AlertMinimalPerf.default 285 283 1.01:1
AttachmentSlotsPerf.default 1094 1080 1.01:1
ChatMinimalPerf.default 658 651 1.01:1
DatepickerMinimalPerf.default 5999 5941 1.01:1
HeaderSlotsPerf.default 775 770 1.01:1
InputMinimalPerf.default 1350 1338 1.01:1
PopupMinimalPerf.default 624 616 1.01:1
SplitButtonMinimalPerf.default 4358 4315 1.01:1
TableMinimalPerf.default 408 404 1.01:1
TooltipMinimalPerf.default 1056 1044 1.01:1
CheckboxMinimalPerf.default 2778 2786 1:1
DropdownMinimalPerf.default 3252 3254 1:1
EmbedMinimalPerf.default 4359 4354 1:1
GridMinimalPerf.default 348 348 1:1
ItemLayoutMinimalPerf.default 1245 1250 1:1
ListWith60ListItems.default 665 665 1:1
PortalMinimalPerf.default 190 190 1:1
ProviderMinimalPerf.default 1193 1191 1:1
SegmentMinimalPerf.default 346 347 1:1
TextAreaMinimalPerf.default 494 493 1:1
CustomToolbarPrototype.default 4143 4151 1:1
ProviderMergeThemesPerf.default 1813 1832 0.99:1
RefMinimalPerf.default 247 249 0.99:1
RosterPerf.default 1205 1226 0.98:1
ToolbarMinimalPerf.default 916 930 0.98:1
ButtonSlotsPerf.default 555 570 0.97:1
ChatDuplicateMessagesPerf.default 307 316 0.97:1
SkeletonMinimalPerf.default 341 351 0.97:1
SliderMinimalPerf.default 1696 1740 0.97:1
VideoMinimalPerf.default 614 632 0.97:1
AccordionMinimalPerf.default 149 156 0.96:1
ListCommonPerf.default 632 676 0.93:1

borderRadius: theme.global.borderRadius.medium,

'> .fluentui-react-card-preview': {
marginLeft: '-12px',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it is not a very good practice to use negative values for margins, maybe (if it is possible) removing the margin from the above component could be better?

Also, the values are fixed, could there be a possibility that the card might not look as it should because of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Regarding negating the margins, I'm also not a fan of this solution but I think it's a compromise between elegance and utility.
I had already discussed this topic with @varholak-peter about having the padding instead on the child components (CardHeader, CardPreview, etc), which would potentially remove this issue as each component governs itself. However, I see 2 issues with this:

  • If our users use Card and not the child components, the component would not follow the Fluent guidelines out of the box.
  • Whenever we have the size prop on Card (according to the current spec), we'll need to change this padding as it won't always be the fixed 12px. This means that we'd probably need to provide some CardContext for the inner components to consume and be compliant.
    Given these 2 constraints, I think the less elegant negative margin solution is the better option as it will guarantee it's Fluent by default, allow us to control the padding from the parent (whenever we have size) and avoid duplicate code on the inner components.
    Regardless of what we choose, we felt it was a discussion that needed to happen more in depth and opted for this just to fast track it for now.

As for the mention about fixed values, 12px matches the, eventual, default size for card which is medium. Given that the size prop won't be implemented for phase 1, we went with a fixed value for now.

@theerebuss theerebuss requested review from a team September 30, 2021 13:36
@theerebuss theerebuss merged commit 8398647 into microsoft:master Oct 4, 2021
@theerebuss theerebuss deleted the card-preview-padding branch October 4, 2021 04:15
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants