[BREAKING] fix(react-text): remove default text styles#23254
[BREAKING] fix(react-text): remove default text styles#23254theerebuss wants to merge 6 commits into
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 d79f38b:
|
| Or by installing only the `@fluentui/react-text` package. Keep in mind you'll need to install the FluentProvider package as well: | ||
|
|
||
| ```sh | ||
| npm install @fluentui/react-text | ||
| npm install @fluentui/react-provider | ||
| ``` | ||
|
|
||
| ```jsx | ||
| import { FluentProvider } from '@fluentui/react-provider'; | ||
| import { Text } from '@fluentui/react-text'; | ||
|
|
||
| const App = () => ( | ||
| <FluentProvider> | ||
| <Text>Fluent UI Text!</Text> | ||
| </FluentProvider> | ||
| ); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
No longer recommended due to possible dependency clashing.
| ## Typography wrappers | ||
|
|
||
|  | ||
|  |
There was a problem hiding this comment.
Updated image to contain the new typography wrapper Caption2 introduced in #22934
| ## API | ||
|
|
||
| For more information about the components, please refer to the [API documentation](https://aka.ms/fluentui-storybook). | ||
| For more information about the components, please refer to the [API documentation](https://react.fluentui.dev/?path=/docs/components-text--default). |
There was a problem hiding this comment.
Points to the new website, given that the URL should be final.
📊 Bundle size reportUnchanged fixtures
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 7bd33dbd7ddfc579e288c8081b8921be8cf421c5 (build) |
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| FluentProviderWithTheme | mount | 262 | 247 | 10 | Possible regression |
All results
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| Avatar | mount | 942 | 907 | 5000 | |
| Button | mount | 572 | 565 | 5000 | |
| FluentProvider | mount | 1925 | 1864 | 5000 | |
| FluentProviderWithTheme | mount | 262 | 247 | 10 | Possible regression |
| FluentProviderWithTheme | virtual-rerender | 224 | 215 | 10 | |
| FluentProviderWithTheme | virtual-rerender-with-unmount | 306 | 283 | 10 | |
| MakeStyles | mount | 1711 | 1699 | 50000 |
|
If that's not the case, 'initial' or 'inherit' would be more clear than 'none' and match CSS's keyword. EDIT: |
| * Aligns text based on the parent container. | ||
| * | ||
| * @default start | ||
| * @default 'none' |
There was a problem hiding this comment.
What do you think about using inherit for the default value to better align with CSS keywords?
There was a problem hiding this comment.
When a prop is nullable, the default can be for us to not set any style and leave them undefined. This can avoid creating another value in the union.
There was a problem hiding this comment.
I like the idea of having the prop be undefined by default. inherit doesn't feel like quite the right name and the prop is already optional.
There was a problem hiding this comment.
I think inherit would create more confusion as we wouldn't actually apply that. I went with none to keep it consistent with our lib as I'm not aware of any component working in undefined values, as we're forcing Required on component state.
I'm pro using undefined but it needs to be coherent and standardized.
There was a problem hiding this comment.
IMO folks meant following:
-align?: 'none' | 'start' | 'center' | 'end' | 'justify';
+align?: 'start' | 'center' | 'end' | 'justify';optional operator ads undefined type already
There was a problem hiding this comment.
unset is another good option that matches CSS. The CSS keyword unset represents the default value and is equivalent to not setting the property at all.
All these properties default to inherit since they're inherited properties, so inherit is also a reasonable string even though its not explicitly applied. However, if you ever introduced a non-inherited property, you'd need a different string.
There was a problem hiding this comment.
don't think unset could be used as that would go against implementation intent. we dont wanna do actual "reset" of css style definition.
There was a problem hiding this comment.
we had additional offline sync with @andrefcdias on this - we will create a draft RFC for alignment across all component APIs on how to approach "default" values. once that will be resolved we can go back and re-solve this convo accordingly. ty!
There was a problem hiding this comment.
undefined is fine with me!
To clarify, unset means "not set by the component" rather than "reset" (aka initial). I felt that none implies actual "reset" which is why I've been asking for a name change :)
| fontFamily: tokens.fontFamilyBase, | ||
| fontSize: tokens.fontSizeBase300, | ||
| fontWeight: tokens.fontWeightRegular, | ||
| ...typographyStyles.body1, |
There was a problem hiding this comment.
Leveraging typographyStyles to improve clarity on why we use said values and to avoid duplication.
| state.align === 'center' && styles.alignCenter, | ||
| state.align === 'end' && styles.alignEnd, | ||
| state.align === 'justify' && styles.alignJustify, | ||
| sizeMap[state.size], |
|
@andrefcdias we discussed this change in the ship meeting, and there was some concern about the changes to the But we wanted to get the |

Current Behavior
Textre-applies by default what's already enforced byFluentProviderNew Behavior
Textwill no longer apply these styles by default with the introduction of a new default for the props -none.Documentation was also updated and cleaned up to match the rest of the components.
FluentProvidernow also appliesline-heightby default.Related Issue(s)
Fixes #22855