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.

145 lines (137 loc) 4.13 kB
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import React, { useState } from "react"; import { storiesOf } from "@storybook/react"; import { Box } from "../box"; import { Inline } from "../inline"; import { Radio } from "."; storiesOf("Forms/Radio", module).add("Default", function () { function RadioWithValue() { var _useState = useState("a"), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue = _useState2[1]; return React.createElement(Box, { extend: { flexDirection: "row" } }, React.createElement(Box, { as: "label", extend: { flexDirection: "row", marginRight: "10px" } }, React.createElement(Radio, { name: "choice", value: "a", checked: value == "a", onChange: function onChange() { return setValue("a"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Alpha")), React.createElement(Box, { as: "label", extend: { flexDirection: "row", marginRight: "10px" } }, React.createElement(Radio, { name: "choice", value: "b", checked: value == "b", onChange: function onChange() { return setValue("b"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Beta")), React.createElement(Box, { as: "label", extend: { flexDirection: "row" } }, React.createElement(Radio, { name: "choice", value: "c", checked: value == "c", onChange: function onChange() { return setValue("c"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Charlie"))); } return React.createElement(RadioWithValue, null); }).add("With Disabled", function () { function RadioWithValue() { var _useState3 = useState("a"), _useState4 = _slicedToArray(_useState3, 2), value = _useState4[0], setValue = _useState4[1]; return React.createElement(Box, { extend: { flexDirection: "row" } }, React.createElement(Box, { as: "label", extend: { flexDirection: "row", marginRight: "10px" } }, React.createElement(Radio, { name: "choice", disabled: true, value: "a", checked: value == "a", onChange: function onChange() { return setValue("a"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Alpha")), React.createElement(Box, { as: "label", extend: { flexDirection: "row", marginRight: "10px" } }, React.createElement(Radio, { name: "choice", value: "b", checked: value == "b", onChange: function onChange() { return setValue("b"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Beta")), React.createElement(Box, { as: "label", extend: { flexDirection: "row" } }, React.createElement(Radio, { name: "choice", value: "c", checked: value == "c", onChange: function onChange() { return setValue("c"); } }), React.createElement(Inline, { extend: { marginLeft: "5px" } }, "Charlie"))); } return React.createElement(RadioWithValue, null); });