@redocly/theme 0.1.1 → 0.1.4

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 (203) hide show
  1. package/Button/Button.d.ts +17 -0
  2. package/Button/Button.js +34 -0
  3. package/Button/index.d.ts +1 -0
  4. package/Button/index.js +1 -0
  5. package/CodeBlock/CodeBlock.d.ts +1 -0
  6. package/CodeBlock/CodeBlock.js +7 -0
  7. package/CodeBlock/index.d.ts +1 -0
  8. package/CodeBlock/index.js +1 -0
  9. package/CopyButton/CopyButton.d.ts +6 -0
  10. package/CopyButton/CopyButton.js +69 -0
  11. package/CopyButton/CopyButtonWrapper.d.ts +9 -0
  12. package/CopyButton/CopyButtonWrapper.js +37 -0
  13. package/CopyButton/index.d.ts +2 -0
  14. package/CopyButton/index.js +2 -0
  15. package/Headings/Headings.d.ts +3 -0
  16. package/Headings/Headings.js +10 -0
  17. package/Headings/index.d.ts +1 -0
  18. package/Headings/index.js +1 -0
  19. package/JsonViewer/JsonViewer.d.ts +10 -0
  20. package/JsonViewer/JsonViewer.js +92 -0
  21. package/JsonViewer/index.d.ts +1 -0
  22. package/JsonViewer/index.js +1 -0
  23. package/JsonViewer/styled.d.ts +1 -0
  24. package/JsonViewer/styled.js +7 -0
  25. package/Logo/Logo.d.ts +10 -0
  26. package/Logo/Logo.js +25 -0
  27. package/Navbar/Navbar.d.ts +9 -0
  28. package/Navbar/Navbar.js +23 -0
  29. package/Navbar/NavbarItem.d.ts +40 -0
  30. package/Navbar/NavbarItem.js +43 -0
  31. package/Navbar/NavbarMenu.d.ts +4 -0
  32. package/Navbar/NavbarMenu.js +29 -0
  33. package/Panel/CodePanel.d.ts +1 -0
  34. package/Panel/CodePanel.js +13 -0
  35. package/Panel/ContentPanel.d.ts +1 -0
  36. package/Panel/ContentPanel.js +12 -0
  37. package/Panel/DarkHeader.d.ts +1 -0
  38. package/Panel/DarkHeader.js +7 -0
  39. package/Panel/Panel.d.ts +2 -0
  40. package/Panel/Panel.js +10 -0
  41. package/Panel/PanelBody.d.ts +6 -0
  42. package/Panel/PanelBody.js +15 -0
  43. package/Panel/PanelComponent.d.ts +10 -0
  44. package/Panel/PanelComponent.js +40 -0
  45. package/Panel/PanelHeader.d.ts +7 -0
  46. package/Panel/PanelHeader.js +16 -0
  47. package/Panel/PanelHeaderTitle.d.ts +1 -0
  48. package/Panel/PanelHeaderTitle.js +7 -0
  49. package/Panel/index.d.ts +7 -0
  50. package/Panel/index.js +7 -0
  51. package/SamplesPanelControls/SamplesPanelControls.d.ts +4 -0
  52. package/SamplesPanelControls/SamplesPanelControls.js +17 -0
  53. package/SamplesPanelControls/index.d.ts +1 -0
  54. package/SamplesPanelControls/index.js +1 -0
  55. package/SidebarLogo/SidebarLogo.d.ts +9 -0
  56. package/SidebarLogo/SidebarLogo.js +29 -0
  57. package/SidebarLogo/index.d.ts +1 -0
  58. package/SidebarLogo/index.js +1 -0
  59. package/SourceCode/SourceCode.d.ts +24 -0
  60. package/SourceCode/SourceCode.js +31 -0
  61. package/SourceCode/index.d.ts +1 -0
  62. package/SourceCode/index.js +1 -0
  63. package/Tooltip/Tooltip.d.ts +12 -0
  64. package/Tooltip/Tooltip.js +57 -0
  65. package/Tooltip/index.d.ts +1 -0
  66. package/Tooltip/index.js +1 -0
  67. package/globalStyle.d.ts +1 -0
  68. package/globalStyle.js +7 -0
  69. package/hooks/index.d.ts +3 -0
  70. package/hooks/index.js +3 -0
  71. package/hooks/useControl.d.ts +6 -0
  72. package/hooks/useControl.js +12 -0
  73. package/hooks/useMount.d.ts +1 -0
  74. package/hooks/useMount.js +7 -0
  75. package/hooks/useUnmount.d.ts +1 -0
  76. package/hooks/useUnmount.js +9 -0
  77. package/icons/ShelfIcon/ShelfIcon.d.ts +10 -0
  78. package/icons/ShelfIcon/ShelfIcon.js +33 -0
  79. package/icons/ShelfIcon/index.d.ts +2 -0
  80. package/icons/ShelfIcon/index.js +1 -0
  81. package/icons/index.d.ts +1 -0
  82. package/icons/index.js +1 -0
  83. package/index.d.ts +14 -0
  84. package/mocks/Link.d.ts +2 -0
  85. package/mocks/Link.js +17 -0
  86. package/mocks/utils.d.ts +1 -0
  87. package/mocks/utils.js +3 -0
  88. package/package.json +2 -78
  89. package/src/Button/Button.stories.tsx +74 -0
  90. package/src/Button/Button.tsx +122 -0
  91. package/src/Button/__tests__/Button.test.tsx +42 -0
  92. package/src/Button/__tests__/__snapshots__/Button.test.tsx.snap +274 -0
  93. package/src/Button/index.ts +1 -0
  94. package/src/CodeBlock/CodeBlock.ts +125 -0
  95. package/src/CodeBlock/__tests__/CodeBlock.test.tsx +12 -0
  96. package/src/CodeBlock/__tests__/__snapshots__/CodeBlock.test.tsx.snap +140 -0
  97. package/src/CodeBlock/index.ts +1 -0
  98. package/src/CopyButton/CopyButton.stories.tsx +18 -0
  99. package/src/CopyButton/CopyButton.tsx +26 -0
  100. package/src/CopyButton/CopyButtonWrapper.tsx +52 -0
  101. package/src/CopyButton/__tests__/CopyButton.test.tsx +35 -0
  102. package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +16 -0
  103. package/src/CopyButton/__tests__/__snapshots__/CopyButton.test.tsx.snap +55 -0
  104. package/src/CopyButton/__tests__/__snapshots__/CopyButtonWrapper.test.tsx.snap +46 -0
  105. package/src/CopyButton/index.ts +2 -0
  106. package/src/Headings/Headings.stories.tsx +36 -0
  107. package/src/Headings/Headings.ts +23 -0
  108. package/src/Headings/__tests__/Headings.test.tsx +24 -0
  109. package/src/Headings/__tests__/__snapshots__/Headings.test.tsx.snap +57 -0
  110. package/src/Headings/index.ts +1 -0
  111. package/src/Introduction.stories.mdx +7 -0
  112. package/src/JsonViewer/JsonViewer.stories.tsx +57 -0
  113. package/src/JsonViewer/JsonViewer.tsx +130 -0
  114. package/src/JsonViewer/__tests__/JsonViewer.test.tsx +82 -0
  115. package/src/JsonViewer/__tests__/__snapshots__/JsonViewer.test.tsx.snap +2728 -0
  116. package/src/JsonViewer/index.ts +1 -0
  117. package/src/JsonViewer/styled.ts +103 -0
  118. package/src/Logo/Logo.tsx +23 -0
  119. package/src/Navbar/Navbar.stories.tsx +38 -0
  120. package/src/Navbar/Navbar.tsx +60 -0
  121. package/src/Navbar/NavbarItem.tsx +90 -0
  122. package/src/Navbar/NavbarMenu.tsx +29 -0
  123. package/src/Panel/CodePanel.stories.tsx +27 -0
  124. package/src/Panel/CodePanel.ts +31 -0
  125. package/src/Panel/ContentPanel.stories.tsx +27 -0
  126. package/src/Panel/ContentPanel.ts +43 -0
  127. package/src/Panel/DarkHeader.ts +8 -0
  128. package/src/Panel/Panel.stories.tsx +58 -0
  129. package/src/Panel/Panel.ts +18 -0
  130. package/src/Panel/PanelBody.ts +30 -0
  131. package/src/Panel/PanelComponent.tsx +73 -0
  132. package/src/Panel/PanelHeader.ts +25 -0
  133. package/src/Panel/PanelHeaderTitle.ts +11 -0
  134. package/src/Panel/__tests__/CodePanel.test.tsx +26 -0
  135. package/src/Panel/__tests__/ContentPanel.test.tsx +26 -0
  136. package/src/Panel/__tests__/Panel.test.tsx +54 -0
  137. package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +258 -0
  138. package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +278 -0
  139. package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +398 -0
  140. package/src/Panel/index.ts +7 -0
  141. package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +18 -0
  142. package/src/SamplesPanelControls/SamplesPanelControls.ts +70 -0
  143. package/src/SamplesPanelControls/__tests__/SamplesPanelControls.test.tsx +36 -0
  144. package/src/SamplesPanelControls/__tests__/__snapshots__/SamplesPanelControls.test.tsx.snap +228 -0
  145. package/src/SamplesPanelControls/index.ts +1 -0
  146. package/src/SidebarLogo/SidebarLogo.stories.tsx +21 -0
  147. package/src/SidebarLogo/SidebarLogo.tsx +47 -0
  148. package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +32 -0
  149. package/src/SidebarLogo/__tests__/__snapshots__/SidebarLogo.test.tsx.snap +62 -0
  150. package/src/SidebarLogo/index.ts +1 -0
  151. package/src/SourceCode/SourceCode.stories.tsx +29 -0
  152. package/src/SourceCode/SourceCode.tsx +67 -0
  153. package/src/SourceCode/__tests__/SourceCode.test.tsx +47 -0
  154. package/src/SourceCode/__tests__/__snapshots__/SourceCode.test.tsx.snap +786 -0
  155. package/src/SourceCode/index.ts +1 -0
  156. package/src/Tooltip/Tooltip.stories.tsx +27 -0
  157. package/src/Tooltip/Tooltip.tsx +171 -0
  158. package/src/Tooltip/__tests__/Tooltip.test.tsx +41 -0
  159. package/src/Tooltip/__tests__/__snapshots__/Tooltip.test.tsx.snap +83 -0
  160. package/src/Tooltip/index.ts +1 -0
  161. package/src/globalStyle.ts +512 -0
  162. package/src/hooks/index.ts +3 -0
  163. package/src/hooks/useControl.ts +20 -0
  164. package/src/hooks/useMount.ts +8 -0
  165. package/src/hooks/useUnmount.ts +10 -0
  166. package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +36 -0
  167. package/src/icons/ShelfIcon/ShelfIcon.tsx +45 -0
  168. package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +54 -0
  169. package/src/icons/ShelfIcon/__tests__/__snapshots__/ShelfIcon.test.tsx.snap +235 -0
  170. package/src/icons/ShelfIcon/index.ts +2 -0
  171. package/src/icons/index.ts +1 -0
  172. package/src/index.ts +14 -0
  173. package/src/mocks/Link.tsx +7 -0
  174. package/src/mocks/utils.ts +3 -0
  175. package/src/utils/ClipboardService.ts +92 -0
  176. package/src/utils/__tests__/ClipboardService.test.ts +24 -0
  177. package/src/utils/__tests__/__snapshots__/highlight.test.ts.snap +5 -0
  178. package/src/utils/__tests__/__snapshots__/jsonToHtml.test.ts.snap +5 -0
  179. package/src/utils/__tests__/css-variables.test.ts +20 -0
  180. package/src/utils/__tests__/highlight.test.ts +51 -0
  181. package/src/utils/__tests__/jsonToHtml.test.ts +40 -0
  182. package/src/utils/__tests__/media-css.test.ts +20 -0
  183. package/src/utils/__tests__/theme-helpers.test.ts +25 -0
  184. package/src/utils/css-variables.ts +2 -0
  185. package/src/utils/highlight.ts +81 -0
  186. package/src/utils/index.ts +6 -0
  187. package/src/utils/jsonToHtml.ts +122 -0
  188. package/src/utils/media-css.ts +16 -0
  189. package/src/utils/theme-helpers.ts +34 -0
  190. package/utils/ClipboardService.d.ts +8 -0
  191. package/utils/ClipboardService.js +83 -0
  192. package/utils/css-variables.d.ts +1 -0
  193. package/utils/css-variables.js +4 -0
  194. package/utils/highlight.d.ts +32 -0
  195. package/utils/highlight.js +65 -0
  196. package/utils/index.d.ts +6 -0
  197. package/utils/index.js +6 -0
  198. package/utils/jsonToHtml.d.ts +1 -0
  199. package/utils/jsonToHtml.js +116 -0
  200. package/utils/media-css.d.ts +12 -0
  201. package/utils/media-css.js +9 -0
  202. package/utils/theme-helpers.d.ts +3 -0
  203. package/utils/theme-helpers.js +27 -0
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from './Button';
2
+ export * from './CopyButton';
3
+ export * from './JsonViewer';
4
+ export * from './Headings';
5
+ export * from './SidebarLogo';
6
+ export * from './CodeBlock';
7
+ export * from './SamplesPanelControls';
8
+ export * from './Tooltip';
9
+ export * from './SourceCode';
10
+ export * from './Panel';
11
+ export * from './icons';
12
+ export * from './hooks';
13
+ export * from './utils';
14
+ export * from './globalStyle';
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Link(props: any): JSX.Element;
package/mocks/Link.js ADDED
@@ -0,0 +1,17 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ // TODO: use real typings here
14
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
15
+ export function Link(props) {
16
+ return _jsx("a", __assign({ href: props.to }, props));
17
+ }
@@ -0,0 +1 @@
1
+ export declare function withPathPrefix(link: string): string;
package/mocks/utils.js ADDED
@@ -0,0 +1,3 @@
1
+ export function withPathPrefix(link) {
2
+ return link;
3
+ }
package/package.json CHANGED
@@ -1,90 +1,14 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Shared UI components",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
- "main": "index.js",
8
7
  "typings": "index.d.ts",
9
- "files": [
10
- "lib"
11
- ],
12
- "scripts": {
13
- "start": "npm run storybook",
14
- "storybook": "start-storybook -p 6006",
15
- "build-storybook": "build-storybook",
16
- "clean": "rm -rf lib",
17
- "compile": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
18
- "build:copy": " cp -R src package.json .npmignore lib/",
19
- "build": "npm run clean && npm run compile && npm run build:copy",
20
- "build:watch": "npm run build && tsc --watch -p tsconfig.build.json & tsc-alias -w -p tsconfig.build.json",
21
- "deploy": "npm publish lib",
22
- "lint": "eslint . --ext .ts,.tsx --cache",
23
- "lint:fix": "eslint . --ext .ts,.tsx --fix",
24
- "prettier-base": "prettier \"**/*.{json,js,jsx,ts,tsx,yml,yaml,html,md}\"",
25
- "prettier": "npm run prettier-base -- --write",
26
- "prettier:check": "npm run prettier-base -- --check",
27
- "ts:check": "tsc --noEmit --skipLibCheck",
28
- "test": "jest",
29
- "test:watch": "jest --watch",
30
- "test:coverage": "jest --coverage",
31
- "chromatic": "chromatic --exit-zero-on-changes"
32
- },
33
8
  "peerDependencies": {
34
9
  "prismjs": "^1.28.0",
35
10
  "react": "^17.0.2",
36
11
  "react-dom": "^17.0.2",
37
12
  "styled-components": "^5.3.1"
38
- },
39
- "devDependencies": {
40
- "@storybook/addon-actions": "^6.4.22",
41
- "@storybook/addon-essentials": "^6.4.22",
42
- "@storybook/addon-interactions": "^6.4.22",
43
- "@storybook/addon-links": "^6.4.22",
44
- "@storybook/builder-webpack5": "^6.4.22",
45
- "@storybook/core-common": "^6.4.22",
46
- "@storybook/manager-webpack5": "^6.4.22",
47
- "@storybook/node-logger": "^6.4.22",
48
- "@storybook/preset-create-react-app": "^4.1.0",
49
- "@storybook/react": "^6.4.22",
50
- "@storybook/testing-library": "^0.0.11",
51
- "@testing-library/jest-dom": "^5.16.4",
52
- "@testing-library/react": "^12.1.4",
53
- "@testing-library/user-event": "^13.5.0",
54
- "@types/jest": "^27.4.1",
55
- "@types/node": "^16.11.26",
56
- "@types/prismjs": "^1.26.0",
57
- "@types/react": "^17.0.43",
58
- "@types/react-dom": "^17.0.14",
59
- "@types/styled-components": "^5.1.25",
60
- "@typescript-eslint/eslint-plugin": "^5.21.0",
61
- "@typescript-eslint/parser": "^5.22.0",
62
- "chromatic": "^6.5.4",
63
- "esbuild": "^0.14.38",
64
- "eslint": "^8.13.0",
65
- "eslint-config-prettier": "^8.5.0",
66
- "eslint-import-resolver-typescript": "^2.7.1",
67
- "eslint-plugin-import": "^2.26.0",
68
- "eslint-plugin-jest": "^26.1.4",
69
- "eslint-plugin-react": "^7.29.4",
70
- "eslint-plugin-react-hooks": "^4.5.0",
71
- "eslint-plugin-storybook": "^0.5.11",
72
- "husky": "^7.0.4",
73
- "jest": "^27.5.1",
74
- "jest-styled-components": "^7.0.8",
75
- "lint-staged": "^12.4.1",
76
- "prettier": "2.6.2",
77
- "react": "^17.0.2",
78
- "react-dom": "^17.0.2",
79
- "react-refresh": "^0.13.0",
80
- "react-scripts": "5.0.1",
81
- "styled-components": "^5.3.5",
82
- "ts-jest": "^27.1.4",
83
- "tsc-alias": "^1.6.7",
84
- "typescript": "^4.6.3",
85
- "webpack": "^5.72.0"
86
- },
87
- "lint-staged": {
88
- "**/*": "prettier --write --ignore-unknown"
89
13
  }
