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

Adds Divider web component #26901

Merged
merged 2 commits into from
Feb 25, 2023
Merged

Adds Divider web component #26901

merged 2 commits into from
Feb 25, 2023

Conversation

halerankin
Copy link
Contributor

@halerankin halerankin commented Feb 17, 2023

Adds Divider web component.

component spec

Horizontal (default):
image

Horizontal with content in default position:
image

Horizontal flex-start:
image

Horizontal flex-end:
image

Horizontal inset:
image

Horizontal, brand color, with icon
image

Vertical:
Min-height is 20px. Storybook container is much larger than the component itself.
image

Vertical w content in default position:
image

Vertical w content, inset:
image

Vertical flex-start:
image

Vertical flex-end:
image

Colors
Strong
image

Brand
image

Subtle
image

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 17, 2023

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:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 17, 2023

📊 Bundle size report

🤖 This report was generated against e793ad8a7f7ae0239a808439d121cf012dd414e5

@size-auditor
Copy link

size-auditor bot commented Feb 17, 2023

Asset size changes

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

Baseline commit: e793ad8a7f7ae0239a808439d121cf012dd414e5 (build)

@miroslavstastny miroslavstastny requested review from a team and removed request for spmonahan and tudorpopams February 21, 2023 14:51
* Determines the alignment of the content within the divider. Select from center, start, or end.
*/
@attr({ attribute: 'align-content' })
public alignContent?: DividerAlignContent;
Copy link
Member

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:

public size: AvatarSize | undefined;
  • this PR uses optionals.

Can we agree on a single thing? FUIR9 uses optionals.

Copy link
Contributor Author

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.

Copy link
Member

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:

  1. It makes DOM bigger, which might be a performance concern.
  2. 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:

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.

Copy link
Contributor Author

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.

Copy link
Member

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.
👍

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.

I am concern by all the hardcoded px values in styles.

@micahgodbolt micahgodbolt removed their assignment Feb 21, 2023
@halerankin
Copy link
Contributor Author

Thanks for yesterday's feedback @miroslavstastny and @chrisdholt
I just pushed new changes.

* Determines the alignment of the content within the divider. Select from center, start, or end.
*/
@attr({ attribute: 'align-content' })
public alignContent?: DividerAlignContent;
Copy link
Member

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.
👍

@chrisdholt chrisdholt merged commit 7d9573d into microsoft:web-components-v3 Feb 25, 2023
chrisdholt pushed a commit that referenced this pull request Apr 29, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 30, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request Apr 30, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 2, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 2, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 2, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 3, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 6, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 6, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 8, 2024
* Adds Divider component

* Generates change
radium-v pushed a commit that referenced this pull request May 10, 2024
* Adds Divider component

* Generates change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants