Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add text as new component #26090

Conversation

chrisdholt
Copy link
Member

New Behavior

This PR does two things:

  1. Adds Text as a new component

  2. Updates the package to support ESM and get storybook building, etc.

While I would have rather done separate PR's for this, and am happy to if we need to, in order to get storybook up and running on ESM I needed to have something to build :). The first commit contains most all the component code. The second is primarily the ESM updates within the repo (pathing, storybook webpack changes, dep updates locally for typescript, tslib, and ts-loader.

Related Issue(s)

  • Fixes #

@fabricteam
Copy link
Collaborator

fabricteam commented Dec 22, 2022

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
533 B
341 B
global-context
createContextSelector
554 B
348 B
priority-overflow
createOverflowManager
3.153 kB
1.299 kB
react-accordion
Accordion (including children components)
79.243 kB
24.436 kB
react-alert
Alert
84.688 kB
21.233 kB
react-avatar
Avatar
48.874 kB
13.864 kB
react-avatar
AvatarGroup
14.996 kB
6.013 kB
react-avatar
AvatarGroupItem
63.452 kB
17.959 kB
react-badge
Badge
22.646 kB
7.228 kB
react-badge
CounterBadge
23.536 kB
7.512 kB
react-badge
PresenceBadge
24.096 kB
7.09 kB
react-button
Button
36.849 kB
9.907 kB
react-button
CompoundButton
43.874 kB
11.123 kB
react-button
MenuButton
39.543 kB
10.807 kB
react-button
SplitButton
46.989 kB
12.192 kB
react-button
ToggleButton
52.716 kB
11.381 kB
react-card
Card - All
67.664 kB
19.635 kB
react-card
Card
63.346 kB
18.539 kB
react-card
CardFooter
8.607 kB
3.622 kB
react-card
CardHeader
9.65 kB
3.962 kB
react-card
CardPreview
8.708 kB
3.678 kB
react-combobox
Combobox (including child components)
76.135 kB
24.738 kB
react-combobox
Dropdown (including child components)
75.864 kB
24.699 kB
react-components
react-components: Button, FluentProvider & webLightTheme
62.94 kB
17.663 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.888 kB
53.022 kB
react-components
react-components: FluentProvider & webLightTheme
33.446 kB
11.033 kB
react-dialog
Dialog (including children components)
83.147 kB
24.799 kB
react-divider
Divider
16.505 kB
5.925 kB
react-image
Image
10.826 kB
4.286 kB
react-infobutton
InfoButton
7.742 kB
3.265 kB
react-input
Input
24.428 kB
7.899 kB
react-label
Label
9.384 kB
3.883 kB
react-link
Link
11.852 kB
4.888 kB
react-menu
Menu (including children components)
117.055 kB
36.238 kB
react-menu
Menu (including selectable components)
120.124 kB
36.75 kB
react-overflow
hooks only
11.004 kB
4.188 kB
react-persona
Persona
53.992 kB
15.25 kB
react-popover
Popover
103.624 kB
31.927 kB
react-portal
Portal
10.628 kB
3.899 kB
react-portal-compat
PortalCompatProvider
5.857 kB
1.978 kB
react-positioning
usePositioning
20.009 kB
7.532 kB
react-progress
Progress
13.131 kB
5.039 kB
react-provider
FluentProvider
15.807 kB
5.909 kB
react-radio
Radio
36.436 kB
12.126 kB
react-radio
RadioGroup
14.294 kB
5.723 kB
react-select
Select
23.255 kB
7.954 kB
react-slider
Slider
31.978 kB
10.149 kB
react-spinbutton
SpinButton
45.826 kB
12.858 kB
react-spinner
Spinner
20.023 kB
6.461 kB
react-switch
Switch
33.388 kB
10.578 kB
react-text
Text - Default
11.828 kB
4.627 kB
react-text
Text - Wrappers
15.138 kB
5.064 kB
react-textarea
Textarea
25.687 kB
8.331 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
29.65 kB
6.444 kB
react-theme
Teams: Light theme
17.486 kB
5.057 kB
react-tooltip
Tooltip
41.993 kB
14.799 kB
react-utilities
SSRProvider
180 B
159 B
🤖 This report was generated against 7c94cbd46051ea57bba4e8885c86e89967bb412c

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 22, 2022

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 18ec7f8:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Dec 22, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 7c94cbd46051ea57bba4e8885c86e89967bb412c (build)

@chrisdholt chrisdholt force-pushed the users/chhol/add-text-as-new-component branch 2 times, most recently from fbbd80c to 4e9bb34 Compare December 22, 2022 22:49
@chrisdholt
Copy link
Member Author

