Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6a250b7
Separate types to types.ts file.
Feb 2, 2018
b35ac65
Convert bulk scss to mergeStyles. Needs to be reviewed, this is rough.
Feb 2, 2018
fe0a2cc
Add comments for style types.
Feb 2, 2018
077aec6
Convert Check to mergeStyle pattern
Feb 2, 2018
653e516
Add more props and types
Feb 2, 2018
7043de2
Fix most style conversions.
Feb 2, 2018
90edfb0
Remove setUserSelect related lines. Rename rootIsChecked to just chec…
Feb 3, 2018
45ccb3a
Remove setUserSelect related lines. Rename rootIsChecked to just chec…
Feb 3, 2018
b0ae601
merge
Feb 3, 2018
1726d5b
Fix line-height
Feb 3, 2018
456a308
Export types in index.
Feb 3, 2018
047428e
npm run change output
Feb 3, 2018
b3ac3fa
Merge branch 'master' into mergeStyles/Check
Feb 5, 2018
98377dc
Fix import for Travis
jordandrako Feb 6, 2018
5a03aa5
Move className logic to styles file.
Feb 6, 2018
21832aa
nit, remove _ in _sharedCircleCheck
Feb 7, 2018
e68c604
Merge branch 'master' into mergeStyles/Check
Feb 7, 2018
def08c6
Merge branch 'master' into mergeStyles/Check
Feb 8, 2018
3872a95
Combine checked conditionals into array.
Feb 8, 2018
d0d9590
Make ICheckStyles required, remove checkHost
Feb 9, 2018
babf3ba
Export base component
Feb 12, 2018
04a146c
Remove unused import
Feb 12, 2018
e531bbc
Make icons jsx
Feb 12, 2018
6dd8473
Remove uneeded const
Feb 12, 2018
d8b8504
Merge branch 'master' into mergeStyles/Check
Feb 12, 2018
1d6604c
Merge branch 'master' into mergeStyles/Check
Feb 12, 2018
e0ed9c0
Merge branch 'master' of github.com:OfficeDev/office-ui-fabric-react …
Feb 12, 2018
a04339d
Merge branch 'master' into mergeStyles/Check
jordandrako Feb 21, 2018
4920468
Merge branch 'master' into mergeStyles/Check
jordandrako Feb 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Convert Check to mergeStyles",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from 'react';
import {
BaseComponent,
classNamesFunction,
customizable,
} from '@uifabric/utilities';
import {
ICheckProps,
ICheckStyleProps,
ICheckStyles
} from './Check.types';
import { Icon } from '../../Icon';
import { getStyles } from './Check.styles';

const getClassNames = classNamesFunction<ICheckStyleProps, ICheckStyles>();

@customizable('Check', ['theme'])
export class CheckBase extends BaseComponent<ICheckProps, {}> {
public static defaultProps: ICheckProps = {
checked: false
};

public shouldComponentUpdate(newProps: ICheckProps) {
return this.props.checked !== newProps.checked;
}

public render(): JSX.Element {
const {
checked,
className,
theme
} = this.props;

const classNames = getClassNames(getStyles!, { theme: theme!, className, checked });

return (
<div className={ classNames.root } >
<Icon iconName='CircleRing' className={ classNames.circle } />
<Icon iconName='StatusCircleCheckmark' className={ classNames.check } />
</div>
);
}
}
142 changes: 142 additions & 0 deletions packages/office-ui-fabric-react/src/components/Check/Check.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { ICheckStyleProps, ICheckStyles } from './Check.types';
import {
getTheme,
HighContrastSelector,
IStyle,
ITheme,
} from '@uifabric/styling';
import { memoizeFunction } from '@uifabric/utilities';

export const getStyles = (
props: ICheckStyleProps
): ICheckStyles => {
const {
checkBoxHeight = '18px',
checked,
className,
theme,
} = props;

const { palette, semanticColors } = theme;

const sharedCircleCheck: IStyle = {
fontSize: checkBoxHeight,
position: 'absolute',
left: 0,
top: 0,
width: checkBoxHeight,
height: checkBoxHeight,
textAlign: 'center',
verticalAlign: 'middle'
};

return ({
root: [
'ms-Check',

{
// lineHeight currently needs to be a string to output without 'px'
lineHeight: '1',
width: checkBoxHeight,
height: checkBoxHeight,
verticalAlign: 'top',
position: 'relative',
userSelect: 'none',

selectors: {
':before': {
content: '""',
position: 'absolute',
top: '1px',
right: '1px',
bottom: '1px',
left: '1px',
borderRadius: '50%',
opacity: 1,
background: semanticColors.bodyBackground,
},

/**
* TODO: Come back to this once .checkHost has been
* converted to mergeStyles
*/
'.checkHost:hover &, .checkHost:focus &, &:hover, &:focus': {
Copy link
Member

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?

Copy link
Contributor Author

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>

opacity: 1
}
}
},

checked && [
'is-checked',
{
selectors: {
':before': {
background: palette.themePrimary,
opacity: 1,
selectors: {
[HighContrastSelector]: {
background: 'Window'
}
}
}
}
},
],
className
],

circle: [
'ms-Check-circle',
sharedCircleCheck,

{
color: palette.neutralTertiaryAlt,

selectors: {
[HighContrastSelector]: {
color: 'WindowText'
}
}
},

checked && {
color: palette.white
}
],

check: [
'ms-Check-check',
sharedCircleCheck,

{
opacity: 0,
color: palette.neutralTertiaryAlt,
fontSize: '16px',
left: '.5px',

selectors: {
':hover': {
opacity: 1
},

[HighContrastSelector]: {
MsHighContrastAdjust: 'none'
}
}
},

checked && {
opacity: 1,
color: palette.white,
fontWeight: 900,

selectors: {
[HighContrastSelector]: {
border: 'none',
color: 'WindowText'
}
}
}
]
});
};
76 changes: 13 additions & 63 deletions packages/office-ui-fabric-react/src/components/Check/Check.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,13 @@
import * as React from 'react';
import { BaseComponent, css } from '../../Utilities';
import { Icon } from '../../Icon';
import * as stylesImport from './Check.scss';
const styles: any = stylesImport;

export interface ICheckProps extends React.Props<Check> {
/**
* Gets the component ref.
*/
componentRef?: () => void;

/**
* Whether or not this menu item is currently checked.
* @defaultvalue false
*/
checked?: boolean;
/**
* Deprecated at v0.65.1 and will be removed by v 1.0. Use 'checked' instead.
* @deprecated
*/
isChecked?: boolean;

alwaysShowCheck?: boolean;
}

export class Check extends BaseComponent<ICheckProps, {}> {
public static defaultProps = {
isChecked: false
};

public shouldComponentUpdate(newProps: ICheckProps) {
return this.props.isChecked !== newProps.isChecked || this.props.checked !== newProps.checked;
}

public render() {
let { isChecked } = this.props;
const { checked } = this.props;

isChecked = isChecked || checked;

return (
<div
className={ css(
'ms-Check',
styles.root,
{
[`is-checked ${styles.rootIsChecked}`]: isChecked
}
) }
>
{ <Icon
className={ 'ms-Check-circle ' + styles.circle }
iconName={ 'CircleRing' }
/> }
{ <Icon
className={ 'ms-Check-check ' + styles.check }
iconName={ 'StatusCircleCheckmark' }
/> }
</div>
);
}
}
import { styled } from '@uifabric/utilities';
import {
ICheckProps,
ICheckStyleProps,
ICheckStyles
} from './Check.types';
import { CheckBase } from './Check.base';
import { getStyles } from './Check.styles';

export const Check = styled<ICheckProps, ICheckStyleProps, ICheckStyles>(
CheckBase,
getStyles
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as React from 'react';
import { CheckBase } from './Check.base';
import { IStyle, ITheme } from '@uifabric/styling';
import { IStyleFunction } from '@uifabric/utilities';

export interface ICheckProps extends React.Props<CheckBase> {
/**
* Gets the component ref.
*/
componentRef?: (component: ICheckProps) => void;

/**
* Whether or not this menu item is currently checked.
* @defaultvalue false
*/
checked?: boolean;

/**
* Call to provide customized styling that will layer on top of the variant rules
*/
getStyles?: IStyleFunction<ICheckStyleProps, ICheckStyles>;

/**
* Flag to always show the check icon. Not currently working.
*/
alwaysShowCheck?: boolean;

/**
* Theme provided by HOC.
*/
theme?: ITheme;

/**
* Additional css class to apply to the Check
* @defaultvalue undefined
*/
className?: string;
}

export interface ICheckStyleProps {
/**
* Accept theme prop.
*/
theme: ITheme;

/**
* Accept custom classNames
*/
className?: string;

/**
* Accept custom checkBox size in pixels.
* @defaultvalue '18px'
*/
checkBoxHeight?: string;

checked?: boolean;
}

export interface ICheckStyles {
/**
* Style for the root element.
*/
root: IStyle;

/**
* The 'check' icon styles.
*/
check: IStyle;

/**
* The 'circle' icon styles.
*/
circle: IStyle;
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './Check';
export * from './Check';
Copy link
Member

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?

Copy link
Contributor Author

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).

export * from './Check.base';
export * from './Check.types';