UNPKG

@alicloud/console-components

Version:

Alibaba Cloud React Components

73 lines (72 loc) 3.82 kB
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; /** * title: "多项选项卡(支持横纵布局)" * description: "使用 `<Checkbox.Group>` 渲染 `<Checkbox>` 分组,定制Checkbox的为卡片样式" */ import React, { useState } from 'react'; import { Checkbox } from '@alicloud/console-components'; import styled from 'styled-components'; var List = [ { label: '文本信息A', value: 'A', }, { label: '文本信息B', value: 'B', }, { label: '文本信息C', value: 'C', disabled: true, }, { label: '文本信息D', value: 'D', }, ]; var disableStyle = { backgroundColor: '#f6f6f6', }; var checkedStyle = { backgroundColor: '#eff3f8', }; export default (function () { var _a = useState([]), checkedList = _a[0], setCheckedList = _a[1]; var getStyle = function (item) { if (item.disabled) { return disableStyle; } if (checkedList.find(function (i) { return i === item.value; })) { return checkedStyle; } return {}; }; return (React.createElement(Checkbox.Group, { value: checkedList, onChange: setCheckedList }, React.createElement(Container, null, List.slice(0, 2).map(function (item) { return (React.createElement(CheckItem, { style: getStyle(item) }, React.createElement(Checkbox, { value: item.value, disabled: item.disabled }, item.label, React.createElement("br", null), React.createElement("span", { style: { margin: '0 0 0 24px', color: '#808080', display: 'inline-block', lineHeight: '16px', } }, "\u5BF9\u4E8E\u9009\u9879\u7684\u63CF\u8FF0/\u89E3\u91CA\u6587\u6848\uFF0C\u5BF9\u4E8E\u9009\u9879\u7684\u63CF\u8FF0/\u89E3\u91CA\u6587\u6848")))); })), React.createElement(Container, null, List.slice(2, 4).map(function (item) { return (React.createElement(CheckItem, { style: getStyle(item) }, React.createElement(Checkbox, { value: item.value, disabled: item.disabled }, item.label, React.createElement("br", null), React.createElement("span", { style: { margin: '0 0 0 24px', color: '#808080', display: 'inline-block', lineHeight: '16px', } }, "\u5BF9\u4E8E\u9009\u9879\u7684\u63CF\u8FF0/\u89E3\u91CA\u6587\u6848\uFF0C\u5BF9\u4E8E\u9009\u9879\u7684\u63CF\u8FF0/\u89E3\u91CA\u6587\u6848")))); })))); }); var CheckItem = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 4px;\n border: 1px solid #e5e5e5;\n padding: 16px;\n margin: 4px;\n width: 230px;\n display: inline-block;\n &:hover {\n background-color: #f7f9fa;\n box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.16);\n }\n"], ["\n border-radius: 4px;\n border: 1px solid #e5e5e5;\n padding: 16px;\n margin: 4px;\n width: 230px;\n display: inline-block;\n &:hover {\n background-color: #f7f9fa;\n box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.16);\n }\n"]))); var Container = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n max-width: 470px; /* 2 * (230px + 4px * 2) */\n"], ["\n display: flex;\n justify-content: space-between;\n width: 100%;\n max-width: 470px; /* 2 * (230px + 4px * 2) */\n"]))); var templateObject_1, templateObject_2;