UNPKG

vcc-ui

Version:

VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.

72 lines (68 loc) 2.16 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from "react"; import { bool, func } from "prop-types"; import { useFela } from "react-fela"; import { Block } from "../block"; import { getThemeStyle } from "../../get-theme-style"; var checkboxStyle = function checkboxStyle(_ref) { var theme = _ref.theme; return { boxSizing: "border-box", borderWidth: 1, borderStyle: "solid", appearance: "none", width: 20, height: 20, margin: 0, padding: 0, flexShrink: 0, flexGrow: 0, display: "flex", justifyContent: "center", alignItems: "center", position: "relative", cursor: "pointer", outline: 0, borderColor: theme.tokens.inputBorder, background: theme.tokens.inputBackground, ":focus": { borderColor: theme.tokens.inputBorderFocus }, "[disabled]": { cursor: "not-allowed", borderColor: theme.tokens.inputDisabledBorder, ":checked": { ":before": { borderRight: "2px solid ".concat(theme.tokens.inputDisabledControl), borderBottom: "2px solid ".concat(theme.tokens.inputDisabledControl) } } }, ":checked": { ":before": { boxSizing: "border-box", transform: "translateY(-1px) rotate(45deg)", display: "block", content: "''", width: 5, height: 10, position: "absolute", borderRight: "2px solid ".concat(theme.tokens.inputControl), borderBottom: "2px solid ".concat(theme.tokens.inputControl) } } }; }; export function Checkbox(props) { var _useFela = useFela(), theme = _useFela.theme; return React.createElement(Block, _extends({}, props, { as: "input", type: "checkbox", extend: [checkboxStyle, getThemeStyle("checkbox", theme)] })); } Checkbox.propTypes = { onChange: func.isRequired, checked: bool };