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

[docs] boolean vs enum API #10023

Merged
merged 3 commits into from Jan 24, 2018
Merged

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jan 24, 2018

Write down the solution so we enforce it everywhere.

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation core labels Jan 24, 2018
### boolean vs enum

You can potentially expose the variations of a component with a *boolean* or an *enum*.
For instance, let's say you have a button of different types. You can use one of the two following options. Each has pros and cons:
Copy link
Member

Choose a reason for hiding this comment

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

"You can use one of the two following options, each with its pros and cons:"

You can potentially expose the variations of a component with a *boolean* or an *enum*.
For instance, let's say you have a button of different types. You can use one of the two following options. Each has pros and cons:
- Option 1 *boolean*: `<Button>`, `<Button raised />`, `<Button fab />`.
With this API, people can use the shorthand notation.
Copy link
Member

Choose a reason for hiding this comment

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

"you can use"?

```

- Option 2 *enum*: `<Button>`, `<Button type="raised">`, `<Button type="fab">`.
With this API, you prevent invalid combination from being used, you bound the number of properties you exposes and you can easily support new values in the future.
Copy link
Member

Choose a reason for hiding this comment

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

"you exposes, and you"
(Oxford comma)

- We use an *enum* when the degrees of freedom required is **> 2**.

Going back to the previous button example, it requires 3 degrees of freedom.
We use an *enum*.
Copy link
Member

Choose a reason for hiding this comment

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

"Going back to the previous button example; since it requires 3 degrees of freedom, we use an enum.
(Connect cause and effect clauses in a single sentence.)

@mbrookes
Copy link
Member

Side note, we gonna have to rename the type property to nativeType or buttonType to dodge the name conflict.

Or use something other than type? @kof suggested variant, for example.

@oliviertassinari
Copy link
Member Author

Or use something other than type? @kof suggested variant, for example.

It's an option too. It's 3 additional characters and more component to change.
I mean, we are already using type in 6 other components (simple breaking change).

@@ -81,7 +82,7 @@ type Props = {
```

- Option 2 *enum*: `<Button>`, `<Button type="raised">`, `<Button type="fab">`.
With this API, you prevent invalid combination from being used, you bound the number of properties you exposes and you can easily support new values in the future.
With this API, you prevent invalid combination from being used, you bound the number of properties you exposes, and you can easily support new values in the future.
Copy link
Member

Choose a reason for hiding this comment

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

"you expose" (sorry, don't know how I missed it!)

@oliviertassinari oliviertassinari self-assigned this Jan 24, 2018
@mbrookes mbrookes merged commit a3e213c into mui:v1-beta Jan 24, 2018
@oliviertassinari oliviertassinari deleted the boolean-vs-enum branch January 29, 2018 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants