Skip to content

Commit

Permalink
Stack: Adding basis prop to mimick flexBasis CSS property (#19053)
Browse files Browse the repository at this point in the history
* Stack: Adding basis prop to mimick flexBasis CSS property.

* Change files

* Adding default value as auto for basis prop.

* Updating snapshots

* Updating snapshots.
  • Loading branch information
khmakoto authored Mar 17, 2022
1 parent 956f573 commit f4ed6d1
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Stack: Adding basis prop to mimick flexBasis CSS property.",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`Card Item renders correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -111,6 +112,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -136,6 +138,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -202,6 +205,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -227,6 +231,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -293,6 +298,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -318,6 +324,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -384,6 +391,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -409,6 +417,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -475,6 +484,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -500,6 +510,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -525,6 +536,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -591,6 +603,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -616,6 +629,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -641,6 +655,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -707,6 +722,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -773,6 +789,7 @@ exports[`Card Item renders correctly when filling up the margins while being the
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -839,6 +856,7 @@ exports[`Card Item renders correctly when having tokens passed to it 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exports[`CardView renders a Horizontal Card with an onClick function specified c
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -86,6 +87,7 @@ exports[`CardView renders a Horizontal Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -107,6 +109,7 @@ exports[`CardView renders a Horizontal Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -128,6 +131,7 @@ exports[`CardView renders a Horizontal Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -209,6 +213,7 @@ exports[`CardView renders a Vertical Card with an onClick function specified cor
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down Expand Up @@ -260,6 +265,7 @@ exports[`CardView renders a Vertical Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -281,6 +287,7 @@ exports[`CardView renders a Vertical Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand All @@ -302,6 +309,7 @@ exports[`CardView renders a Vertical Card with contents correctly 1`] = `
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
flex-basis: auto;
flex-shrink: 0;
font-family: 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-size: 18px;
Expand Down
1 change: 1 addition & 0 deletions packages/react/etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8494,6 +8494,7 @@ export type IStackItemComponent = IComponent<IStackItemProps, IStackItemTokens,
// @public (undocumented)
export interface IStackItemProps extends IStackItemSlots, IStyleableComponentProps<IStackItemProps, IStackItemTokens, IStackItemStyles>, React_2.HTMLAttributes<HTMLElement> {
align?: 'auto' | 'stretch' | 'baseline' | 'start' | 'center' | 'end';
basis?: React_2.CSSProperties['flexBasis'];
className?: string;
disableShrink?: boolean;
grow?: boolean | number | 'inherit' | 'initial' | 'unset';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const alignMap: { [key: string]: string } = {
};

export const StackItemStyles: IStackItemComponent['styles'] = (props, theme, tokens): IStackItemStylesReturnType => {
const { grow, shrink, disableShrink, align, verticalFill, order, className } = props;
const { grow, shrink, disableShrink, align, verticalFill, order, className, basis = 'auto' } = props;

const classNames = getGlobalClassNames(GlobalClassNames, theme);

Expand All @@ -20,12 +20,15 @@ export const StackItemStyles: IStackItemComponent['styles'] = (props, theme, tok
theme.fonts.medium,
classNames.root,
{
flexBasis: basis,
margin: tokens.margin,
padding: tokens.padding,
height: verticalFill ? '100%' : 'auto',
width: 'auto',
},
grow && { flexGrow: grow === true ? 1 : grow },
grow && {
flexGrow: grow === true ? 1 : grow,
},
(disableShrink || (!grow && !shrink)) && {
flexShrink: 0,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export interface IStackItemProps
*/
verticalFill?: boolean;

/**
* Defines the initial main size of the StackItem, setting the size of the content box unless otherwise set with
* box-sizing.
* @defaultvalue auto
*/
basis?: React.CSSProperties['flexBasis'];

/**
* Defines order of the StackItem.
* @defaultvalue 0
Expand Down
Loading

0 comments on commit f4ed6d1

Please sign in to comment.