@redocly/theme 0.7.3 → 0.7.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.
Files changed (51) hide show
  1. package/lib/Catalog/Catalog.d.ts +8 -0
  2. package/lib/Catalog/Catalog.js +167 -0
  3. package/lib/Catalog/CatalogCard.d.ts +5 -0
  4. package/lib/Catalog/CatalogCard.js +113 -0
  5. package/lib/Catalog/Filter.d.ts +5 -0
  6. package/lib/Catalog/Filter.js +88 -0
  7. package/lib/Catalog/Tags.d.ts +4 -0
  8. package/lib/Catalog/Tags.js +32 -0
  9. package/lib/Feedback/ReportDialog.d.ts +3 -0
  10. package/lib/Feedback/ReportDialog.js +66 -0
  11. package/lib/Feedback/index.d.ts +2 -0
  12. package/lib/Feedback/index.js +5 -1
  13. package/lib/Feedback/types.d.ts +5 -3
  14. package/lib/Feedback/useReportDialog.d.ts +7 -0
  15. package/lib/Feedback/useReportDialog.js +28 -0
  16. package/lib/Markdown/CodeSample/CodeSample.js +8 -41
  17. package/lib/Sidebar/ArrowBack.js +2 -2
  18. package/lib/Sidebar/SidebarLayout.d.ts +5 -1
  19. package/lib/Sidebar/SidebarLayout.js +26 -1
  20. package/lib/config.d.ts +90 -82
  21. package/lib/config.js +24 -18
  22. package/lib/globalStyle.js +12 -10
  23. package/lib/mocks/hooks/index.d.ts +4 -0
  24. package/lib/mocks/hooks/index.js +16 -6
  25. package/lib/ui/Checkbox.d.ts +1 -0
  26. package/lib/ui/Checkbox.js +70 -0
  27. package/lib/ui/Highlight.d.ts +5 -0
  28. package/lib/ui/Highlight.js +63 -0
  29. package/lib/ui/darkColors.js +4 -2
  30. package/package.json +4 -2
  31. package/src/Catalog/Catalog.tsx +198 -0
  32. package/src/Catalog/CatalogCard.tsx +95 -0
  33. package/src/Catalog/Filter.tsx +103 -0
  34. package/src/Catalog/Tags.tsx +36 -0
  35. package/src/Feedback/ReportDialog.tsx +51 -0
  36. package/src/Feedback/index.ts +2 -0
  37. package/src/Feedback/types.ts +5 -3
  38. package/src/Feedback/useReportDialog.ts +34 -0
  39. package/src/Markdown/CodeSample/CodeSample.tsx +11 -57
  40. package/src/Sidebar/ArrowBack.tsx +2 -2
  41. package/src/Sidebar/SidebarLayout.tsx +38 -1
  42. package/src/config.ts +24 -18
  43. package/src/globalStyle.ts +12 -10
  44. package/src/mocks/hooks/index.ts +17 -6
  45. package/src/types/portal/src/shared/types/catalog.d.ts +55 -0
  46. package/src/ui/Checkbox.tsx +64 -0
  47. package/src/ui/Highlight.tsx +48 -0
  48. package/src/ui/darkColors.tsx +4 -2
  49. package/lib/hooks/useReportDialog.d.ts +0 -1
  50. package/lib/hooks/useReportDialog.js +0 -16
  51. package/src/hooks/useReportDialog.ts +0 -14
