-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Adds Divider web component #26901
Adds Divider web component #26901
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 355a672:
|
📊 Bundle size report🤖 This report was generated against e793ad8a7f7ae0239a808439d121cf012dd414e5 |
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: e793ad8a7f7ae0239a808439d121cf012dd414e5 (build) |
* Determines the alignment of the content within the divider. Select from center, start, or end. | ||
*/ | ||
@attr({ attribute: 'align-content' }) | ||
public alignContent?: DividerAlignContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisdholt - there is no unified approach to declaring optional attributes. We mix all the following:
badge.appearance
assigns a default value:
public appearance: BadgeAppearance = BadgeAppearance.filled; progress-bar.shape
is marked as mandatory even though it should not be required:
public shape: ProgressBarShape; avatar.avatar-size
in another PR usesType | undefined
:
public size: AvatarSize | undefined;
- this PR uses optionals.
Can we agree on a single thing? FUIR9 uses optionals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to NOT set a default value?
public appearance: BadgeAppearance = BadgeAppearance.filled;
When I review a spec, one thing I look for is the default state of a given component. When we build and style the component accordingly, the consumer gets the default look and behavior without any further customizations. I would think this is a good thing.
As for optionals, this is a good practice that I picked up while working with another team. If I don't have a default value, I would opt for this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to NOT set a default value?
public appearance: BadgeAppearance = BadgeAppearance.filled;
The reason is the reflect
mode of Fast @attr
.
It is a bidirectional binding, which will reflect any value assignment in Javascript to DOM.
<!-- this is what I author in HTML -->
<fluent-badge></fluent-badge>
<!-- ⬇️ this is what I get in DOM -->
<fluent-badge appearance="filled" color="brand"></fluent-badge>
I see 2 problems with this:
- It makes DOM bigger, which might be a performance concern.
- It makes DOM different to HTML, which makes debugging more difficult and confusing ("Where does the
color="brand"
come from? I've never set it anywhere."
When I experienced this for the first time, I proposed to use fromView
mode for all the attributes but that brings another problem: we depend on the attribute to be present in DOM in our CSS selectors:
:host([appearance='ghost']) { |
So we might use default value in attributes in fromView
mode but we still could not depend on them in styles which would make the whole thing even more confusing.
For that reason, me and @chrisdholt decided to not use default attribute values, document what the default is and author the CSS appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miroslavstastny @chrisdholt I just pushed changes for this. Please let me know if this is what you meant by not using default attribute values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Attributes marked as optional, no default value assigned, but documented in the jsdoc.
Default styles (when the prop is not set) correctly 'render' the default appearance, they never test for the default attribute value (in this case there is no [align-content: 'center']
selector.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concern by all the hardcoded px
values in styles.
Thanks for yesterday's feedback @miroslavstastny and @chrisdholt |
change/@fluentui-web-components-b786537a-e6c4-4798-89b5-b0f60dca78e8.json
Outdated
Show resolved
Hide resolved
* Determines the alignment of the content within the divider. Select from center, start, or end. | ||
*/ | ||
@attr({ attribute: 'align-content' }) | ||
public alignContent?: DividerAlignContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Attributes marked as optional, no default value assigned, but documented in the jsdoc.
Default styles (when the prop is not set) correctly 'render' the default appearance, they never test for the default attribute value (in this case there is no [align-content: 'center']
selector.
👍
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
* Adds Divider component * Generates change
Adds Divider web component.
component spec
Horizontal (default):
![image](https://user-images.githubusercontent.com/12279161/214972970-5fab8adc-0b53-4cef-9837-0657955c185b.png)
Horizontal with content in default position:
![image](https://user-images.githubusercontent.com/12279161/214973298-5d6220a1-da6c-45df-af82-63ad5e546e26.png)
Horizontal flex-start:
![image](https://user-images.githubusercontent.com/12279161/214973341-4f7042b3-c452-468d-b3b1-93e34bc2d381.png)
Horizontal flex-end:
![image](https://user-images.githubusercontent.com/12279161/214973367-b2d9ac66-cd0f-4317-9796-051775c33961.png)
Horizontal inset:
![image](https://user-images.githubusercontent.com/12279161/214973016-9552f193-1b9d-419f-8a46-48f91d537e7e.png)
Horizontal, brand color, with icon
![image](https://user-images.githubusercontent.com/12279161/215227634-2fbe2cd7-0ac8-4850-84e5-251d2777b601.png)
Vertical:
![image](https://user-images.githubusercontent.com/12279161/214973062-669553fa-bb12-45bd-9e00-cb6e0330e623.png)
Min-height is 20px. Storybook container is much larger than the component itself.
Vertical w content in default position:
![image](https://user-images.githubusercontent.com/12279161/214973114-c6745c67-9772-43d3-8050-28383da09160.png)
Vertical w content, inset:
![image](https://user-images.githubusercontent.com/12279161/214973185-92aa226e-2c19-4076-a7a2-8c324472415b.png)
Vertical flex-start:
![image](https://user-images.githubusercontent.com/12279161/214973594-49a78930-2011-4c35-beea-7b924b35c750.png)
Vertical flex-end:
![image](https://user-images.githubusercontent.com/12279161/214973641-0b0a38a6-b964-4fb3-ac10-ef63aeda6ab9.png)
Colors
![image](https://user-images.githubusercontent.com/12279161/214973730-9fd66a71-3057-4309-a351-db22ab129aef.png)
Strong
Brand
![image](https://user-images.githubusercontent.com/12279161/214973797-67ee3a64-d1f3-427e-9d5c-60b5ac057098.png)
Subtle
![image](https://user-images.githubusercontent.com/12279161/214973839-88762297-9871-4313-9e4f-007774c9e149.png)