@fluentui-react-native/text 0.13.0 → 0.14.0
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 +16 -1
- package/CHANGELOG.md +10 -2
- package/MIGRATION.md +98 -0
- package/README.md +5 -0
- package/SPEC.md +235 -0
- package/assets/Text_example_block_win32.png +0 -0
- package/assets/Text_example_customized_win32.png +0 -0
- package/assets/Text_example_inline_win32.png +0 -0
- package/assets/Text_example_pressable_win32.png +0 -0
- package/assets/Text_example_underlined_win32.png +0 -0
- package/assets/Text_example_variants_win32.png +0 -0
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/text",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Fri,
|
|
5
|
+
"date": "Fri, 05 Aug 2022 23:21:34 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/text_v0.14.0",
|
|
7
|
+
"version": "0.14.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "email not defined",
|
|
12
|
+
"package": "@fluentui-react-native/text",
|
|
13
|
+
"commit": "4716cf81c971eed5f609a861c128dcfc4b2f0b46",
|
|
14
|
+
"comment": "Update out of date documentation (#1964)"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 29 Jul 2022 21:04:39 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/text_v0.13.0",
|
|
7
22
|
"version": "0.13.0",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/text
|
|
2
2
|
|
|
3
|
-
This log was last generated on Fri,
|
|
3
|
+
This log was last generated on Fri, 05 Aug 2022 23:21:34 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.14.0
|
|
8
|
+
|
|
9
|
+
Fri, 05 Aug 2022 23:21:34 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Update out of date documentation (#1964) (email not defined)
|
|
14
|
+
|
|
7
15
|
## 0.13.0
|
|
8
16
|
|
|
9
|
-
Fri, 29 Jul 2022 21:
|
|
17
|
+
Fri, 29 Jul 2022 21:04:39 GMT
|
|
10
18
|
|
|
11
19
|
### Minor changes
|
|
12
20
|
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Text Migration
|
|
2
|
+
|
|
3
|
+
## Migration from v0 Text
|
|
4
|
+
|
|
5
|
+
In the short term, the new `Text` control is named `TextV1` while it clashes with the existing older control. Once we deprecate the old control, it will be renamed to `Text`. It may be useful to rename the control to `Text` using the import syntax to simplify the rename:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { TextV1 as Text } from '@fluentui-react-native/text';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Component renames
|
|
12
|
+
|
|
13
|
+
| v0 `Text` | v1 `Text` |
|
|
14
|
+
| --------------------------- | --------------------------- |
|
|
15
|
+
| `<Text>Hello, World</Text>` | `<Text>Hello, World</Text>` |
|
|
16
|
+
|
|
17
|
+
### Props unchanged
|
|
18
|
+
|
|
19
|
+
- Any props that are part of `ViewProps` and `TextProps` from `react-native`
|
|
20
|
+
- `color`
|
|
21
|
+
|
|
22
|
+
### Props changed
|
|
23
|
+
|
|
24
|
+
- `variant` => Prop name remains identical, but will support a different collection of named font variants. Newly defined v1 variants can be found in [Typography.types](../../theming/theme-types/src/Typography.types.ts) under theme-types.
|
|
25
|
+
|
|
26
|
+
### Props added
|
|
27
|
+
|
|
28
|
+
- `align`
|
|
29
|
+
- `block`
|
|
30
|
+
- `font`
|
|
31
|
+
- `italic`
|
|
32
|
+
- `strikethrough`
|
|
33
|
+
- `size`
|
|
34
|
+
- `truncate`
|
|
35
|
+
- `underline`
|
|
36
|
+
- `weight`
|
|
37
|
+
- `wrap`
|
|
38
|
+
|
|
39
|
+
### Props removed
|
|
40
|
+
|
|
41
|
+
- `disabled` is not supported in the v1 Text
|
|
42
|
+
|
|
43
|
+
### Tokens unchanged
|
|
44
|
+
|
|
45
|
+
- Any props that are part of `FontTokens`, `IForegroundColorTokens`
|
|
46
|
+
|
|
47
|
+
### Tokens changed
|
|
48
|
+
|
|
49
|
+
- Global font tokens have been editted according to design token redlines
|
|
50
|
+
|
|
51
|
+
| Token | Win32 |
|
|
52
|
+
| ----------- | ------------- |
|
|
53
|
+
| Family | |
|
|
54
|
+
| `Base` | `SegoeUI` |
|
|
55
|
+
| `Monospace` | `Consolas` |
|
|
56
|
+
| `Numeric` | `Bahnschrift` |
|
|
57
|
+
| Size | |
|
|
58
|
+
| `100` | `10px`/`14px` |
|
|
59
|
+
| `200` | `12px`/`16px` |
|
|
60
|
+
| `300` | `14px`/`20px` |
|
|
61
|
+
| `400` | `16px`/`22px` |
|
|
62
|
+
| `500` | `20px`/`26px` |
|
|
63
|
+
| `600` | `24px`/`32px` |
|
|
64
|
+
| `700` | `28px`/`36px` |
|
|
65
|
+
| `800` | `32px`/`40px` |
|
|
66
|
+
| `900` | `40px`/`52px` |
|
|
67
|
+
| `1000` | `68px`/`92px` |
|
|
68
|
+
| Weight | |
|
|
69
|
+
| `Regular` | `400` |
|
|
70
|
+
| `Medium` | `500` |
|
|
71
|
+
| `Semibold` | `600` |
|
|
72
|
+
| `Bold` | `700` |
|
|
73
|
+
|
|
74
|
+
### Tokens not supported natively on win32
|
|
75
|
+
|
|
76
|
+
- `lineHeight`
|
|
77
|
+
- `letterSpacing`
|
|
78
|
+
- `textDecorationColor`
|
|
79
|
+
- `textShadowColor`
|
|
80
|
+
- `textShadowOffset`
|
|
81
|
+
- `textShadowRadius`
|
|
82
|
+
- `textTransform`
|
|
83
|
+
|
|
84
|
+
### Updating ThemeProvider
|
|
85
|
+
|
|
86
|
+
If you are using the older theme provider `ThemeProvider` from `@uifabricshared/theming-react-native`, you will need to update the `ThemeProvider` to pull from `@fluentui-react-native/theme` to have the control work properly with themes. Please see [this page](../../../docs/pages/Guides/UpdateThemeProvider.md) for guidance.
|
|
87
|
+
|
|
88
|
+
### Migrating customized Text
|
|
89
|
+
|
|
90
|
+
Please see [this page](../../../docs/pages/Guides/UpdatingCustomize.md) for guidance on how to move from the old `customize` API to the new one.
|
|
91
|
+
|
|
92
|
+
### Other Prop differences
|
|
93
|
+
|
|
94
|
+
- `block` => On win32, instead of setting it as a boolean prop, block display is applied by default, and is overridden as inline when `<Text>` is wrapped by a parent `<Text>`.
|
|
95
|
+
|
|
96
|
+
### Slot differences
|
|
97
|
+
|
|
98
|
+
There are no slot differences for FURN `Text`
|
package/README.md
ADDED
package/SPEC.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Text
|
|
2
|
+
|
|
3
|
+
In the short term, the new `Text` control is named `TextV1` while it clashes with the existing older control. Once we deprecate the old control, it will be renamed to `Text`. It may be useful to rename the control to `Text` using the import syntax to simplify the rename:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { TextV1 as Text } from '@fluentui-react-native/text';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
FURN components that have imported from experimental-text now use the above syntax to use `TextV1`.
|
|
10
|
+
|
|
11
|
+
## Background
|
|
12
|
+
|
|
13
|
+
The `Text` component is for displaying text, and supports nesting, styling, and touch handling.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
If using FURN's theming, the `Text` requires use of the `ThemeProvider` from `@fluentui-react-native/theme` to work properly with themes. Please see [this page](../../../docs/pages/Guides/UpdateThemeProvider.md) for information on updating your `ThemeProvider` if using the version from `@uifabricshared/theming-react-native`.
|
|
18
|
+
|
|
19
|
+
## Sample Code
|
|
20
|
+
|
|
21
|
+
Basic example:
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Text>Hello World</Text>
|
|
25
|
+
```
|
|
26
|
+
More examples on the [Test pages for Text](../../../apps/fluent-tester/src/TestComponents/TextExperimental). Instructions on running the tester app can be found [here](../../../apps/fluent-tester/README.md).
|
|
27
|
+
|
|
28
|
+
## Visual Examples
|
|
29
|
+
|
|
30
|
+
Win32:
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
```jsx
|
|
35
|
+
<Text underline>This line has been underlined and striked through</Text>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
```jsx
|
|
41
|
+
<>
|
|
42
|
+
<Text>Every block of text gets its own line.</Text>
|
|
43
|
+
<Text>This is a new block</Text>
|
|
44
|
+
</>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
<Text>
|
|
51
|
+
<Text>Text components inside a parent text component is inline text</Text>
|
|
52
|
+
<Text>This entire block is a RichLabel.</Text>
|
|
53
|
+
</Text>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
```jsx
|
|
59
|
+
const RedCaptionBold = Text.customize({ variant: 'captionStandard', fontWeight: '700', color: '#ff0000' });
|
|
60
|
+
<RedCaptionBold>RedCaptionBold</RedCaptionBold>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
V1 `Text` component supports variant types that have preset font family, size, and weight values.
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
<Caption1>Caption1</Caption1>
|
|
68
|
+
<Body1>Body1</Body1>
|
|
69
|
+
<Body1Strong>Body1Strong</Body1Strong>
|
|
70
|
+
<Body2>Body2</Body2>
|
|
71
|
+
<Body2Strong>Body2Strong</Body2Strong>
|
|
72
|
+
<Subtitle2>Subtitle2</Subtitle2>
|
|
73
|
+
<Subtitle2Strong>Subtitle2Strong</Subtitle2Strong>
|
|
74
|
+
<Subtitle1>Subtitle1</Subtitle1>
|
|
75
|
+
<Subtitle1Strong>Subtitle1Strong</Subtitle1Strong>
|
|
76
|
+
<Title1>Title1</Title1>
|
|
77
|
+
<Title1Strong>Title1Strong</Title1Strong>
|
|
78
|
+
<LargeTitle>LargeTitle</LargeTitle>
|
|
79
|
+
<Display>Display</Display>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
<Text variant={'bodyStandard'}>
|
|
86
|
+
Press{' '}
|
|
87
|
+
<Text
|
|
88
|
+
variant={'bodyStandard'}
|
|
89
|
+
color="blue"
|
|
90
|
+
keyDownEvents={handledNativeKeyboardEvents}
|
|
91
|
+
onPress={_onPress2}
|
|
92
|
+
onKeyDown={_onKeyDown2}
|
|
93
|
+
>
|
|
94
|
+
here
|
|
95
|
+
</Text>{' '}
|
|
96
|
+
to view an alert.
|
|
97
|
+
</Text>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## API
|
|
101
|
+
|
|
102
|
+
The `Text` control is rendered as a `react-native` Text(`RNText`). However, `RNText`and `Text` do not align in their set of props entirely.
|
|
103
|
+
|
|
104
|
+
### Props
|
|
105
|
+
|
|
106
|
+
Below is the set of props the Text supports:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
export type TextProps<TBase = ITextProps> = TBase &
|
|
110
|
+
FontVariantTokens & {
|
|
111
|
+
/**
|
|
112
|
+
* foreground text color
|
|
113
|
+
*/
|
|
114
|
+
color?: ColorValue;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Aligns text based on the parent container.
|
|
118
|
+
*
|
|
119
|
+
* @defaultValue start
|
|
120
|
+
*/
|
|
121
|
+
align?: TextAlign;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Applies a block display for the content.
|
|
125
|
+
*
|
|
126
|
+
* @defaultValue false
|
|
127
|
+
*/
|
|
128
|
+
block?: boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Applies the font family to the content.
|
|
132
|
+
*
|
|
133
|
+
* @defaultValue base
|
|
134
|
+
*/
|
|
135
|
+
font?: TextFont;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Applies the italic font style to the content.
|
|
139
|
+
*
|
|
140
|
+
* @defaultValue false
|
|
141
|
+
*/
|
|
142
|
+
italic?: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Applies the strikethrough text decoration to the content.
|
|
146
|
+
*
|
|
147
|
+
* @defaultValue false
|
|
148
|
+
*/
|
|
149
|
+
strikethrough?: boolean;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Applies font size and line height based on the theme tokens.
|
|
153
|
+
*
|
|
154
|
+
* @defaultValue 300
|
|
155
|
+
*/
|
|
156
|
+
size?: TextSize;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Truncate overflowing text for block displays.
|
|
160
|
+
*
|
|
161
|
+
* @defaultValue false
|
|
162
|
+
*/
|
|
163
|
+
truncate?: boolean;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Applies the underline text decoration to the content.
|
|
167
|
+
*
|
|
168
|
+
* @defaultValue false
|
|
169
|
+
*/
|
|
170
|
+
underline?: boolean;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Applies font weight to the content.
|
|
174
|
+
*
|
|
175
|
+
* @defaultValue regular
|
|
176
|
+
*/
|
|
177
|
+
weight?: TextWeight;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Wraps the text content on white spaces.
|
|
181
|
+
*
|
|
182
|
+
* @defaultValue true
|
|
183
|
+
*/
|
|
184
|
+
wrap?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
8/1/22 Notes:
|
|
188
|
+
|
|
189
|
+
- `block` => On win32, instead of setting it as a boolean prop, block display is applied by default, and is overridden as inline when `<Text>` is wrapped by a parent `<Text>`.
|
|
190
|
+
|
|
191
|
+
- `font` => According to design token redlines, `font` prop is given a giant string with a delimiter of font families for each enum type (`base`/`numeric`/`monospace`), We currently don't have a way to deal with this fontFamily format. We only support a single font family for each font type.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Styling Tokens
|
|
195
|
+
|
|
196
|
+
Tokens can be used to customize the styling of the control by using the `customize` function on the `Text`. For more information on using the `customize` API, please see [this page](../../framework/composition/README.md). The `Text` has the following tokens:
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
export type TextTokens = FontTokens & IForegroundColorTokens & TextStyle;
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Behaviors
|
|
203
|
+
|
|
204
|
+
### Pressable Text
|
|
205
|
+
|
|
206
|
+
`Text` can be rendered as pressable.
|
|
207
|
+
|
|
208
|
+
### Interaction
|
|
209
|
+
|
|
210
|
+
#### Keyboard interaction
|
|
211
|
+
|
|
212
|
+
The following is a set of keys that interact with the `Text` component:
|
|
213
|
+
|
|
214
|
+
| Key | Description |
|
|
215
|
+
| ------- | --------------------------------------------------------------- |
|
|
216
|
+
| `Tab` | If `onPress` or `focusable` is set, component will gain focus. |
|
|
217
|
+
| `Space` | Executes the function passed into the `onPress` prop. |
|
|
218
|
+
|
|
219
|
+
#### Cursor interaction for Pressable Text
|
|
220
|
+
|
|
221
|
+
- Cursor moves onto pressable text: Should immediately change the styling of the `Text` so that it appears to be hovered.
|
|
222
|
+
- Cursor moves out of pressable text: Should immediately remove the hovered styling of the `Text`.
|
|
223
|
+
- Mouse click: Should handle `onPress` event of `Text` and move focus to its target.
|
|
224
|
+
|
|
225
|
+
#### Touch interaction
|
|
226
|
+
|
|
227
|
+
The same behavior as above translated for touch events. This means that there is no equivalent for `onHoverIn` and `onHoverOut`, which makes it so that the hovered state cannot be accessed.
|
|
228
|
+
|
|
229
|
+
## Accessibility
|
|
230
|
+
|
|
231
|
+
### Expected behavior
|
|
232
|
+
|
|
233
|
+
- Should mix in the accessibility props expected for a `Text` component.
|
|
234
|
+
- Should be keyboard tabbable and focusable.
|
|
235
|
+
- onAccessibilityTap defaults to onPress unless set otherwise
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|