import { css } from '@microsoft/fast-element'; import { checkedState, nativeDisabledState } from '../styles/states/index.js'; import { borderRadiusCircular, colorCompoundBrandBackground, colorCompoundBrandBackgroundHover, colorCompoundBrandBackgroundPressed, colorNeutralBackgroundDisabled, colorNeutralForeground3, colorNeutralForeground3Hover, colorNeutralForeground3Pressed, colorNeutralForegroundDisabled, colorNeutralForegroundInverted, colorNeutralForegroundInvertedHover, colorNeutralForegroundInvertedPressed, colorNeutralStrokeAccessible, colorNeutralStrokeAccessibleHover, colorNeutralStrokeAccessiblePressed, colorNeutralStrokeDisabled, colorStrokeFocus2, colorTransparentBackground, colorTransparentStroke, curveEasyEase, durationNormal, shadow4, spacingHorizontalXXS, strokeWidthThick, } from '../theme/design-tokens.js'; import { display } from '../utils/display.js'; export const styles = css` ${display('inline-flex')} :host { box-sizing: border-box; align-items: center; flex-direction: row; outline: none; user-select: none; contain: content; padding: 0 ${spacingHorizontalXXS}; width: 40px; height: 20px; background-color: ${colorTransparentBackground}; border: 1px solid ${colorNeutralStrokeAccessible}; border-radius: ${borderRadiusCircular}; } :host(:enabled) { cursor: pointer; } :host(:hover) { background: none; border-color: ${colorNeutralStrokeAccessibleHover}; } :host(:active) { border-color: ${colorNeutralStrokeAccessiblePressed}; } :host(${nativeDisabledState}), :host([readonly]) { border: 1px solid ${colorNeutralStrokeDisabled}; background-color: none; pointer: default; } :host(${checkedState}) { background: ${colorCompoundBrandBackground}; border-color: ${colorCompoundBrandBackground}; } :host(${checkedState}:hover) { background: ${colorCompoundBrandBackgroundHover}; border-color: ${colorCompoundBrandBackgroundHover}; } :host(${checkedState}:active) { background: ${colorCompoundBrandBackgroundPressed}; border-color: ${colorCompoundBrandBackgroundPressed}; } :host(${checkedState}${nativeDisabledState}) { background: ${colorNeutralBackgroundDisabled}; border-color: ${colorNeutralStrokeDisabled}; } .checked-indicator { height: 14px; width: 14px; border-radius: 50%; margin-inline-start: 0; background-color: ${colorNeutralForeground3}; transition-duration: ${durationNormal}; transition-timing-function: ${curveEasyEase}; transition-property: margin-inline-start; } :host(${checkedState}) .checked-indicator { background-color: ${colorNeutralForegroundInverted}; margin-inline-start: calc(100% - 14px); } :host(${checkedState}:hover) .checked-indicator { background: ${colorNeutralForegroundInvertedHover}; } :host(${checkedState}:active) .checked-indicator { background: ${colorNeutralForegroundInvertedPressed}; } :host(:hover) .checked-indicator { background-color: ${colorNeutralForeground3Hover}; } :host(:active) .checked-indicator { background-color: ${colorNeutralForeground3Pressed}; } :host(${nativeDisabledState}) .checked-indicator, :host([readonly]) .checked-indicator { background: ${colorNeutralForegroundDisabled}; } :host(${checkedState}${nativeDisabledState}) .checked-indicator { background: ${colorNeutralForegroundDisabled}; } :host(:focus-visible) { outline: none; } :host(:not([slot='input']):focus-visible) { border-color: ${colorTransparentStroke}; outline: ${strokeWidthThick} solid ${colorTransparentStroke}; outline-offset: 1px; box-shadow: ${shadow4}, 0 0 0 2px ${colorStrokeFocus2}; } @media (forced-colors: active) { :host { border-color: InactiveBorder; } :host(${checkedState}), :host(${checkedState}:active), :host(${checkedState}:hover) { background: Highlight; border-color: Highlight; } .checked-indicator, :host(:hover) .checked-indicator, :host(:active) .checked-indicator { background-color: CanvasText; } :host(${checkedState}) .checked-indicator, :host(${checkedState}:hover) .checked-indicator, :host(${checkedState}:active) .checked-indicator { background-color: HighlightText; } :host(${nativeDisabledState}) .checked-indicator, :host(${checkedState}${nativeDisabledState}) .checked-indicator { background-color: GrayText; } } `;