@redocly/theme 0.1.0 → 0.1.3
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.
- package/Button/Button.d.ts +17 -0
- package/Button/Button.js +34 -0
- package/{lib/src/Button/index.ts → Button/index.d.ts} +0 -0
- package/Button/index.js +1 -0
- package/CodeBlock/CodeBlock.d.ts +1 -0
- package/CodeBlock/CodeBlock.js +7 -0
- package/{lib/src/CodeBlock/index.ts → CodeBlock/index.d.ts} +0 -0
- package/CodeBlock/index.js +1 -0
- package/CopyButton/CopyButton.d.ts +6 -0
- package/CopyButton/CopyButton.js +69 -0
- package/CopyButton/CopyButtonWrapper.d.ts +9 -0
- package/CopyButton/CopyButtonWrapper.js +37 -0
- package/{lib/src/CopyButton/index.ts → CopyButton/index.d.ts} +0 -0
- package/CopyButton/index.js +2 -0
- package/Headings/Headings.d.ts +3 -0
- package/Headings/Headings.js +10 -0
- package/{lib/src/Headings/index.ts → Headings/index.d.ts} +0 -0
- package/Headings/index.js +1 -0
- package/JsonViewer/JsonViewer.d.ts +10 -0
- package/JsonViewer/JsonViewer.js +92 -0
- package/{lib/src/JsonViewer/index.ts → JsonViewer/index.d.ts} +0 -0
- package/JsonViewer/index.js +1 -0
- package/JsonViewer/styled.d.ts +1 -0
- package/JsonViewer/styled.js +7 -0
- package/Logo/Logo.d.ts +10 -0
- package/Logo/Logo.js +25 -0
- package/Navbar/Navbar.d.ts +9 -0
- package/Navbar/Navbar.js +23 -0
- package/Navbar/NavbarItem.d.ts +40 -0
- package/Navbar/NavbarItem.js +43 -0
- package/Navbar/NavbarMenu.d.ts +4 -0
- package/Navbar/NavbarMenu.js +29 -0
- package/Panel/CodePanel.d.ts +1 -0
- package/Panel/CodePanel.js +13 -0
- package/Panel/ContentPanel.d.ts +1 -0
- package/Panel/ContentPanel.js +12 -0
- package/Panel/DarkHeader.d.ts +1 -0
- package/Panel/DarkHeader.js +7 -0
- package/Panel/Panel.d.ts +2 -0
- package/Panel/Panel.js +10 -0
- package/Panel/PanelBody.d.ts +6 -0
- package/Panel/PanelBody.js +15 -0
- package/Panel/PanelComponent.d.ts +10 -0
- package/Panel/PanelComponent.js +40 -0
- package/Panel/PanelHeader.d.ts +7 -0
- package/Panel/PanelHeader.js +16 -0
- package/Panel/PanelHeaderTitle.d.ts +1 -0
- package/Panel/PanelHeaderTitle.js +7 -0
- package/{lib/src/Panel/index.ts → Panel/index.d.ts} +0 -0
- package/Panel/index.js +7 -0
- package/SamplesPanelControls/SamplesPanelControls.d.ts +4 -0
- package/SamplesPanelControls/SamplesPanelControls.js +17 -0
- package/{lib/src/SamplesPanelControls/index.ts → SamplesPanelControls/index.d.ts} +0 -0
- package/SamplesPanelControls/index.js +1 -0
- package/SidebarLogo/SidebarLogo.d.ts +9 -0
- package/SidebarLogo/SidebarLogo.js +29 -0
- package/{lib/src/SidebarLogo/index.ts → SidebarLogo/index.d.ts} +0 -0
- package/SidebarLogo/index.js +1 -0
- package/SourceCode/SourceCode.d.ts +24 -0
- package/SourceCode/SourceCode.js +31 -0
- package/{lib/src/SourceCode/index.ts → SourceCode/index.d.ts} +0 -0
- package/SourceCode/index.js +1 -0
- package/Tooltip/Tooltip.d.ts +12 -0
- package/Tooltip/Tooltip.js +57 -0
- package/{lib/src/Tooltip/index.ts → Tooltip/index.d.ts} +0 -0
- package/Tooltip/index.js +1 -0
- package/globalStyle.d.ts +1 -0
- package/globalStyle.js +7 -0
- package/{lib/src/hooks/index.ts → hooks/index.d.ts} +0 -0
- package/hooks/index.js +3 -0
- package/hooks/useControl.d.ts +6 -0
- package/hooks/useControl.js +12 -0
- package/hooks/useMount.d.ts +1 -0
- package/hooks/useMount.js +7 -0
- package/hooks/useUnmount.d.ts +1 -0
- package/hooks/useUnmount.js +9 -0
- package/icons/ShelfIcon/ShelfIcon.d.ts +10 -0
- package/icons/ShelfIcon/ShelfIcon.js +33 -0
- package/{lib/src/icons/ShelfIcon/index.ts → icons/ShelfIcon/index.d.ts} +0 -0
- package/icons/ShelfIcon/index.js +1 -0
- package/{lib/src/icons/index.ts → icons/index.d.ts} +0 -0
- package/icons/index.js +1 -0
- package/{lib/src/index.ts → index.d.ts} +0 -0
- package/index.js +14 -0
- package/mocks/Link.d.ts +2 -0
- package/mocks/Link.js +17 -0
- package/mocks/utils.d.ts +1 -0
- package/mocks/utils.js +3 -0
- package/package.json +1 -5
- package/src/Button/Button.stories.tsx +74 -0
- package/{lib/src → src}/Button/Button.tsx +0 -0
- package/src/Button/__tests__/Button.test.tsx +42 -0
- package/src/Button/__tests__/__snapshots__/Button.test.tsx.snap +274 -0
- package/src/Button/index.ts +1 -0
- package/{lib/src → src}/CodeBlock/CodeBlock.ts +0 -0
- package/src/CodeBlock/__tests__/CodeBlock.test.tsx +12 -0
- package/src/CodeBlock/__tests__/__snapshots__/CodeBlock.test.tsx.snap +140 -0
- package/src/CodeBlock/index.ts +1 -0
- package/src/CopyButton/CopyButton.stories.tsx +18 -0
- package/{lib/src → src}/CopyButton/CopyButton.tsx +0 -0
- package/{lib/src → src}/CopyButton/CopyButtonWrapper.tsx +0 -0
- package/src/CopyButton/__tests__/CopyButton.test.tsx +35 -0
- package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +16 -0
- package/src/CopyButton/__tests__/__snapshots__/CopyButton.test.tsx.snap +55 -0
- package/src/CopyButton/__tests__/__snapshots__/CopyButtonWrapper.test.tsx.snap +46 -0
- package/src/CopyButton/index.ts +2 -0
- package/src/Headings/Headings.stories.tsx +36 -0
- package/{lib/src → src}/Headings/Headings.ts +0 -0
- package/src/Headings/__tests__/Headings.test.tsx +24 -0
- package/src/Headings/__tests__/__snapshots__/Headings.test.tsx.snap +57 -0
- package/src/Headings/index.ts +1 -0
- package/src/Introduction.stories.mdx +7 -0
- package/src/JsonViewer/JsonViewer.stories.tsx +57 -0
- package/{lib/src → src}/JsonViewer/JsonViewer.tsx +0 -0
- package/src/JsonViewer/__tests__/JsonViewer.test.tsx +82 -0
- package/src/JsonViewer/__tests__/__snapshots__/JsonViewer.test.tsx.snap +2728 -0
- package/src/JsonViewer/index.ts +1 -0
- package/{lib/src → src}/JsonViewer/styled.ts +0 -0
- package/{lib/src → src}/Logo/Logo.tsx +0 -0
- package/src/Navbar/Navbar.stories.tsx +38 -0
- package/{lib/src → src}/Navbar/Navbar.tsx +0 -0
- package/{lib/src → src}/Navbar/NavbarItem.tsx +0 -0
- package/{lib/src → src}/Navbar/NavbarMenu.tsx +0 -0
- package/src/Panel/CodePanel.stories.tsx +27 -0
- package/{lib/src → src}/Panel/CodePanel.ts +0 -0
- package/src/Panel/ContentPanel.stories.tsx +27 -0
- package/{lib/src → src}/Panel/ContentPanel.ts +0 -0
- package/{lib/src → src}/Panel/DarkHeader.ts +0 -0
- package/src/Panel/Panel.stories.tsx +58 -0
- package/{lib/src → src}/Panel/Panel.ts +0 -0
- package/{lib/src → src}/Panel/PanelBody.ts +0 -0
- package/{lib/src → src}/Panel/PanelComponent.tsx +0 -0
- package/{lib/src → src}/Panel/PanelHeader.ts +0 -0
- package/{lib/src → src}/Panel/PanelHeaderTitle.ts +0 -0
- package/src/Panel/__tests__/CodePanel.test.tsx +26 -0
- package/src/Panel/__tests__/ContentPanel.test.tsx +26 -0
- package/src/Panel/__tests__/Panel.test.tsx +54 -0
- package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +258 -0
- package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +278 -0
- package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +398 -0
- package/src/Panel/index.ts +7 -0
- package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +18 -0
- package/{lib/src → src}/SamplesPanelControls/SamplesPanelControls.ts +0 -0
- package/src/SamplesPanelControls/__tests__/SamplesPanelControls.test.tsx +36 -0
- package/src/SamplesPanelControls/__tests__/__snapshots__/SamplesPanelControls.test.tsx.snap +228 -0
- package/src/SamplesPanelControls/index.ts +1 -0
- package/src/SidebarLogo/SidebarLogo.stories.tsx +21 -0
- package/{lib/src → src}/SidebarLogo/SidebarLogo.tsx +0 -0
- package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +32 -0
- package/src/SidebarLogo/__tests__/__snapshots__/SidebarLogo.test.tsx.snap +62 -0
- package/src/SidebarLogo/index.ts +1 -0
- package/src/SourceCode/SourceCode.stories.tsx +29 -0
- package/{lib/src → src}/SourceCode/SourceCode.tsx +0 -0
- package/src/SourceCode/__tests__/SourceCode.test.tsx +47 -0
- package/src/SourceCode/__tests__/__snapshots__/SourceCode.test.tsx.snap +786 -0
- package/src/SourceCode/index.ts +1 -0
- package/src/Tooltip/Tooltip.stories.tsx +27 -0
- package/{lib/src → src}/Tooltip/Tooltip.tsx +0 -0
- package/src/Tooltip/__tests__/Tooltip.test.tsx +41 -0
- package/src/Tooltip/__tests__/__snapshots__/Tooltip.test.tsx.snap +83 -0
- package/src/Tooltip/index.ts +1 -0
- package/{lib/src → src}/globalStyle.ts +0 -0
- package/src/hooks/index.ts +3 -0
- package/{lib/src → src}/hooks/useControl.ts +0 -0
- package/{lib/src → src}/hooks/useMount.ts +0 -0
- package/{lib/src → src}/hooks/useUnmount.ts +0 -0
- package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +36 -0
- package/{lib/src → src}/icons/ShelfIcon/ShelfIcon.tsx +0 -0
- package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +54 -0
- package/src/icons/ShelfIcon/__tests__/__snapshots__/ShelfIcon.test.tsx.snap +235 -0
- package/src/icons/ShelfIcon/index.ts +2 -0
- package/src/icons/index.ts +1 -0
- package/src/index.ts +14 -0
- package/{lib/src → src}/mocks/Link.tsx +0 -0
- package/{lib/src → src}/mocks/utils.ts +0 -0
- package/{lib/src → src}/utils/ClipboardService.ts +0 -0
- package/src/utils/__tests__/ClipboardService.test.ts +24 -0
- package/src/utils/__tests__/__snapshots__/highlight.test.ts.snap +5 -0
- package/src/utils/__tests__/__snapshots__/jsonToHtml.test.ts.snap +5 -0
- package/src/utils/__tests__/css-variables.test.ts +20 -0
- package/src/utils/__tests__/highlight.test.ts +51 -0
- package/src/utils/__tests__/jsonToHtml.test.ts +40 -0
- package/src/utils/__tests__/media-css.test.ts +20 -0
- package/src/utils/__tests__/theme-helpers.test.ts +25 -0
- package/{lib/src → src}/utils/css-variables.ts +0 -0
- package/{lib/src → src}/utils/highlight.ts +0 -0
- package/{lib/src → src}/utils/index.ts +0 -0
- package/{lib/src → src}/utils/jsonToHtml.ts +0 -0
- package/{lib/src → src}/utils/media-css.ts +0 -0
- package/{lib/src → src}/utils/theme-helpers.ts +0 -0
- package/utils/ClipboardService.d.ts +8 -0
- package/utils/ClipboardService.js +83 -0
- package/utils/css-variables.d.ts +1 -0
- package/utils/css-variables.js +4 -0
- package/utils/highlight.d.ts +32 -0
- package/utils/highlight.js +65 -0
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/jsonToHtml.d.ts +1 -0
- package/utils/jsonToHtml.js +116 -0
- package/utils/media-css.d.ts +12 -0
- package/utils/media-css.js +9 -0
- package/utils/theme-helpers.d.ts +3 -0
- package/utils/theme-helpers.js +27 -0
- package/LICENSE +0 -1
- package/lib/package.json +0 -91
package/index.js
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';
|
package/mocks/Link.d.ts
ADDED
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
|
+
}
|
package/mocks/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withPathPrefix(link: string): string;
|
package/mocks/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Shared UI components",
|
|
5
5
|
"author": "team@redocly.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"typings": "index.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
"lib"
|
|
11
|
-
],
|
|
12
9
|
"scripts": {
|
|
13
10
|
"start": "npm run storybook",
|
|
14
11
|
"storybook": "start-storybook -p 6006",
|
|
@@ -28,7 +25,6 @@
|
|
|
28
25
|
"test": "jest",
|
|
29
26
|
"test:watch": "jest --watch",
|
|
30
27
|
"test:coverage": "jest --coverage",
|
|
31
|
-
"prepare": "husky install",
|
|
32
28
|
"chromatic": "chromatic --exit-zero-on-changes"
|
|
33
29
|
},
|
|
34
30
|
"peerDependencies": {
|
|
@@ -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
|
+
};
|
|
File without changes
|
|
@@ -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';
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { CodeBlock } from '../CodeBlock';
|
|
5
|
+
|
|
6
|
+
describe('CodeBlock', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const { container } = render(<CodeBlock>Test</CodeBlock>);
|
|
9
|
+
|
|
10
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CodeBlock renders 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
max-height: var(--code-block-max-height,600px);
|
|
6
|
+
word-break: var(--code-block-word-break,initial);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.c0 code[class*='language-'],
|
|
10
|
+
.c0 pre[class*='language-'] {
|
|
11
|
+
text-shadow: 0 -0.1em 0.2em black;
|
|
12
|
+
text-align: left;
|
|
13
|
+
white-space: pre;
|
|
14
|
+
word-spacing: normal;
|
|
15
|
+
word-break: normal;
|
|
16
|
+
word-wrap: normal;
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
-moz-tab-size: 4;
|
|
19
|
+
-o-tab-size: 4;
|
|
20
|
+
tab-size: 4;
|
|
21
|
+
-webkit-hyphens: none;
|
|
22
|
+
-moz-hyphens: none;
|
|
23
|
+
-ms-hyphens: none;
|
|
24
|
+
-webkit-hyphens: none;
|
|
25
|
+
-moz-hyphens: none;
|
|
26
|
+
-ms-hyphens: none;
|
|
27
|
+
hyphens: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.c0 pre[class*='language-'] {
|
|
31
|
+
padding: 1em;
|
|
32
|
+
margin: 0.5em 0;
|
|
33
|
+
overflow: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.c0 .token.comment,
|
|
37
|
+
.c0 .token.prolog,
|
|
38
|
+
.c0 .token.doctype,
|
|
39
|
+
.c0 .token.cdata {
|
|
40
|
+
color: hsl(30,20%,50%);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.c0 .token.punctuation {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.c0 .namespace {
|
|
48
|
+
opacity: 0.7;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.c0 .token.property,
|
|
52
|
+
.c0 .token.tag,
|
|
53
|
+
.c0 .token.number,
|
|
54
|
+
.c0 .token.constant,
|
|
55
|
+
.c0 .token.symbol {
|
|
56
|
+
color: var(--color-content-inverse);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.c0 .token.boolean {
|
|
60
|
+
color: var(--color-error-500);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.c0 .token.selector,
|
|
64
|
+
.c0 .token.attr-name,
|
|
65
|
+
.c0 .token.string,
|
|
66
|
+
.c0 .token.char,
|
|
67
|
+
.c0 .token.builtin,
|
|
68
|
+
.c0 .token.inserted {
|
|
69
|
+
color: #fee39e;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.c0 .token.selector + a,
|
|
73
|
+
.c0 .token.attr-name + a,
|
|
74
|
+
.c0 .token.string + a,
|
|
75
|
+
.c0 .token.char + a,
|
|
76
|
+
.c0 .token.builtin + a,
|
|
77
|
+
.c0 .token.inserted + a,
|
|
78
|
+
.c0 .token.selector + a:visited,
|
|
79
|
+
.c0 .token.attr-name + a:visited,
|
|
80
|
+
.c0 .token.string + a:visited,
|
|
81
|
+
.c0 .token.char + a:visited,
|
|
82
|
+
.c0 .token.builtin + a:visited,
|
|
83
|
+
.c0 .token.inserted + a:visited {
|
|
84
|
+
color: #4ed2ba;
|
|
85
|
+
-webkit-text-decoration: underline;
|
|
86
|
+
text-decoration: underline;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.c0 .token.property.string {
|
|
90
|
+
color: #9efaa7;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.c0 .token.operator,
|
|
94
|
+
.c0 .token.entity,
|
|
95
|
+
.c0 .token.url,
|
|
96
|
+
.c0 .token.variable {
|
|
97
|
+
color: #f5b83d;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.c0 .token.atrule,
|
|
101
|
+
.c0 .token.attr-value,
|
|
102
|
+
.c0 .token.keyword {
|
|
103
|
+
color: #ffdbf4;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.c0 .token.regex,
|
|
107
|
+
.c0 .token.important {
|
|
108
|
+
color: #e90;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.c0 .token.important,
|
|
112
|
+
.c0 .token.bold {
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.c0 .token.italic {
|
|
117
|
+
font-style: italic;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.c0 .token.entity {
|
|
121
|
+
cursor: help;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.c0 .token.deleted {
|
|
125
|
+
color: red;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media print {
|
|
129
|
+
.c0 code[class*='language-'],
|
|
130
|
+
.c0 pre[class*='language-'] {
|
|
131
|
+
text-shadow: none;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
<div
|
|
136
|
+
class="c0"
|
|
137
|
+
>
|
|
138
|
+
Test
|
|
139
|
+
</div>
|
|
140
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CodeBlock';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { CopyButton } from './CopyButton';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'CopyButton',
|
|
8
|
+
component: CopyButton,
|
|
9
|
+
} as ComponentMeta<typeof CopyButton>;
|
|
10
|
+
|
|
11
|
+
const Template: ComponentStory<typeof CopyButton> = (args) => (
|
|
12
|
+
<CopyButton {...args}>Copy</CopyButton>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const Default = Template.bind({});
|
|
16
|
+
Default.args = {
|
|
17
|
+
text: 'Something useful',
|
|
18
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, getByText, render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { CopyButton } from '../CopyButton';
|
|
5
|
+
|
|
6
|
+
const mockSetState = jest.fn();
|
|
7
|
+
|
|
8
|
+
jest.mock('react', () => {
|
|
9
|
+
const original = jest.requireActual('react');
|
|
10
|
+
return {
|
|
11
|
+
...original,
|
|
12
|
+
useState: (initial: any) => [initial, mockSetState],
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('CopyButton', () => {
|
|
17
|
+
it('renders', () => {
|
|
18
|
+
const { container } = render(<CopyButton text="test copy" dataTestId="copy" />);
|
|
19
|
+
|
|
20
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('changes button text on click', () => {
|
|
24
|
+
Object.assign(navigator, {
|
|
25
|
+
clipboard: { writeText: jest.fn() },
|
|
26
|
+
});
|
|
27
|
+
const textToCopy = 'test copy';
|
|
28
|
+
const { container } = render(<CopyButton text={textToCopy} />);
|
|
29
|
+
const button = getByText(container, /Copy/);
|
|
30
|
+
|
|
31
|
+
fireEvent.click(button);
|
|
32
|
+
|
|
33
|
+
expect(navigator.clipboard.writeText).toBeCalledWith(textToCopy);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { renderWithTheme } from '../../../tests/utils';
|
|
4
|
+
import { CopyButtonWrapper } from '../CopyButtonWrapper';
|
|
5
|
+
|
|
6
|
+
describe('CopyButtonWrapper', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const { container } = renderWithTheme(
|
|
9
|
+
<CopyButtonWrapper data="Something" dataTestId="copy">
|
|
10
|
+
{({ renderCopyButton }) => <div>{renderCopyButton()}</div>}
|
|
11
|
+
</CopyButtonWrapper>,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
});
|