@@ -0,0 +1,198 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { ResolvedNavItem } from '@redocly/theme/src/types/portal';
5
+
6
+ import type { CatalogConfig } from '@theme/types/portal/src/shared/types/catalog';
7
+ import { usePageSharedData } from '@portal/hooks/index.js';
8
+ import { H2 } from '@theme/Typography/H2';
9
+ import { H3 } from '@theme/Typography/H3';
10
+ import { Button } from '@theme/Button/Button';
11
+ import { HighlightContext } from '@theme/ui/Highlight';
12
+ import { CatalogCard } from '@theme/Catalog/CatalogCard';
13
+ import { Filter } from '@theme/Catalog/Filter';
14
+ import { useCatalog } from '@portal/hooks/index';
15
+
16
+ export default function Catalog(props: {
17
+ pageProps: {
18
+ catalogId: string;
19
+ catalogConfig: CatalogConfig;
20
+ };
21
+ }) {
22
+ const { catalogConfig } = props.pageProps;
23
+ const items = usePageSharedData('catalog') as ResolvedNavItem[];
24
+
25
+ const { filterTerm, setFilterTerm, groups, filters } = useCatalog(items, catalogConfig);
26
+ const [isFilterPanelFocused, setIsFilterPanelFocused] = React.useState(false);
27
+
28
+ return (
29
+ <HighlightContext.Provider value={[filterTerm]}>
30
+ <CatalogPageWrapper>
31
+ <CatalogPageSidebar isActiveInMobileMode={isFilterPanelFocused}>
32
+ <StyledInput
33
+ placeholder="Filter..."
34
+ value={filterTerm}
35
+ onFocus={() => setIsFilterPanelFocused(true)}
36
+ onChange={(e) => setFilterTerm(e.target.value)}
37
+ />
38
+ {filters.map((filter, idx) => (
39
+ <Filter filter={filter} key={filter.property + '-' + idx} />
40
+ ))}
41
+ <MobileStickyApplyFilters>
42
+ <Button color="secondary" onClick={() => setIsFilterPanelFocused(false)}>
43
+ Apply filters
44
+ </Button>
45
+ </MobileStickyApplyFilters>
46
+ </CatalogPageSidebar>
47
+ <CatalogPageContent>
48
+ {catalogConfig.title ? <CatalogTitle> {catalogConfig.title} </CatalogTitle> : null}
49
+ {catalogConfig.description ? (
50
+ <CatalogDescription> {catalogConfig.description} </CatalogDescription>
51
+ ) : null}
52
+ {groups.map((group) => (
53
+ <React.Fragment key={group.title}>
54
+ <H3>
55
+ {group.title} ({group.items.length})
56
+ </H3>
57
+ <CatalogCards>
58
+ {group.items.map((item) => (
59
+ <CatalogCard item={item} key={item.link} />
60
+ ))}
61
+ </CatalogCards>
62
+ </React.Fragment>
63
+ ))}
64
+ </CatalogPageContent>
65
+ </CatalogPageWrapper>
66
+ </HighlightContext.Provider>
67
+ );
68
+ }
69
+
70
+ const MobileStickyApplyFilters = styled.div`
71
+ position: fixed;
72
+ display: none;
73
+ background-color: var(--sidebar-background-color);
74
+ bottom: 0;
75
+ padding: 16px 30px;
76
+ left: 0px;
77
+ right: 0px;
78
+
79
+ ${Button} {
80
+ width: 100%;
81
+ margin: 0;
82
+ }
83
+ `;
84
+
85
+ const CatalogPageSidebar = styled.aside<{ isActiveInMobileMode?: boolean }>`
86
+ width: var(--sidebar-width);
87
+ border-right: 1px solid var(--sidebar-border-color);
88
+ padding: 20px 30px;
89
+ position: sticky;
90
+ top: var(--navbar-height);
91
+ height: calc(100vh - var(--navbar-height));
92
+ overflow: auto;
93
+
94
+ @media screen and (max-width: 767px) {
95
+ transition: height 0.2s ease-in-out;
96
+ width: 100%;
97
+ ${({ isActiveInMobileMode }) =>
98
+ isActiveInMobileMode ? 'padding-bottom: 66px;' : 'height: 76px;'};
99
+ background-color: var(--sidebar-background-color);
100
+ border-bottom: 1px solid var(--sidebar-border-color);
101
+ z-index: 100;
102
+
103
+ ${MobileStickyApplyFilters} {
104
+ display: ${({ isActiveInMobileMode }) => (isActiveInMobileMode ? 'block' : 'none')};
105
+ }
106
+ }
107
+ `;
108
+
109
+ const CatalogPageContent = styled.main`
110
+ flex: 1;
111
+ padding: 32px;
112
+ `;
113
+
114
+ const CatalogCards = styled.div`
115
+ display: grid;
116
+ grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
117
+ gap: 32px;
118
+ `;
119
+
120
+ const CatalogTitle = styled(H2)`
121
+ && {
122
+ margin: 0;
123
+ }
124
+ `;
125
+
126
+ const CatalogDescription = styled.p`
127
+ margin: 16px 0 32px 0;
128
+ font-size: 16px;
129
+ color: var(--text-color-secondary);
130
+ `;
131
+
132
+ const CatalogPageWrapper = styled.div`
133
+ --sidebar-width: var(--catalog-sidebar-width, 300px);
134
+
135
+ display: flex;
136
+ flex-direction: row;
137
+
138
+ font-weight: var(--font-weight-regular);
139
+ padding: 0;
140
+
141
+ color: var(--text-color);
142
+ font-size: var(--font-size-base);
143
+ font-family: var(--font-family-base);
144
+ line-height: var(--line-height-base);
145
+
146
+ hr {
147
+ border: 0;
148
+ width: calc(100% + 48px);
149
+ margin: auto -24px 0 -24px;
150
+ border-top: 1px solid var(--border-color);
151
+ }
152
+ a:not([role='button']) {
153
+ text-decoration: none;
154
+ color: var(--link-text-color);
155
+ font-weight: var(--link-font-weight);
156
+ }
157
+
158
+ @media screen and (max-width: 767px) {
159
+ flex-direction: column;
160
+ }
161
+ `;
162
+
163
+ // TODO: merge this input with the input from reference docs
164
+ // the on in ref docs is dark, needs separate variables most likely
165
+ const StyledInput = styled.input`
166
+ border: 1px solid rgba(0, 0, 0, 0.23);
167
+ min-width: 200px;
168
+ outline-color: var(--color-primary-500);
169
+ width: 100%;
170
+
171
+ outline: none;
172
+ padding: var(--input-padding);
173
+ border-radius: var(--input-border-radius);
174
+ background-color: var(--input-background-color);
175
+ color: var(--text-color);
176
+ font-family: var(--input-font-family);
177
+ font-size: var(--input-font-size);
178
+ line-height: var(--input-line-height);
179
+
180
+ &::placeholder {
181
+ opacity: 0.6;
182
+ color: var(--text-color);
183
+ }
184
+
185
+ &:hover {
186
+ color: var(--text-color);
187
+ border: 1px solid rgba(0, 0, 0, 0.23);
188
+ }
189
+
190
+ &:focus {
191
+ color: var(--text-color);
192
+ border: 1px solid rgba(0, 0, 0, 0.23);
193
+ }
194
+
195
+ &:-webkit-autofill {
196
+ background-color: var(--input-background-color);
197
+ }
198
+ `;
@@ -0,0 +1,95 @@
1
+ import * as React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { CatalogItem } from '@theme/types/portal/src/shared/types/catalog';
5
+ import { Link } from '@portal/Link';
6
+ import { Highlight } from '@theme/ui/Highlight';
7
+ import { Tags } from '@theme/Catalog/Tags';
8
+
9
+ export function CatalogCard({ item }: { item: CatalogItem }): JSX.Element {
10
+ return (
11
+ <Link key={item.docsLink || item.link} to={item.docsLink || item.link}>
12
+ <StyledCard>
13
+ <CardTitle>
14
+ <Highlight>{item.title}</Highlight>
15
+ </CardTitle>
16
+ {/* <div>{item.image}</div> */}
17
+ <CardDescription>
18
+ <Highlight>{item.description ?? ''}</Highlight>
19
+ </CardDescription>
20
+ {item.tags ? <Tags tags={item.tags as string[]} /> : null}
21
+ <hr />
22
+ <CardFooter>View documentation</CardFooter>
23
+ </StyledCard>
24
+ </Link>
25
+ );
26
+ }
27
+
28
+ const StyledCard = styled.div`
29
+ min-height: 268px;
30
+ height: 100%;
31
+ box-shadow: var(--box-shadow);
32
+
33
+ display: flex;
34
+ flex-direction: column;
35
+
36
+ color: var(--text-color);
37
+ background-color: var(--thin-tile-background-color);
38
+ border-radius: 4px;
39
+
40
+ border: 1px solid var(--border-color);
41
+ box-shadow: 0px 0px 10px 0px rgba(35, 35, 35, 0.05);
42
+ transition: all 0.2s ease-in-out;
43
+
44
+ &:hover {
45
+ /* box-shadow: 0px 12px 30px 0px rgba(35, 35, 35, 0.2); */
46
+ box-shadow: 0px 10px 30px 0px rgba(35, 35, 35, 0.1);
47
+ border: 1px solid var(--border-color);
48
+ transform: translateY(-2px);
49
+ }
50
+
51
+ border-radius: 8px;
52
+ width: 100%;
53
+ padding: 24px 24px 0;
54
+ display: flex;
55
+ flex-direction: column;
56
+ cursor: pointer;
57
+ `;
58
+
59
+ const CardTitle = styled.h4`
60
+ line-height: 26px;
61
+ letter-spacing: 0.8px;
62
+ font-size: 20px;
63
+ font-weight: var(--font-weight-bold);
64
+ margin: 0;
65
+ margin-bottom: 16px;
66
+ `;
67
+
68
+ const CardDescription = styled.div`
69
+ display: -webkit-box;
70
+ -webkit-line-clamp: 3;
71
+ -webkit-box-orient: vertical;
72
+ overflow: hidden;
73
+ text-overflow: ellipsis;
74
+ line-height: var(--line-height);
75
+ letter-spacing: 0px;
76
+ font-size: 16px;
77
+ color: var(--text-color-secondary);
78
+ text-align: inherit;
79
+ font-weight: 400;
80
+ `;
81
+
82
+ const CardFooter = styled.div`
83
+ height: 46px;
84
+ display: flex;
85
+ align-items: flex-start;
86
+ justify-content: center;
87
+ flex-direction: column;
88
+ font-size: 16px;
89
+ font-weight: var(--font-weight-bold);
90
+
91
+ a:hover & {
92
+ text-decoration: var(--link-hover-text-decoration);
93
+ color: var(--link-hover-text-color);
94
+ }
95
+ `;
@@ -0,0 +1,103 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { ResolvedFilter } from '@theme/types/portal/src/shared/types/catalog';
5
+ import { Checkbox } from '@theme/ui/Checkbox';
6
+
7
+ export function Filter({ filter }: { filter: ResolvedFilter }) {
8
+ if (!filter.parentUsed) return null;
9
+ return (
10
+ <FilterGroup key={filter.property + filter.title}>
11
+ <FilterTitle>{filter.title} filter</FilterTitle>
12
+ {filter.type === 'select' ? (
13
+ <StyledSelect
14
+ onChange={(e) => filter.selectOption(e.target.value)}
15
+ value={filter.selectedOptions.values().next()?.value || ''}
16
+ >
17
+ <option key="none" value="">
18
+ All
19
+ </option>
20
+ {filter.filteredOptions.map((value: any) => (
21
+ <option key={value.value} value={value.value}>
22
+ {value.value} ({value.count})
23
+ </option>
24
+ ))}
25
+ </StyledSelect>
26
+ ) : (
27
+ filter.filteredOptions.map((value: any) => {
28
+ const id = 'filter--' + filter.property + '--' + slug(value.value);
29
+ return (
30
+ <FilterValue key={id}>
31
+ <Checkbox
32
+ type="checkbox"
33
+ id={id}
34
+ checked={filter.selectedOptions.has(value.value)}
35
+ onChange={() => filter.toggleOption(value.value)}
36
+ />
37
+ <label htmlFor={id}>
38
+ {value.value} ({value.count})
39
+ </label>
40
+ </FilterValue>
41
+ );
42
+ })
43
+ )}
44
+ </FilterGroup>
45
+ );
46
+ }
47
+
48
+ const FilterGroup = styled.div`
49
+ padding: 16px 0;
50
+ border-bottom: 1px solid var(--border-color);
51
+
52
+ &:last-of-type {
53
+ border-bottom: none;
54
+ }
55
+ `;
56
+
57
+ const FilterTitle = styled.h4`
58
+ font-size: 18px;
59
+ font-weight: var(--font-weight-bold);
60
+ margin: 0;
61
+ margin-bottom: 16px;
62
+ `;
63
+
64
+ const FilterValue = styled.label`
65
+ display: block;
66
+ cursor: pointer;
67
+ font-size: 16px;
68
+ margin: 8px 0;
69
+
70
+ input {
71
+ cursor: pointer;
72
+ }
73
+ `;
74
+
75
+ const StyledSelect = styled.select`
76
+ border: 1px solid rgba(0, 0, 0, 0.23);
77
+
78
+ padding: var(--input-padding);
79
+ border-radius: var(--input-border-radius);
80
+ background-color: var(--input-background-color);
81
+ color: var(--text-color);
82
+ font-family: var(--input-font-family);
83
+ font-size: var(--input-font-size);
84
+ line-height: var(--input-line-height);
85
+
86
+ min-width: 200px;
87
+ outline-color: var(--color-primary-500);
88
+ transition: outline 0.25s ease;
89
+ display: inline-block;
90
+ text-align: left;
91
+ appearance: none;
92
+
93
+ background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
94
+ background-repeat: no-repeat;
95
+ background-position: right 10px center;
96
+ background-size: 1em;
97
+ width: 100%;
98
+ `;
99
+
100
+ // TODO: import from portal
101
+ function slug(str: string): string {
102
+ return str.replace(/\s/g, '-').toLowerCase();
103
+ }
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { Highlight } from '@theme/ui/Highlight';
5
+
6
+ export function Tags({ tags }: { tags: string[] }) {
7
+ return (
8
+ <TagsWrapper>
9
+ {tags.map((tag) => (
10
+ <Tag key={tag} className={'tag-' + slug(tag)}>
11
+ <Highlight>{tag}</Highlight>
12
+ </Tag>
13
+ ))}
14
+ </TagsWrapper>
15
+ );
16
+ }
17
+
18
+ const TagsWrapper = styled.div`
19
+ margin-top: 16px;
20
+ `;
21
+
22
+ const Tag = styled.div`
23
+ display: inline-block;
24
+ background-color: #d3f4ef;
25
+ color: #000;
26
+ padding: 2px 5px;
27
+ border-radius: var(--border-radius);
28
+ margin-right: 5px;
29
+ margin-bottom: 5px;
30
+ font-size: 0.8em;
31
+ `;
32
+
33
+ // TODO: import from portal
34
+ function slug(str: string): string {
35
+ return str.replace(/\s/g, '-').toLowerCase();
36
+ }
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { Comment } from '@theme/Feedback/Comment';
5
+ import type { ReportDialogProps } from '@theme/Feedback';
6
+ import { useSubmitFeedback } from '@portal/Feedback/useSubmitFeedback';
7
+
8
+ export const ReportDialog = ({
9
+ location,
10
+ settings,
11
+ onSubmit,
12
+ onCancel,
13
+ }: ReportDialogProps): JSX.Element => {
14
+ const { label } = settings;
15
+ const { submitFeedback } = useSubmitFeedback();
16
+
17
+ return (
18
+ <Wrapper className="modal">
19
+ <Comment
20
+ settings={{ label, onCancel }}
21
+ onSubmit={(value) => {
22
+ submitFeedback('problem', { ...value, location });
23
+ onSubmit();
24
+ }}
25
+ />
26
+ </Wrapper>
27
+ );
28
+ };
29
+
30
+ const Wrapper = styled.div`
31
+ font-family: var(--font-family-base);
32
+ position: fixed;
33
+ top: 0;
34
+ left: 0;
35
+ width: 100vw;
36
+ height: 100vh;
37
+ background: var(--modal-overlay-background-color);
38
+ z-index: 10000;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+
43
+ & > * {
44
+ background: var(--modal-background-color);
45
+ box-shadow: var(--modal-box-shadow);
46
+ padding: 15px;
47
+ margin: 15px;
48
+ max-width: 500px;
49
+ max-height: 300px;
50
+ }
51
+ `;
@@ -2,4 +2,6 @@ export { Rating } from '@theme/Feedback/Rating';
2
2
  export { Sentiment } from '@theme/Feedback/Sentiment';
