@fluentui/react-text 0.0.0-nightly050f89bf0020211102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1277 -0
- package/CHANGELOG.md +471 -0
- package/LICENSE +15 -0
- package/MIGRATION.md +680 -0
- package/README.md +99 -0
- package/Spec.md +162 -0
- package/assets/typography-examples.gif +0 -0
- package/dist/react-text.d.ts +163 -0
- package/lib/Body.d.ts +1 -0
- package/lib/Body.js +2 -0
- package/lib/Body.js.map +1 -0
- package/lib/Caption.d.ts +1 -0
- package/lib/Caption.js +2 -0
- package/lib/Caption.js.map +1 -0
- package/lib/Display.d.ts +1 -0
- package/lib/Display.js +2 -0
- package/lib/Display.js.map +1 -0
- package/lib/Headline.d.ts +1 -0
- package/lib/Headline.js +2 -0
- package/lib/Headline.js.map +1 -0
- package/lib/LargeTitle.d.ts +1 -0
- package/lib/LargeTitle.js +2 -0
- package/lib/LargeTitle.js.map +1 -0
- package/lib/Subheadline.d.ts +1 -0
- package/lib/Subheadline.js +2 -0
- package/lib/Subheadline.js.map +1 -0
- package/lib/Text.d.ts +1 -0
- package/lib/Text.js +2 -0
- package/lib/Text.js.map +1 -0
- package/lib/Title1.d.ts +1 -0
- package/lib/Title1.js +2 -0
- package/lib/Title1.js.map +1 -0
- package/lib/Title2.d.ts +1 -0
- package/lib/Title2.js +2 -0
- package/lib/Title2.js.map +1 -0
- package/lib/Title3.d.ts +1 -0
- package/lib/Title3.js +2 -0
- package/lib/Title3.js.map +1 -0
- package/lib/common/isConformant.d.ts +4 -0
- package/lib/common/isConformant.js +16 -0
- package/lib/common/isConformant.js.map +1 -0
- package/lib/components/Body/Body.d.ts +6 -0
- package/lib/components/Body/Body.js +27 -0
- package/lib/components/Body/Body.js.map +1 -0
- package/lib/components/Body/index.d.ts +1 -0
- package/lib/components/Body/index.js +2 -0
- package/lib/components/Body/index.js.map +1 -0
- package/lib/components/Caption/Caption.d.ts +6 -0
- package/lib/components/Caption/Caption.js +27 -0
- package/lib/components/Caption/Caption.js.map +1 -0
- package/lib/components/Caption/index.d.ts +1 -0
- package/lib/components/Caption/index.js +2 -0
- package/lib/components/Caption/index.js.map +1 -0
- package/lib/components/Display/Display.d.ts +6 -0
- package/lib/components/Display/Display.js +27 -0
- package/lib/components/Display/Display.js.map +1 -0
- package/lib/components/Display/index.d.ts +1 -0
- package/lib/components/Display/index.js +2 -0
- package/lib/components/Display/index.js.map +1 -0
- package/lib/components/Headline/Headline.d.ts +6 -0
- package/lib/components/Headline/Headline.js +27 -0
- package/lib/components/Headline/Headline.js.map +1 -0
- package/lib/components/Headline/index.d.ts +1 -0
- package/lib/components/Headline/index.js +2 -0
- package/lib/components/Headline/index.js.map +1 -0
- package/lib/components/LargeTitle/LargeTitle.d.ts +6 -0
- package/lib/components/LargeTitle/LargeTitle.js +27 -0
- package/lib/components/LargeTitle/LargeTitle.js.map +1 -0
- package/lib/components/LargeTitle/index.d.ts +1 -0
- package/lib/components/LargeTitle/index.js +2 -0
- package/lib/components/LargeTitle/index.js.map +1 -0
- package/lib/components/Subheadline/Subheadline.d.ts +6 -0
- package/lib/components/Subheadline/Subheadline.js +27 -0
- package/lib/components/Subheadline/Subheadline.js.map +1 -0
- package/lib/components/Subheadline/index.d.ts +1 -0
- package/lib/components/Subheadline/index.js +2 -0
- package/lib/components/Subheadline/index.js.map +1 -0
- package/lib/components/Text/Text.d.ts +6 -0
- package/lib/components/Text/Text.js +15 -0
- package/lib/components/Text/Text.js.map +1 -0
- package/lib/components/Text/Text.types.d.ts +77 -0
- package/lib/components/Text/Text.types.js +2 -0
- package/lib/components/Text/Text.types.js.map +1 -0
- package/lib/components/Text/index.d.ts +5 -0
- package/lib/components/Text/index.js +6 -0
- package/lib/components/Text/index.js.map +1 -0
- package/lib/components/Text/renderText.d.ts +5 -0
- package/lib/components/Text/renderText.js +15 -0
- package/lib/components/Text/renderText.js.map +1 -0
- package/lib/components/Text/useText.d.ts +12 -0
- package/lib/components/Text/useText.js +49 -0
- package/lib/components/Text/useText.js.map +1 -0
- package/lib/components/Text/useTextStyles.d.ts +5 -0
- package/lib/components/Text/useTextStyles.js +110 -0
- package/lib/components/Text/useTextStyles.js.map +1 -0
- package/lib/components/Title1/Title1.d.ts +6 -0
- package/lib/components/Title1/Title1.js +27 -0
- package/lib/components/Title1/Title1.js.map +1 -0
- package/lib/components/Title1/index.d.ts +1 -0
- package/lib/components/Title1/index.js +2 -0
- package/lib/components/Title1/index.js.map +1 -0
- package/lib/components/Title2/Title2.d.ts +6 -0
- package/lib/components/Title2/Title2.js +27 -0
- package/lib/components/Title2/Title2.js.map +1 -0
- package/lib/components/Title2/index.d.ts +1 -0
- package/lib/components/Title2/index.js +2 -0
- package/lib/components/Title2/index.js.map +1 -0
- package/lib/components/Title3/Title3.d.ts +6 -0
- package/lib/components/Title3/Title3.js +27 -0
- package/lib/components/Title3/Title3.js.map +1 -0
- package/lib/components/Title3/index.d.ts +1 -0
- package/lib/components/Title3/index.js +2 -0
- package/lib/components/Title3/index.js.map +1 -0
- package/lib/components/wrapper.d.ts +7 -0
- package/lib/components/wrapper.js +17 -0
- package/lib/components/wrapper.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/typographyStyles/index.d.ts +2 -0
- package/lib/typographyStyles/index.js +3 -0
- package/lib/typographyStyles/index.js.map +1 -0
- package/lib/typographyStyles/typographyStyles.d.ts +14 -0
- package/lib/typographyStyles/typographyStyles.js +76 -0
- package/lib/typographyStyles/typographyStyles.js.map +1 -0
- package/lib-commonjs/Body.d.ts +1 -0
- package/lib-commonjs/Body.js +10 -0
- package/lib-commonjs/Body.js.map +1 -0
- package/lib-commonjs/Caption.d.ts +1 -0
- package/lib-commonjs/Caption.js +10 -0
- package/lib-commonjs/Caption.js.map +1 -0
- package/lib-commonjs/Display.d.ts +1 -0
- package/lib-commonjs/Display.js +10 -0
- package/lib-commonjs/Display.js.map +1 -0
- package/lib-commonjs/Headline.d.ts +1 -0
- package/lib-commonjs/Headline.js +10 -0
- package/lib-commonjs/Headline.js.map +1 -0
- package/lib-commonjs/LargeTitle.d.ts +1 -0
- package/lib-commonjs/LargeTitle.js +10 -0
- package/lib-commonjs/LargeTitle.js.map +1 -0
- package/lib-commonjs/Subheadline.d.ts +1 -0
- package/lib-commonjs/Subheadline.js +10 -0
- package/lib-commonjs/Subheadline.js.map +1 -0
- package/lib-commonjs/Text.d.ts +1 -0
- package/lib-commonjs/Text.js +10 -0
- package/lib-commonjs/Text.js.map +1 -0
- package/lib-commonjs/Title1.d.ts +1 -0
- package/lib-commonjs/Title1.js +10 -0
- package/lib-commonjs/Title1.js.map +1 -0
- package/lib-commonjs/Title2.d.ts +1 -0
- package/lib-commonjs/Title2.js +10 -0
- package/lib-commonjs/Title2.js.map +1 -0
- package/lib-commonjs/Title3.d.ts +1 -0
- package/lib-commonjs/Title3.js +10 -0
- package/lib-commonjs/Title3.js.map +1 -0
- package/lib-commonjs/common/isConformant.d.ts +4 -0
- package/lib-commonjs/common/isConformant.js +27 -0
- package/lib-commonjs/common/isConformant.js.map +1 -0
- package/lib-commonjs/components/Body/Body.d.ts +6 -0
- package/lib-commonjs/components/Body/Body.js +30 -0
- package/lib-commonjs/components/Body/Body.js.map +1 -0
- package/lib-commonjs/components/Body/index.d.ts +1 -0
- package/lib-commonjs/components/Body/index.js +10 -0
- package/lib-commonjs/components/Body/index.js.map +1 -0
- package/lib-commonjs/components/Caption/Caption.d.ts +6 -0
- package/lib-commonjs/components/Caption/Caption.js +30 -0
- package/lib-commonjs/components/Caption/Caption.js.map +1 -0
- package/lib-commonjs/components/Caption/index.d.ts +1 -0
- package/lib-commonjs/components/Caption/index.js +10 -0
- package/lib-commonjs/components/Caption/index.js.map +1 -0
- package/lib-commonjs/components/Display/Display.d.ts +6 -0
- package/lib-commonjs/components/Display/Display.js +30 -0
- package/lib-commonjs/components/Display/Display.js.map +1 -0
- package/lib-commonjs/components/Display/index.d.ts +1 -0
- package/lib-commonjs/components/Display/index.js +10 -0
- package/lib-commonjs/components/Display/index.js.map +1 -0
- package/lib-commonjs/components/Headline/Headline.d.ts +6 -0
- package/lib-commonjs/components/Headline/Headline.js +30 -0
- package/lib-commonjs/components/Headline/Headline.js.map +1 -0
- package/lib-commonjs/components/Headline/index.d.ts +1 -0
- package/lib-commonjs/components/Headline/index.js +10 -0
- package/lib-commonjs/components/Headline/index.js.map +1 -0
- package/lib-commonjs/components/LargeTitle/LargeTitle.d.ts +6 -0
- package/lib-commonjs/components/LargeTitle/LargeTitle.js +30 -0
- package/lib-commonjs/components/LargeTitle/LargeTitle.js.map +1 -0
- package/lib-commonjs/components/LargeTitle/index.d.ts +1 -0
- package/lib-commonjs/components/LargeTitle/index.js +10 -0
- package/lib-commonjs/components/LargeTitle/index.js.map +1 -0
- package/lib-commonjs/components/Subheadline/Subheadline.d.ts +6 -0
- package/lib-commonjs/components/Subheadline/Subheadline.js +30 -0
- package/lib-commonjs/components/Subheadline/Subheadline.js.map +1 -0
- package/lib-commonjs/components/Subheadline/index.d.ts +1 -0
- package/lib-commonjs/components/Subheadline/index.js +10 -0
- package/lib-commonjs/components/Subheadline/index.js.map +1 -0
- package/lib-commonjs/components/Text/Text.d.ts +6 -0
- package/lib-commonjs/components/Text/Text.js +26 -0
- package/lib-commonjs/components/Text/Text.js.map +1 -0
- package/lib-commonjs/components/Text/Text.types.d.ts +77 -0
- package/lib-commonjs/components/Text/Text.types.js +6 -0
- package/lib-commonjs/components/Text/Text.types.js.map +1 -0
- package/lib-commonjs/components/Text/index.d.ts +5 -0
- package/lib-commonjs/components/Text/index.js +18 -0
- package/lib-commonjs/components/Text/index.js.map +1 -0
- package/lib-commonjs/components/Text/renderText.d.ts +5 -0
- package/lib-commonjs/components/Text/renderText.js +27 -0
- package/lib-commonjs/components/Text/renderText.js.map +1 -0
- package/lib-commonjs/components/Text/useText.d.ts +12 -0
- package/lib-commonjs/components/Text/useText.js +60 -0
- package/lib-commonjs/components/Text/useText.js.map +1 -0
- package/lib-commonjs/components/Text/useTextStyles.d.ts +5 -0
- package/lib-commonjs/components/Text/useTextStyles.js +120 -0
- package/lib-commonjs/components/Text/useTextStyles.js.map +1 -0
- package/lib-commonjs/components/Title1/Title1.d.ts +6 -0
- package/lib-commonjs/components/Title1/Title1.js +30 -0
- package/lib-commonjs/components/Title1/Title1.js.map +1 -0
- package/lib-commonjs/components/Title1/index.d.ts +1 -0
- package/lib-commonjs/components/Title1/index.js +10 -0
- package/lib-commonjs/components/Title1/index.js.map +1 -0
- package/lib-commonjs/components/Title2/Title2.d.ts +6 -0
- package/lib-commonjs/components/Title2/Title2.js +30 -0
- package/lib-commonjs/components/Title2/Title2.js.map +1 -0
- package/lib-commonjs/components/Title2/index.d.ts +1 -0
- package/lib-commonjs/components/Title2/index.js +10 -0
- package/lib-commonjs/components/Title2/index.js.map +1 -0
- package/lib-commonjs/components/Title3/Title3.d.ts +6 -0
- package/lib-commonjs/components/Title3/Title3.js +30 -0
- package/lib-commonjs/components/Title3/Title3.js.map +1 -0
- package/lib-commonjs/components/Title3/index.d.ts +1 -0
- package/lib-commonjs/components/Title3/index.js +10 -0
- package/lib-commonjs/components/Title3/index.js.map +1 -0
- package/lib-commonjs/components/wrapper.d.ts +7 -0
- package/lib-commonjs/components/wrapper.js +29 -0
- package/lib-commonjs/components/wrapper.js.map +1 -0
- package/lib-commonjs/index.d.ts +10 -0
- package/lib-commonjs/index.js +28 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/typographyStyles/index.d.ts +2 -0
- package/lib-commonjs/typographyStyles/index.js +11 -0
- package/lib-commonjs/typographyStyles/index.js.map +1 -0
- package/lib-commonjs/typographyStyles/typographyStyles.d.ts +14 -0
- package/lib-commonjs/typographyStyles/typographyStyles.js +109 -0
- package/lib-commonjs/typographyStyles/typographyStyles.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# @fluentui/react-text
|
2
|
+
|
3
|
+
> WIP 🚧 - These are not production-ready components as we are still in a Beta phase.
|
4
|
+
|
5
|
+
<!-- TODO: Add link to the new website -->
|
6
|
+
|
7
|
+
The Text component exists to ensure consistency in your application's content by setting fixed sizes and other styles.
|
8
|
+
This package also exports wrappers which ensure your text follows the Fluent design standards of typography.
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
To use the Text components in your application, you can start by installing the main package of Fluent UI components:
|
13
|
+
|
14
|
+
<!-- TODO: Validate if FluentProvider works without theme. If not, which theme should we refer to -->
|
15
|
+
|
16
|
+
```sh
|
17
|
+
npm install @fluentui/react-components
|
18
|
+
```
|
19
|
+
|
20
|
+
```jsx
|
21
|
+
import { FluentProvider, Text } from '@fluentui/react-components';
|
22
|
+
|
23
|
+
const App = () => (
|
24
|
+
<FluentProvider>
|
25
|
+
<Text>Fluent UI Text!</Text>
|
26
|
+
</FluentProvider>
|
27
|
+
);
|
28
|
+
```
|
29
|
+
|
30
|
+
Or by installing only the `@fluentui/react-text` package. Keep in mind you'll need to install the FluentProvider package as well:
|
31
|
+
|
32
|
+
```sh
|
33
|
+
npm install @fluentui/react-text
|
34
|
+
npm install @fluentui/react-provider
|
35
|
+
```
|
36
|
+
|
37
|
+
```jsx
|
38
|
+
import { FluentProvider } from '@fluentui/react-provider';
|
39
|
+
import { Text } from '@fluentui/react-text';
|
40
|
+
|
41
|
+
const App = () => (
|
42
|
+
<FluentProvider>
|
43
|
+
<Text>Fluent UI Text!</Text>
|
44
|
+
</FluentProvider>
|
45
|
+
);
|
46
|
+
```
|
47
|
+
|
48
|
+
## Typography wrappers
|
49
|
+
|
50
|
+

