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

Decide on convention of type, kind, and variant for v11 #9623

Closed
Tracked by #9535
joshblack opened this issue Sep 8, 2021 · 9 comments
Closed
Tracked by #9535

Decide on convention of type, kind, and variant for v11 #9623

joshblack opened this issue Sep 8, 2021 · 9 comments

Comments

@joshblack
Copy link
Contributor

joshblack commented Sep 8, 2021

Background

We would like to be consistent in our terminology with how a user can configure a component to render differently in terms of appearance. In our codebase currently, we use several style of props to indicate that a component can have different visual appearances, including:

In this proposal, we would like to define what the exact term used must be for components and when to use these other prop names, if at all.

Links & Resources

@joshblack joshblack mentioned this issue Sep 8, 2021
20 tasks
@joshblack joshblack changed the title type vs kind Decide on convention of type vs kind vs variant for v11 Sep 8, 2021
@joshblack joshblack changed the title Decide on convention of type vs kind vs variant for v11 Decide on convention of type, kind, and variant for v11 Sep 8, 2021
@joshblack
Copy link
Contributor Author

  • Button
    • Uses kind because type conflicts with <button type="...">

@joshblack
Copy link
Contributor Author

joshblack commented Sep 9, 2021

Figma Research

Overview

Figma uses a term called a Component Set to describe a collection of components, called variants, that all share their properties. However, the variants will have different combinations of values for these properties.

A Property is the name of some variable aspect of a component. For example, the property names of a button component could be the type, size, state, or whether it has an icon.

A Property value is the different options available for a property. For example, the state property for a button could have default, hover, pressed, and disabled values.

To recap, a Component Set is made up of Variants. A Variant is a unique combination of properties and their values.

Deep Dive

A Component Set could be one-dimensional. For example, a button could have a state property with the values: standard, hover, pressed, or disabled.

Our Button Component Set, in this case, would contain the following variants:

image

In this case, the variants are specifically:

  • Button with state: standard
  • Button with state: hover
  • Button with state: pressed
  • Button with state: disabled

A Component Set could also be multi-dimensional. For example, a button could have several types such as primary and secondary. In this case, our Button Component Set would look like:

image

In this case, the variants are:

  • Button, type: primary, state: standard
  • Button, type: primary, state: hover
  • Button, type: primary, state: pressed
  • Button, type: primary, state: disabled
  • Button, type: secondary, state: standard
  • Button, type: secondary, state: hover
  • Button, type: secondary, state: pressed
  • Button, type: secondary, state: disabled

Note: all variants within the component set will use the same properties and values, but each variant needs to be a unique combination of them. You don’t need to have a component for every possible combination of properties and values.

image

Background

We would like to standardize on terms used to describe components and how they change between visual appearance and behavior. Examples of this include:

  • A button that has several visual appearances (primary, secondary, tertiary, danger, etc)
  • A notification component
    • Different behavior: toast, inline
    • Modifier: low contrast
    • Notification type: info, warn, error

Industry Analysis

Design Systems

Name URL Property Notes
ANT Design Link type
Salesforce Link type
Shopify Link type
Primer Link type
Chakra UI Link variant
Atlassian Link none They use separate components
Fluent none They use separate components

Conclusion

The recommendation is to use the variant terminology based on Figma along with the type terminology. A type should refer to functional or visual differences in a component. Modifiers should be a distinct property (like low contrast) so that they can be combined with type.

If a component has both visual AND behavior differences, then we create distinct components based on the behavior. For example, a notification has two different behaviors for toast and inline. These would become two distinct components, Toast Notification and Inline Notification with a type prop that corresponds to the notification type.

Links & Resources

Definitions

Component Set
A collection of components, called variants, that all share their properties,but have different combinations of values for those properties
Variant
A unique combination of the properties and values in a component set
Properties
The variable aspects of our component. For example: the properties of a button component could be the `type`, `size`, `state`, or whether it has an icon.
Values
The different options available for each property. For example: the state property could have `default`, `hover`, `pressed`, and `disabled` values.

@joshblack
Copy link
Contributor Author

Figma Research (Migration)

An interesting aspect of: https://help.figma.com/hc/en-us/articles/360056440594-Create-and-use-variants#Manage_variants is that the default name of the first property when creating variants will be: variant.

image

image

They also show renaming this automatic field to type later on:

image

@vpicone
Copy link
Contributor

vpicone commented Sep 9, 2021

Great stuff! Thanks for putting in the time researching. Do we have any idea how many components might need to be renamed ala Notification? I'm wary of using a totally new component for a thing that could be a prop, but agree it makes sense in some cases.

I might have missed it, but if we use type for primary, secondary etc. how does a dev pass in the native "type" attribute?

@aagonzales
Copy link
Member

aagonzales commented Sep 9, 2021

I still worry about the term type in the larger context. It can mean different things depending on your context throughout the system:

  • type = component "variant"
  • type = typography, text, type styles

Type (variant) and type (text) can be seen a lot on the same page through out component docs.

I could be more ok with type if we labeled it "Component type" instead of just "type" by itself.

@joshblack
Copy link
Contributor Author

@vpicone thankfully no name changes! And for ambiguity, I think we'll need to have a prop like nativeType or htmlType that will point to the underlying HTML Element type.

@aagonzales totally agreed

@aagonzales
Copy link
Member

aagonzales commented Sep 16, 2021

Another factor that we should consider is how these terms are being used in the ecosystem. This is what teams are using in their docs (not sure if its the same in their code).

  • Jan said .com uses "variant"
  • Looks like Cloud PAL uses "variations"
  • AI Apps actually uses both "type" and "variant"
  • CC&C use "type"

@aagonzales
Copy link
Member

I think we're missing a term somewhere.

  1. There are two [insert term] of notification components. Inline and Toast. This have major functional, behavioral, and style differences.
    image

  2. Within inline notification there are four [insert terms] of inline notifications, error, warning, info and success. These most commonly only have usage differences. (This is the term we're missing)
    image

  3. Within an success-inline-notification there are two [style modifiers], high contrast and low contrast. These are only aesthetic style differences.
    image

  4. Within an inline notification you can add a [modifier] such as an action to enhance minor functionality.
    image


If 1. Type then is 2. Kind? Or is 1. Variant and 2. is type?

@joshblack
Copy link
Contributor Author

@aagonzales here's one attempt at thinking about it:

There are two types of notification components: Inline and Toast. These have major functional, behavioral, and style differences but still fall under the umbrella of notifications

An inline notification component has a status/state/type property that can be one of error, warning, info, and success.

The success-inline-notification by default uses a low contrast style. It has a high contrast property to create high contrast variants.

Within an inline notification you can add a [modifier] such as an action to enhance minor functionality.

I think when we have items inside of a component it could fall under the umbrella of component composition versus types/variants of a component. The guidance then becomes around the types of content a component allows versus it being a variant distinction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants