Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 7270655

Browse files
authored
feat(FlexItem): allow custom values as size (#2313)
* accept direct value in styles * augmenting the types in FlexItem * changelog
1 parent 077f0cb commit 7270655

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
4646
- Add `useTelemetry()` hook for adding telemetry information for the Fluent components and improve return types for the `useStyles` and `useStateManager` hooks @mnajdova ([#2257](https://github.com/microsoft/fluent-ui-react/pull/2257))
4747
- Add `target` prop to `EventListener` component and `useEventListener()` hook @layershifter ([#2287](https://github.com/microsoft/fluent-ui-react/pull/2287))
4848
- Add `disabled` prop accordion title @jurokapsiar ([#2290](https://github.com/microsoft/fluent-ui-react/pull/2290))
49+
- Allow custom values for `size` in `FlexItem` @silviuavram ([#2313](https://github.com/microsoft/fluent-ui-react/pull/2313))
4950

5051
### Documentation
5152
- Add per-component performance charts @miroslavstastny ([#2240](https://github.com/microsoft/fluent-ui-react/pull/2240))

packages/react/src/components/Flex/FlexItem.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface FlexItemProps extends UIComponentProps, ChildrenComponentProps<
2323
align?: 'auto' | 'start' | 'end' | 'center' | 'baseline' | 'stretch'
2424

2525
/** Defines size of the item. */
26-
size?: 'size.half' | 'size.quarter' | 'size.small' | 'size.medium' | 'size.large'
26+
size?: 'size.half' | 'size.quarter' | 'size.small' | 'size.medium' | 'size.large' | string
2727

2828
/**
2929
* Item can fill remaining space of the container.
@@ -65,7 +65,14 @@ class FlexItem extends UIComponent<FlexItemProps> {
6565
children: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
6666

6767
align: PropTypes.oneOf(['auto', 'start', 'end', 'center', 'baseline', 'stretch']),
68-
size: PropTypes.oneOf(['size.half', 'size.quarter', 'size.small', 'size.medium', 'size.large']),
68+
size: PropTypes.oneOf([
69+
'size.half',
70+
'size.quarter',
71+
'size.small',
72+
'size.medium',
73+
'size.large',
74+
PropTypes.string,
75+
]),
6976

7077
stretch: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
7178
shrink: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),

packages/react/src/themes/teams/components/Flex/flexItemStyles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const flexItemStyles: ComponentSlotStylesPrepared<FlexItemProps, FlexItemVariabl
99
return {
1010
...(p.align && { alignSelf: toFlexAlignment(p.align) }),
1111

12-
...(p.size && toFlexItemSizeValues(v[p.size])),
12+
...(p.size && toFlexItemSizeValues(v.hasOwnProperty(p.size) ? v[p.size] : p.size)),
1313

1414
...(typeof p.shrink === 'number' && { flexShrink: p.shrink }),
1515
...(p.shrink === false && { flexShrink: 0 }),

0 commit comments

Comments
 (0)