UNPKG

@braineet/ui

Version:

Braineet design system

85 lines (82 loc) 3.87 kB
/* stylelint-disable no-descending-specificity */ import styled, { css } from 'styled-components'; import { borderRadius, fluid } from '../../utils'; import Box from '../box'; import Text from '../text'; export var StyledLabel = styled(Box).withConfig({ displayName: "styles__StyledLabel", componentId: "sc-1g1klcf-0" })(["position:relative;display:inline-flex;align-items:center;flex-grow:0;padding:8px;box-sizing:border-box;cursor:", ";", " ", " ", " ", " ", " ", " ", " ", " ", ""], function (p) { return !p.readOnly ? 'pointer' : 'default'; }, borderRadius(4), function (props) { return props.disabled && DisabledLabel; }, function (p) { return !p.readOnly && !p.checked && css(["&:hover{background-color:", ";}"], function (props) { return props.theme.utils.lighten('black', 0.1); }); }, borderRadius(4), function (p) { return p.style; }, function (props) { return props.checked && CheckedToggle; }, function (props) { return props.disabled && DisabledToggle; }, function (props) { return props.error && ErrorToggle; }, function (p) { return p.stylesProps; }); export var DefaultToggleInput = styled.input.withConfig({ displayName: "styles__DefaultToggleInput", componentId: "sc-1g1klcf-1" })(["position:relative;display:flex;align-items:center;justify-content:center;appearance:none;flex-shrink:0;cursor:pointer;"]); export var StyledText = styled(Text).withConfig({ displayName: "styles__StyledText", componentId: "sc-1g1klcf-2" })(["display:block;line-height:1;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow-wrap:break-word;", ""], function (props) { return props.error && ErrorText; }); /** * Styles Label */ var DisabledLabel = css(["cursor:not-allowed;"]); /** * Styles Toggle */ var CheckedToggle = css(["background-color:", ";"], function (props) { return props.theme.colors.brand10; }); var DisabledToggle = css(["opacity:", ";&:hover{background-color:transparent;}"], function (props) { return props.opacity || '0.24'; }); var ErrorToggle = css(["background-color:", ";"], function (props) { return props.theme.colors.error10; }); var ErrorText = css(["color:", ";"], function (props) { return props.theme.colors.error50; }); export var SwitchInput = styled(DefaultToggleInput).withConfig({ displayName: "styles__SwitchInput", componentId: "sc-1g1klcf-3" })(["width:", ";min-width:", ";height:", ";transition:background-color 0.4s;background-color:", ";", " &:checked{background-color:", ";}&:focus:not(:disabled){border:none;outline-offset:2px;outline:2px solid ", ";}&:focus:not(:focus-visible){border:none;outline:none;}&:disabled{background-color:", ";cursor:not-allowed;}"], fluid(26), fluid(26), fluid(16), function (props) { return props.theme.colors.black; }, borderRadius(37), function (props) { return props.theme.colors.brand; }, function (p) { return p.theme.colors.brand; }, function (p) { return p.theme.colors.blackOpacity10; }); export var SwitchCircle = styled.span.withConfig({ displayName: "styles__SwitchCircle", componentId: "sc-1g1klcf-4" })(["position:absolute;top:calc(50% - 6px);line-height:1;height:", ";width:", ";transition:all 0.2s cubic-bezier(0.4,0,0.2,1);transform:translate(2px);background-color:", ";svg,path{fill:", ";color:", ";display:block;opacity:0;}", " ", ":checked ~ &{svg,path{opacity:1;}transform:translate(12px);}", ":disabled ~ &{svg,path{fill:", ";color:", ";display:block;}}"], fluid(12), fluid(12), function (props) { return props.theme.colors.background.white; }, function (props) { return props.theme.colors.brand; }, function (props) { return props.theme.colors.brand; }, borderRadius(50, true), SwitchInput, SwitchInput, function (props) { return props.theme.colors.black; }, function (props) { return props.theme.colors.black; });