|
|
@ -10,6 +10,8 @@ import { getSizeStyles, SizeProps } from '../utils/styles'; |
|
|
|
|
|
|
|
|
|
|
|
interface StackProps extends FlexProps, SizeProps, Omit<React.HTMLAttributes<HTMLElement>, 'className' | 'style'> { |
|
|
|
interface StackProps extends FlexProps, SizeProps, Omit<React.HTMLAttributes<HTMLElement>, 'className' | 'style'> { |
|
|
|
gap?: ResponsiveProp<ThemeSpacingTokens>; |
|
|
|
gap?: ResponsiveProp<ThemeSpacingTokens>; |
|
|
|
|
|
|
|
rowGap?: ResponsiveProp<ThemeSpacingTokens>; |
|
|
|
|
|
|
|
columnGap?: ResponsiveProp<ThemeSpacingTokens>; |
|
|
|
alignItems?: ResponsiveProp<AlignItems>; |
|
|
|
alignItems?: ResponsiveProp<AlignItems>; |
|
|
|
justifyContent?: ResponsiveProp<JustifyContent>; |
|
|
|
justifyContent?: ResponsiveProp<JustifyContent>; |
|
|
|
direction?: ResponsiveProp<Direction>; |
|
|
|
direction?: ResponsiveProp<Direction>; |
|
|
@ -20,6 +22,8 @@ interface StackProps extends FlexProps, SizeProps, Omit<React.HTMLAttributes<HTM |
|
|
|
export const Stack = React.forwardRef<HTMLDivElement, StackProps>((props, ref) => { |
|
|
|
export const Stack = React.forwardRef<HTMLDivElement, StackProps>((props, ref) => { |
|
|
|
const { |
|
|
|
const { |
|
|
|
gap = 1, |
|
|
|
gap = 1, |
|
|
|
|
|
|
|
rowGap, |
|
|
|
|
|
|
|
columnGap, |
|
|
|
alignItems, |
|
|
|
alignItems, |
|
|
|
justifyContent, |
|
|
|
justifyContent, |
|
|
|
direction, |
|
|
|
direction, |
|
|
@ -37,7 +41,20 @@ export const Stack = React.forwardRef<HTMLDivElement, StackProps>((props, ref) = |
|
|
|
maxHeight, |
|
|
|
maxHeight, |
|
|
|
...rest |
|
|
|
...rest |
|
|
|
} = props; |
|
|
|
} = props; |
|
|
|
const styles = useStyles2(getStyles, gap, alignItems, justifyContent, direction, wrap, grow, shrink, basis, flex); |
|
|
|
const styles = useStyles2( |
|
|
|
|
|
|
|
getStyles, |
|
|
|
|
|
|
|
gap, |
|
|
|
|
|
|
|
rowGap, |
|
|
|
|
|
|
|
columnGap, |
|
|
|
|
|
|
|
alignItems, |
|
|
|
|
|
|
|
justifyContent, |
|
|
|
|
|
|
|
direction, |
|
|
|
|
|
|
|
wrap, |
|
|
|
|
|
|
|
grow, |
|
|
|
|
|
|
|
shrink, |
|
|
|
|
|
|
|
basis, |
|
|
|
|
|
|
|
flex |
|
|
|
|
|
|
|
); |
|
|
|
const sizeStyles = useStyles2(getSizeStyles, width, minWidth, maxWidth, height, minHeight, maxHeight); |
|
|
|
const sizeStyles = useStyles2(getSizeStyles, width, minWidth, maxWidth, height, minHeight, maxHeight); |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div ref={ref} className={cx(styles.flex, sizeStyles)} {...rest}> |
|
|
|
<div ref={ref} className={cx(styles.flex, sizeStyles)} {...rest}> |
|
|
@ -51,6 +68,8 @@ Stack.displayName = 'Stack'; |
|
|
|
const getStyles = ( |
|
|
|
const getStyles = ( |
|
|
|
theme: GrafanaTheme2, |
|
|
|
theme: GrafanaTheme2, |
|
|
|
gap: StackProps['gap'], |
|
|
|
gap: StackProps['gap'], |
|
|
|
|
|
|
|
rowGap: StackProps['rowGap'], |
|
|
|
|
|
|
|
columnGap: StackProps['columnGap'], |
|
|
|
alignItems: StackProps['alignItems'], |
|
|
|
alignItems: StackProps['alignItems'], |
|
|
|
justifyContent: StackProps['justifyContent'], |
|
|
|
justifyContent: StackProps['justifyContent'], |
|
|
|
direction: StackProps['direction'], |
|
|
|
direction: StackProps['direction'], |
|
|
@ -80,6 +99,12 @@ const getStyles = ( |
|
|
|
getResponsiveStyle(theme, gap, (val) => ({ |
|
|
|
getResponsiveStyle(theme, gap, (val) => ({ |
|
|
|
gap: theme.spacing(val), |
|
|
|
gap: theme.spacing(val), |
|
|
|
})), |
|
|
|
})), |
|
|
|
|
|
|
|
getResponsiveStyle(theme, rowGap, (val) => ({ |
|
|
|
|
|
|
|
rowGap: theme.spacing(val), |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
getResponsiveStyle(theme, columnGap, (val) => ({ |
|
|
|
|
|
|
|
columnGap: theme.spacing(val), |
|
|
|
|
|
|
|
})), |
|
|
|
getResponsiveStyle(theme, grow, (val) => ({ |
|
|
|
getResponsiveStyle(theme, grow, (val) => ({ |
|
|
|
flexGrow: val, |
|
|
|
flexGrow: val, |
|
|
|
})), |
|
|
|
})), |
|
|
|