-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Convert Check to mergeStyles #3880
Conversation
Start converting check to mergeStyles
|
||
return ( | ||
<div | ||
className={ css( |
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.
css doesn't need to be used and should be removed. Can you move all of the logic to getStyles so that we have it in one place?
|
||
const { palette, semanticColors } = theme; | ||
|
||
const _sharedCircleCheck: IStyle = { |
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: We typically only prepend the _ when it's a private member of a class but not a local variable.
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.
Commit pushed
} from '@uifabric/styling'; | ||
import { memoizeFunction } from '@uifabric/utilities'; | ||
|
||
const DEFAULT_CHECKBOX_HEIGHT: string = '18px'; |
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 shouldn't "hard code" this value unless the consumer will never need to change it. It seems like in this case we should expose this as a public prop.
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.
const {
checkBoxHeight = DEFAULT_CHECKBOX_HEIGHT,
checked,
className,
theme,
} = props;
Setting checkBoxHeight to equal that variable is just the way to set it as default and is overridden by what the user set in props. To be honest, I didn't need DEFAULT_CHECKBOX_HEIGHT, but I thought it'd be a nice easy way to see/change the default later down the road.
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.
@battletoilet Could you take another look at this review?
root: [ | ||
{ | ||
// lineHeight currently needs to be a string to output without 'px' | ||
lineHeight: '1', |
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.
@dzearing apparently this is a bug where providing the type number automatically converts the value into a string with 'px' appended.
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.
Yup, there was a PR to fix it by Micheal but had to be reverted as some people are using lineHeight: 20 intending for it to output line-height: 20px.
im curious if there are any significant performance changes in details list with this change. Check is a high traffic component there. |
@dzearing So I rendered like 5000 Checks with sass and with mergeStyles, and couldn't see any noticeable difference in page load speed or anything. I think perf is fine. |
@jordandrako woot, thanks! |
* TODO: Come back to this once .checkHost has been | ||
* converted to mergeStyles | ||
*/ | ||
'.checkHost:hover &, .checkHost:focus &, &:hover, &:focus': { |
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.
Hmmm. I'm not sure this will work. Is "checkHost" a global? Where is this coming from?
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.
checkHost is coming from the Check.scss file but only used in DetailsRowCheck.tsx.
<div
{ ...buttonProps }
role='checkbox'
className={
css(className, 'ms-DetailsRow-check', DetailsRowCheckStyles.check, CheckStyles.checkHost, {
[`ms-DetailsRow-check--isDisabled ${DetailsRowCheckStyles.isDisabled}`]: !props.canSelect,
[`ms-DetailsRow-check--isHeader ${DetailsRowCheckStyles.isHeader}`]: props.isHeader
})
}
aria-checked={ isPressed }
data-selection-toggle={ true }
data-automationid='DetailsRowCheck'
>
<Check
checked={ isPressed }
/>
</div>
<div | ||
className={ classNames.root } | ||
> | ||
{ Icon({ |
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'm confused why this isn't JSX.
<Icon className={ ... } iconName={ ... } />
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.
That was how it was written before, I was trying to keep the number of logic changes unrelated to mergeStyles to a minimum.
@@ -0,0 +1,145 @@ | |||
import { ICheckStyleProps, ICheckStyles } from './Check.types'; | |||
import { | |||
concatStyleSets, |
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.
Some of these imports aren't needed. Not sure why no-unused-imports isn't picking this up.
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.
Hmm, me either. I'll take the unused ones out.
export * from './Check'; |
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.
export CheckBase
as well perhaps.
Also did you want to delete the scss file?
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.
Alright.
Not yet, there are some rogue components importing it directly. I'll come back to delete once those are converted (namely DetailsList... lol).
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.
minor feedback.
…into mergeStyles/Check
Addressed the issue
@dzearing @battletoilet Could I get approval on this? |
I've approved, @jordandrako sorry it got buried in too many PRs. There is a conflict. Can you double check what changed? |
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.
fix conflicts.
* master: (28 commits) Scrollable pane sort stickies (microsoft#4111) Allow ScrollablePane to accept native properties. (microsoft#4095) Sticky (microsoft#4091) Applying package updates. [ColorRectangle, Sticky] Fixed null root refs (microsoft#4099) DatePicker: order of callbacks for onSelectDate and onAfterMenuDismiss (microsoft#4092) Applying package updates. Alhenry fix split button props (microsoft#4090) Fixing ComboBox styling by reverting button classname move (microsoft#4088) Update CODEOWNERS Undoing terrible change. [DetailsList] Fixed focus test (microsoft#4087) Added icons package screener test (microsoft#4082) ContextualMenu: Fix ContextualMenuUtility imports (microsoft#4085) [ContextualMenu] Made disabled buttons focusable (microsoft#4074) Convert Check to mergeStyles (microsoft#3880) [DetailsList] Add public focusIndex function (microsoft#3852) ComboBox button should have data-is-focusable="false" (microsoft#4070) Applying package updates. Focus Zone: Allow Tab to Skip Selection (microsoft#4061) ...
* Separate types to types.ts file. Start converting check to mergeStyles * Convert bulk scss to mergeStyles. Needs to be reviewed, this is rough. * Add comments for style types. * Convert Check to mergeStyle pattern * Add more props and types * Fix most style conversions. * Remove setUserSelect related lines. Rename rootIsChecked to just checked state. * Remove setUserSelect related lines. Rename rootIsChecked to just checked state. * Fix line-height * Export types in index. * npm run change output * Fix import for Travis * Move className logic to styles file. * nit, remove _ in _sharedCircleCheck * Combine checked conditionals into array. * Make ICheckStyles required, remove checkHost * Export base component * Remove unused import * Make icons jsx * Remove uneeded const
Pull request checklist
$ npm run change
Description of changes
Focus areas to test
Check still looks a behaves the same. Try theming the Check.