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.

85 lines (72 loc) 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Radio = Radio; var _react = _interopRequireDefault(require("react")); var _reactFela = require("react-fela"); var _propTypes = require("prop-types"); var _inline = require("../inline"); var _getThemeStyle = require("../../get-theme-style"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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); } var radioStyle = function radioStyle(_ref) { var theme = _ref.theme; return { boxSizing: "border-box", borderWidth: 1, borderStyle: "solid", appearance: "none", borderRadius: "50%", width: 20, height: 20, margin: 0, padding: 0, display: "flex", justifyContent: "center", alignItems: "center", position: "relative", cursor: "pointer", borderColor: theme.tokens.inputBorder, background: theme.tokens.inputBackground, outline: 0, ":focus": { borderColor: theme.tokens.inputBorderFocus }, ":checked": { ":before": { borderRadius: "50%", display: "block", content: "''", width: 8, height: 8, backgroundColor: theme.tokens.inputControl, position: "absolute" } }, "[disabled]": { cursor: "not-allowed", borderColor: theme.tokens.inputDisabledBorder, ":checked": { ":before": { backgroundColor: theme.tokens.inputDisabledControl } } } }; }; function Radio(props) { var _useFela = (0, _reactFela.useFela)(), theme = _useFela.theme; return _react.default.createElement(_inline.Inline, _extends({}, props, { as: "input", type: "radio", extend: [radioStyle, (0, _getThemeStyle.getThemeStyle)("radio", theme)] })); } Radio.propTypes = { onChange: _propTypes.func.isRequired, checked: _propTypes.bool.isRequired, /** Should be the same for all radio buttons belonging to same group */ name: _propTypes.string.isRequired };