import * as React from 'react'; import { ThemedComponentClass, themr } from '@friendsofreactjs/react-css-themr'; import { SWITCHCHECKBOX } from '../ThemeIdentifiers'; import * as baseTheme from './SwitchCheckboxIcon.scss'; // import { createUniqueIDFactory } from '@shopify/javascript-utilities/other'; import { classNames } from '@shopify/react-utilities/styles'; import Icon from '../Icon/Icon'; export type ISwitchType = 'normal' | 'trueFalse' | 'yesNo'; export interface Props { // Set theme for SwitchCheckbox theme?: any; // To apply custom styling. componentStyle?: React.CSSProperties; // Set a custom class componentClass?: string; componentId?: string; children?: React.ReactNode; // component props to handle toggle disabled?: boolean; isOpen?: boolean; handleToggle: (value?: boolean) => void; switchType?:ISwitchType; allowNull?:boolean; } const SwitchCheckboxIcon = (props: Props) => { const { theme, componentClass, componentStyle, isOpen, allowNull = true } = props; const { children, handleToggle, switchType= 'normal' } = props; let switchTypeClass = theme.switchNormal; switch (switchType) { case 'normal': switchTypeClass = theme.switchNormal; break; case 'trueFalse': switchTypeClass = theme.switchTrueFalse; break; case 'yesNo' : switchTypeClass = theme.switchYesNo; break; default: switchTypeClass = theme.switchNormal; break; } const className = classNames( componentClass, theme.switchCheckbox, switchTypeClass, isOpen === false && theme.falseSelect, isOpen === true && theme.trueSelect, typeof isOpen !== 'boolean' && !isOpen && theme.nullSelect , allowNull && theme.disableSwitch ); return (