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

Enum Stringification #1921

Merged
merged 19 commits into from
Jan 15, 2018
Merged

Enum Stringification #1921

merged 19 commits into from
Jan 15, 2018

Conversation

themadcreator
Copy link
Contributor

For all exported enums, supply explicit enum values (preferably strings) so that users can use fully qualified enum object or simple string constants.

Some enums use numerical values for functional purposes -- these were not changed (e.g. Month, Elevation).

@themadcreator
Copy link
Contributor Author

themadcreator commented Dec 14, 2017

Blocked on Popover2 merge since tetherUtils (failing compilation) will be deleted

@@ -202,8 +202,8 @@ export function iconClass(iconName?: string) {
}

export function intentClass(intent = Intent.NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that this is your commit at all, but why do we even have a default argument when we treat it as though nothing was passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

intent = "none" is technically not the same as intent = null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/shrug

@@ -163,12 +165,6 @@ export class Toaster extends AbstractPureComponent<IToasterProps, IToasterState>
);
}

protected validateProps(props: IToasterProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation is no longer valid because I changed the prop typing.

OCTOBER,
NOVEMBER,
DECEMBER,
JANUARY = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why numbers and not strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, take a look at the comment. It explicitly mentions comparing with Date.getMonth() which uses zero-indexed months.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, whoops, missed the comment. Good good.

OCTOBER,
NOVEMBER,
DECEMBER,
JANUARY = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, whoops, missed the comment. Good good.

BOTTOM_LEFT = "bottom_left",
LEFT_BOTTOM = "left_bottom",
LEFT = "left",
LEFT_TOP = "left_top",
Copy link
Contributor

Choose a reason for hiding this comment

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

convention elsewhere is dashes for lowercase strings. left-top

* @default Position.TOP
*/
position?: Position;
position?: Position.TOP | Position.BOTTOM;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not complete. it's actually TOP_* and BOTTOM_*: can align left/right too.

@@ -179,7 +175,7 @@ export class Toaster extends AbstractPureComponent<IToasterProps, IToasterState>
}

private getPositionClasses() {
const positions = Position[this.props.position].split("_");
const positions = this.props.position.split("_");
Copy link
Contributor

Choose a reason for hiding this comment

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

be sure to update this with the change to -

*/
TOP_LEFT,
TOP_LEFT = "top_left",
Copy link
Contributor

Choose a reason for hiding this comment

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

top-left

@adidahiya
Copy link
Contributor

are you using yarn lint-fix? do you have this setting enabled in vscode?

image

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

yay Records

@adidahiya
Copy link
Contributor

Please merge master to get the new required status check

@themadcreator
Copy link
Contributor Author

I did enable auto-lint on save but it's not working properly for some reason

@blueprint-bot
Copy link

Fix more docs examples

Preview: documentation | table

@adidahiya adidahiya changed the base branch from master to develop January 15, 2018 17:12
@adidahiya adidahiya self-assigned this Jan 15, 2018
@adidahiya adidahiya added this to the 2.0.0-beta.1 milestone Jan 15, 2018
@blueprint-bot
Copy link

Merge branch 'develop' into gg/string-enums

Preview: documentation | table

@adidahiya adidahiya merged commit 57e66a7 into develop Jan 15, 2018
@adidahiya adidahiya deleted the gg/string-enums branch January 15, 2018 18:20
@adidahiya adidahiya modified the milestones: 2.0.0-beta.1, 2.0.0 Jan 17, 2018
@adidahiya adidahiya mentioned this pull request Jan 29, 2018
15 tasks
@giladgray giladgray mentioned this pull request Feb 6, 2018
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.

5 participants