@redocly/theme 0.1.2 → 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/Button/index.d.ts +1 -0
- package/Button/index.js +1 -0
- package/CodeBlock/CodeBlock.d.ts +1 -0
- package/CodeBlock/CodeBlock.js +7 -0
- package/CodeBlock/index.d.ts +1 -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/CopyButton/index.d.ts +2 -0
- package/CopyButton/index.js +2 -0
- package/Headings/Headings.d.ts +3 -0
- package/Headings/Headings.js +10 -0
- package/Headings/index.d.ts +1 -0
- package/Headings/index.js +1 -0
- package/JsonViewer/JsonViewer.d.ts +10 -0
- package/JsonViewer/JsonViewer.js +92 -0
- package/JsonViewer/index.d.ts +1 -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/Panel/index.d.ts +7 -0
- package/Panel/index.js +7 -0
- package/SamplesPanelControls/SamplesPanelControls.d.ts +4 -0
- package/SamplesPanelControls/SamplesPanelControls.js +17 -0
- package/SamplesPanelControls/index.d.ts +1 -0
- package/SamplesPanelControls/index.js +1 -0
- package/SidebarLogo/SidebarLogo.d.ts +9 -0
- package/SidebarLogo/SidebarLogo.js +29 -0
- package/SidebarLogo/index.d.ts +1 -0
- package/SidebarLogo/index.js +1 -0
- package/SourceCode/SourceCode.d.ts +24 -0
- package/SourceCode/SourceCode.js +31 -0
- package/SourceCode/index.d.ts +1 -0
- package/SourceCode/index.js +1 -0
- package/Tooltip/Tooltip.d.ts +12 -0
- package/Tooltip/Tooltip.js +57 -0
- package/Tooltip/index.d.ts +1 -0
- package/Tooltip/index.js +1 -0
- package/globalStyle.d.ts +1 -0
- package/globalStyle.js +7 -0
- package/hooks/index.d.ts +3 -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/icons/ShelfIcon/index.d.ts +2 -0
- package/icons/ShelfIcon/index.js +1 -0
- package/icons/index.d.ts +1 -0
- package/icons/index.js +1 -0
- package/index.d.ts +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 -4
- 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 +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
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Panel renders collapsed 1`] = `
|
|
4
|
+
.c4 {
|
|
5
|
+
height: 9px;
|
|
6
|
+
width: 9px;
|
|
7
|
+
-webkit-transform: rotateZ(0deg);
|
|
8
|
+
-ms-transform: rotateZ(0deg);
|
|
9
|
+
transform: rotateZ(0deg);
|
|
10
|
+
fill: inherit;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
-webkit-transition: -webkit-transform 0.2s ease-out;
|
|
13
|
+
-webkit-transition: transform 0.2s ease-out;
|
|
14
|
+
transition: transform 0.2s ease-out;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.c1 {
|
|
18
|
+
position: relative;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
display: -webkit-box;
|
|
21
|
+
display: -webkit-flex;
|
|
22
|
+
display: -ms-flexbox;
|
|
23
|
+
display: flex;
|
|
24
|
+
-webkit-align-items: center;
|
|
25
|
+
-webkit-box-align: center;
|
|
26
|
+
-ms-flex-align: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
-webkit-box-pack: justify;
|
|
29
|
+
-webkit-justify-content: space-between;
|
|
30
|
+
-ms-flex-pack: justify;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
35
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
36
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
37
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
38
|
+
pointer-events: auto;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.c3 {
|
|
42
|
+
line-height: 1;
|
|
43
|
+
margin-right: 5px;
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
color: var(--color-content);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.c2 {
|
|
49
|
+
display: -webkit-inline-box;
|
|
50
|
+
display: -webkit-inline-flex;
|
|
51
|
+
display: -ms-inline-flexbox;
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
-webkit-align-items: center;
|
|
54
|
+
-webkit-box-align: center;
|
|
55
|
+
-ms-flex-align: center;
|
|
56
|
+
align-items: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.c0 {
|
|
60
|
+
border-radius: var(--panels-border-radius);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.c0:not(:last-child) {
|
|
64
|
+
margin-bottom: 10px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
<div
|
|
68
|
+
class="c0"
|
|
69
|
+
data-cy="panel-panel-header"
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
class="c1"
|
|
73
|
+
data-cy="panel-header"
|
|
74
|
+
>
|
|
75
|
+
<div
|
|
76
|
+
class="c2"
|
|
77
|
+
>
|
|
78
|
+
<span
|
|
79
|
+
class="c3"
|
|
80
|
+
data-cy="title"
|
|
81
|
+
>
|
|
82
|
+
Panel header
|
|
83
|
+
</span>
|
|
84
|
+
<svg
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
class="c4"
|
|
87
|
+
viewBox="0 0 4.25 7"
|
|
88
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
89
|
+
>
|
|
90
|
+
<path
|
|
91
|
+
d="M0.205025 1.19467L3.00503 3.99467C3.27839 4.26804 3.72161 4.26804 3.99497 3.99467C4.26834 3.7213 4.26834 3.27809 3.99497 3.00472L1.19497 0.20472C0.921608 -0.0686469 0.478392 -0.0686469 0.205025 0.20472C-0.0683418 0.478087 -0.0683417 0.921303 0.205025 1.19467Z"
|
|
92
|
+
/>
|
|
93
|
+
<path
|
|
94
|
+
d="M3.00503 3.00501L0.205025 5.80501C-0.0683417 6.07838 -0.0683417 6.5216 0.205025 6.79496C0.478392 7.06833 0.921608 7.06833 1.19497 6.79496L3.99497 3.99496C4.26834 3.7216 4.26834 3.27838 3.99497 3.00501C3.72161 2.73165 3.27839 2.73165 3.00503 3.00501Z"
|
|
95
|
+
/>
|
|
96
|
+
</svg>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
exports[`Panel renders expanded 1`] = `
|
|
103
|
+
.c7 {
|
|
104
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
105
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
106
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
107
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
108
|
+
background-color: var(--panels-background-color);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.c5 {
|
|
112
|
+
height: 9px;
|
|
113
|
+
width: 9px;
|
|
114
|
+
-webkit-transform: rotateZ(90deg);
|
|
115
|
+
-ms-transform: rotateZ(90deg);
|
|
116
|
+
transform: rotateZ(90deg);
|
|
117
|
+
fill: inherit;
|
|
118
|
+
vertical-align: middle;
|
|
119
|
+
-webkit-transition: -webkit-transform 0.2s ease-out;
|
|
120
|
+
-webkit-transition: transform 0.2s ease-out;
|
|
121
|
+
transition: transform 0.2s ease-out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.c2 {
|
|
125
|
+
position: relative;
|
|
126
|
+
z-index: 1;
|
|
127
|
+
display: -webkit-box;
|
|
128
|
+
display: -webkit-flex;
|
|
129
|
+
display: -ms-flexbox;
|
|
130
|
+
display: flex;
|
|
131
|
+
-webkit-align-items: center;
|
|
132
|
+
-webkit-box-align: center;
|
|
133
|
+
-ms-flex-align: center;
|
|
134
|
+
align-items: center;
|
|
135
|
+
-webkit-box-pack: justify;
|
|
136
|
+
-webkit-justify-content: space-between;
|
|
137
|
+
-ms-flex-pack: justify;
|
|
138
|
+
justify-content: space-between;
|
|
139
|
+
white-space: nowrap;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
142
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
143
|
+
border-bottom-right-radius: 0;
|
|
144
|
+
border-bottom-left-radius: 0;
|
|
145
|
+
pointer-events: auto;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.c4 {
|
|
149
|
+
line-height: 1;
|
|
150
|
+
margin-right: 5px;
|
|
151
|
+
font-weight: 700;
|
|
152
|
+
color: var(--color-content);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.c3 {
|
|
156
|
+
display: -webkit-inline-box;
|
|
157
|
+
display: -webkit-inline-flex;
|
|
158
|
+
display: -ms-inline-flexbox;
|
|
159
|
+
display: inline-flex;
|
|
160
|
+
-webkit-align-items: center;
|
|
161
|
+
-webkit-box-align: center;
|
|
162
|
+
-ms-flex-align: center;
|
|
163
|
+
align-items: center;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.c0 {
|
|
167
|
+
border-radius: var(--panels-border-radius);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.c0 .c1 + .c6 {
|
|
171
|
+
border-top-left-radius: 0;
|
|
172
|
+
border-top-right-radius: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.c0:not(:last-child) {
|
|
176
|
+
margin-bottom: 10px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
<div
|
|
180
|
+
class="c0"
|
|
181
|
+
data-cy="panel-panel-header"
|
|
182
|
+
>
|
|
183
|
+
<div
|
|
184
|
+
class="c1 c2"
|
|
185
|
+
data-cy="panel-header"
|
|
186
|
+
>
|
|
187
|
+
<div
|
|
188
|
+
class="c3"
|
|
189
|
+
>
|
|
190
|
+
<span
|
|
191
|
+
class="c4"
|
|
192
|
+
data-cy="title"
|
|
193
|
+
>
|
|
194
|
+
Panel header
|
|
195
|
+
</span>
|
|
196
|
+
<svg
|
|
197
|
+
aria-hidden="true"
|
|
198
|
+
class="c5"
|
|
199
|
+
viewBox="0 0 4.25 7"
|
|
200
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
201
|
+
>
|
|
202
|
+
<path
|
|
203
|
+
d="M0.205025 1.19467L3.00503 3.99467C3.27839 4.26804 3.72161 4.26804 3.99497 3.99467C4.26834 3.7213 4.26834 3.27809 3.99497 3.00472L1.19497 0.20472C0.921608 -0.0686469 0.478392 -0.0686469 0.205025 0.20472C-0.0683418 0.478087 -0.0683417 0.921303 0.205025 1.19467Z"
|
|
204
|
+
/>
|
|
205
|
+
<path
|
|
206
|
+
d="M3.00503 3.00501L0.205025 5.80501C-0.0683417 6.07838 -0.0683417 6.5216 0.205025 6.79496C0.478392 7.06833 0.921608 7.06833 1.19497 6.79496L3.99497 3.99496C4.26834 3.7216 4.26834 3.27838 3.99497 3.00501C3.72161 2.73165 3.27839 2.73165 3.00503 3.00501Z"
|
|
207
|
+
/>
|
|
208
|
+
</svg>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<div
|
|
212
|
+
class="c6 c7"
|
|
213
|
+
data-cy="panel-body"
|
|
214
|
+
>
|
|
215
|
+
Panel body
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
`;
|
|
219
|
+
|
|
220
|
+
exports[`Panel renders with header 1`] = `
|
|
221
|
+
.c7 {
|
|
222
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
223
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
224
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
225
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
226
|
+
background-color: var(--panels-background-color);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.c5 {
|
|
230
|
+
height: 9px;
|
|
231
|
+
width: 9px;
|
|
232
|
+
-webkit-transform: rotateZ(90deg);
|
|
233
|
+
-ms-transform: rotateZ(90deg);
|
|
234
|
+
transform: rotateZ(90deg);
|
|
235
|
+
fill: inherit;
|
|
236
|
+
vertical-align: middle;
|
|
237
|
+
-webkit-transition: -webkit-transform 0.2s ease-out;
|
|
238
|
+
-webkit-transition: transform 0.2s ease-out;
|
|
239
|
+
transition: transform 0.2s ease-out;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.c2 {
|
|
243
|
+
position: relative;
|
|
244
|
+
z-index: 1;
|
|
245
|
+
display: -webkit-box;
|
|
246
|
+
display: -webkit-flex;
|
|
247
|
+
display: -ms-flexbox;
|
|
248
|
+
display: flex;
|
|
249
|
+
-webkit-align-items: center;
|
|
250
|
+
-webkit-box-align: center;
|
|
251
|
+
-ms-flex-align: center;
|
|
252
|
+
align-items: center;
|
|
253
|
+
-webkit-box-pack: justify;
|
|
254
|
+
-webkit-justify-content: space-between;
|
|
255
|
+
-ms-flex-pack: justify;
|
|
256
|
+
justify-content: space-between;
|
|
257
|
+
white-space: nowrap;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
260
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
261
|
+
border-bottom-right-radius: 0;
|
|
262
|
+
border-bottom-left-radius: 0;
|
|
263
|
+
pointer-events: auto;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.c4 {
|
|
267
|
+
line-height: 1;
|
|
268
|
+
margin-right: 5px;
|
|
269
|
+
font-weight: 700;
|
|
270
|
+
color: var(--color-content);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.c3 {
|
|
274
|
+
display: -webkit-inline-box;
|
|
275
|
+
display: -webkit-inline-flex;
|
|
276
|
+
display: -ms-inline-flexbox;
|
|
277
|
+
display: inline-flex;
|
|
278
|
+
-webkit-align-items: center;
|
|
279
|
+
-webkit-box-align: center;
|
|
280
|
+
-ms-flex-align: center;
|
|
281
|
+
align-items: center;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.c0 {
|
|
285
|
+
border-radius: var(--panels-border-radius);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.c0 .c1 + .c6 {
|
|
289
|
+
border-top-left-radius: 0;
|
|
290
|
+
border-top-right-radius: 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.c0:not(:last-child) {
|
|
294
|
+
margin-bottom: 10px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
<div
|
|
298
|
+
class="c0"
|
|
299
|
+
data-cy="panel-panel-header"
|
|
300
|
+
>
|
|
301
|
+
<div
|
|
302
|
+
class="c1 c2"
|
|
303
|
+
data-cy="panel-header"
|
|
304
|
+
>
|
|
305
|
+
<div
|
|
306
|
+
class="c3"
|
|
307
|
+
>
|
|
308
|
+
<span
|
|
309
|
+
class="c4"
|
|
310
|
+
data-cy="title"
|
|
311
|
+
>
|
|
312
|
+
Panel header
|
|
313
|
+
</span>
|
|
314
|
+
<svg
|
|
315
|
+
aria-hidden="true"
|
|
316
|
+
class="c5"
|
|
317
|
+
viewBox="0 0 4.25 7"
|
|
318
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
319
|
+
>
|
|
320
|
+
<path
|
|
321
|
+
d="M0.205025 1.19467L3.00503 3.99467C3.27839 4.26804 3.72161 4.26804 3.99497 3.99467C4.26834 3.7213 4.26834 3.27809 3.99497 3.00472L1.19497 0.20472C0.921608 -0.0686469 0.478392 -0.0686469 0.205025 0.20472C-0.0683418 0.478087 -0.0683417 0.921303 0.205025 1.19467Z"
|
|
322
|
+
/>
|
|
323
|
+
<path
|
|
324
|
+
d="M3.00503 3.00501L0.205025 5.80501C-0.0683417 6.07838 -0.0683417 6.5216 0.205025 6.79496C0.478392 7.06833 0.921608 7.06833 1.19497 6.79496L3.99497 3.99496C4.26834 3.7216 4.26834 3.27838 3.99497 3.00501C3.72161 2.73165 3.27839 2.73165 3.00503 3.00501Z"
|
|
325
|
+
/>
|
|
326
|
+
</svg>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
<div
|
|
330
|
+
class="c6 c7"
|
|
331
|
+
data-cy="panel-body"
|
|
332
|
+
>
|
|
333
|
+
Panel body
|
|
334
|
+
</div>
|
|
335
|
+
</div>
|
|
336
|
+
`;
|
|
337
|
+
|
|
338
|
+
exports[`Panel renders with header as function 1`] = `
|
|
339
|
+
.c1 {
|
|
340
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
341
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
342
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
343
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
344
|
+
background-color: var(--panels-background-color);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.c0 {
|
|
348
|
+
border-radius: var(--panels-border-radius);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.c0:not(:last-child) {
|
|
352
|
+
margin-bottom: 10px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
<div
|
|
356
|
+
class="c0"
|
|
357
|
+
>
|
|
358
|
+
<div>
|
|
359
|
+
Custom Header component:
|
|
360
|
+
{"expanded":true}
|
|
361
|
+
</div>
|
|
362
|
+
<div
|
|
363
|
+
class="c1"
|
|
364
|
+
data-cy="panel-body"
|
|
365
|
+
>
|
|
366
|
+
Panel body
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
`;
|
|
370
|
+
|
|
371
|
+
exports[`Panel renders without header 1`] = `
|
|
372
|
+
.c1 {
|
|
373
|
+
border-top-left-radius: var(--panels-border-radius);
|
|
374
|
+
border-top-right-radius: var(--panels-border-radius);
|
|
375
|
+
border-bottom-right-radius: var(--panels-border-radius);
|
|
376
|
+
border-bottom-left-radius: var(--panels-border-radius);
|
|
377
|
+
background-color: var(--panels-background-color);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.c0 {
|
|
381
|
+
border-radius: var(--panels-border-radius);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.c0:not(:last-child) {
|
|
385
|
+
margin-bottom: 10px;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
<div
|
|
389
|
+
class="c0"
|
|
390
|
+
>
|
|
391
|
+
<div
|
|
392
|
+
class="c1"
|
|
393
|
+
data-cy="panel-body"
|
|
394
|
+
>
|
|
395
|
+
Panel body
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { SampleControls, SamplesControlButton } from './SamplesPanelControls';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Samples Control Button',
|
|
8
|
+
component: SamplesControlButton,
|
|
9
|
+
} as ComponentMeta<typeof SamplesControlButton>;
|
|
10
|
+
|
|
11
|
+
const Template: ComponentStory<typeof SamplesControlButton> = (args) => (
|
|
12
|
+
<SampleControls style={{ width: '200px' }}>
|
|
13
|
+
<SamplesControlButton {...args}>Copy</SamplesControlButton>
|
|
14
|
+
</SampleControls>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const Default = Template.bind({});
|
|
18
|
+
Default.args = {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { CodeBlock } from '../CodeBlock';
|
|
4
|
+
|
|
5
|
+
export const SamplesControlButton = styled.button`
|
|
6
|
+
background-color: var(--samples-panel-controls-background-color);
|
|
7
|
+
border: 0;
|
|
8
|
+
outline: 0;
|
|
9
|
+
border-radius: var(--global-border-radius);
|
|
10
|
+
height: 20px;
|
|
11
|
+
color: var(--color-content-inverse);
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
line-height: 12px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
padding: 1px 6px;
|
|
16
|
+
min-width: 90px;
|
|
17
|
+
|
|
18
|
+
${({ theme }) => theme.mediaQueries.small} {
|
|
19
|
+
padding: 2px 20px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:hover,
|
|
23
|
+
:focus {
|
|
24
|
+
background-color: var(--samples-panel-controls-hover-background-color);
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export const SampleControls = styled.div`
|
|
29
|
+
padding: 10px 0;
|
|
30
|
+
opacity: 0.7;
|
|
31
|
+
transition: opacity 0.3s ease;
|
|
32
|
+
text-align: right;
|
|
33
|
+
|
|
34
|
+
&:focus-within {
|
|
35
|
+
opacity: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
> div,
|
|
39
|
+
> ${SamplesControlButton} {
|
|
40
|
+
/* can have tooltip wrapper div also */
|
|
41
|
+
margin-top: 5px;
|
|
42
|
+
margin-left: 10px;
|
|
43
|
+
|
|
44
|
+
${({ theme }) => theme.mediaQueries.small} {
|
|
45
|
+
margin-top: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:first-child {
|
|
49
|
+
margin-left: 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
export const SampleControlsWrap = styled.div`
|
|
55
|
+
&:hover ${SampleControls} {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
export const PreformattedCodeBlock = styled(CodeBlock.withComponent('pre'))`
|
|
61
|
+
overflow-x: auto;
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-family: var(--code-font-family);
|
|
64
|
+
padding: 20px;
|
|
65
|
+
border-radius: var(--global-border-radius);
|
|
66
|
+
background-color: var(--samples-panel-controls-background-color);
|
|
67
|
+
color: var(--color-content-inverse);
|
|
68
|
+
font-size: var(--code-font-size);
|
|
69
|
+
white-space: var(--code-wrap, pre);
|
|
70
|
+
`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { renderWithTheme } from '../../../tests/utils';
|
|
5
|
+
import {
|
|
6
|
+
SampleControls,
|
|
7
|
+
SamplesControlButton,
|
|
8
|
+
PreformattedCodeBlock,
|
|
9
|
+
} from '../SamplesPanelControls';
|
|
10
|
+
|
|
11
|
+
describe('SampleControls & SamplesControlButton', () => {
|
|
12
|
+
it('renders', () => {
|
|
13
|
+
const { container } = renderWithTheme(
|
|
14
|
+
<SampleControls>
|
|
15
|
+
<SamplesControlButton>Copy</SamplesControlButton>
|
|
16
|
+
</SampleControls>,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('StyledPre', () => {
|
|
24
|
+
it('renders', () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<PreformattedCodeBlock>
|
|
27
|
+
Test: <br />
|
|
28
|
+
<a className="token string" href="#" target="_blank" rel="noopener noreferrer">
|
|
29
|
+
Click
|
|
30
|
+
</a>
|
|
31
|
+
</PreformattedCodeBlock>,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|