@redocly/theme 0.1.2 → 0.1.5
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 +60 -0
- package/Button/index.d.ts +1 -0
- package/Button/index.js +17 -0
- package/CodeBlock/CodeBlock.d.ts +1 -0
- package/CodeBlock/CodeBlock.js +13 -0
- package/CodeBlock/index.d.ts +1 -0
- package/CodeBlock/index.js +17 -0
- package/CopyButton/CopyButton.d.ts +6 -0
- package/CopyButton/CopyButton.js +73 -0
- package/CopyButton/CopyButtonWrapper.d.ts +9 -0
- package/CopyButton/CopyButtonWrapper.js +40 -0
- package/CopyButton/index.d.ts +2 -0
- package/CopyButton/index.js +18 -0
- package/Headings/Headings.d.ts +3 -0
- package/Headings/Headings.js +16 -0
- package/Headings/index.d.ts +1 -0
- package/Headings/index.js +17 -0
- package/JsonViewer/JsonViewer.d.ts +10 -0
- package/JsonViewer/JsonViewer.js +98 -0
- package/JsonViewer/index.d.ts +1 -0
- package/JsonViewer/index.js +17 -0
- package/JsonViewer/styled.d.ts +1 -0
- package/JsonViewer/styled.js +10 -0
- package/Logo/Logo.d.ts +10 -0
- package/Logo/Logo.js +32 -0
- package/Navbar/Navbar.d.ts +9 -0
- package/Navbar/Navbar.js +30 -0
- package/Navbar/NavbarItem.d.ts +40 -0
- package/Navbar/NavbarItem.js +50 -0
- package/Navbar/NavbarMenu.d.ts +4 -0
- package/Navbar/NavbarMenu.js +35 -0
- package/Panel/CodePanel.d.ts +1 -0
- package/Panel/CodePanel.js +19 -0
- package/Panel/ContentPanel.d.ts +1 -0
- package/Panel/ContentPanel.js +18 -0
- package/Panel/DarkHeader.d.ts +1 -0
- package/Panel/DarkHeader.js +10 -0
- package/Panel/Panel.d.ts +2 -0
- package/Panel/Panel.js +16 -0
- package/Panel/PanelBody.d.ts +6 -0
- package/Panel/PanelBody.js +41 -0
- package/Panel/PanelComponent.d.ts +10 -0
- package/Panel/PanelComponent.js +47 -0
- package/Panel/PanelHeader.d.ts +7 -0
- package/Panel/PanelHeader.js +22 -0
- package/Panel/PanelHeaderTitle.d.ts +1 -0
- package/Panel/PanelHeaderTitle.js +13 -0
- package/Panel/index.d.ts +7 -0
- package/Panel/index.js +23 -0
- package/SamplesPanelControls/SamplesPanelControls.d.ts +4 -0
- package/SamplesPanelControls/SamplesPanelControls.js +23 -0
- package/SamplesPanelControls/index.d.ts +1 -0
- package/SamplesPanelControls/index.js +17 -0
- package/SidebarLogo/SidebarLogo.d.ts +9 -0
- package/SidebarLogo/SidebarLogo.js +36 -0
- package/SidebarLogo/index.d.ts +1 -0
- package/SidebarLogo/index.js +17 -0
- package/SourceCode/SourceCode.d.ts +24 -0
- package/SourceCode/SourceCode.js +36 -0
- package/SourceCode/index.d.ts +1 -0
- package/SourceCode/index.js +17 -0
- package/Tooltip/Tooltip.d.ts +12 -0
- package/Tooltip/Tooltip.js +84 -0
- package/Tooltip/index.d.ts +1 -0
- package/Tooltip/index.js +17 -0
- package/globalStyle.d.ts +1 -0
- package/globalStyle.js +10 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +19 -0
- package/hooks/useControl.d.ts +6 -0
- package/hooks/useControl.js +16 -0
- package/hooks/useMount.d.ts +1 -0
- package/hooks/useMount.js +11 -0
- package/hooks/useUnmount.d.ts +1 -0
- package/hooks/useUnmount.js +13 -0
- package/icons/ShelfIcon/ShelfIcon.d.ts +10 -0
- package/icons/ShelfIcon/ShelfIcon.js +59 -0
- package/icons/ShelfIcon/index.d.ts +2 -0
- package/icons/ShelfIcon/index.js +5 -0
- package/icons/index.d.ts +1 -0
- package/icons/index.js +17 -0
- package/index.d.ts +14 -0
- package/index.js +30 -14
- package/mocks/Link.d.ts +2 -0
- package/mocks/Link.js +21 -0
- package/mocks/utils.d.ts +1 -0
- package/mocks/utils.js +7 -0
- package/package.json +2 -78
- package/src/Button/Button.stories.tsx +74 -0
- package/src/Button/Button.tsx +122 -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/src/CodeBlock/CodeBlock.ts +125 -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/src/CopyButton/CopyButton.tsx +26 -0
- package/src/CopyButton/CopyButtonWrapper.tsx +52 -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/src/Headings/Headings.ts +23 -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/src/JsonViewer/JsonViewer.tsx +130 -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/src/JsonViewer/styled.ts +103 -0
- package/src/Logo/Logo.tsx +23 -0
- package/src/Navbar/Navbar.stories.tsx +38 -0
- package/src/Navbar/Navbar.tsx +60 -0
- package/src/Navbar/NavbarItem.tsx +90 -0
- package/src/Navbar/NavbarMenu.tsx +29 -0
- package/src/Panel/CodePanel.stories.tsx +27 -0
- package/src/Panel/CodePanel.ts +31 -0
- package/src/Panel/ContentPanel.stories.tsx +27 -0
- package/src/Panel/ContentPanel.ts +43 -0
- package/src/Panel/DarkHeader.ts +8 -0
- package/src/Panel/Panel.stories.tsx +58 -0
- package/src/Panel/Panel.ts +18 -0
- package/src/Panel/PanelBody.ts +30 -0
- package/src/Panel/PanelComponent.tsx +73 -0
- package/src/Panel/PanelHeader.ts +25 -0
- package/src/Panel/PanelHeaderTitle.ts +11 -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/src/SamplesPanelControls/SamplesPanelControls.ts +70 -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/src/SidebarLogo/SidebarLogo.tsx +47 -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/src/SourceCode/SourceCode.tsx +67 -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/src/Tooltip/Tooltip.tsx +171 -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/src/globalStyle.ts +512 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useControl.ts +20 -0
- package/src/hooks/useMount.ts +8 -0
- package/src/hooks/useUnmount.ts +10 -0
- package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +36 -0
- package/src/icons/ShelfIcon/ShelfIcon.tsx +45 -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/src/mocks/Link.tsx +7 -0
- package/src/mocks/utils.ts +3 -0
- package/src/utils/ClipboardService.ts +92 -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/src/utils/css-variables.ts +2 -0
- package/src/utils/highlight.ts +81 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/jsonToHtml.ts +122 -0
- package/src/utils/media-css.ts +16 -0
- package/src/utils/theme-helpers.ts +34 -0
- package/utils/ClipboardService.d.ts +8 -0
- package/utils/ClipboardService.js +86 -0
- package/utils/css-variables.d.ts +1 -0
- package/utils/css-variables.js +8 -0
- package/utils/highlight.d.ts +32 -0
- package/utils/highlight.js +93 -0
- package/utils/index.d.ts +6 -0
- package/utils/index.js +22 -0
- package/utils/jsonToHtml.d.ts +1 -0
- package/utils/jsonToHtml.js +120 -0
- package/utils/media-css.d.ts +12 -0
- package/utils/media-css.js +13 -0
- package/utils/theme-helpers.d.ts +3 -0
- package/utils/theme-helpers.js +32 -0
|
@@ -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';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const CodeBlock = styled.div`
|
|
4
|
+
max-height: var(--code-block-max-height, 600px);
|
|
5
|
+
word-break: var(--code-block-word-break, initial);
|
|
6
|
+
/**
|
|
7
|
+
* Based on prism-dark.css
|
|
8
|
+
*/
|
|
9
|
+
code[class*='language-'],
|
|
10
|
+
pre[class*='language-'] {
|
|
11
|
+
/* color: white;
|
|
12
|
+
background: none; */
|
|
13
|
+
text-shadow: 0 -0.1em 0.2em black;
|
|
14
|
+
text-align: left;
|
|
15
|
+
white-space: pre;
|
|
16
|
+
word-spacing: normal;
|
|
17
|
+
word-break: normal;
|
|
18
|
+
word-wrap: normal;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
|
|
21
|
+
-moz-tab-size: 4;
|
|
22
|
+
-o-tab-size: 4;
|
|
23
|
+
tab-size: 4;
|
|
24
|
+
|
|
25
|
+
-webkit-hyphens: none;
|
|
26
|
+
-moz-hyphens: none;
|
|
27
|
+
-ms-hyphens: none;
|
|
28
|
+
hyphens: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@media print {
|
|
32
|
+
code[class*='language-'],
|
|
33
|
+
pre[class*='language-'] {
|
|
34
|
+
text-shadow: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Code blocks */
|
|
39
|
+
pre[class*='language-'] {
|
|
40
|
+
padding: 1em;
|
|
41
|
+
margin: 0.5em 0;
|
|
42
|
+
overflow: auto;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.token.comment,
|
|
46
|
+
.token.prolog,
|
|
47
|
+
.token.doctype,
|
|
48
|
+
.token.cdata {
|
|
49
|
+
color: hsl(30, 20%, 50%);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.token.punctuation {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.namespace {
|
|
57
|
+
opacity: 0.7;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.token.property,
|
|
61
|
+
.token.tag,
|
|
62
|
+
.token.number,
|
|
63
|
+
.token.constant,
|
|
64
|
+
.token.symbol {
|
|
65
|
+
color: var(--color-content-inverse);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.token.boolean {
|
|
69
|
+
color: var(--color-error-500);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.token.selector,
|
|
73
|
+
.token.attr-name,
|
|
74
|
+
.token.string,
|
|
75
|
+
.token.char,
|
|
76
|
+
.token.builtin,
|
|
77
|
+
.token.inserted {
|
|
78
|
+
color: #fee39e;
|
|
79
|
+
|
|
80
|
+
& + a,
|
|
81
|
+
& + a:visited {
|
|
82
|
+
color: #4ed2ba;
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.token.property.string {
|
|
88
|
+
color: #9efaa7;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.token.operator,
|
|
92
|
+
.token.entity,
|
|
93
|
+
.token.url,
|
|
94
|
+
.token.variable {
|
|
95
|
+
color: #f5b83d;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.token.atrule,
|
|
99
|
+
.token.attr-value,
|
|
100
|
+
.token.keyword {
|
|
101
|
+
color: #ffdbf4;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.token.regex,
|
|
105
|
+
.token.important {
|
|
106
|
+
color: #e90;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.token.important,
|
|
110
|
+
.token.bold {
|
|
111
|
+
font-weight: bold;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.token.italic {
|
|
115
|
+
font-style: italic;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.token.entity {
|
|
119
|
+
cursor: help;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.token.deleted {
|
|
123
|
+
color: red;
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
@@ -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
|
+
});
|