chrisdholt commented Jan 10, 2023

@Hotell would be great if you can take a look at the ESM, storybook and package.json updates just to understand my note on issues with deduplication as I had issues getting things building again when making the necessary changes. Also, the build is failing on API extractor and I believe it has to do with which tsconfig is being referenced (perhaps)?

@@ -18,6 +19,12 @@
"main": "dist/esm/index.js",
"types": "dist/web-components.d.ts",
"unpkg": "dist/web-components.min.js",
"exports": {
"./text/define": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case for using this import vs package import?
I guess I am supposed to import components/define for all used components to register the custom elements and package import anything else?
Perhaps worth adding a readme with a brief Usage section.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows one-off imports of individual components as each will have a unique path in the package.

import "@fluentui/web-components/text";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on this, the above example doesn't represent what was originally in the PR, so revisiting this...I think one reason that we went with ./text/define which would be used as below was to leave room for the opportunity for a text specific path to export more than just the defined element. I think that is probably too complex and everything is available via the root of the package, so I've updated this to be available just as "text" per above because it's more intuitive than a "define" path IMO. We can adjust if need be, but this makes more sense than what was originally there (shown below).

import "@fluentui/web-components/text/define";

@Hotell
Copy link
Contributor

Hotell commented Jan 11, 2023

tooling support #26298

  • storybook
  • build
  • tests (this might be impossible to do - not really sure how karma supports ESM)

* HTML Element: \<fluent-text\>
*/
export const definition = Text.compose({
name: `${FluentDesignSystem.prefix}-text`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why the component definition is coupled with FluentDesignSystem.prefix.
We pass registry to definition.define() to support custom/multiple registries. In that case, wouldn't it make sense to pass the prefix to define() as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Let me follow up on this. If you can send a mail I'll take it offline. This was a pattern we established awhile ago and I want to make sure I'm not missing something w/r/t our discussion around "defaultRegistry" vs current implementation.

* HTML Attribute: weight
*/
@attr
weight: TextWeight;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we want to handle and communicate default values?
Just jsdocs? Or assign the default value? And use fromView in that case to prevent DOM pollution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed we'll handle via jsDocs and we'll set defaults via CSS so we don't require reflecting attributes creating an unnecessarily complex DOM just for defaults. Boolean attr's should default to false which may require deltas as seen in this PR with wrap => nowrap.

Regarding fromView, I think that prevents setting via IDL attribute (js properties) so we should likely avoid for this instance.

overflow: visible;
text-overflow: clip;
}
:host([truncate]) ::slotted(*),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUIR9 does not add nowrap styles when truncate is set. It is users responsibility to set wrap={false} together with truncate:

nowrap: {
whiteSpace: 'nowrap',
...shorthands.overflow('hidden'),
},
truncate: {
textOverflow: 'ellipsis',
},

We should unify.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! I think this is likely just a change I made not knowing that and wondering why it wasn't working :)

overflow: hidden;
}
:host([truncate]) ::slotted(*) {
display: block;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUIR9 does not set display: block for truncate.

Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS 4.7 and ESM support for wc 3 is ready ! 🫡 

Copy link
Member

@miroslavstastny miroslavstastny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 approving text component changes

@chrisdholt chrisdholt force-pushed the users/chhol/add-text-as-new-component branch from 4e9bb34 to 7e6d618 Compare January 11, 2023 18:57
@chrisdholt chrisdholt requested a review from a team as a code owner January 11, 2023 18:57
…pdate stories to leverage object.keys of options
@chrisdholt chrisdholt force-pushed the users/chhol/add-text-as-new-component branch from 457d3a6 to 7fc847c Compare January 11, 2023 20:23
@chrisdholt chrisdholt force-pushed the users/chhol/add-text-as-new-component branch from 2c65bd2 to 18ec7f8 Compare January 12, 2023 00:01
@chrisdholt chrisdholt merged commit 5e3ba35 into microsoft:web-components-v3 Jan 12, 2023
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
chrisdholt added a commit that referenced this pull request Apr 29, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 30, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request Apr 30, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 2, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 2, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 2, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 3, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 6, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 6, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 8, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
radium-v pushed a commit that referenced this pull request May 10, 2024
* add text as a new component

* update main.js to .cjs format for esm due to require syntax

* update style rules to align with FUI react v9, export text options, update stories to leverage object.keys of options

* export text, update node resolution to 16 and fix object.keys for size to object.values

* prettier style files, may need to revert if it does not play nice with selectors

* update display for host to ensure we can layout the element properly margin, etc...

* update latest FAST packages

* leverage ValuesOf type helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants