office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
173 lines • 6.95 kB
JavaScript
define(["require", "exports", "../../Utilities", "../../Styling"], function (require, exports, Utilities_1, Styling_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getClassNames = Utilities_1.memoizeFunction(function (theme, styles, className, disabled, checked) {
var semanticColors = theme.semanticColors;
var pillUncheckedBackground = semanticColors.bodyBackground;
var pillCheckedBackground = semanticColors.inputBackgroundChecked;
var pillCheckedHoveredBackground = semanticColors.inputBackgroundCheckedHovered;
var pillCheckedDisabledBackground = semanticColors.disabledText;
var thumbBackground = semanticColors.inputBorderHovered;
var thumbCheckedBackground = semanticColors.inputForegroundChecked;
var thumbDisabledBackground = semanticColors.disabledText;
var thumbCheckedDisabledBackground = semanticColors.disabledBackground;
var pillBorderColor = semanticColors.inputBorder;
var pillBorderHoveredColor = semanticColors.inputBorderHovered;
var pillBorderDisabledColor = semanticColors.disabledText;
var toggleFocusBorderColor = semanticColors.focusBorder;
var textDisabledColor = semanticColors.disabledText;
styles = styles || {};
return Styling_1.mergeStyleSets({
root: [
'ms-Toggle',
checked && 'is-checked',
!disabled && 'is-enabled',
disabled && 'is-disabled',
className,
{
marginBottom: '8px'
},
styles.root
],
label: [
'ms-Toggle-label',
styles.label
],
container: [
'ms-Toggle-innerContainer',
{
display: 'inline-flex',
position: 'relative',
},
styles.container
],
pill: [
'ms-Toggle-background',
Styling_1.getFocusStyle(theme, '-1px'),
{
fontSize: '20px',
lineHeight: '1em',
boxSizing: 'border-box',
position: 'relative',
width: '2.2em',
height: '1em',
borderRadius: '1em',
transition: 'all 0.1s ease',
borderWidth: '1px',
borderStyle: 'solid',
background: pillUncheckedBackground,
borderColor: pillBorderColor,
cursor: 'pointer',
},
styles.pill,
!disabled && [
!checked && {
':hover': [
{
borderColor: pillBorderHoveredColor
},
styles.pillHovered
],
':hover .ms-Toggle-thumb': styles.thumbHovered
},
checked && [
{
background: pillCheckedBackground,
borderColor: 'transparent',
},
styles.pillChecked,
{
':hover': [
{
backgroundColor: pillCheckedHoveredBackground,
borderColor: 'transparent'
},
styles.pillCheckedHovered
],
':hover .ms-Toggle-thumb': [
styles.thumbCheckedHovered
]
}
]
],
disabled && [
{
cursor: 'default'
},
!checked && [
{
borderColor: pillBorderDisabledColor
},
styles.pillDisabled
],
checked && [
{
backgroundColor: pillCheckedDisabledBackground,
borderColor: 'transparent'
},
styles.pillCheckedDisabled
],
]
],
thumb: [
'ms-Toggle-thumb',
{
width: '.5em',
height: '.5em',
borderRadius: '.5em',
position: 'absolute',
top: '.2em',
transition: 'all 0.1s ease',
backgroundColor: thumbBackground,
/* Border is added to handle high contrast mode for Firefox */
borderColor: 'transparent',
borderWidth: '.27em',
borderStyle: 'solid',
boxSizing: 'border-box',
left: '.2em'
},
styles.thumb,
!disabled && checked && [
{
backgroundColor: thumbCheckedBackground,
left: '1.4em'
},
styles.thumbChecked
],
disabled && [
!checked && [
{
backgroundColor: thumbDisabledBackground,
left: '.2em',
},
styles.thumbDisabled
],
checked && [
{
backgroundColor: thumbCheckedDisabledBackground,
left: '1.4em'
},
styles.thumbCheckedDisabled
]
]
],
text: [
'ms-Toggle-stateText',
{
'.ms-Toggle-stateText': {
padding: '0',
margin: '0 10px',
userSelect: 'none'
}
},
disabled && {
'.ms-Toggle-stateText': {
color: textDisabledColor
}
},
styles.text
]
});
});
});
//# sourceMappingURL=Toggle.classNames.js.map