UNPKG

2.16 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.getAvailableAtBadge = exports.findAllByType = exports.breakpointStyle = exports.fontSize = exports.parseMetricToNum = void 0;
5
6var _styledComponents = require("styled-components");
7
8var parseMetricToNum = function parseMetricToNum(fontAsString) {
9 return parseFloat(fontAsString.replace(/[^0-9/.]/g, ''), 10);
10};
11
12exports.parseMetricToNum = parseMetricToNum;
13
14var fontSize = function fontSize(size, lineHeight) {
15 return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], function (props) {
16 return parseMetricToNum(size) / parseMetricToNum(props.theme.global.font.size) * 1 + "rem";
17 }, function (props) {
18 return lineHeight || Math.ceil(parseMetricToNum(size) / parseMetricToNum(props.theme.global.lineHeight)) * (parseMetricToNum(props.theme.global.lineHeight) / parseMetricToNum(size)) + "px";
19 });
20};
21
22exports.fontSize = fontSize;
23
24var breakpointStyle = function breakpointStyle(breakpoint, content) {
25 return (0, _styledComponents.css)(["@media only screen ", "{", ";}"], breakpoint.value && "and (max-width: " + breakpoint.value + "px)", content);
26};
27
28exports.breakpointStyle = breakpointStyle;
29
30var findAllByType = function findAllByType(component, type) {
31 var matches = [];
32
33 if (component.type === type) {
34 matches.push(component);
35 }
36
37 if (component.children) {
38 component.children.forEach(function (child) {
39 matches = matches.concat(findAllByType(child, type));
40 });
41 }
42
43 return matches;
44};
45
46exports.findAllByType = findAllByType;
47
48var getAvailableAtBadge = function getAvailableAtBadge(availableAt) {
49 return [{
50 url: "https://storybook.grommet.io/?selectedKind=" + availableAt + "&full=0&addons=0&stories=1&panelRight=0",
51 badge: 'https://cdn-images-1.medium.com/fit/c/120/120/1*TD1P0HtIH9zF0UEH28zYtw.png',
52 label: 'Storybook'
53 }, {
54 url: "https://codesandbox.io/s/github/grommet/grommet-sandbox?initialpath=" + availableAt.toLowerCase() + "&module=%2Fsrc%2F" + availableAt + ".js",
55 badge: 'https://codesandbox.io/static/img/play-codesandbox.svg',
56 label: 'CodeSandbox'
57 }];
58};
59
60exports.getAvailableAtBadge = getAvailableAtBadge;
\No newline at end of file