@fluentui/web-components 3.0.0-alpha.1 → 3.0.0-alpha.3

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.
Files changed (109) hide show
  1. package/.eslintrc.json +62 -0
  2. package/CHANGELOG.json +208 -8
  3. package/CHANGELOG.md +155 -97
  4. package/build/{clean.js → clean.cjs} +0 -0
  5. package/dist/dts/badge/badge.d.ts +49 -0
  6. package/dist/dts/badge/badge.definition.d.ts +11 -0
  7. package/dist/dts/badge/badge.options.d.ts +73 -0
  8. package/dist/dts/badge/badge.stories.d.ts +12 -0
  9. package/dist/dts/badge/badge.styles.d.ts +4 -0
  10. package/dist/dts/badge/badge.template.d.ts +9 -0
  11. package/dist/dts/badge/define.d.ts +1 -0
  12. package/dist/dts/badge/index.d.ts +5 -0
  13. package/dist/dts/counter-badge/counter-badge.d.ts +90 -0
  14. package/dist/dts/counter-badge/counter-badge.definition.d.ts +11 -0
  15. package/dist/dts/counter-badge/counter-badge.options.d.ts +69 -0
  16. package/dist/dts/counter-badge/counter-badge.stories.d.ts +14 -0
  17. package/dist/dts/counter-badge/counter-badge.styles.d.ts +4 -0
  18. package/dist/dts/counter-badge/counter-badge.template.d.ts +7 -0
  19. package/dist/dts/counter-badge/define.d.ts +1 -0
  20. package/dist/dts/counter-badge/index.d.ts +5 -0
  21. package/dist/dts/fluent-design-system.d.ts +5 -0
  22. package/dist/dts/index-rollup.d.ts +1 -1
  23. package/dist/dts/index.d.ts +6 -1
  24. package/dist/dts/progress-bar/define.d.ts +1 -0
  25. package/dist/dts/progress-bar/index.d.ts +5 -0
  26. package/dist/dts/progress-bar/progress-bar.d.ts +30 -0
  27. package/dist/dts/progress-bar/progress-bar.definition.d.ts +10 -0
  28. package/dist/dts/progress-bar/progress-bar.options.d.ts +41 -0
  29. package/dist/dts/progress-bar/progress-bar.stories.d.ts +9 -0
  30. package/dist/dts/progress-bar/progress-bar.styles.d.ts +4 -0
  31. package/dist/dts/progress-bar/progress-bar.template.d.ts +3 -0
  32. package/dist/dts/spinner/define.d.ts +1 -0
  33. package/dist/dts/spinner/index.d.ts +5 -0
  34. package/dist/dts/spinner/spinner.d.ts +25 -0
  35. package/dist/dts/spinner/spinner.definition.d.ts +11 -0
  36. package/dist/dts/spinner/spinner.options.d.ts +32 -0
  37. package/dist/dts/spinner/spinner.stories.d.ts +8 -0
  38. package/dist/dts/spinner/spinner.styles.d.ts +1 -0
  39. package/dist/dts/spinner/spinner.template.d.ts +3 -0
  40. package/dist/dts/styles/index.d.ts +1 -0
  41. package/dist/dts/styles/partials/badge.partials.d.ts +28 -0
  42. package/dist/dts/styles/partials/index.d.ts +1 -0
  43. package/dist/dts/text/define.d.ts +1 -0
  44. package/dist/dts/text/index.d.ts +5 -0
  45. package/dist/dts/text/text.d.ts +91 -0
  46. package/dist/dts/text/text.definition.d.ts +10 -0
  47. package/dist/dts/text/text.options.d.ts +67 -0
  48. package/dist/dts/text/text.stories.d.ts +8 -0
  49. package/dist/dts/text/text.styles.d.ts +4 -0
  50. package/dist/dts/text/text.template.d.ts +6 -0
  51. package/dist/dts/theme/index.d.ts +2 -2
  52. package/dist/esm/badge/badge.definition.js +18 -0
  53. package/dist/esm/badge/badge.js +42 -0
  54. package/dist/esm/badge/badge.options.js +45 -0
  55. package/dist/esm/badge/badge.stories.js +108 -0
  56. package/dist/esm/badge/badge.styles.js +29 -0
  57. package/dist/esm/badge/badge.template.js +14 -0
  58. package/dist/esm/badge/define.js +3 -0
  59. package/dist/esm/badge/index.js +5 -0
  60. package/dist/esm/counter-badge/counter-badge.definition.js +18 -0
  61. package/dist/esm/counter-badge/counter-badge.js +89 -0
  62. package/dist/esm/counter-badge/counter-badge.options.js +42 -0
  63. package/dist/esm/counter-badge/counter-badge.stories.js +102 -0
  64. package/dist/esm/counter-badge/counter-badge.styles.js +30 -0
  65. package/dist/esm/counter-badge/counter-badge.template.js +12 -0
  66. package/dist/esm/counter-badge/define.js +3 -0
  67. package/dist/esm/counter-badge/index.js +5 -0
  68. package/dist/esm/fluent-design-system.js +5 -0
  69. package/dist/esm/index-rollup.js +1 -1
  70. package/dist/esm/index.js +6 -1
  71. package/dist/esm/progress-bar/define.js +3 -0
  72. package/dist/esm/progress-bar/index.js +5 -0
  73. package/dist/esm/progress-bar/progress-bar.definition.js +17 -0
  74. package/dist/esm/progress-bar/progress-bar.js +18 -0
  75. package/dist/esm/progress-bar/progress-bar.options.js +25 -0
  76. package/dist/esm/progress-bar/progress-bar.stories.js +60 -0
  77. package/dist/esm/progress-bar/progress-bar.styles.js +155 -0
  78. package/dist/esm/progress-bar/progress-bar.template.js +5 -0
  79. package/dist/esm/spinner/define.js +3 -0
  80. package/dist/esm/spinner/index.js +5 -0
  81. package/dist/esm/spinner/spinner.definition.js +18 -0
  82. package/dist/esm/spinner/spinner.js +15 -0
  83. package/dist/esm/spinner/spinner.options.js +21 -0
  84. package/dist/esm/spinner/spinner.stories.js +45 -0
  85. package/dist/esm/spinner/spinner.styles.js +95 -0
  86. package/dist/esm/spinner/spinner.template.js +21 -0
  87. package/dist/esm/styles/index.js +1 -0
  88. package/dist/esm/styles/partials/badge.partials.js +272 -0
  89. package/dist/esm/styles/partials/index.js +1 -0
  90. package/dist/esm/text/define.js +3 -0
  91. package/dist/esm/text/index.js +5 -0
  92. package/dist/esm/text/text.definition.js +17 -0
  93. package/dist/esm/text/text.js +91 -0
  94. package/dist/esm/text/text.options.js +45 -0
  95. package/dist/esm/text/text.stories.js +111 -0
  96. package/dist/esm/text/text.styles.js +104 -0
  97. package/dist/esm/text/text.template.js +5 -0
  98. package/dist/esm/theme/index.js +2 -2
  99. package/dist/esm/theme/set-theme.js +1 -1
  100. package/dist/esm/theme/theme.stories.js +1 -1
  101. package/dist/fluent-web-components.api.json +14330 -8
  102. package/dist/tsdoc-metadata.json +1 -1
  103. package/dist/web-components.d.ts +1460 -1
  104. package/dist/web-components.js +5713 -2
  105. package/dist/web-components.min.js +273 -1
  106. package/docs/api-report.md +1471 -1
  107. package/package.json +48 -16
  108. package/rollup.config.js +5 -0
  109. package/karma.conf.js +0 -147
