@redocly/theme 0.1.10 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CodeBlock/CodeBlock.js +2 -1
  2. package/Markdown/StyledMarkdown.d.ts +0 -2
  3. package/Markdown/StyledMarkdown.js +5 -16
  4. package/Markdown/index.d.ts +0 -1
  5. package/Markdown/index.js +0 -1
  6. package/Navbar/NavbarMenu.js +1 -1
  7. package/OperationBadge/OperationBadge.js +1 -1
  8. package/Search/ClearIcon.js +2 -2
  9. package/Search/Input.js +1 -1
  10. package/Search/Popover.js +1 -1
  11. package/Search/SearchIcon.js +2 -2
  12. package/Sidebar/ApiCallItem.js +1 -1
  13. package/TableOfContent/TableOfContent.js +5 -6
  14. package/globalStyle.d.ts +1 -0
  15. package/globalStyle.js +25 -3
  16. package/mocks/Link.js +4 -1
  17. package/mocks/hooks/usePageData.js +4 -1
  18. package/package.json +1 -1
  19. package/src/CodeBlock/CodeBlock.ts +3 -42
  20. package/src/Markdown/StyledMarkdown.tsx +14 -28
  21. package/src/Markdown/index.ts +0 -1
  22. package/src/Navbar/NavbarMenu.tsx +1 -1
  23. package/src/OperationBadge/OperationBadge.ts +5 -2
  24. package/src/Search/ClearIcon.tsx +12 -13
  25. package/src/Search/Input.tsx +7 -7
  26. package/src/Search/Popover.tsx +2 -2
  27. package/src/Search/SearchIcon.tsx +12 -13
  28. package/src/Sidebar/ApiCallItem.tsx +1 -2
  29. package/src/TableOfContent/TableOfContent.tsx +6 -4
  30. package/src/globalStyle.ts +829 -536
  31. package/src/mocks/Link.tsx +5 -2
  32. package/src/mocks/hooks/usePageData.ts +4 -1
  33. package/src/ui/Typography.tsx +12 -89
  34. package/src/ui/UniversalLink.tsx +3 -8
  35. package/src/utils/ClipboardService.ts +3 -86
  36. package/src/utils/isUrl.ts +4 -4
  37. package/src/utils/theme-helpers.ts +46 -0
  38. package/ui/Typography.d.ts +2 -71
  39. package/ui/Typography.js +15 -93
  40. package/ui/UniversalLink.js +1 -5
  41. package/utils/ClipboardService.d.ts +1 -5
  42. package/utils/ClipboardService.js +2 -73
  43. package/utils/isUrl.d.ts +2 -2
  44. package/utils/isUrl.js +4 -4
  45. package/utils/theme-helpers.d.ts +1 -0
  46. package/utils/theme-helpers.js +42 -2
  47. package/Markdown/CodeSample/CodeSample.d.ts +0 -8
  48. package/Markdown/CodeSample/CodeSample.js +0 -30
  49. package/Markdown/CodeSample/index.d.ts +0 -3
  50. package/Markdown/CodeSample/index.js +0 -19
  51. package/Markdown/CodeSample/styled.d.ts +0 -5
  52. package/Markdown/CodeSample/styled.js +0 -109
  53. package/Markdown/CodeSample/types.d.ts +0 -9
  54. package/Markdown/CodeSample/types.js +0 -2
  55. package/src/Button/Button.stories.tsx +0 -74
  56. package/src/Button/__tests__/Button.test.tsx +0 -42
  57. package/src/Button/__tests__/__snapshots__/Button.test.tsx.snap +0 -274
  58. package/src/CodeBlock/__tests__/CodeBlock.test.tsx +0 -12
  59. package/src/CodeBlock/__tests__/__snapshots__/CodeBlock.test.tsx.snap +0 -140
  60. package/src/CopyButton/CopyButton.stories.tsx +0 -18
  61. package/src/CopyButton/__tests__/CopyButton.test.tsx +0 -35
  62. package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +0 -17
  63. package/src/CopyButton/__tests__/__snapshots__/CopyButton.test.tsx.snap +0 -55
  64. package/src/CopyButton/__tests__/__snapshots__/CopyButtonWrapper.test.tsx.snap +0 -46
  65. package/src/Footer/Footer.stories.tsx +0 -57
  66. package/src/Footer/__tests__/Footer.test.tsx +0 -55
  67. package/src/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +0 -253
  68. package/src/Headings/Headings.stories.tsx +0 -36
  69. package/src/Headings/__tests__/Headings.test.tsx +0 -24
  70. package/src/Headings/__tests__/__snapshots__/Headings.test.tsx.snap +0 -57
  71. package/src/JsonViewer/JsonViewer.stories.tsx +0 -57
  72. package/src/JsonViewer/__tests__/JsonViewer.test.tsx +0 -83
  73. package/src/JsonViewer/__tests__/__snapshots__/JsonViewer.test.tsx.snap +0 -2728
  74. package/src/Layout/__tests__/PageLayout.test.tsx +0 -17
  75. package/src/Layout/__tests__/RootLayout.test.tsx +0 -17
  76. package/src/Layout/__tests__/__snapshots__/PageLayout.test.tsx.snap +0 -38
  77. package/src/Layout/__tests__/__snapshots__/RootLayout.test.tsx.snap +0 -18
  78. package/src/Markdown/CodeSample/CodeSample.tsx +0 -39
  79. package/src/Markdown/CodeSample/index.ts +0 -3
  80. package/src/Markdown/CodeSample/styled.ts +0 -289
  81. package/src/Markdown/CodeSample/types.ts +0 -40
  82. package/src/Navbar/Navbar.stories.tsx +0 -32
  83. package/src/NavbarLogo/NavbarLogo.stories.tsx +0 -20
  84. package/src/NavbarLogo/__tests__/NavbarLogo.test.tsx +0 -47
  85. package/src/NavbarLogo/__tests__/__snapshots__/NavbarLogo.test.tsx.snap +0 -38
  86. package/src/OperationBadge/OperationBadge.stories.tsx +0 -35
  87. package/src/OperationBadge/__tests__/OperationBadge.test.tsx +0 -59
  88. package/src/OperationBadge/__tests__/__snapshots__/OperationBadge.test.tsx.snap +0 -651
  89. package/src/Panel/CodePanel.stories.tsx +0 -26
  90. package/src/Panel/ContentPanel.stories.tsx +0 -26
  91. package/src/Panel/Panel.stories.tsx +0 -56
  92. package/src/Panel/__tests__/CodePanel.test.tsx +0 -26
  93. package/src/Panel/__tests__/ContentPanel.test.tsx +0 -26
  94. package/src/Panel/__tests__/Panel.test.tsx +0 -53
  95. package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +0 -258
  96. package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +0 -278
  97. package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +0 -398
  98. package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +0 -18
  99. package/src/SamplesPanelControls/__tests__/SamplesPanelControls.test.tsx +0 -36
  100. package/src/SamplesPanelControls/__tests__/__snapshots__/SamplesPanelControls.test.tsx.snap +0 -228
  101. package/src/SidebarLogo/SidebarLogo.stories.tsx +0 -21
  102. package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +0 -32
  103. package/src/SidebarLogo/__tests__/__snapshots__/SidebarLogo.test.tsx.snap +0 -62
  104. package/src/SourceCode/SourceCode.stories.tsx +0 -29
  105. package/src/SourceCode/__tests__/SourceCode.test.tsx +0 -48
  106. package/src/SourceCode/__tests__/__snapshots__/SourceCode.test.tsx.snap +0 -786
  107. package/src/TableOfContent/TableOfContent.stories.tsx +0 -39
  108. package/src/Tooltip/Tooltip.stories.tsx +0 -27
  109. package/src/Tooltip/__tests__/Tooltip.test.tsx +0 -41
  110. package/src/Tooltip/__tests__/__snapshots__/Tooltip.test.tsx.snap +0 -83
  111. package/src/Welcome.stories.mdx +0 -7
  112. package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +0 -36
  113. package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +0 -54
  114. package/src/icons/ShelfIcon/__tests__/__snapshots__/ShelfIcon.test.tsx.snap +0 -235
  115. package/src/utils/__tests__/ClipboardService.test.ts +0 -24
  116. package/src/utils/__tests__/__snapshots__/highlight.test.ts.snap +0 -5
  117. package/src/utils/__tests__/__snapshots__/jsonToHtml.test.ts.snap +0 -5
  118. package/src/utils/__tests__/css-variables.test.ts +0 -20
  119. package/src/utils/__tests__/highlight.test.ts +0 -51
  120. package/src/utils/__tests__/jsonToHtml.test.ts +0 -40
  121. package/src/utils/__tests__/media-css.test.ts +0 -20
  122. package/src/utils/__tests__/theme-helpers.test.ts +0 -25
@@ -5,81 +5,10 @@ var ClipboardService = /** @class */ (function () {
5
5
  function ClipboardService() {
6
6
  }
7
7
  ClipboardService.isSupported = function () {
8
- return (typeof document !== 'undefined' &&
9
- !!document.queryCommandSupported &&
10
- document.queryCommandSupported('copy'));
11
- };
12
- ClipboardService.selectElement = function (element) {
13
- if (!element) {
14
- return;
15
- }
16
- var range;
17
- var selection;
18
- if (document.body.createTextRange) {
19
- range = document.body.createTextRange();
20
- range.moveToElementText(element);
21
- range.select();
22
- }
23
- else if (document.createRange && window.getSelection) {
24
- selection = window.getSelection();
25
- range = document.createRange();
26
- range.selectNodeContents(element);
27
- selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
28
- selection === null || selection === void 0 ? void 0 : selection.addRange(range);
29
- }
30
- };
31
- ClipboardService.deselect = function () {
32
- if (document.selection) {
33
- document.selection.empty();
34
- }
35
- else if (window.getSelection) {
36
- var selection = window.getSelection();
37
- if (selection) {
38
- selection.removeAllRanges();
39
- }
40
- }
41
- };
42
- ClipboardService.copySelected = function () {
43
- var result;
44
- try {
45
- result = document.execCommand('copy');
46
- }
47
- catch (err) {
48
- result = false;
49
- }
50
- return result;
51
- };
52
- ClipboardService.copyElement = function (element) {
53
- ClipboardService.selectElement(element);
54
- var res = ClipboardService.copySelected();
55
- if (res) {
56
- ClipboardService.deselect();
57
- }
58
- return res;
8
+ return typeof (navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) !== 'undefined';
59
9
  };
60
10
  ClipboardService.copyCustom = function (text) {
61
- var textArea = document.createElement('textarea');
62
- textArea.style.position = 'fixed';
63
- textArea.style.top = '0';
64
- textArea.style.left = '0';
65
- // Ensure it has a small width and height. Setting to 1px / 1em
66
- // doesn't work as this gives a negative w/h on some browsers.
67
- textArea.style.width = '2em';
68
- textArea.style.height = '2em';
69
- // We don't need padding, reducing the size if it does flash render.
70
- textArea.style.padding = '0';
71
- // Clean up any borders.
72
- textArea.style.border = 'none';
73
- textArea.style.outline = 'none';
74
- textArea.style.boxShadow = 'none';
75
- // Avoid flash of white box if rendered for any reason.
76
- textArea.style.background = 'transparent';
77
- textArea.value = text;
78
- document.body.appendChild(textArea);
79
- textArea.select();
80
- var res = ClipboardService.copySelected();
81
- document.body.removeChild(textArea);
82
- return res;
11
+ return navigator.clipboard.writeText(text);
83
12
  };
84
13
  return ClipboardService;
85
14
  }());
package/utils/isUrl.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Loosely validate a URL `string`.
8
8
  *
9
- * @param {String} string
9
+ * @param {String} input
10
10
  * @return {Boolean}
11
11
  */
12
- export declare function isUrl(string: string): boolean;
12
+ export declare function isUrl(input: unknown): boolean;
package/utils/isUrl.js CHANGED
@@ -12,14 +12,14 @@ var nonLocalhostDomainRE = /^[^\s.]+\.\S{2,}$/;
12
12
  /**
13
13
  * Loosely validate a URL `string`.
14
14
  *
15
- * @param {String} string
15
+ * @param {String} input
16
16
  * @return {Boolean}
17
17
  */
18
- function isUrl(string) {
19
- if (typeof string !== 'string') {
18
+ function isUrl(input) {
19
+ if (typeof input !== 'string') {
20
20
  return false;
21
21
  }
22
- var match = string.match(protocolAndDomainRE);
22
+ var match = input.match(protocolAndDomainRE);
23
23
  if (!match) {
24
24
  return false;
25
25
  }
@@ -1,3 +1,4 @@
1
1
  import type { FlattenSimpleInterpolation } from 'styled-components';
2
2
  export declare function getTypographyCssRulesByComponentName(componentName: string, fallbackName?: string): Record<string, string>;
3
3
  export declare function typography(componentName: string, fallbackName?: string): FlattenSimpleInterpolation;
4
+ export declare function generateCodeBlockTokens(): FlattenSimpleInterpolation | string;
@@ -4,8 +4,38 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  return cooked;
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.typography = exports.getTypographyCssRulesByComponentName = void 0;
7
+ exports.generateCodeBlockTokens = exports.typography = exports.getTypographyCssRulesByComponentName = void 0;
8
8
  var styled_components_1 = require("styled-components");
9
+ var Token;
10
+ (function (Token) {
11
+ Token["Comment"] = "comment";
12
+ Token["Prolog"] = "prolog";
13
+ Token["Doctype"] = "doctype";
14
+ Token["Cdata"] = "cdata";
15
+ Token["Punctuation"] = "punctuation";
16
+ Token["property"] = "property";
17
+ Token["Tag"] = "tag";
18
+ Token["Number"] = "number";
19
+ Token["Constant"] = "constant";
20
+ Token["Symbol"] = "symbol";
21
+ Token["Boolean"] = "boolean";
22
+ Token["Selector"] = "selector";
23
+ Token["String"] = "string";
24
+ Token["Char"] = "char";
25
+ Token["Builtin"] = "builtin";
26
+ Token["Inserted"] = "inserted";
27
+ Token["Operator"] = "operator";
28
+ Token["Entity"] = "entity";
29
+ Token["Url"] = "url";
30
+ Token["Variable"] = "variable";
31
+ Token["Atrule"] = "atrule";
32
+ Token["Keyword"] = "keyword";
33
+ Token["Regex"] = "regex";
34
+ Token["Important"] = "important";
35
+ Token["Bold"] = "bold";
36
+ Token["Italic"] = "italic";
37
+ Token["Deleted"] = "deleted";
38
+ })(Token || (Token = {}));
9
39
  var typographyProperties = Object.entries({
10
40
  fontSize: 'font-size',
11
41
  fontWeight: 'font-weight',
@@ -29,4 +59,14 @@ function typography(componentName, fallbackName) {
29
59
  return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), getTypographyCssRulesByComponentName(componentName, fallbackName));
30
60
  }
31
61
  exports.typography = typography;
32
- var templateObject_1;
62
+ function generateCodeBlockTokens() {
63
+ var res = '';
64
+ for (var _i = 0, _a = Object.values(Token); _i < _a.length; _i++) {
65
+ var token = _a[_i];
66
+ var cssTokenColorVariableName = "--code-block-tokens-".concat(token, "-color");
67
+ res += ".token.".concat(token, " { color: var(").concat(cssTokenColorVariableName, ")}; }\n");
68
+ }
69
+ return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n pre& {\n color: var(--code-block-tokens-default-color);\n }\n ", "\n "], ["\n pre& {\n color: var(--code-block-tokens-default-color);\n }\n ", "\n "])), res);
70
+ }
71
+ exports.generateCodeBlockTokens = generateCodeBlockTokens;
72
+ var templateObject_1, templateObject_2;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- declare type CodeSampleProps = {
3
- language: string;
4
- highlighted: string;
5
- rawContent: string;
6
- };
7
- export declare function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element;
8
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.CodeSample = void 0;
15
- var jsx_runtime_1 = require("react/jsx-runtime");
16
- var react_1 = require("react");
17
- var ClipboardService_1 = require("../../utils/ClipboardService");
18
- var styled_1 = require("../../Markdown/CodeSample/styled");
19
- function CodeSample(_a) {
20
- var rawContent = _a.rawContent, highlighted = _a.highlighted, language = _a.language;
21
- var langClassName = language ? "language-".concat(language) : '';
22
- var _b = (0, react_1.useState)(false), isCopied = _b[0], setIsCopied = _b[1];
23
- var copyCode = function (code) {
24
- ClipboardService_1.ClipboardService.copyCustom(code);
25
- setIsCopied(true);
26
- setTimeout(function () { return setIsCopied(false); }, 1500);
27
- };
28
- return ((0, jsx_runtime_1.jsxs)(styled_1.Wrapper, __assign({ className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" }, { children: [(0, jsx_runtime_1.jsxs)(styled_1.CodeSampleButtonContainer, __assign({ onClick: function () { return copyCode(rawContent); } }, { children: [!isCopied && (0, jsx_runtime_1.jsx)(styled_1.CopyCodeButton, __assign({ title: "Copy the code snippet" }, { children: "Copy" })), isCopied && (0, jsx_runtime_1.jsx)(styled_1.DoneIndicator, { children: "Copied" })] })), (0, jsx_runtime_1.jsx)("pre", __assign({ className: langClassName }, { children: (0, jsx_runtime_1.jsx)("code", { className: langClassName, dangerouslySetInnerHTML: { __html: highlighted } }) }))] })));
29
- }
30
- exports.CodeSample = CodeSample;
@@ -1,3 +0,0 @@
1
- export * from '../../Markdown/CodeSample/CodeSample';
2
- export * from '../../Markdown/CodeSample/styled';
3
- export * from '../../Markdown/CodeSample/types';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("../../Markdown/CodeSample/CodeSample"), exports);
18
- __exportStar(require("../../Markdown/CodeSample/styled"), exports);
19
- __exportStar(require("../../Markdown/CodeSample/types"), exports);
@@ -1,5 +0,0 @@
1
- export declare const CodeButton: import("styled-components").FlattenSimpleInterpolation;
2
- export declare const CodeSampleButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const CopyCodeButton: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export declare const DoneIndicator: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Wrapper = exports.DoneIndicator = exports.CopyCodeButton = exports.CodeSampleButtonContainer = exports.CodeButton = void 0;
31
- var polished_1 = require("polished");
32
- var styled_components_1 = __importStar(require("styled-components"));
33
- var Typography_1 = require("../../ui/Typography");
34
- function genTokens(tokens) {
35
- var _a;
36
- if (!tokens) {
37
- return '';
38
- }
39
- var res = '';
40
- for (var _i = 0, _b = Object.keys(tokens); _i < _b.length; _i++) {
41
- var token = _b[_i];
42
- if (token !== 'default') {
43
- res += ".token.".concat(token, " { color: ").concat((_a = tokens[token]) === null || _a === void 0 ? void 0 : _a.color, "; }\n");
44
- }
45
- }
46
- if (tokens.default) {
47
- return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n pre& {\n ", "\n }\n ", "\n "], ["\n pre& {\n ", "\n }\n ", "\n "])), (0, Typography_1.typography)(tokens.default), res);
48
- }
49
- return res;
50
- }
51
- var getCodeBlockBackgroundColor = function (theme) {
52
- return Array.isArray(theme.codeBlock.backgroundColor)
53
- ? theme.codeBlock.backgroundColor[0]
54
- : theme.codeBlock.backgroundColor;
55
- };
56
- exports.CodeButton = (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0 5px;\n border-radius: 4px;\n"], ["\n padding: 0 5px;\n border-radius: 4px;\n"])));
57
- exports.CodeSampleButtonContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: 12px;\n right: 5px;\n"], ["\n position: absolute;\n top: 12px;\n right: 5px;\n"])));
58
- exports.CopyCodeButton = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n display: none;\n\n &:hover {\n cursor: pointer;\n }\n"], ["\n ", "\n display: none;\n\n &:hover {\n cursor: pointer;\n }\n"])), exports.CodeButton);
59
- exports.DoneIndicator = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n cursor: default;\n"], ["\n ", "\n cursor: default;\n"])), exports.CodeButton);
60
- var lightStyleCodeButton = (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ",\n ", " {\n color: ", ";\n }\n\n ", ":hover {\n color: ", ";\n outline: 1px solid ", ";\n }\n"], ["\n ", ",\n ", " {\n color: ", ";\n }\n\n ", ":hover {\n color: ", ";\n outline: 1px solid ", ";\n }\n"])), exports.CopyCodeButton, exports.DoneIndicator, function (_a) {
61
- var theme = _a.theme;
62
- return theme.codeBlock.copyButton.visibleText;
63
- }, exports.CopyCodeButton, function (_a) {
64
- var theme = _a.theme;
65
- return theme.codeBlock.copyButton.visibleText;
66
- }, function (_a) {
67
- var theme = _a.theme;
68
- return theme.codeBlock.copyButton.visibleText;
69
- });
70
- var darkStyleCodeButton = (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", ",\n ", " {\n color: ", ";\n }\n\n ", ":hover {\n color: white;\n color: ", ";\n background-color: ", ";\n }\n"], ["\n ", ",\n ", " {\n color: ", ";\n }\n\n ", ":hover {\n color: white;\n color: ", ";\n background-color: ", ";\n }\n"])), exports.CopyCodeButton, exports.DoneIndicator, function (_a) {
71
- var theme = _a.theme;
72
- return theme.codeBlock.copyButton.visibleText;
73
- }, exports.CopyCodeButton, function (_a) {
74
- var theme = _a.theme;
75
- return theme.codeBlock.copyButton.contrastText;
76
- }, function (_a) {
77
- var theme = _a.theme;
78
- return theme.codeBlock.copyButton.background;
79
- });
80
- var lightStyleTokens = (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: #999988;\n font-style: italic;\n }\n\n .token.namespace {\n opacity: 0.7;\n }\n\n .token.string,\n .token.attr-value {\n color: #e3116c;\n }\n .token.punctuation,\n .token.operator {\n color: #393a34; /* no highlight */\n }\n\n .token.entity,\n .token.url,\n .token.symbol,\n .token.number,\n .token.boolean,\n .token.variable,\n .token.constant,\n .token.property,\n .token.regex,\n .token.inserted {\n color: #36acaa;\n }\n\n .token.atrule,\n .token.keyword,\n .token.attr-name,\n .language-autohotkey .token.selector {\n color: #00a4db;\n }\n\n .token.function,\n .token.deleted,\n .language-autohotkey .token.tag {\n color: #9a050f;\n }\n\n .token.tag,\n .token.selector,\n .language-autohotkey .token.keyword {\n color: #00009f;\n }\n"], ["\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: #999988;\n font-style: italic;\n }\n\n .token.namespace {\n opacity: 0.7;\n }\n\n .token.string,\n .token.attr-value {\n color: #e3116c;\n }\n .token.punctuation,\n .token.operator {\n color: #393a34; /* no highlight */\n }\n\n .token.entity,\n .token.url,\n .token.symbol,\n .token.number,\n .token.boolean,\n .token.variable,\n .token.constant,\n .token.property,\n .token.regex,\n .token.inserted {\n color: #36acaa;\n }\n\n .token.atrule,\n .token.keyword,\n .token.attr-name,\n .language-autohotkey .token.selector {\n color: #00a4db;\n }\n\n .token.function,\n .token.deleted,\n .language-autohotkey .token.tag {\n color: #9a050f;\n }\n\n .token.tag,\n .token.selector,\n .language-autohotkey .token.keyword {\n color: #00009f;\n }\n"])));
81
- var darkStyleTokens = (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: hsl(30, 20%, 50%);\n }\n\n .token.property,\n .token.tag,\n .token.number,\n .token.constant,\n .token.symbol {\n color: #62bff9;\n }\n .token.boolean {\n color: firebrick;\n }\n .token.selector,\n .token.attr-name,\n .token.string,\n .token.char,\n .token.builtin,\n .token.inserted {\n color: #a0fbaa;\n & + a,\n & + a:visited {\n color: #4ed2ba;\n text-decoration: underline;\n }\n }\n .token.operator,\n .token.entity,\n .token.url,\n .token.variable {\n color: hsl(40, 90%, 60%);\n }\n .token.atrule,\n .token.attr-value,\n .token.keyword {\n color: hsl(350, 40%, 70%);\n }\n .token.regex,\n .token.important {\n color: #e90;\n }\n\n .token.deleted {\n color: red;\n }\n"], ["\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: hsl(30, 20%, 50%);\n }\n\n .token.property,\n .token.tag,\n .token.number,\n .token.constant,\n .token.symbol {\n color: #62bff9;\n }\n .token.boolean {\n color: firebrick;\n }\n .token.selector,\n .token.attr-name,\n .token.string,\n .token.char,\n .token.builtin,\n .token.inserted {\n color: #a0fbaa;\n & + a,\n & + a:visited {\n color: #4ed2ba;\n text-decoration: underline;\n }\n }\n .token.operator,\n .token.entity,\n .token.url,\n .token.variable {\n color: hsl(40, 90%, 60%);\n }\n .token.atrule,\n .token.attr-value,\n .token.keyword {\n color: hsl(350, 40%, 70%);\n }\n .token.regex,\n .token.important {\n color: #e90;\n }\n\n .token.deleted {\n color: red;\n }\n"])));
82
- exports.Wrapper = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: auto;\n border-radius: 4px;\n position: relative;\n\n ", "\n\n &:hover {\n ", " ", " {\n display: block;\n }\n }\n\n pre {\n white-space: ", ";\n color: white;\n padding: 12px 14px 15px 14px;\n overflow-x: auto;\n line-height: normal;\n border-radius: 4px;\n\n font-family: ", ";\n background-color: ", ";\n\n code {\n background-color: transparent;\n border: 0;\n padding: 0;\n\n color: ", ";\n\n &:before,\n &:after {\n content: none;\n }\n }\n }\n\n pre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n border: 0;\n border-radius: ", ";\n }\n\n code[class='language-text'] {\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n\n code[class*='language-'],\n pre[class*='language-'] {\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n word-wrap: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n\n .token.important,\n .token.bold {\n font-weight: bold;\n }\n .token.italic {\n font-style: italic;\n }\n .token.entity {\n cursor: help;\n }\n .token.punctuation {\n opacity: 0.7;\n }\n .namespace {\n opacity: 0.7;\n }\n\n ", "\n ", "\n }\n"], ["\n overflow: auto;\n border-radius: 4px;\n position: relative;\n\n ", "\n\n &:hover {\n ", " ", " {\n display: block;\n }\n }\n\n pre {\n white-space: ", ";\n color: white;\n padding: 12px 14px 15px 14px;\n overflow-x: auto;\n line-height: normal;\n border-radius: 4px;\n\n font-family: ", ";\n background-color: ", ";\n\n code {\n background-color: transparent;\n border: 0;\n padding: 0;\n\n color: ", ";\n\n &:before,\n &:after {\n content: none;\n }\n }\n }\n\n pre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n border: 0;\n border-radius: ", ";\n }\n\n code[class='language-text'] {\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n\n code[class*='language-'],\n pre[class*='language-'] {\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n word-wrap: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n\n .token.important,\n .token.bold {\n font-weight: bold;\n }\n .token.italic {\n font-style: italic;\n }\n .token.entity {\n cursor: help;\n }\n .token.punctuation {\n opacity: 0.7;\n }\n .namespace {\n opacity: 0.7;\n }\n\n ", "\n ", "\n }\n"])), function (_a) {
83
- var theme = _a.theme;
84
- return (0, polished_1.getLuminance)(getCodeBlockBackgroundColor(theme)) < 0.25
85
- ? darkStyleCodeButton
86
- : lightStyleCodeButton;
87
- }, exports.CodeSampleButtonContainer, exports.CopyCodeButton, function (_a) {
88
- var theme = _a.theme;
89
- return (theme.typography.code.wrap ? 'pre-wrap' : 'pre');
90
- }, function (_a) {
91
- var theme = _a.theme;
92
- return theme.typography.code.fontFamily;
93
- }, function (_a) {
94
- var theme = _a.theme;
95
- return theme.codeBlock.backgroundColor;
96
- }, function (_a) {
97
- var theme = _a.theme;
98
- return (0, polished_1.getLuminance)(theme.codeBlock.backgroundColor) < 0.5 ? 'white' : '#393A34';
99
- }, function (_a) {
100
- var theme = _a.theme;
101
- return theme.shape.borderRadius;
102
- }, function (_a) {
103
- var theme = _a.theme;
104
- return (0, polished_1.getLuminance)(getCodeBlockBackgroundColor(theme)) < 0.5 ? darkStyleTokens : lightStyleTokens;
105
- }, function (_a) {
106
- var theme = _a.theme;
107
- return genTokens(theme.codeBlock.tokens);
108
- });
109
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -1,9 +0,0 @@
1
- import { ITypography } from '../../ui/Typography';
2
- export declare type Token = 'comment' | 'prolog' | 'doctype' | 'cdata' | 'punctuation' | 'property' | 'tag' | 'number' | 'constant' | 'symbol' | 'boolean' | 'selector' | 'string' | 'char' | 'builtin' | 'inserted' | 'operator' | 'entity' | 'url' | 'variable' | 'atrule' | 'keyword' | 'regex' | 'important' | 'important' | 'bold' | 'italic' | 'entity' | 'deleted';
3
- export declare type Tokens = {
4
- [P in Token]?: {
5
- color: string;
6
- };
7
- } & {
8
- default?: ITypography;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
-
4
- import { Button } from '@theme/Button';
5
-
6
- export default {
7
- title: 'Components/Button',
8
- component: Button,
9
- argTypes: {
10
- size: {
11
- control: 'radio',
12
- options: ['small', 'medium', 'large', 'xlarge'],
13
- },
14
- color: {
15
- control: 'radio',
16
- options: ['primary', 'secondary', 'default'],
17
- },
18
- },
19
- } as ComponentMeta<typeof Button>;
20
-
21
- const Template: ComponentStory<typeof Button> = (args) => <Button {...args}>Click</Button>;
22
-
23
- export const Primary = Template.bind({});
24
- Primary.args = {
25
- color: 'primary',
26
- disabled: false,
27
- blinking: false,
28
- fullWidth: false,
29
- variant: 'contained',
30
- size: 'small',
31
- extraClass: 'test',
32
- };
33
-
34
- export const Secondary = Template.bind({});
35
- Secondary.args = {
36
- color: 'secondary',
37
- disabled: false,
38
- blinking: false,
39
- fullWidth: false,
40
- variant: 'contained',
41
- size: 'small',
42
- extraClass: 'test',
43
- };
44
-
45
- export const Outlined = Template.bind({});
46
- Outlined.args = {
47
- color: 'primary',
48
- disabled: false,
49
- blinking: false,
50
- fullWidth: false,
51
- variant: 'outlined',
52
- size: 'small',
53
- extraClass: 'test',
54
- };
55
-
56
- export const Disabled = Template.bind({});
57
- Disabled.args = {
58
- color: 'secondary',
59
- disabled: true,
60
- blinking: false,
61
- fullWidth: false,
62
- variant: 'contained',
63
- size: 'small',
64
- };
65
-
66
- export const Large = Template.bind({});
67
- Large.args = {
68
- color: 'default',
69
- disabled: false,
70
- blinking: false,
71
- fullWidth: false,
72
- variant: 'contained',
73
- size: 'large',
74
- };
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
-
4
- import { Button } from '@theme/Button';
5
-
6
- describe('Button', () => {
7
- it('renders', () => {
8
- const { container } = render(<Button>Test</Button>);
9
-
10
- expect(container.firstChild).toMatchSnapshot();
11
- });
12
-
13
- it('renders blinking', () => {
14
- const { container } = render(<Button blinking>Test</Button>);
15
-
16
- expect(container.firstChild).toMatchSnapshot();
17
- });
18
-
19
- it('renders with extra class', () => {
20
- const { container } = render(<Button extraClass="quick-fox">Test</Button>);
21
-
22
- expect(container.firstChild).toHaveClass('quick-fox');
23
- });
24
-
25
- it('renders disabled', () => {
26
- const { container } = render(<Button disabled>Test</Button>);
27
-
28
- expect(container.firstChild).toMatchSnapshot();
29
- });
30
-
31
- it('renders full width', () => {
32
- const { container } = render(<Button fullWidth>Test</Button>);
33
-
34
- expect(container.firstChild).toMatchSnapshot();
35
- });
36
-
37
- it('renders outlined', () => {
38
- const { container } = render(<Button variant="outlined">Test</Button>);
39
-
40
- expect(container.firstChild).toMatchSnapshot();
41
- });
42
- });