-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Alignment enum #2089
Alignment enum #2089
Conversation
docs about Alignment enumPreview: documentation | landing | table |
copyright, nitsPreview: documentation | landing | table |
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.
this is wonky
@@ -26,6 +26,8 @@ export interface IButtonProps extends IActionProps { | |||
* Text alignment within button. By default, icons and text will be centered within the button. | |||
* Passing this prop will cause the text container to fill the button and align the text within that | |||
* to the appropriate side. `icon` and `rightIcon` will be pushed to either side. | |||
* | |||
* The `Alignment` enum provides constants for allowed 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.
then why not use the enum here?
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.
like #2090, i want to show the actual options in the docs, not the type alias name.
@@ -15,6 +15,8 @@ export interface IButtonGroupProps extends IProps, React.HTMLProps<HTMLDivElemen | |||
* `align="left"` will left-align button text and push `rightIcon` to right side. | |||
* `align="right"` right-aligns text and pushes `icon` to left side. | |||
* This prop only has an effect if buttons are wider than their default widths. | |||
* | |||
* The `Alignment` enum provides constants for allowed 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.
same
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.
string literals are not assignable to enum types (we learned this with string enums #1921)
@@ -12,6 +12,7 @@ import { IProps } from "../../common/props"; | |||
export interface INavbarGroupProps extends React.HTMLProps<HTMLDivElement>, IProps { | |||
/** | |||
* The side of the navbar on which the group should appear. | |||
* The `Alignment` enum provides constants for these 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.
same
* Licensed under the terms of the LICENSE file distributed with this project. | ||
*/ | ||
|
||
export type AlignmentType = "center" | "left" | "right"; |
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.
why do you need this in addition to the enum?
@adidahiya we learned in #1921 that let me know how you'd like to proceed. |
If you really want both a type and an enum, you have to do something like this: export type Alignment = "left" | "center" | "right";
export const Alignment = {
LEFT: "left" as Alignment,
CENTER: "center" as Alignment,
RIGHT: "right" as ALIGNMENT,
}; ... so we should either do that (overload one symbol) or do nothing at all |
I think you mean |
@adidahiya hmm yeah thoughts on migrating |
const/type Alignment allows string literal or constant usagePreview: documentation | landing | table |
Alignment
enum andClasses.alignmentClass()