UNPKG

3.3 kBJavaScriptView Raw
1import "core-js/modules/es.array.index-of.js";
2import "core-js/modules/es.array.map.js";
3import "core-js/modules/es.object.assign.js";
4import "core-js/modules/es.object.keys.js";
5
6function _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); }
7
8function _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; }
9
10function _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; }
11
12import React from 'react';
13import { styled } from '@storybook/theming';
14import { transparentize } from 'polished';
15import { withReset } from '../typography/shared';
16import { getBlockBackgroundStyle } from './BlockBackgroundStyles';
17var Label = styled.div(function (_ref) {
18 var theme = _ref.theme;
19 return {
20 marginRight: 30,
21 fontSize: "".concat(theme.typography.size.s1, "px"),
22 color: theme.base === 'light' ? transparentize(0.4, theme.color.defaultText) : transparentize(0.6, theme.color.defaultText)
23 };
24});
25var Sample = styled.div({
26 overflow: 'hidden',
27 whiteSpace: 'nowrap',
28 textOverflow: 'ellipsis'
29});
30var TypeSpecimen = styled.div({
31 display: 'flex',
32 flexDirection: 'row',
33 alignItems: 'baseline',
34 '&:not(:last-child)': {
35 marginBottom: '1rem'
36 }
37});
38var Wrapper = styled.div(withReset, function (_ref2) {
39 var theme = _ref2.theme;
40 return Object.assign({}, getBlockBackgroundStyle(theme), {
41 margin: '25px 0 40px',
42 padding: '30px 20px'
43 });
44});
45
46/**
47 * Convenient styleguide documentation showing examples of type
48 * with different sizes and weights and configurable sample text.
49 */
50export var Typeset = function Typeset(_ref3) {
51 var fontFamily = _ref3.fontFamily,
52 fontSizes = _ref3.fontSizes,
53 fontWeight = _ref3.fontWeight,
54 sampleText = _ref3.sampleText,
55 props = _objectWithoutProperties(_ref3, ["fontFamily", "fontSizes", "fontWeight", "sampleText"]);
56
57 return /*#__PURE__*/React.createElement(Wrapper, _extends({}, props, {
58 className: "docblock-typeset"
59 }), fontSizes.map(function (size) {
60 return /*#__PURE__*/React.createElement(TypeSpecimen, {
61 key: size
62 }, /*#__PURE__*/React.createElement(Label, null, size), /*#__PURE__*/React.createElement(Sample, {
63 style: {
64 fontFamily: fontFamily,
65 fontSize: size,
66 fontWeight: fontWeight,
67 lineHeight: 1.2
68 }
69 }, sampleText || 'Was he a beast if music could move him so?'));
70 }));
71};
72Typeset.displayName = "Typeset";
\No newline at end of file