3
3
  export { Comment } from '@theme/Feedback/Comment';
4
4
  export { Reasons } from '@theme/Feedback/Reasons';
5
+ export { ReportDialog } from '@theme/Feedback/ReportDialog';
6
+ export { useReportDialog } from '@theme/Feedback/useReportDialog';
5
7
  export * from './types';
@@ -56,9 +56,11 @@ export type ReasonsProps = {
56
56
  };
57
57
  };
58
58
 
59
- export type ProblemProps = {
60
- onSubmit: (value: string, location: string) => void; // TODO: maybe we don't need location here
61
- settings?: {
59
+ export type ReportDialogProps = {
60
+ location: string;
61
+ onSubmit: () => void;
62
+ onCancel: () => void;
63
+ settings: {
62
64
  label?: string;
63
65
  };
64
66
  };
@@ -0,0 +1,34 @@
1
+ import { useState } from 'react';
2
+
3
+ import type { ReportDialogProps } from '@theme/Feedback/types';
4
+
5
+ type ReportSettings = {
6
+ hide?: boolean;
7
+ label?: string;
8
+ tooltipText?: string;
9
+ };
10
+
11
+ export function useReportDialog(reportSettings: ReportSettings): Record<string, any> {
12
+ const [isReportDialogShown, setIsReportDialogShown] = useState(false);
13
+ const isReportButtonShown = reportSettings.hide === false; // TODO: report temporary disabled by default
14
+
15
+ const showReportDialog = () => {
16
+ setIsReportDialogShown(true);
17
+ };
18
+ const hideReportDialog = () => {
19
+ setIsReportDialogShown(false);
20
+ };
21
+ const reportButtonProps = {
22
+ onClick: showReportDialog,
23
+ title: reportSettings.tooltipText || 'Report a problem',
24
+ };
25
+ const reportDialogProps: Partial<ReportDialogProps> = {
26
+ settings: {
27
+ label: reportSettings.label || 'What is wrong with a code?',
28
+ },
29
+ onSubmit: hideReportDialog,
30
+ onCancel: hideReportDialog,
31
+ };
32
+
33
+ return { isReportDialogShown, isReportButtonShown, reportButtonProps, reportDialogProps };
34
+ }
@@ -3,9 +3,7 @@ import styled, { css } from 'styled-components';
3
3
 
4
4
  import { ClipboardService } from '@theme/utils/ClipboardService';
5
5
  import { useThemeConfig } from '@theme/hooks/useThemeConfig';
6
- import { Comment } from '@theme/Feedback';
7
- import { useSubmitFeedback } from '@portal/Feedback/useSubmitFeedback';
8
- import { useReportDialog } from '@theme/hooks/useReportDialog';
6
+ import { ReportDialog, useReportDialog } from '@theme/Feedback';
9
7
 
10
8
  export type CodeSampleProps = {
11
9
  language: string;
@@ -15,60 +13,38 @@ export type CodeSampleProps = {
15
13
 
16
14
  export function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element {
17
15
  const langClassName = language ? `language-${language}` : '';
18
- const { markdown: { copyCodeSnippet = {}, reportCodeSnippet = {} } = {} } = useThemeConfig();
19
- const { submitFeedback } = useSubmitFeedback();
16
+ const { codeSnippet: { copy = {}, report = {} } = {} } = useThemeConfig();
20
17
 
21
18
  const [isCopied, setIsCopied] = useState(false);
22
- const [isDialogShown, showDialog, hideDialog] = useReportDialog(false);
19
+ const { isReportDialogShown, isReportButtonShown, reportButtonProps, reportDialogProps } =
20
+ useReportDialog(report);
23
21
 
24
22
  const copyCode = (code: string) => {
25
23
  ClipboardService.copyCustom(code);
26
24
  setIsCopied(true);
27
- setTimeout(() => setIsCopied(false), copyCodeSnippet.toasterDuration || 1000);
25
+ setTimeout(() => setIsCopied(false), copy.toasterDuration || 1500);
28
26
  };
29
27
 
30
28
  return (
31
29
  <Wrapper className="code-sample" data-component-name="Markdown/CodeSample/CodeSample">
32
30
  <CodeSampleButtonContainer>
33
- {!copyCodeSnippet.hide && (
31
+ {!copy.hide && (
34
32
  <>
35
33
  {!isCopied && (
36
34
  <Button
37
35
  onClick={() => copyCode(rawContent)}
38
- title={copyCodeSnippet.tooltipText || 'Copy to clipboard'}
36
+ title={copy.tooltipText || 'Copy to clipboard'}
39
37
  >
40
- {copyCodeSnippet.buttonText || 'Copy'}
38
+ {copy.buttonText || 'Copy'}
41
39
  </Button>
42
40
  )}
43
- {isCopied && <DoneIndicator>{copyCodeSnippet.toasterText || 'Copied!'}</DoneIndicator>}
41
+ {isCopied && <DoneIndicator>{copy.toasterText || 'Copied!'}</DoneIndicator>}
44
42
  </>
45
43
  )}
46
44
 
47
- {!reportCodeSnippet.hide && (
48
- <Button
49
- onClick={() => showDialog()}
50
- title={reportCodeSnippet.tooltipText || 'Report a problem'}
51
- >
52
- Report
53
- </Button>
54
- )}
45
+ {isReportButtonShown && <Button {...reportButtonProps}>Report</Button>}
55
46
 
56
- {isDialogShown && (
57
- <ReportDialog id="modal">
58
- <Comment
59
- settings={{
60
- label: reportCodeSnippet.label || 'What is wrong with a code?',
61
- onCancel: () => {
62
- hideDialog();
63
- },
64
- }}
65
- onSubmit={(value) => {
66
- submitFeedback('problem', { ...value, location: rawContent });
67
- hideDialog();
68
- }}
69
- />
70
- </ReportDialog>
71
- )}
47
+ {isReportDialogShown && <ReportDialog {...reportDialogProps} location={rawContent} />}
72
48
  </CodeSampleButtonContainer>
73
49
  <pre className={langClassName}>
74
50
  <code className={langClassName} dangerouslySetInnerHTML={{ __html: highlighted }} />
@@ -245,25 +221,3 @@ const Wrapper = styled.div`
245
221
  ${darkStyleTokens};
246
222
  }
247
223
  `;
248
-
249
- const ReportDialog = styled.div`
250
- position: fixed;
251
- top: 0;
252
- left: 0;
253
- width: 100vw;
254
- height: 100vh;
255
- background: var(--modal-overlay-background-color);
256
- z-index: 10000;
257
- display: flex;
258
- align-items: center;
259
- justify-content: center;
260
-
261
- & > * {
262
- background: var(--modal-background-color);
263
- box-shadow: var(--modal-box-shadow);
264
- padding: 15px;
265
- margin: 15px;
266
- max-width: 500px;
267
- max-height: 300px;
268
- }
269
- `;
@@ -7,7 +7,7 @@ const Arrow = ({ className }: { className?: string }): JSX.Element => (
7
7
  fill="none"
8
8
  xmlns="http://www.w3.org/2000/svg"
9
9
  viewBox="0 0 12 10"
10
- width="12px"
10
+ width="10px"
11
11
  height="10px"
12
12
  className={className}
13
13
  >
@@ -19,7 +19,7 @@ const Arrow = ({ className }: { className?: string }): JSX.Element => (
19
19
 
20
20
  export const ArrowBack = styled(Arrow)`
21
21
  fill: var(--sidebar-back-button-icon-color);
22
- margin-right: calc(var(--sidebar-spacing-unit) * 1.5);
22
+ margin-right: calc(var(--sidebar-spacing-unit));
23
23
 
24
24
  background-image: var(--sidebar-back-button-icon);
25
25
  background-repeat: no-repeat;