@@ -0,0 +1,95 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { display } from '@microsoft/fast-foundation';
3
+ import { colorBrandStroke1, colorBrandStroke2, colorNeutralStrokeOnBrand2 } from '../theme/design-tokens.js';
4
+ export const styles = css `
5
+ ${display('flex')}
6
+
7
+ :host {
8
+ display: flex;
9
+ align-items: center;
10
+ height: 32px;
11
+ width: 32px;
12
+ }
13
+ :host([size='tiny']) {
14
+ height: 20px;
15
+ width: 20px;
16
+ }
17
+ :host([size='extra-small']) {
18
+ height: 24px;
19
+ width: 24px;
20
+ }
21
+ :host([size='small']) {
22
+ height: 28px;
23
+ width: 28px;
24
+ }
25
+ :host([size='large']) {
26
+ height: 36px;
27
+ width: 36px;
28
+ }
29
+ :host([size='extra-large']) {
30
+ height: 40px;
31
+ width: 40px;
32
+ }
33
+ :host([size='huge']) {
34
+ height: 44px;
35
+ width: 44px;
36
+ }
37
+ .progress {
38
+ height: 100%;
39
+ width: 100%;
40
+ }
41
+
42
+ .background {
43
+ fill: none;
44
+ stroke: ${colorBrandStroke2};
45
+ stroke-width: 1.5px;
46
+ }
47
+
48
+ :host([appearance='inverted']) .background {
49
+ stroke: rgba(255, 255, 255, 0.2);
50
+ }
51
+
52
+ .determinate {
53
+ stroke: ${colorBrandStroke1};
54
+ fill: none;
55
+ stroke-width: 1.5px;
56
+ stroke-linecap: round;
57
+ transform-origin: 50% 50%;
58
+ transform: rotate(-90deg);
59
+ transition: all 0.2s ease-in-out;
60
+ }
61
+
62
+ :host([appearance='inverted']) .determinite {
63
+ stroke: ${colorNeutralStrokeOnBrand2};
64
+ }
65
+
66
+ .indeterminate-indicator-1 {
67
+ stroke: ${colorBrandStroke1};
68
+ fill: none;
69
+ stroke-width: 1.5px;
70
+ stroke-linecap: round;
71
+ transform-origin: 50% 50%;
72
+ transform: rotate(-90deg);
73
+ transition: all 0.2s ease-in-out;
74
+ animation: spin-infinite 3s cubic-bezier(0.53, 0.21, 0.29, 0.67) infinite;
75
+ }
76
+
77
+ :host([appearance='inverted']) .indeterminate-indicator-1 {
78
+ stroke: ${colorNeutralStrokeOnBrand2};
79
+ }
80
+
81
+ @keyframes spin-infinite {
82
+ 0% {
83
+ stroke-dasharray: 0.01px 43.97px;
84
+ transform: rotate(0deg);
85
+ }
86
+ 50% {
87
+ stroke-dasharray: 21.99px 21.99px;
88
+ transform: rotate(450deg);
89
+ }
90
+ 100% {
91
+ stroke-dasharray: 0.01px 43.97px;
92
+ transform: rotate(1080deg);
93
+ }
94
+ }
95
+ `;
@@ -0,0 +1,21 @@
1
+ import { progressRingTemplate } from '@microsoft/fast-foundation';
2
+ export const template = progressRingTemplate({
3
+ indeterminateIndicator: `
4
+ <svg class="progress" part="progress" viewBox="0 0 16 16">
5
+ <circle
6
+ class="background"
7
+ part="background"
8
+ cx="8px"
9
+ cy="8px"
10
+ r="7px"
11
+ ></circle>
12
+ <circle
13
+ class="indeterminate-indicator-1"
14
+ part="indeterminate-indicator-1"
15
+ cx="8px"
16
+ cy="8px"
17
+ r="7px"
18
+ ></circle>
19
+ </svg>
20
+ `,
21
+ });
@@ -0,0 +1 @@
1
+ export * from './partials/index.js';
@@ -0,0 +1,272 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { display } from '@microsoft/fast-foundation';
3
+ import { borderRadiusCircular, colorBrandBackground, colorBrandBackground2, colorBrandForeground1, colorBrandForeground2, colorBrandStroke2, colorNeutralBackground1, colorNeutralBackground4, colorNeutralBackground5, colorNeutralForeground1, colorNeutralForeground3, colorNeutralForegroundInverted, colorNeutralForegroundOnBrand, colorNeutralForegroundStaticInverted, colorNeutralStroke2, colorNeutralStrokeAccessible, colorPaletteDarkOrangeBackground1, colorPaletteDarkOrangeBackground3, colorPaletteDarkOrangeBorder1, colorPaletteDarkOrangeForeground1, colorPaletteDarkOrangeForeground3, colorPaletteGreenBackground1, colorPaletteGreenBackground3, colorPaletteGreenBorder2, colorPaletteGreenForeground1, colorPaletteGreenForeground2, colorPaletteGreenForeground3, colorPaletteRedBackground1, colorPaletteRedBackground3, colorPaletteRedBorder1, colorPaletteRedForeground1, colorPaletteRedForeground3, colorPaletteYellowBackground1, colorPaletteYellowBackground3, colorPaletteYellowBorder1, colorPaletteYellowForeground2, colorTransparentStroke, fontFamilyBase, fontSizeBase100, fontSizeBase200, fontWeightSemibold, lineHeightBase100, lineHeightBase200, spacingHorizontalSNudge, spacingHorizontalXS, spacingHorizontalXXS, strokeWidthThin, } from '../../theme/design-tokens.js';
4
+ const textPadding = spacingHorizontalXXS;
5
+ export const badgeBaseStyles = css.partial `
6
+ ${display('inline-flex')} :host {
7
+ position: relative;
8
+ box-sizing: border-box;
9
+ align-items: center;
10
+ justify-content: center;
11
+ font-family: ${fontFamilyBase};
12
+ font-weight: ${fontWeightSemibold};
13
+ font-size: ${fontSizeBase200};
14
+ line-height: ${lineHeightBase200};
15
+ min-width: 20px;
16
+ height: 20px;
17
+ padding-inline: calc(${spacingHorizontalXS} + ${textPadding});
18
+ border-radius: ${borderRadiusCircular};
19
+ border-color: ${colorTransparentStroke};
20
+ background-color: ${colorBrandBackground};
21
+ color: ${colorNeutralForegroundOnBrand};
22
+ }
23
+
24
+ ::slotted(svg) {
25
+ font-size: 12px;
26
+ }
27
+
28
+ :host(:not([appearance='ghost']))::after {
29
+ position: absolute;
30
+ content: '';
31
+ top: 0;
32
+ left: 0;
33
+ bottom: 0;
34
+ right: 0;
35
+ border-style: solid;
36
+ border-width: ${strokeWidthThin};
37
+ border-color: inherit;
38
+ border-radius: inherit;
39
+ }
40
+ `;
41
+ /**
42
+ * @public
43
+ * The badge's size styles
44
+ */
45
+ export const badgeSizeStyles = css.partial `
46
+ :host([size='tiny']) {
47
+ width: 6px;
48
+ height: 6px;
49
+ font-size: 4px;
50
+ line-height: 4px;
51
+ padding-inline: 0;
52
+ min-width: unset;
53
+ }
54
+ :host([size='tiny']) ::slotted(svg) {
55
+ font-size: 6px;
56
+ }
57
+ :host([size='extra-small']) {
58
+ width: 10px;
59
+ height: 10px;
60
+ font-size: 6px;
61
+ line-height: 6px;
62
+ padding-inline: 0;
63
+ min-width: unset;
64
+ }
65
+ :host([size='extra-small']) ::slotted(svg) {
66
+ font-size: 10px;
67
+ }
68
+ :host([size='small']) {
69
+ min-width: 16px;
70
+ height: 16px;
71
+ font-size: ${fontSizeBase100};
72
+ line-height: ${lineHeightBase100};
73
+ padding-inline: calc(${spacingHorizontalXXS} + ${textPadding});
74
+ }
75
+ :host([size='small']) ::slotted(svg) {
76
+ font-size: 12px;
77
+ }
78
+ :host([size='large']) {
79
+ min-width: 24px;
80
+ height: 24px;
81
+ font-size: ${fontSizeBase200};
82
+ line-height: ${lineHeightBase200};
83
+ padding-inline: calc(${spacingHorizontalXS} + ${textPadding});
84
+ }
85
+ :host([size='large']) ::slotted(svg) {
86
+ font-size: 16px;
87
+ }
88
+ :host([size='extra-large']) {
89
+ min-width: 32px;
90
+ height: 32px;
91
+ font-size: ${fontSizeBase200};
92
+ line-height: ${lineHeightBase200};
93
+ padding-inline: calc(${spacingHorizontalSNudge} + ${textPadding});
94
+ }
95
+ :host([size='extra-large']) ::slotted(svg) {
96
+ font-size: 20px;
97
+ }
98
+ `;
99
+ /**
100
+ * The badge's `filled` appearance styles
101
+ * Filled appearance is default so do not
102
+ * Include that attribute as it's not present by default
103
+ * @public
104
+ */
105
+ export const badgeFilledStyles = css.partial `
106
+ :host([color='danger']) {
107
+ background-color: ${colorPaletteRedBackground3};
108
+ color: ${colorNeutralForegroundOnBrand};
109
+ }
110
+
111
+ :host([color='important']) {
112
+ background-color: ${colorNeutralForeground1};
113
+ color: ${colorNeutralBackground1};
114
+ }
115
+
116
+ :host([color='informative']) {
117
+ background-color: ${colorNeutralBackground5};
118
+ color: ${colorNeutralForeground3};
119
+ }
120
+
121
+ :host([color='severe']) {
122
+ background-color: ${colorPaletteDarkOrangeBackground3};
123
+ color: ${colorNeutralForegroundOnBrand};
124
+ }
125
+
126
+ :host([color='subtle']) {
127
+ background-color: ${colorNeutralBackground1};
128
+ color: ${colorNeutralForeground1};
129
+ }
130
+
131
+ :host([color='success']) {
132
+ background-color: ${colorPaletteGreenBackground3};
133
+ color: ${colorNeutralForegroundOnBrand};
134
+ }
135
+
136
+ :host([color='warning']) {
137
+ background-color: ${colorPaletteYellowBackground3};
138
+ color: ${colorNeutralForeground1};
139
+ }
140
+ `;
141
+ /**
142
+ * The badge's `ghost` appearance styles
143
+ * @public
144
+ */
145
+ export const badgeGhostStyles = css.partial `
146
+ :host([appearance='ghost']) {
147
+ color: ${colorBrandBackground};
148
+ background-color: initial;
149
+ }
150
+
151
+ :host([appearance='ghost'][color='danger']) {
152
+ color: ${colorPaletteRedForeground3};
153
+ }
154
+
155
+ :host([appearance='ghost'][color='important']) {
156
+ color: ${colorNeutralForeground1};
157
+ }
158
+
159
+ :host([appearance='ghost'][color='informative']) {
160
+ color: ${colorNeutralForeground3};
161
+ }
162
+
163
+ :host([appearance='ghost'][color='severe']) {
164
+ color: ${colorPaletteDarkOrangeForeground3};
165
+ }
166
+
167
+ :host([appearance='ghost'][color='subtle']) {
168
+ color: ${colorNeutralForegroundInverted};
169
+ }
170
+
171
+ :host([appearance='ghost'][color='success']) {
172
+ color: ${colorPaletteGreenForeground3};
173
+ }
174
+
175
+ :host([appearance='ghost'][color='warning']) {
176
+ color: ${colorPaletteYellowForeground2};
177
+ }
178
+ `;
179
+ /**
180
+ * The badge's `outline` appearance styles
181
+ * @public
182
+ */
183
+ export const badgeOutlineStyles = css.partial `
184
+ :host([appearance='outline']) {
185
+ border-color: currentColor;
186
+ color: ${colorBrandForeground1};
187
+ background-color: initial;
188
+ }
189
+
190
+ :host([appearance='outline'][color='danger']) {
191
+ color: ${colorPaletteRedForeground3};
192
+ }
193
+
194
+ :host([appearance='outline'][color='important']) {
195
+ color: ${colorNeutralForeground3};
196
+ border-color: ${colorNeutralStrokeAccessible};
197
+ }
198
+
199
+ :host([appearance='outline'][color='informative']) {
200
+ color: ${colorNeutralForeground3};
201
+ border-color: ${colorNeutralStroke2};
202
+ }
203
+
204
+ :host([appearance='outline'][color='severe']) {
205
+ color: ${colorPaletteDarkOrangeForeground3};
206
+ }
207
+
208
+ :host([appearance='outline'][color='subtle']) {
209
+ color: ${colorNeutralForegroundStaticInverted};
210
+ }
211
+
212
+ :host([appearance='outline'][color='success']) {
213
+ color: ${colorPaletteGreenForeground2};
214
+ }
215
+
216
+ :host([appearance='outline'][color='warning']) {
217
+ color: ${colorPaletteYellowForeground2};
218
+ }
219
+ `;
220
+ /**
221
+ * The badge's `tint` appearance styles
222
+ * @public
223
+ */
224
+ export const badgeTintStyles = css.partial `
225
+ :host([appearance='tint']) {
226
+ background-color: ${colorBrandBackground2};
227
+ color: ${colorBrandForeground2};
228
+ border-color: ${colorBrandStroke2};
229
+ }
230
+
231
+ :host([appearance='tint'][color='danger']) {
232
+ background-color: ${colorPaletteRedBackground1};
233
+ color: ${colorPaletteRedForeground1};
234
+ border-color: ${colorPaletteRedBorder1};
235
+ }
236
+
237
+ :host([appearance='tint'][color='important']) {
238
+ background-color: ${colorNeutralForeground3};
239
+ color: ${colorNeutralBackground1};
240
+ border-color: ${colorTransparentStroke};
241
+ }
242
+
243
+ :host([appearance='tint'][color='informative']) {
244
+ background-color: ${colorNeutralBackground4};
245
+ color: ${colorNeutralForeground3};
246
+ border-color: ${colorNeutralStroke2};
247
+ }
248
+
249
+ :host([appearance='tint'][color='severe']) {
250
+ background-color: ${colorPaletteDarkOrangeBackground1};
251
+ color: ${colorPaletteDarkOrangeForeground1};
252
+ border-color: ${colorPaletteDarkOrangeBorder1};
253
+ }
254
+
255
+ :host([appearance='tint'][color='subtle']) {
256
+ background-color: ${colorNeutralBackground1};
257
+ color: ${colorNeutralForeground3};
258
+ border-color: ${colorNeutralStroke2};
259
+ }
260
+
261
+ :host([appearance='tint'][color='success']) {
262
+ background-color: ${colorPaletteGreenBackground1};
263
+ color: ${colorPaletteGreenForeground1};
264
+ border-color: ${colorPaletteGreenBorder2};
265
+ }
266
+
267
+ :host([appearance='tint'][color='warning']) {
268
+ background-color: ${colorPaletteYellowBackground1};
269
+ color: ${colorPaletteYellowForeground2};
270
+ border-color: ${colorPaletteYellowBorder1};
271
+ }
272
+ `;
@@ -0,0 +1 @@
1
+ export * from './badge.partials.js';
@@ -0,0 +1,3 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { definition } from './text.definition.js';
3
+ definition.define(FluentDesignSystem.registry);
@@ -0,0 +1,5 @@
1
+ export * from './text.js';
2
+ export * from './text.options.js';
3
+ export { template as TextTemplate } from './text.template.js';
4
+ export { styles as TextStyles } from './text.styles.js';
5
+ export { definition as TextDefinition } from './text.definition.js';
@@ -0,0 +1,17 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { Text } from './text.js';
3
+ import { styles } from './text.styles.js';
4
+ import { template } from './text.template.js';
5
+ /**
6
+ * The Fluent Text Element.
7
+ *
8
+ *
9
+ * @public
10
+ * @remarks
11
+ * HTML Element: \<fluent-text\>
12
+ */
13
+ export const definition = Text.compose({
14
+ name: `${FluentDesignSystem.prefix}-text`,
15
+ template,
16
+ styles,
17
+ });
@@ -0,0 +1,91 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, FASTElement } from '@microsoft/fast-element';
3
+ /**
4
+ * The base class used for constructing a fluent-text custom element
5
+ * @public
6
+ */
7
+ export class Text extends FASTElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ /**
11
+ * The text will not wrap
12
+ * NOTE: In Fluent UI React v9 this is "wrap"
13
+ * Boolean attributes which default to true in HTML can't be switched off in the DOM
14
+ *
15
+ * @public
16
+ * @remarks
17
+ * HTML Attribute: nowrap
18
+ */
19
+ this.nowrap = false;
20
+ /**
21
+ * The text truncates
22
+ *
23
+ * @public
24
+ * @remarks
25
+ * HTML Attribute: truncate
26
+ */
27
+ this.truncate = false;
28
+ /**
29
+ * The text style is italic
30
+ *
31
+ * @public
32
+ * @remarks
33
+ * HTML Attribute: italic
34
+ */
35
+ this.italic = false;
36
+ /**
37
+ * The text style is underline
38
+ *
39
+ * @public
40
+ * @remarks
41
+ * HTML Attribute: underline
42
+ */
43
+ this.underline = false;
44
+ /**
45
+ * The text style is strikethrough
46
+ *
47
+ * @public
48
+ * @remarks
49
+ * HTML Attribute: strikethrough
50
+ */
51
+ this.strikethrough = false;
52
+ /**
53
+ * An text can take up the width of its container.
54
+ *
55
+ * @public
56
+ * @remarks
57
+ * HTML Attribute: block
58
+ */
59
+ this.block = false;
60
+ }
61
+ }
62
+ __decorate([
63
+ attr({ mode: 'boolean' })
64
+ ], Text.prototype, "nowrap", void 0);
65
+ __decorate([
66
+ attr({ mode: 'boolean' })
67
+ ], Text.prototype, "truncate", void 0);
68
+ __decorate([
69
+ attr({ mode: 'boolean' })
70
+ ], Text.prototype, "italic", void 0);
71
+ __decorate([
72
+ attr({ mode: 'boolean' })
73
+ ], Text.prototype, "underline", void 0);
74
+ __decorate([
75
+ attr({ mode: 'boolean' })
76
+ ], Text.prototype, "strikethrough", void 0);
77
+ __decorate([
78
+ attr({ mode: 'boolean' })
79
+ ], Text.prototype, "block", void 0);
80
+ __decorate([
81
+ attr
82
+ ], Text.prototype, "size", void 0);
83
+ __decorate([
84
+ attr
85
+ ], Text.prototype, "font", void 0);
86
+ __decorate([
87
+ attr
88
+ ], Text.prototype, "weight", void 0);
89
+ __decorate([
90
+ attr
91
+ ], Text.prototype, "align", void 0);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * TextSize constants
3
+ * @public
4
+ */
5
+ export const TextSize = {
6
+ _100: '100',
7
+ _200: '200',
8
+ _300: '300',
9
+ _400: '400',
10
+ _500: '500',
11
+ _600: '600',
12
+ _700: '700',
13
+ _800: '800',
14
+ _900: '900',
15
+ _1000: '1000',
16
+ };
17
+ /**
18
+ * TextFont Constants
19
+ * @public
20
+ */
21
+ export const TextFont = {
22
+ base: 'base',
23
+ numeric: 'numeric',
24
+ monospace: 'monospace',
25
+ };
26
+ /**
27
+ * TextWeight Constants
28
+ * @public
29
+ */
30
+ export const TextWeight = {
31
+ medium: 'medium',
32
+ regular: 'regular',
33
+ semibold: 'semibold',
34
+ bold: 'bold',
35
+ };
36
+ /**
37
+ * TextAlign Constants
38
+ * @public
39
+ */
40
+ export const TextAlign = {
41
+ start: 'start',
42
+ end: 'end',
43
+ center: 'center',
44
+ justify: 'justify',
45
+ };
@@ -0,0 +1,111 @@
1
+ import { html } from '@microsoft/fast-element';
2
+ import { renderComponent } from '../__test__/helpers.js';
3
+ import './define.js';
4
+ import { TextAlign, TextFont, TextSize, TextWeight } from './text.options.js';
5
+ /**
6
+ * Used to generate slotted content for stories
7
+ * @param as - the element to generate
8
+ * @param content - the content for the element
9
+ * @returns ViewTemplate
10
+ */
11
+ const generateSemanticElementTemplate = (as, content) => {
12
+ switch (as) {
13
+ case 'h1':
14
+ return html `<h1>${content}</h1>`;
15
+ case 'h2':
16
+ return html `<h2>${content}</h2>`;
17
+ case 'h3':
18
+ return html `<h3>${content}</h3>`;
19
+ case 'h4':
20
+ return html `<h4>${content}</h4>`;
21
+ case 'h5':
22
+ return html `<h5>${content}</h5>`;
23
+ case 'h6':
24
+ return html `<h6>${content}</h6>`;
25
+ case 'p':
26
+ return html `<p>${content}</p>`;
27
+ case 'pre':
28
+ return html `<pre>${content}</pre>`;
29
+ case 'span':
30
+ default:
31
+ return html `<span>${content}</span>`;
32
+ }
33
+ };
34
+ const storyTemplate = html `
35
+ <fluent-text
36
+ align=${x => x.align}
37
+ font=${x => x.font}
38
+ size=${x => x.size}
39
+ weight=${x => x.weight}
40
+ ?nowrap=${x => x.nowrap}
41
+ ?truncate=${x => x.truncate}
42
+ ?italic=${x => x.italic}
43
+ ?underline=${x => x.underline}
44
+ ?strikethrough=${x => x.strikethrough}
45
+ ?block=${x => x.block}
46
+ >${x => generateSemanticElementTemplate(x.as, x.content)}</fluent-text
47
+ >
48
+ `;
49
+ export default {
50
+ title: 'Components/Text',
51
+ args: {
52
+ content: 'Text',
53
+ nowrap: false,
54
+ truncate: false,
55
+ italic: false,
56
+ underline: false,
57
+ strikethrough: false,
58
+ block: false,
59
+ },
60
+ argTypes: {
61
+ as: {
62
+ options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'span'],
63
+ control: {
64
+ type: 'select',
65
+ },
66
+ },
67
+ size: {
68
+ options: Object.values(TextSize),
69
+ control: {
70
+ type: 'select',
71
+ },
72
+ },
73
+ weight: {
74
+ options: Object.keys(TextWeight),
75
+ control: {
76
+ type: 'select',
77
+ },
78
+ },
79
+ align: {
80
+ options: Object.keys(TextAlign),
81
+ control: {
82
+ type: 'select',
83
+ },
84
+ },
85
+ font: {
86
+ options: Object.keys(TextFont),
87
+ control: {
88
+ type: 'select',
89
+ },
90
+ },
91
+ nowrap: {
92
+ control: 'boolean',
93
+ },
94
+ truncate: {
95
+ control: 'boolean',
96
+ },
97
+ italic: {
98
+ control: 'boolean',
99
+ },
100
+ underline: {
101
+ control: 'boolean',
102
+ },
103
+ strikethrough: {
104
+ control: 'boolean',
105
+ },
106
+ block: {
107
+ control: 'boolean',
108
+ },
109
+ },
110
+ };
111
+ export const Text = renderComponent(storyTemplate).bind({});