|
51
|
+
|
52
|
+
Wrappers offer an easy way to use text according to the Fluent Design System while also providing semantic code readability.
|
53
|
+
|
54
|
+
Below is an example of the Display wrapper vs using the Text component:
|
55
|
+
|
56
|
+
```tsx
|
57
|
+
import { Text, Display } from '@fluentui/react-text';
|
58
|
+
|
59
|
+
const Example = () => (
|
60
|
+
<>
|
61
|
+
<Text size={1000} weight="semibold">
|
62
|
+
This text is styled like a Display variant.
|
63
|
+
</Text>
|
64
|
+
<Display>This text is also styled like a Display variant.</Display>
|
65
|
+
</>
|
66
|
+
);
|
67
|
+
```
|
68
|
+
|
69
|
+
As you can see, using the `Display` wrapper is a lot easier to read and provides a clearer visual of the page's layout.
|
70
|
+
|
71
|
+
## Semantic elements
|
72
|
+
|
73
|
+
By default, Text and all the typography wrappers render a `<span>` element. You should use the `as` property to ensure your page has proper semantic elements such as heading or paragraph elements.
|
74
|
+
|
75
|
+
```html
|
76
|
+
<div>
|
77
|
+
<Headline as="h1">Headline</Headline>
|
78
|
+
<Subheadline as="h2">Subheadline</Subheadline>
|
79
|
+
<Text as="p">This is simple example</Text>
|
80
|
+
</div>
|
81
|
+
```
|
82
|
+
|
83
|
+
This will result in the following DOM structure:
|
84
|
+
|
85
|
+
```html
|
86
|
+
<div>
|
87
|
+
<h1>Headline</h1>
|
88
|
+
<h2>Subheadline</h2>
|
89
|
+
<p>This is simple example</p>
|
90
|
+
</div>
|
91
|
+
```
|
92
|
+
|
93
|
+
## API
|
94
|
+
|
95
|
+
For more information about the components, please refer to the [API documentation](https://aka.ms/fluentui-storybook).
|
96
|
+
|
97
|
+
## Migration
|
98
|
+
|
99
|
+
For migration information, have a look at the [migration guide](./MIGRATION.md).
|
package/Spec.md
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
# @fluentui/react-text Spec
|
2
|
+
|
3
|
+
## Background
|
4
|
+
|
5
|
+
Text is a typography and styling abstraction component that can be used to ensure the consistency of all text across your application.
|
6
|
+
|
7
|
+
Fabric used the `variant` prop to set any styling/format to the Text component, while also providing other utilities like `nowrap` and `block`.
|
8
|
+
|
9
|
+
```jsx
|
10
|
+
<Text>This is a Text component</Text>
|
11
|
+
|
12
|
+
<Text variant="medium">Text</Text>
|
13
|
+
|
14
|
+
<Text block>Text</Text>
|
15
|
+
|
16
|
+
<Text nowrap>Text with ellipsis</Text>
|
17
|
+
```
|
18
|
+
|
19
|
+
Stardust's approach provides a more open API, allowing the user to customize `Text` to their own specific needs.
|
20
|
+
|
21
|
+
```jsx
|
22
|
+
<Text weight="light" content="This text is light." />
|
23
|
+
|
24
|
+
<Text color="green" content="Green text" />
|
25
|
+
|
26
|
+
<Text align="end" content="Text aligned to end" />
|
27
|
+
|
28
|
+
<Text error content="There has been an error." />
|
29
|
+
|
30
|
+
<Text disabled content="This feature has been disabled." />
|
31
|
+
```
|
32
|
+
|
33
|
+
## Prior Art
|
34
|
+
|
35
|
+
- [Open UI research](https://github.com/openui/open-ui/pull/351)
|
36
|
+
- [Convergence epic](https://github.com/microsoft/fluentui/issues/16847)
|
37
|
+
|
38
|
+
## Comparison of [Fabric Text](https://developer.microsoft.com/en-us/fluentui#/controls/web/text) and [Stardust Text](https://fluentsite.z22.web.core.windows.net/0.56.0/components/text/definition)
|
39
|
+
|
40
|
+
| Purpose | Fabric | Northstar | Matching |
|
41
|
+
| ---------------------------------------------------------------------------------------------------------------- | ------- | ------------- | -------------------- |
|
42
|
+
| An element type to render as (string or component). | as | as | Matching |
|
43
|
+
| Truncates text as needed | nowrap | truncated | Matching |
|
44
|
+
| Set font size for text | variant | size | Matching |
|
45
|
+
| Renders Text as a block element | block | | Missing in Northstar |
|
46
|
+
| Accessibility behavior if overridden by the user. | | accessibility | Missing in Fabric |
|
47
|
+
| Align text content. | | align | Missing in Fabric |
|
48
|
+
| At mentions can be formatted to draw users' attention. Mentions for "me" can be formatted to appear differently. | | atMention | Missing in Fabric |
|
49
|
+
| A component can have a color. | | color | Missing in Fabric |
|
50
|
+
| Shorthand for primary content. | | content | Missing in Fabric |
|
51
|
+
| Set as disabled Text component | | disabled | Missing in Fabric |
|
52
|
+
| Set as error Text component | | error | Missing in Fabric |
|
53
|
+
| The text can appear more important and draw user's attention | | important | Missing in Fabric |
|
54
|
+
| Set as success Text component | | success | Missing in Fabric |
|
55
|
+
| The text can signify a temporary state | | temporary | Missing in Fabric |
|
56
|
+
| Set as timestamp Text component | | timestamp | Missing in Fabric |
|
57
|
+
| Override for theme site variables to allow modifications of component styling via themes. | | variables | Missing in Fabric |
|
58
|
+
| The weight for the Text component | | weight | Missing in Fabric |
|
59
|
+
| Additional CSS class name(s) to apply. | | className | Missing in Fabric |
|
60
|
+
| Additional CSS styles to apply to the component instance. | | styles | Missing in Fabric |
|
61
|
+
| - | | design | Missing in Fabric |
|
62
|
+
|
63
|
+
## API Proposal
|
64
|
+
|
65
|
+
The new Text will provide props to customize text according to the standards defined by Fluent design. The component will not be tied down to specific application usage, like Stardust did, for example, with `mention` and `timestamp` props, and will allow a bigger degree of freedom when customizing, unlike we did in Fabric.
|
66
|
+
We're also introducing a new concept of wrappers for the main design variants (i.e. 'Title', 'Subtitle', 'Caption') to improve readability and semantics of the code. The wrappers are expected to have fixed styles in terms of size and font family, but flexible for the other supported props in Text.
|
67
|
+
These wrappers follow the Fluent UI language so for any deviation, regarding the fixed styles mentioned above, should use the Text component instead, given that this is fully customizable.
|
68
|
+
|
69
|
+
| Property | Type | Default value | Comments |
|
70
|
+
| ------------- | ---------------------------------------------------------------------- | ------------- | -------- |
|
71
|
+
| as | "span" \| "p" \| "h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6" \| "pre" | "span" | |
|
72
|
+
| wrap | boolean | true | |
|
73
|
+
| truncate | boolean | false | |
|
74
|
+
| block | boolean | false | |
|
75
|
+
| italic | boolean | false | |
|
76
|
+
| underline | boolean | false | |
|
77
|
+
| strikethrough | boolean | false | |
|
78
|
+
| size | number - 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 | 300 | |
|
79
|
+
| font | string - "base" \| "monospace" \| "numeric" | "base" | |
|
80
|
+
| weight | string - "regular" \| "medium" \| "semibold" | "regular" | |
|
81
|
+
| align | string - "start" \| "center" \| "end" \| "justify" | "start" | |
|
82
|
+
|
83
|
+
### make-styles rules
|
84
|
+
|
85
|
+
Finally, we're also making available the styling used internally in Text for a lightweight styling solution if you want to avoid using Text or the added JavaScript layers of Text/wrappers.
|
86
|
+
This is achieved with the `make-styles` rules being available to the user so that they can follow the Fluent design standards for Typography.
|
87
|
+
|
88
|
+
## Sample Code
|
89
|
+
|
90
|
+
### Using Text
|
91
|
+
|
92
|
+
```jsx
|
93
|
+
<Text weight="semibold" size={1000}>This text is semibold and huge.</Text>
|
94
|
+
|
95
|
+
<Text align="end" italic>Text aligned to the end</Text>
|
96
|
+
|
97
|
+
<Text strikethrough>This text has a strikethrough.</Text>
|
98
|
+
```
|
99
|
+
|
100
|
+
### Using the wrappers
|
101
|
+
|
102
|
+
```jsx
|
103
|
+
<Display bold>This text is huge.</Display>
|
104
|
+
<LargeTitle>This is a large title.</LargeTitle>
|
105
|
+
<Title as="h1">Title</Title>
|
106
|
+
<Subtitle as="h2">Sub title</Subtitle>
|
107
|
+
<Caption>Captioned</Caption>
|
108
|
+
```
|
109
|
+
|
110
|
+
### Using styles directly
|
111
|
+
|
112
|
+
```jsx
|
113
|
+
import { typographyStyles } from '@fluentui/react-text';
|
114
|
+
|
115
|
+
const useStyles = makeStyles({
|
116
|
+
root: typographyStyles.title,
|
117
|
+
caption: typographyStyles.caption,
|
118
|
+
});
|
119
|
+
|
120
|
+
const Test = () => {
|
121
|
+
const styles = useStyles();
|
122
|
+
|
123
|
+
return (
|
124
|
+
<>
|
125
|
+
<p className={styles.root}>
|
126
|
+
<span>I am styled like a title</span>
|
127
|
+
<span className={styles.caption}>I am styled like a caption</span>
|
128
|
+
</p>
|
129
|
+
</>
|
130
|
+
);
|
131
|
+
};
|
132
|
+
```
|
133
|
+
|
134
|
+
## Behaviours
|
135
|
+
|
136
|
+
### Screen readers
|
137
|
+
|
138
|
+
#### Truncate
|
139
|
+
|
140
|
+
When using a screen reader, truncated text will be read completely, as truncation is used strictly to prevent text overflow.
|
141
|
+
|
142
|
+
Sample:
|
143
|
+
|
144
|
+
```jsx
|
145
|
+
<Text truncate>This is a very long text that will be truncated.</Text>
|
146
|
+
```
|
147
|
+
|
148
|
+
Visual result:
|
149
|
+
|
150
|
+
```
|
151
|
+
This is a very long text...
|
152
|
+
```
|
153
|
+
|
154
|
+
Screen reader:
|
155
|
+
|
156
|
+
```
|
157
|
+
This is a very long text that will be truncated.
|
158
|
+
```
|
159
|
+
|
160
|
+
## Accesibility
|
161
|
+
|
162
|
+
Accessibility is included in the entirety of the spec and there are no specific themes to address here.
|
Binary file
|
@@ -0,0 +1,163 @@
|
|
1
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
2
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
4
|
+
import type { FunctionComponent } from 'react';
|
5
|
+
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
6
|
+
import * as React_2 from 'react';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Text wrapper component for the Body typography variant
|
10
|
+
*/
|
11
|
+
declare const Body_2: FunctionComponent<TextWrapperProps>;
|
12
|
+
export { Body_2 as Body }
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Text wrapper component for the Caption typography variant
|
16
|
+
*/
|
17
|
+
export declare const Caption: FunctionComponent<TextWrapperProps>;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Text wrapper component for the Display typography variant
|
21
|
+
*/
|
22
|
+
export declare const Display: FunctionComponent<TextWrapperProps>;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Text wrapper component for the Headline typography variant
|
26
|
+
*/
|
27
|
+
export declare const Headline: FunctionComponent<TextWrapperProps>;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Text wrapper component for the Large Title typography variant
|
31
|
+
*/
|
32
|
+
export declare const LargeTitle: FunctionComponent<TextWrapperProps>;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Render the final JSX of Text
|
36
|
+
*/
|
37
|
+
export declare const renderText: (state: TextState) => JSX.Element;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Text wrapper component for the Subheadline typography variant
|
41
|
+
*/
|
42
|
+
export declare const Subheadline: FunctionComponent<TextWrapperProps>;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Typography and styling abstraction component used to ensure consistency of text.
|
46
|
+
*/
|
47
|
+
declare const Text_2: ForwardRefComponent<TextProps>;
|
48
|
+
export { Text_2 as Text }
|
49
|
+
|
50
|
+
export declare type TextCommons = {
|
51
|
+
/**
|
52
|
+
* Wraps the text content on white spaces.
|
53
|
+
*
|
54
|
+
* @defaultValue true
|
55
|
+
*/
|
56
|
+
wrap: boolean;
|
57
|
+
/**
|
58
|
+
* Truncate overflowing text for block displays.
|
59
|
+
*
|
60
|
+
* @defaultValue false
|
61
|
+
*/
|
62
|
+
truncate: boolean;
|
63
|
+
/**
|
64
|
+
* Applies a block display for the content.
|
65
|
+
*
|
66
|
+
* @defaultValue false
|
67
|
+
*/
|
68
|
+
block: boolean;
|
69
|
+
/**
|
70
|
+
* Applies the italic font style to the content.
|
71
|
+
*
|
72
|
+
* @defaultValue false
|
73
|
+
*/
|
74
|
+
italic: boolean;
|
75
|
+
/**
|
76
|
+
* Applies the underline text decoration to the content.
|
77
|
+
*
|
78
|
+
* @defaultValue false
|
79
|
+
*/
|
80
|
+
underline: boolean;
|
81
|
+
/**
|
82
|
+
* Applies the strikethrough text decoration to the content.
|
83
|
+
*
|
84
|
+
* @defaultValue false
|
85
|
+
*/
|
86
|
+
strikethrough: boolean;
|
87
|
+
/**
|
88
|
+
* Applies font size and line height based on the theme tokens.
|
89
|
+
*
|
90
|
+
* @defaultValue 300
|
91
|
+
*/
|
92
|
+
size: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000;
|
93
|
+
/**
|
94
|
+
* Applies the font family to the content.
|
95
|
+
*
|
96
|
+
* @defaultValue base
|
97
|
+
*/
|
98
|
+
font: 'base' | 'monospace' | 'numeric';
|
99
|
+
/**
|
100
|
+
* Applies font weight to the content.
|
101
|
+
*
|
102
|
+
* @defaultValue regular
|
103
|
+
*/
|
104
|
+
weight: 'regular' | 'medium' | 'semibold';
|
105
|
+
/**
|
106
|
+
* Aligns text based on the parent container.
|
107
|
+
*
|
108
|
+
* @defaultValue start
|
109
|
+
*/
|
110
|
+
align: 'start' | 'center' | 'end' | 'justify';
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Text Props
|
115
|
+
*/
|
116
|
+
export declare type TextProps = ComponentProps<TextSlots> & Partial<TextCommons>;
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Text slots
|
120
|
+
*/
|
121
|
+
export declare type TextSlots = {
|
122
|
+
root: IntrinsicShorthandProps<'span', 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'pre'>;
|
123
|
+
};
|
124
|
+
|
125
|
+
/**
|
126
|
+
* State used in rendering Text
|
127
|
+
*/
|
128
|
+
export declare type TextState = ComponentState<TextSlots> & TextCommons;
|
129
|
+
|
130
|
+
declare type TextWrapperProps = Omit<TextProps, 'font' | 'size'>;
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Text wrapper component for the Title 1 typography variant
|
134
|
+
*/
|
135
|
+
export declare const Title1: FunctionComponent<TextWrapperProps>;
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Text wrapper component for the Title 2 typography variant
|
139
|
+
*/
|
140
|
+
export declare const Title2: FunctionComponent<TextWrapperProps>;
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Text wrapper component for the Title 3 typography variant
|
144
|
+
*/
|
145
|
+
export declare const Title3: FunctionComponent<TextWrapperProps>;
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Create the state required to render Text.
|
149
|
+
*
|
150
|
+
* The returned state can be modified with hooks such as useTextStyles,
|
151
|
+
* before being passed to renderText.
|
152
|
+
*
|
153
|
+
* @param props - props from this instance of Text
|
154
|
+
* @param ref - reference to root HTMLElement of Text
|
155
|
+
*/
|
156
|
+
export declare const useText: (props: TextProps, ref: React_2.Ref<HTMLElement>) => TextState;
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Apply styling to the Text slots based on the state
|
160
|
+
*/
|
161
|
+
export declare const useTextStyles: (state: TextState) => TextState;
|
162
|
+
|
163
|
+
export { }
|
package/lib/Body.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Body/index';
|
package/lib/Body.js
ADDED
package/lib/Body.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Body.js","sourceRoot":"","sources":["../src/Body.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/lib/Caption.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Caption/index';
|
package/lib/Caption.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Caption.js","sourceRoot":"","sources":["../src/Caption.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/lib/Display.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Display/index';
|
package/lib/Display.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Display.js","sourceRoot":"","sources":["../src/Display.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Headline/index';
|
package/lib/Headline.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Headline.js","sourceRoot":"","sources":["../src/Headline.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/LargeTitle/index';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LargeTitle.js","sourceRoot":"","sources":["../src/LargeTitle.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Subheadline/index';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Subheadline.js","sourceRoot":"","sources":["../src/Subheadline.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
|
package/lib/Text.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Text/index';
|
package/lib/Text.js
ADDED
package/lib/Text.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/lib/Title1.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Title1/index';
|
package/lib/Title1.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Title1.js","sourceRoot":"","sources":["../src/Title1.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/Title2.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Title2/index';
|
package/lib/Title2.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Title2.js","sourceRoot":"","sources":["../src/Title2.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/Title3.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Title3/index';
|
package/lib/Title3.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Title3.js","sourceRoot":"","sources":["../src/Title3.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { isConformant as baseIsConformant } from '@fluentui/react-conformance';
|
2
|
+
import makeStylesTests from '@fluentui/react-conformance-make-styles';
|
3
|
+
export function isConformant(testInfo) {
|
4
|
+
var defaultOptions = {
|
5
|
+
asPropHandlesRef: true,
|
6
|
+
componentPath: module.parent.filename.replace('.test', ''),
|
7
|
+
extraTests: makeStylesTests,
|
8
|
+
testOptions: {
|
9
|
+
'make-styles-overrides-win': {
|
10
|
+
callCount: 2
|
11
|
+
}
|
12
|
+
}
|
13
|
+
};
|
14
|
+
baseIsConformant(defaultOptions, testInfo);
|
15
|
+
}
|
16
|
+
//# sourceMappingURL=isConformant.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/common/isConformant.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,IAAI,gBAAzB,QAAiD,6BAAjD;AAEA,OAAO,eAAP,MAA4B,yCAA5B;AAEA,OAAM,SAAU,YAAV,CACJ,QADI,EACqF;AAEzF,MAAM,cAAc,GAAyC;AAC3D,IAAA,gBAAgB,EAAE,IADyC;AAE3D,IAAA,aAAa,EAAE,MAAO,CAAC,MAAR,CAAgB,QAAhB,CAAyB,OAAzB,CAAiC,OAAjC,EAA0C,EAA1C,CAF4C;AAG3D,IAAA,UAAU,EAAE,eAH+C;AAI3D,IAAA,WAAW,EAAE;AACX,mCAA6B;AAC3B,QAAA,SAAS,EAAE;AADgB;AADlB;AAJ8C,GAA7D;AAaA,EAAA,gBAAgB,CAAC,cAAD,EAAiB,QAAjB,CAAhB;AACD","sourceRoot":""}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { __styles } from '@fluentui/react-make-styles';
|
2
|
+
import { typographyStyles } from '../../typographyStyles/index';
|
3
|
+
import { createWrapper } from '../wrapper';
|
4
|
+
/**
|
5
|
+
* Styles for the root slot
|
6
|
+
*/
|
7
|
+
|
8
|
+
var useStyles = /*#__PURE__*/__styles({
|
9
|
+
"root": {
|
10
|
+
"Bahqtrf": "fk6fouc",
|
11
|
+
"Be2twd7": "fkhj508",
|
12
|
+
"Bg96gwp": "f1i3iumi",
|
13
|
+
"Bhrd7zp": "figsok6"
|
14
|
+
}
|
15
|
+
}, {
|
16
|
+
"d": [".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}"]
|
17
|
+
});
|
18
|
+
/**
|
19
|
+
* Text wrapper component for the Body typography variant
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
export var Body = /*#__PURE__*/createWrapper({
|
24
|
+
useStyles: useStyles,
|
25
|
+
displayName: 'Body'
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=Body.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Body/Body.tsx"],"names":[],"mappings":"AACA,yBAA2B,6BAA3B;AACA,SAAS,gBAAT,QAAiC,8BAAjC;AACA,SAAS,aAAT,QAAgD,YAAhD;AAEA;;AAEG;;AACH,IAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;AAIA;;AAEG;;;AACH,OAAO,IAAM,IAAI,gBAAwC,aAAa,CAAC;AAAE,EAAA,SAAS,EAAA,SAAX;AAAa,EAAA,WAAW,EAAE;AAA1B,CAAD,CAA/D","sourceRoot":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './Body';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Body/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { __styles } from '@fluentui/react-make-styles';
|
2
|
+
import { typographyStyles } from '../../typographyStyles/index';
|
3
|
+
import { createWrapper } from '../wrapper';
|
4
|
+
/**
|
5
|
+
* Styles for the root slot
|
6
|
+
*/
|
7
|
+
|
8
|
+
var useStyles = /*#__PURE__*/__styles({
|
9
|
+
"root": {
|
10
|
+
"Bahqtrf": "fk6fouc",
|
11
|
+
"Be2twd7": "fy9rknc",
|
12
|
+
"Bg96gwp": "fwrc4pm",
|
13
|
+
"Bhrd7zp": "figsok6"
|
14
|
+
}
|
15
|
+
}, {
|
16
|
+
"d": [".fk6fouc{font-family:var(--fontFamilyBase);}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".figsok6{font-weight:var(--fontWeightRegular);}"]
|
17
|
+
});
|
18
|
+
/**
|
19
|
+
* Text wrapper component for the Caption typography variant
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
export var Caption = /*#__PURE__*/createWrapper({
|
24
|
+
useStyles: useStyles,
|
25
|
+
displayName: 'Caption'
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=Caption.js.map
|