-
Notifications
You must be signed in to change notification settings - Fork 601
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
feat(toggle): add new component and msft styles #212
feat(toggle): add new component and msft styles #212
Conversation
@@ -1,2 +1,3 @@ | |||
export * from "./button"; | |||
export * from "./toggle"; |
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.
Likely should alphabetize
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.
I think the components should be together, and then the "other" stuff should be separate (managed-classes in this case)
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.
In theory, Foundation is a component.
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 needs to be part of the linter if we're going to nit on it. Chris, if you're passionate about this being alphabetical please file an issue against fast-tslint-rules
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.
Sure - didn't feel like a nit. But I'll file and take care of the issue. It does feel like something that's going to make it extremely hard for people to find things if we aren't grouping in a logical progression. Especially with a flat structure in src. I'll file an issue.
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.
Synced with @nicholasrice on this. In the index.ts files where we import all things in "src" we will alphabetize. This does not need to be the case in .tsx files for regular imports. Unfortunately, due to some weird configs with .ts lint, we'll need to enforce this by principle. Trying to enforce alphabetizing in these files using .tslint would create a massive hinderance to our dev experience and overall code readability
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.
Got it.
import * as React from "react"; | ||
|
||
export interface IToggleProps { | ||
children?: React.ReactNode | React.ReactNode[]; |
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.
Is this really a place where we want to support anything?
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.
In the label... sure why not? I don't think it needs to be text-only. If they want a glyph or hyperlink, they should be able to add one
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.
I agree - requiring a string seems unnecessarily restrictive.
/** | ||
* Toggle base component | ||
*/ | ||
/* tslint:disable-next-line */ |
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.
I think we can remove this tslint rule
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.
ok - it's in the base component you put up so it should be removed from there too
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.
for sure
* Toggle base component | ||
*/ | ||
/* tslint:disable-next-line */ | ||
class Toggle extends Foundation<IToggleProps & IManagedClasses<IToggleClassNameContract>, React.AllHTMLAttributes<HTMLElement>, IToggleState> { |
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.
We should try to be as specific as possible here. The reason that button supported All was due to the fact that there were serious conflicts when trying to allow HTMLAnchor | HTMLButton. Here though, I don't we lose the purpose of this if we tell the user they can pass an href.
@@ -10,4 +10,25 @@ const designSystemDefaults: IDesignSystem = { | |||
brandColor: "#0078D4" | |||
}; | |||
|
|||
/** | |||
* Returns RGBA from hex value with optional alpha |
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.
we should pull this into a utilities folder if we're going to use this one. We may also want to just interpolate the values below
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.
Also - questions as to whether or not this should live here or another package - colors, jss-utiltites...likely a team convo. But I'd pull from the design system folder.
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.
We probably need to figure out the full color story or there is going to be a lot of redoing work. I could have simply added the rgba values, but this seems like something we would want anyway. I can move, but we should figure this out as a team.
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.
Agree on syncing as a team here. Not saying it needs to land, but I think we can start categorizing in utils for now at the very least.
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.
It would likely live in the color package - that already takes a dependency on chroma-js
which probably has this functionality, so you might just use that
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.
Cool, I'll look into that @nicholasrice
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.
Ok @nicholasrice, I see a function think I can use from chroma-js to accomplish this. Do I need to add chroma to the styles-msft repo to use?
} | ||
}; | ||
|
||
export default styles; |
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.
I think you need a newline 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.
We need our linter or whatever to yell about this.
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.
Yeah, it should be - not sure why it isn't
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.
I believe I fixed an issue in the linter with a PR, if it's not updating let me know and I'll see if I can repro on your branch. There was an issue with Mac not jumping into all files.
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.
Cool - will let you know.
@@ -0,0 +1,6 @@ | |||
import * as React from "react"; | |||
import { IFoundationProps, IToggleClassNameContract, IToggleProps, Toggle } from "@microsoft/fast-components-react-base"; |
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.
can you remove the spacing between the brackets and the imports?
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.
Yea the linter will fail this
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.
UPDATE: Leave spacing here due to the linter not being able to lint this. It should now lint import and exports to include space. Within the ts files themselves, there should be no spaces.
unselectedString: "Off" | ||
} | ||
] | ||
} as IGenericExample<IToggleProps>; |
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.
I think @nicholasrice added something that updates this to generate snapshots
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.
+1 Check out the button component
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.
yep all updated
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.
yep done
@@ -2,6 +2,10 @@ import Button from "./button"; | |||
export {Button}; | |||
export * from "./button"; | |||
|
|||
import Toggle from "./toggle"; |
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.
Should alphabetize
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 above, I think we should have our components separate from our other stuff. If we vote otherwise, I'm fine with it though.
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.
Foundation is technically a component. I think maintainability is key unless we are going to comment and denote the intentional difference in structure. I think alphabetizing keeps everything in easy to understand and intuitive, but we can discuss as a team.
@@ -1,2 +1,5 @@ | |||
import ButtonExamples from "../src/button/examples.data"; | |||
export {ButtonExamples}; | |||
|
|||
import ToggleExamples from "../src/toggle/examples.data"; | |||
export {ToggleExamples}; |
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.
Is this not yelling at you for a newline?
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.
Nah, I can add it back in though. I received maybe one or two warnings about this at different times, but it seems all over the place when it "cares"
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.
The rule is never more than one newline I believe, so this would be valid.
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 would get caught on CI as well.
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.
Responded to some comments
@@ -2,6 +2,10 @@ import Button from "./button"; | |||
export {Button}; | |||
export * from "./button"; | |||
|
|||
import Toggle from "./toggle"; |
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 above, I think we should have our components separate from our other stuff. If we vote otherwise, I'm fine with it though.
@@ -1,2 +1,5 @@ | |||
import ButtonExamples from "../src/button/examples.data"; | |||
export {ButtonExamples}; | |||
|
|||
import ToggleExamples from "../src/toggle/examples.data"; | |||
export {ToggleExamples}; |
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.
The rule is never more than one newline I believe, so this would be valid.
import * as React from "react"; | ||
|
||
export interface IToggleProps { | ||
children?: React.ReactNode | React.ReactNode[]; |
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.
I agree - requiring a string seems unnecessarily restrictive.
@@ -0,0 +1,13 @@ | |||
import * as React from "react"; | |||
|
|||
export interface IToggleProps { |
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.
We've changed naming conventions for props slightly - can you align the prop names to the format button uses?
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.
Will do
} | ||
|
||
/** | ||
* Generates global aria-disabled |
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 comment doesn't really map to the function name - can you align the two?
or you could remove this method entirely - I think it makes sense when there is a bunch of conditional logic for rendering attributes, but if you're simply setting one attribute I think it is more readable to apply that in the render method directly.
<div
aria-disabled={ this.props.disabled || null }
//...
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.
Sure thing
|
||
return toggleAttributes; | ||
} | ||
|
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 here - there doesn't seem to be much rhyme or reason why some attributes are applied here but others are applied in the render method- I'd just put all these in the render method and reduce some of the code-clutter that having an extra method creates.
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.
Sure thing
/> | ||
<span /> | ||
</div> | ||
<span id={this.props.spanId}> |
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.
maybe we should call this statusLabel
or something? spanId
isn't a very semantic name.
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.
Changed to statusLabelId to match other naming
unselectedString: "Off" | ||
} | ||
] | ||
} as IGenericExample<IToggleProps>; |
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.
+1 Check out the button component
@@ -0,0 +1,6 @@ | |||
import * as React from "react"; | |||
import { IFoundationProps, IToggleClassNameContract, IToggleProps, Toggle } from "@microsoft/fast-components-react-base"; |
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.
Yea the linter will fail this
@@ -10,4 +10,25 @@ const designSystemDefaults: IDesignSystem = { | |||
brandColor: "#0078D4" | |||
}; | |||
|
|||
/** | |||
* Returns RGBA from hex value with optional alpha |
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.
It would likely live in the color package - that already takes a dependency on chroma-js
which probably has this functionality, so you might just use that
|
||
const styles: ComponentStyles<IToggleClassNameContract, IDesignSystem> = { | ||
toggle: { | ||
'& > label': { |
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.
+1
We're going to be mapping more directly to BEM principles - meaning that the span
that indicates the status of the toggle would have a class directly associated to it, such as toggle_status_indicator
ddcc3dc
to
03776d2
Compare
…dhere to FAST standards and BEM standards
5ffd72e
to
d477813
Compare
8a815c8
to
fc42419
Compare
fc42419
to
39dbed8
Compare
37d507a
to
84135dc
Compare
data: [ | ||
{ | ||
managedClasses: { | ||
toggle: "toggle" }, |
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.
nit, formatting
For details on formatting pull requests.