1 | import "core-js/modules/es.array.index-of.js";
|
2 | import "core-js/modules/es.array.map.js";
|
3 | import "core-js/modules/es.object.assign.js";
|
4 | import "core-js/modules/es.object.keys.js";
|
5 | import "core-js/modules/es.object.values.js";
|
6 | import "core-js/modules/es.string.bold.js";
|
7 |
|
8 | 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); }
|
9 |
|
10 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
11 |
|
12 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
13 |
|
14 | import React from 'react';
|
15 | import { styled } from '@storybook/theming';
|
16 | import { transparentize } from 'polished';
|
17 | import { getBlockBackgroundStyle } from './BlockBackgroundStyles';
|
18 | import { ResetWrapper } from '../typography/DocumentFormatting';
|
19 | var ItemTitle = styled.div(function (_ref) {
|
20 | var theme = _ref.theme;
|
21 | return {
|
22 | fontWeight: theme.typography.weight.bold,
|
23 | color: theme.color.defaultText
|
24 | };
|
25 | });
|
26 | var ItemSubtitle = styled.div(function (_ref2) {
|
27 | var theme = _ref2.theme;
|
28 | return {
|
29 | color: theme.base === 'light' ? transparentize(0.2, theme.color.defaultText) : transparentize(0.6, theme.color.defaultText)
|
30 | };
|
31 | });
|
32 | var ItemDescription = styled.div({
|
33 | flex: '0 0 30%',
|
34 | lineHeight: '20px',
|
35 | marginTop: 5
|
36 | });
|
37 | var SwatchLabel = styled.div(function (_ref3) {
|
38 | var theme = _ref3.theme;
|
39 | return {
|
40 | flex: 1,
|
41 | textAlign: 'center',
|
42 | fontFamily: theme.typography.fonts.mono,
|
43 | fontSize: theme.typography.size.s1,
|
44 | lineHeight: 1,
|
45 | overflow: 'hidden',
|
46 | color: theme.base === 'light' ? transparentize(0.4, theme.color.defaultText) : transparentize(0.6, theme.color.defaultText),
|
47 | '> div': {
|
48 | display: 'inline-block',
|
49 | overflow: 'hidden',
|
50 | maxWidth: '100%',
|
51 | textOverflow: 'ellipsis'
|
52 | },
|
53 | span: {
|
54 | display: 'block',
|
55 | marginTop: 2
|
56 | }
|
57 | };
|
58 | });
|
59 | var SwatchLabels = styled.div({
|
60 | display: 'flex',
|
61 | flexDirection: 'row'
|
62 | });
|
63 | var Swatch = styled.div({
|
64 | flex: 1
|
65 | });
|
66 | var SwatchColors = styled.div(function (_ref4) {
|
67 | var theme = _ref4.theme;
|
68 | return Object.assign({}, getBlockBackgroundStyle(theme), {
|
69 | display: 'flex',
|
70 | flexDirection: 'row',
|
71 | height: 50,
|
72 | marginBottom: 5,
|
73 | overflow: 'hidden'
|
74 | });
|
75 | });
|
76 | var SwatchSpecimen = styled.div({
|
77 | display: 'flex',
|
78 | flexDirection: 'column',
|
79 | flex: 1,
|
80 | position: 'relative',
|
81 | marginBottom: 30
|
82 | });
|
83 | var Swatches = styled.div({
|
84 | flex: 1,
|
85 | display: 'flex',
|
86 | flexDirection: 'row'
|
87 | });
|
88 | var Item = styled.div({
|
89 | display: 'flex',
|
90 | alignItems: 'flex-start'
|
91 | });
|
92 | var ListName = styled.div({
|
93 | flex: '0 0 30%'
|
94 | });
|
95 | var ListSwatches = styled.div({
|
96 | flex: 1
|
97 | });
|
98 | var ListHeading = styled.div(function (_ref5) {
|
99 | var theme = _ref5.theme;
|
100 | return {
|
101 | display: 'flex',
|
102 | flexDirection: 'row',
|
103 | alignItems: 'center',
|
104 | paddingBottom: 20,
|
105 | fontWeight: theme.typography.weight.bold,
|
106 | color: theme.base === 'light' ? transparentize(0.4, theme.color.defaultText) : transparentize(0.6, theme.color.defaultText)
|
107 | };
|
108 | });
|
109 | var List = styled.div(function (_ref6) {
|
110 | var theme = _ref6.theme;
|
111 | return {
|
112 | fontSize: theme.typography.size.s2,
|
113 | lineHeight: "20px",
|
114 | display: 'flex',
|
115 | flexDirection: 'column'
|
116 | };
|
117 | });
|
118 |
|
119 | function renderSwatch(color) {
|
120 | return React.createElement(Swatch, {
|
121 | key: color,
|
122 | title: color,
|
123 | style: {
|
124 | background: color
|
125 | }
|
126 | });
|
127 | }
|
128 |
|
129 | renderSwatch.displayName = "renderSwatch";
|
130 |
|
131 | function renderSwatchLabel(color, colorDescription) {
|
132 | return React.createElement(SwatchLabel, {
|
133 | key: color,
|
134 | title: color
|
135 | }, React.createElement("div", null, color, colorDescription && React.createElement("span", null, colorDescription)));
|
136 | }
|
137 |
|
138 | renderSwatchLabel.displayName = "renderSwatchLabel";
|
139 |
|
140 | function renderSwatchSpecimen(colors) {
|
141 | if (Array.isArray(colors)) {
|
142 | return React.createElement(SwatchSpecimen, null, React.createElement(SwatchColors, null, colors.map(function (color) {
|
143 | return renderSwatch(color);
|
144 | })), React.createElement(SwatchLabels, null, colors.map(function (color) {
|
145 | return renderSwatchLabel(color);
|
146 | })));
|
147 | }
|
148 |
|
149 | return React.createElement(SwatchSpecimen, null, React.createElement(SwatchColors, null, Object.values(colors).map(function (color) {
|
150 | return renderSwatch(color);
|
151 | })), React.createElement(SwatchLabels, null, Object.keys(colors).map(function (color) {
|
152 | return renderSwatchLabel(color, colors[color]);
|
153 | })));
|
154 | }
|
155 |
|
156 | renderSwatchSpecimen.displayName = "renderSwatchSpecimen";
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | export var ColorItem = function ColorItem(_ref7) {
|
163 | var title = _ref7.title,
|
164 | subtitle = _ref7.subtitle,
|
165 | colors = _ref7.colors;
|
166 | return React.createElement(Item, null, React.createElement(ItemDescription, null, React.createElement(ItemTitle, null, title), React.createElement(ItemSubtitle, null, subtitle)), React.createElement(Swatches, null, renderSwatchSpecimen(colors)));
|
167 | };
|
168 | ColorItem.displayName = "ColorItem";
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 | export var ColorPalette = function ColorPalette(_ref8) {
|
175 | var children = _ref8.children,
|
176 | props = _objectWithoutProperties(_ref8, ["children"]);
|
177 |
|
178 | return React.createElement(ResetWrapper, null, React.createElement(List, _extends({}, props, {
|
179 | className: "docblock-colorpalette"
|
180 | }), React.createElement(ListHeading, null, React.createElement(ListName, null, "Name"), React.createElement(ListSwatches, null, "Swatches")), children));
|
181 | };
|
182 | ColorPalette.displayName = "ColorPalette"; |
\ | No newline at end of file |