90
- }
14
+ }
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+
4
+ import { Button } from './Button';
5
+
6
+ export default {
7
+ title: '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
+ };
@@ -0,0 +1,122 @@
1
+ import styled, { css, FlattenSimpleInterpolation, keyframes, Keyframes } from 'styled-components';
2
+
3
+ export type ButtonSize = 'small' | 'medium' | 'large' | 'xlarge' | string;
4
+ export type ButtonColor = 'primary' | 'secondary' | 'default' | string;
5
+ export type ButtonVariant = 'outlined' | 'contained';
6
+
7
+ export interface ButtonProps {
8
+ color?: ButtonColor;
9
+ disabled?: boolean;
10
+ blinking?: boolean;
11
+ fullWidth?: boolean;
12
+ variant?: ButtonVariant;
13
+ size?: ButtonSize;
14
+ extraClass?: string;
15
+ }
16
+
17
+ const getBlink = (): Keyframes => keyframes`
18
+ 0% {
19
+ color: var(--button-color);
20
+ background-color: var(--button-active-background-color);
21
+ }
22
+
23
+ 50% {
24
+ background-color: var(--button-background-color);
25
+ }
26
+
27
+ 100% {
28
+ color: var(--button-color);
29
+ background-color: var(--button-active-background-color);
30
+ }
31
+ `;
32
+
33
+ const getSize = (size: ButtonSize = 'medium'): FlattenSimpleInterpolation => css`
34
+ font-size: var(--button-${size}-font-size);
35
+ padding: var(--button-${size}-padding);
36
+ min-width: var(--button-${size}-min-width);
37
+ `;
38
+
39
+ export const baseButtonStyles = css`
40
+ outline: none;
41
+ border: none;
42
+ border-radius: var(--button-border-radius);
43
+ font-weight: var(--button-font-weight);
44
+ font-size: 14px;
45
+ padding: 2px 20px;
46
+ cursor: pointer;
47
+ transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
48
+ line-height: 1;
49
+
50
+ font-family: var(--button-font-family);
51
+ box-shadow: var(--button-box-shadow);
52
+
53
+ &:hover {
54
+ box-shadow: var(--button-active-box-shadow);
55
+ }
56
+
57
+ &:active {
58
+ box-shadow: var(--button-active-box-shadow);
59
+ }
60
+ `;
61
+
62
+ export const Button = styled.button.attrs(({ color = 'default', extraClass }: ButtonProps) => ({
63
+ className: `button-color-${color}${extraClass ? ` ${extraClass}` : ''}`,
64
+ }))<ButtonProps>`
65
+ text-decoration: none;
66
+ text-align: center;
67
+
68
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
69
+
70
+ ${baseButtonStyles}
71
+
72
+ ${({ variant }) =>
73
+ variant === 'outlined'
74
+ ? css`
75
+ color: var(--button-background-color);
76
+ border: 2px solid var(--button-background-color);
77
+ background-color: transparent;
78
+ &:hover {
79
+ border: 2px solid var(--button-active-background-color);
80
+ background-color: transparent;
81
+ }
82
+
83
+ &:active {
84
+ border: 2px solid var(--button-outlined-active-border-color);
85
+ }
86
+ `
87
+ : css`
88
+ color: var(--button-color);
89
+ background-color: var(--button-background-color);
90
+ &:hover {
91
+ background-color: var(--button-hover-background-color);
92
+ }
93
+
94
+ &:active {
95
+ background-color: var(--button-active-background-color);
96
+ }
97
+ `};
98
+
99
+ ${({ size }) => getSize(size)}
100
+
101
+ & + & {
102
+ margin-left: 0.85em;
103
+ }
104
+
105
+ ${({ blinking }) =>
106
+ blinking &&
107
+ css`
108
+ pointer-events: none;
109
+ animation: ${getBlink()} 1.2s infinite;
110
+ `}
111
+
112
+ ${({ disabled }) =>
113
+ disabled &&
114
+ css`
115
+ &,
116
+ &:hover {
117
+ cursor: default;
118
+ color: #999999;
119
+ pointer-events: none;
120
+ }
121
+ `}
122
+ `;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+
4
+ import { Button } from '../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
+ });
@@ -0,0 +1,274 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Button renders 1`] = `
4
+ .c1 {
5
+ -webkit-text-decoration: none;
6
+ text-decoration: none;
7
+ text-align: center;
8
+ width: auto;
9
+ outline: none;
10
+ border: none;
11
+ border-radius: var(--button-border-radius);
12
+ font-weight: var(--button-font-weight);
13
+ font-size: 14px;
14
+ padding: 2px 20px;
15
+ cursor: pointer;
16
+ -webkit-transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
17
+ transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
18
+ line-height: 1;
19
+ font-family: var(--button-font-family);
20
+ box-shadow: var(--button-box-shadow);
21
+ color: var(--button-color);
22
+ background-color: var(--button-background-color);
23
+ font-size: var(--button-medium-font-size);
24
+ padding: var(--button-medium-padding);
25
+ min-width: var(--button-medium-min-width);
26
+ }
27
+
28
+ .c1:hover {
29
+ box-shadow: var(--button-active-box-shadow);
30
+ }
31
+
32
+ .c1:active {
33
+ box-shadow: var(--button-active-box-shadow);
34
+ }
35
+
36
+ .c1:hover {
37
+ background-color: var(--button-hover-background-color);
38
+ }
39
+
40
+ .c1:active {
41
+ background-color: var(--button-active-background-color);
42
+ }
43
+
44
+ .c0 + .c0 {
45
+ margin-left: 0.85em;
46
+ }
47
+
48
+ <button
49
+ class="c0 c1 button-color-default"
50
+ >
51
+ Test
52
+ </button>
53
+ `;
54
+
55
+ exports[`Button renders blinking 1`] = `
56
+ .c1 {
57
+ -webkit-text-decoration: none;
58
+ text-decoration: none;
59
+ text-align: center;
60
+ width: auto;
61
+ outline: none;
62
+ border: none;
63
+ border-radius: var(--button-border-radius);
64
+ font-weight: var(--button-font-weight);
65
+ font-size: 14px;
66
+ padding: 2px 20px;
67
+ cursor: pointer;
68
+ -webkit-transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
69
+ transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
70
+ line-height: 1;
71
+ font-family: var(--button-font-family);
72
+ box-shadow: var(--button-box-shadow);
73
+ color: var(--button-color);
74
+ background-color: var(--button-background-color);
75
+ font-size: var(--button-medium-font-size);
76
+ padding: var(--button-medium-padding);
77
+ min-width: var(--button-medium-min-width);
78
+ pointer-events: none;
79
+ -webkit-animation: hiqtTO 1.2s infinite;
80
+ animation: hiqtTO 1.2s infinite;
81
+ }
82
+
83
+ .c1:hover {
84
+ box-shadow: var(--button-active-box-shadow);
85
+ }
86
+
87
+ .c1:active {
88
+ box-shadow: var(--button-active-box-shadow);
89
+ }
90
+
91
+ .c1:hover {
92
+ background-color: var(--button-hover-background-color);
93
+ }
94
+
95
+ .c1:active {
96
+ background-color: var(--button-active-background-color);
97
+ }
98
+
99
+ .c0 + .c0 {
100
+ margin-left: 0.85em;
101
+ }
102
+
103
+ <button
104
+ class="c0 c1 button-color-default"
105
+ >
106
+ Test
107
+ </button>
108
+ `;
109
+
110
+ exports[`Button renders disabled 1`] = `
111
+ .c1 {
112
+ -webkit-text-decoration: none;
113
+ text-decoration: none;
114
+ text-align: center;
115
+ width: auto;
116
+ outline: none;
117
+ border: none;
118
+ border-radius: var(--button-border-radius);
119
+ font-weight: var(--button-font-weight);
120
+ font-size: 14px;
121
+ padding: 2px 20px;
122
+ cursor: pointer;
123
+ -webkit-transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
124
+ transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
125
+ line-height: 1;
126
+ font-family: var(--button-font-family);
127
+ box-shadow: var(--button-box-shadow);
128
+ color: var(--button-color);
129
+ background-color: var(--button-background-color);
130
+ font-size: var(--button-medium-font-size);
131
+ padding: var(--button-medium-padding);
132
+ min-width: var(--button-medium-min-width);
133
+ }
134
+
135
+ .c1:hover {
136
+ box-shadow: var(--button-active-box-shadow);
137
+ }
138
+
139
+ .c1:active {
140
+ box-shadow: var(--button-active-box-shadow);
141
+ }
142
+
143
+ .c1:hover {
144
+ background-color: var(--button-hover-background-color);
145
+ }
146
+
147
+ .c1:active {
148
+ background-color: var(--button-active-background-color);
149
+ }
150
+
151
+ .c0 + .c0 {
152
+ margin-left: 0.85em;
153
+ }
154
+
155
+ .c1,
156
+ .c1:hover {
157
+ cursor: default;
158
+ color: #999999;
159
+ pointer-events: none;
160
+ }
161
+
162
+ <button
163
+ class="c0 c1 button-color-default"
164
+ disabled=""
165
+ >
166
+ Test
167
+ </button>
168
+ `;
169
+
170
+ exports[`Button renders full width 1`] = `
171
+ .c1 {
172
+ -webkit-text-decoration: none;
173
+ text-decoration: none;
174
+ text-align: center;
175
+ width: 100%;
176
+ outline: none;
177
+ border: none;
178
+ border-radius: var(--button-border-radius);
179
+ font-weight: var(--button-font-weight);
180
+ font-size: 14px;
181
+ padding: 2px 20px;
182
+ cursor: pointer;
183
+ -webkit-transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
184
+ transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
185
+ line-height: 1;
186
+ font-family: var(--button-font-family);
187
+ box-shadow: var(--button-box-shadow);
188
+ color: var(--button-color);
189
+ background-color: var(--button-background-color);
190
+ font-size: var(--button-medium-font-size);
191
+ padding: var(--button-medium-padding);
192
+ min-width: var(--button-medium-min-width);
193
+ }
194
+
195
+ .c1:hover {
196
+ box-shadow: var(--button-active-box-shadow);
197
+ }
198
+
199
+ .c1:active {
200
+ box-shadow: var(--button-active-box-shadow);
201
+ }
202
+
203
+ .c1:hover {
204
+ background-color: var(--button-hover-background-color);
205
+ }
206
+
207
+ .c1:active {
208
+ background-color: var(--button-active-background-color);
209
+ }
210
+
211
+ .c0 + .c0 {
212
+ margin-left: 0.85em;
213
+ }
214
+
215
+ <button
216
+ class="c0 c1 button-color-default"
217
+ >
218
+ Test
219
+ </button>
220
+ `;
221
+
222
+ exports[`Button renders outlined 1`] = `
223
+ .c1 {
224
+ -webkit-text-decoration: none;
225
+ text-decoration: none;
226
+ text-align: center;
227
+ width: auto;
228
+ outline: none;
229
+ border: none;
230
+ border-radius: var(--button-border-radius);
231
+ font-weight: var(--button-font-weight);
232
+ font-size: 14px;
233
+ padding: 2px 20px;
234
+ cursor: pointer;
235
+ -webkit-transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
236
+ transition: background-color 0.25s ease,border-color 0.25s ease,box-shadow 0.25s ease;
237
+ line-height: 1;
238
+ font-family: var(--button-font-family);
239
+ box-shadow: var(--button-box-shadow);
240
+ color: var(--button-background-color);
241
+ border: 2px solid var(--button-background-color);
242
+ background-color: transparent;
243
+ font-size: var(--button-medium-font-size);
244
+ padding: var(--button-medium-padding);
245
+ min-width: var(--button-medium-min-width);
246
+ }
247
+
248
+ .c1:hover {
249
+ box-shadow: var(--button-active-box-shadow);
250
+ }
251
+
252
+ .c1:active {
253
+ box-shadow: var(--button-active-box-shadow);
254
+ }
255
+
256
+ .c1:hover {
257
+ border: 2px solid var(--button-active-background-color);
258
+ background-color: transparent;
259
+ }
260
+
261
+ .c1:active {
262
+ border: 2px solid var(--button-outlined-active-border-color);
263
+ }
264
+
265
+ .c0 + .c0 {
266
+ margin-left: 0.85em;
267
+ }
268
+
269
+ <button
270
+ class="c0 c1 button-color-default"
271
+ >
272
+ Test
273
+ </button>
274
+ `;
@@ -0,0 +1 @@
1
+ export * from './Button';