@redocly/theme 0.7.4 → 0.8.0
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/lib/Catalog/Catalog.d.ts +8 -0
- package/lib/Catalog/Catalog.js +167 -0
- package/lib/Catalog/CatalogCard.d.ts +5 -0
- package/lib/Catalog/CatalogCard.js +113 -0
- package/lib/Catalog/Filter.d.ts +5 -0
- package/lib/Catalog/Filter.js +88 -0
- package/lib/Catalog/Tags.d.ts +4 -0
- package/lib/Catalog/Tags.js +32 -0
- package/lib/Feedback/ReportDialog.d.ts +3 -0
- package/lib/Feedback/ReportDialog.js +66 -0
- package/lib/Feedback/index.d.ts +2 -0
- package/lib/Feedback/index.js +5 -1
- package/lib/Feedback/types.d.ts +5 -3
- package/lib/Feedback/useReportDialog.d.ts +7 -0
- package/lib/Feedback/useReportDialog.js +28 -0
- package/lib/Markdown/CodeSample/CodeSample.js +5 -38
- package/lib/Sidebar/ArrowBack.js +2 -2
- package/lib/Sidebar/MenuGroup.js +1 -1
- package/lib/Sidebar/Sidebar.d.ts +1 -0
- package/lib/Sidebar/Sidebar.js +5 -2
- package/lib/Sidebar/SidebarLayout.d.ts +6 -1
- package/lib/Sidebar/SidebarLayout.js +27 -2
- package/lib/TableOfContent/TableOfContent.js +1 -1
- package/lib/config.js +2 -2
- package/lib/globalStyle.js +13 -11
- package/lib/hooks/useActiveHeading.js +2 -7
- package/lib/hooks/useActiveSectionId.js +1 -1
- package/lib/hooks/useMobileMenu.js +1 -1
- package/lib/mocks/hooks/index.d.ts +4 -0
- package/lib/mocks/hooks/index.js +9 -1
- package/lib/ui/Checkbox.d.ts +1 -0
- package/lib/ui/Checkbox.js +70 -0
- package/lib/ui/Highlight.d.ts +5 -0
- package/lib/ui/Highlight.js +63 -0
- package/lib/ui/Jumbotron.js +2 -2
- package/lib/ui/darkColors.js +4 -2
- package/package.json +6 -8
- package/src/Catalog/Catalog.tsx +198 -0
- package/src/Catalog/CatalogCard.tsx +95 -0
- package/src/Catalog/Filter.tsx +103 -0
- package/src/Catalog/Tags.tsx +36 -0
- package/src/Feedback/ReportDialog.tsx +51 -0
- package/src/Feedback/index.ts +2 -0
- package/src/Feedback/types.ts +5 -3
- package/src/Feedback/useReportDialog.ts +34 -0
- package/src/Markdown/CodeSample/CodeSample.tsx +7 -50
- package/src/Sidebar/ArrowBack.tsx +2 -2
- package/src/Sidebar/MenuGroup.tsx +1 -1
- package/src/Sidebar/Sidebar.tsx +6 -2
- package/src/Sidebar/SidebarLayout.tsx +41 -2
- package/src/TableOfContent/TableOfContent.tsx +1 -1
- package/src/config.ts +2 -2
- package/src/globalStyle.ts +13 -11
- package/src/hooks/useActiveHeading.ts +3 -12
- package/src/hooks/useActiveSectionId.ts +1 -1
- package/src/hooks/useMobileMenu.ts +2 -2
- package/src/mocks/hooks/index.ts +10 -1
- package/src/types/portal/src/shared/types/catalog.d.ts +55 -0
- package/src/ui/Checkbox.tsx +64 -0
- package/src/ui/Highlight.tsx +48 -0
- package/src/ui/Jumbotron.tsx +2 -2
- package/src/ui/darkColors.tsx +4 -2
- package/lib/hooks/useReportDialog.d.ts +0 -1
- package/lib/hooks/useReportDialog.js +0 -16
- package/src/hooks/useReportDialog.ts +0 -14
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const index_js_1 = require("../mocks/hooks/index.js");
|
|
9
|
+
const H2_1 = require("../Typography/H2");
|
|
10
|
+
const H3_1 = require("../Typography/H3");
|
|
11
|
+
const Button_1 = require("../Button/Button");
|
|
12
|
+
const Highlight_1 = require("../ui/Highlight");
|
|
13
|
+
const CatalogCard_1 = require("../Catalog/CatalogCard");
|
|
14
|
+
const Filter_1 = require("../Catalog/Filter");
|
|
15
|
+
const index_1 = require("../mocks/hooks/index");
|
|
16
|
+
function Catalog(props) {
|
|
17
|
+
const { catalogConfig } = props.pageProps;
|
|
18
|
+
const items = (0, index_js_1.usePageSharedData)('catalog');
|
|
19
|
+
const { filterTerm, setFilterTerm, groups, filters } = (0, index_1.useCatalog)(items, catalogConfig);
|
|
20
|
+
const [isFilterPanelFocused, setIsFilterPanelFocused] = react_1.default.useState(false);
|
|
21
|
+
return (react_1.default.createElement(Highlight_1.HighlightContext.Provider, { value: [filterTerm] },
|
|
22
|
+
react_1.default.createElement(CatalogPageWrapper, null,
|
|
23
|
+
react_1.default.createElement(CatalogPageSidebar, { isActiveInMobileMode: isFilterPanelFocused },
|
|
24
|
+
react_1.default.createElement(StyledInput, { placeholder: "Filter...", value: filterTerm, onFocus: () => setIsFilterPanelFocused(true), onChange: (e) => setFilterTerm(e.target.value) }),
|
|
25
|
+
filters.map((filter, idx) => (react_1.default.createElement(Filter_1.Filter, { filter: filter, key: filter.property + '-' + idx }))),
|
|
26
|
+
react_1.default.createElement(MobileStickyApplyFilters, null,
|
|
27
|
+
react_1.default.createElement(Button_1.Button, { color: "secondary", onClick: () => setIsFilterPanelFocused(false) }, "Apply filters"))),
|
|
28
|
+
react_1.default.createElement(CatalogPageContent, null,
|
|
29
|
+
catalogConfig.title ? react_1.default.createElement(CatalogTitle, null,
|
|
30
|
+
" ",
|
|
31
|
+
catalogConfig.title,
|
|
32
|
+
" ") : null,
|
|
33
|
+
catalogConfig.description ? (react_1.default.createElement(CatalogDescription, null,
|
|
34
|
+
" ",
|
|
35
|
+
catalogConfig.description,
|
|
36
|
+
" ")) : null,
|
|
37
|
+
groups.map((group) => (react_1.default.createElement(react_1.default.Fragment, { key: group.title },
|
|
38
|
+
react_1.default.createElement(H3_1.H3, null,
|
|
39
|
+
group.title,
|
|
40
|
+
" (",
|
|
41
|
+
group.items.length,
|
|
42
|
+
")"),
|
|
43
|
+
react_1.default.createElement(CatalogCards, null, group.items.map((item) => (react_1.default.createElement(CatalogCard_1.CatalogCard, { item: item, key: item.link })))))))))));
|
|
44
|
+
}
|
|
45
|
+
exports.default = Catalog;
|
|
46
|
+
const MobileStickyApplyFilters = styled_components_1.default.div `
|
|
47
|
+
position: fixed;
|
|
48
|
+
display: none;
|
|
49
|
+
background-color: var(--sidebar-background-color);
|
|
50
|
+
bottom: 0;
|
|
51
|
+
padding: 16px 30px;
|
|
52
|
+
left: 0px;
|
|
53
|
+
right: 0px;
|
|
54
|
+
|
|
55
|
+
${Button_1.Button} {
|
|
56
|
+
width: 100%;
|
|
57
|
+
margin: 0;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const CatalogPageSidebar = styled_components_1.default.aside `
|
|
61
|
+
width: var(--sidebar-width);
|
|
62
|
+
border-right: 1px solid var(--sidebar-border-color);
|
|
63
|
+
padding: 20px 30px;
|
|
64
|
+
position: sticky;
|
|
65
|
+
top: var(--navbar-height);
|
|
66
|
+
height: calc(100vh - var(--navbar-height));
|
|
67
|
+
overflow: auto;
|
|
68
|
+
|
|
69
|
+
@media screen and (max-width: 767px) {
|
|
70
|
+
transition: height 0.2s ease-in-out;
|
|
71
|
+
width: 100%;
|
|
72
|
+
${({ isActiveInMobileMode }) => isActiveInMobileMode ? 'padding-bottom: 66px;' : 'height: 76px;'};
|
|
73
|
+
background-color: var(--sidebar-background-color);
|
|
74
|
+
border-bottom: 1px solid var(--sidebar-border-color);
|
|
75
|
+
z-index: 100;
|
|
76
|
+
|
|
77
|
+
${MobileStickyApplyFilters} {
|
|
78
|
+
display: ${({ isActiveInMobileMode }) => (isActiveInMobileMode ? 'block' : 'none')};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
const CatalogPageContent = styled_components_1.default.main `
|
|
83
|
+
flex: 1;
|
|
84
|
+
padding: 32px;
|
|
85
|
+
`;
|
|
86
|
+
const CatalogCards = styled_components_1.default.div `
|
|
87
|
+
display: grid;
|
|
88
|
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
89
|
+
gap: 32px;
|
|
90
|
+
`;
|
|
91
|
+
const CatalogTitle = (0, styled_components_1.default)(H2_1.H2) `
|
|
92
|
+
&& {
|
|
93
|
+
margin: 0;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
const CatalogDescription = styled_components_1.default.p `
|
|
97
|
+
margin: 16px 0 32px 0;
|
|
98
|
+
font-size: 16px;
|
|
99
|
+
color: var(--text-color-secondary);
|
|
100
|
+
`;
|
|
101
|
+
const CatalogPageWrapper = styled_components_1.default.div `
|
|
102
|
+
--sidebar-width: var(--catalog-sidebar-width, 300px);
|
|
103
|
+
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: row;
|
|
106
|
+
|
|
107
|
+
font-weight: var(--font-weight-regular);
|
|
108
|
+
padding: 0;
|
|
109
|
+
|
|
110
|
+
color: var(--text-color);
|
|
111
|
+
font-size: var(--font-size-base);
|
|
112
|
+
font-family: var(--font-family-base);
|
|
113
|
+
line-height: var(--line-height-base);
|
|
114
|
+
|
|
115
|
+
hr {
|
|
116
|
+
border: 0;
|
|
117
|
+
width: calc(100% + 48px);
|
|
118
|
+
margin: auto -24px 0 -24px;
|
|
119
|
+
border-top: 1px solid var(--border-color);
|
|
120
|
+
}
|
|
121
|
+
a:not([role='button']) {
|
|
122
|
+
text-decoration: none;
|
|
123
|
+
color: var(--link-text-color);
|
|
124
|
+
font-weight: var(--link-font-weight);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@media screen and (max-width: 767px) {
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
// TODO: merge this input with the input from reference docs
|
|
132
|
+
// the on in ref docs is dark, needs separate variables most likely
|
|
133
|
+
const StyledInput = styled_components_1.default.input `
|
|
134
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
135
|
+
min-width: 200px;
|
|
136
|
+
outline-color: var(--color-primary-500);
|
|
137
|
+
width: 100%;
|
|
138
|
+
|
|
139
|
+
outline: none;
|
|
140
|
+
padding: var(--input-padding);
|
|
141
|
+
border-radius: var(--input-border-radius);
|
|
142
|
+
background-color: var(--input-background-color);
|
|
143
|
+
color: var(--text-color);
|
|
144
|
+
font-family: var(--input-font-family);
|
|
145
|
+
font-size: var(--input-font-size);
|
|
146
|
+
line-height: var(--input-line-height);
|
|
147
|
+
|
|
148
|
+
&::placeholder {
|
|
149
|
+
opacity: 0.6;
|
|
150
|
+
color: var(--text-color);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&:hover {
|
|
154
|
+
color: var(--text-color);
|
|
155
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:focus {
|
|
159
|
+
color: var(--text-color);
|
|
160
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&:-webkit-autofill {
|
|
164
|
+
background-color: var(--input-background-color);
|
|
165
|
+
}
|
|
166
|
+
`;
|
|
167
|
+
//# sourceMappingURL=Catalog.js.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CatalogCard = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const Link_1 = require("../mocks/Link");
|
|
33
|
+
const Highlight_1 = require("../ui/Highlight");
|
|
34
|
+
const Tags_1 = require("../Catalog/Tags");
|
|
35
|
+
function CatalogCard({ item }) {
|
|
36
|
+
var _a;
|
|
37
|
+
return (React.createElement(Link_1.Link, { key: item.docsLink || item.link, to: item.docsLink || item.link },
|
|
38
|
+
React.createElement(StyledCard, null,
|
|
39
|
+
React.createElement(CardTitle, null,
|
|
40
|
+
React.createElement(Highlight_1.Highlight, null, item.title)),
|
|
41
|
+
React.createElement(CardDescription, null,
|
|
42
|
+
React.createElement(Highlight_1.Highlight, null, (_a = item.description) !== null && _a !== void 0 ? _a : '')),
|
|
43
|
+
item.tags ? React.createElement(Tags_1.Tags, { tags: item.tags }) : null,
|
|
44
|
+
React.createElement("hr", null),
|
|
45
|
+
React.createElement(CardFooter, null, "View documentation"))));
|
|
46
|
+
}
|
|
47
|
+
exports.CatalogCard = CatalogCard;
|
|
48
|
+
const StyledCard = styled_components_1.default.div `
|
|
49
|
+
min-height: 268px;
|
|
50
|
+
height: 100%;
|
|
51
|
+
box-shadow: var(--box-shadow);
|
|
52
|
+
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
|
|
56
|
+
color: var(--text-color);
|
|
57
|
+
background-color: var(--thin-tile-background-color);
|
|
58
|
+
border-radius: 4px;
|
|
59
|
+
|
|
60
|
+
border: 1px solid var(--border-color);
|
|
61
|
+
box-shadow: 0px 0px 10px 0px rgba(35, 35, 35, 0.05);
|
|
62
|
+
transition: all 0.2s ease-in-out;
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
/* box-shadow: 0px 12px 30px 0px rgba(35, 35, 35, 0.2); */
|
|
66
|
+
box-shadow: 0px 10px 30px 0px rgba(35, 35, 35, 0.1);
|
|
67
|
+
border: 1px solid var(--border-color);
|
|
68
|
+
transform: translateY(-2px);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
width: 100%;
|
|
73
|
+
padding: 24px 24px 0;
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
`;
|
|
78
|
+
const CardTitle = styled_components_1.default.h4 `
|
|
79
|
+
line-height: 26px;
|
|
80
|
+
letter-spacing: 0.8px;
|
|
81
|
+
font-size: 20px;
|
|
82
|
+
font-weight: var(--font-weight-bold);
|
|
83
|
+
margin: 0;
|
|
84
|
+
margin-bottom: 16px;
|
|
85
|
+
`;
|
|
86
|
+
const CardDescription = styled_components_1.default.div `
|
|
87
|
+
display: -webkit-box;
|
|
88
|
+
-webkit-line-clamp: 3;
|
|
89
|
+
-webkit-box-orient: vertical;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
text-overflow: ellipsis;
|
|
92
|
+
line-height: var(--line-height);
|
|
93
|
+
letter-spacing: 0px;
|
|
94
|
+
font-size: 16px;
|
|
95
|
+
color: var(--text-color-secondary);
|
|
96
|
+
text-align: inherit;
|
|
97
|
+
font-weight: 400;
|
|
98
|
+
`;
|
|
99
|
+
const CardFooter = styled_components_1.default.div `
|
|
100
|
+
height: 46px;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: flex-start;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
font-weight: var(--font-weight-bold);
|
|
107
|
+
|
|
108
|
+
a:hover & {
|
|
109
|
+
text-decoration: var(--link-hover-text-decoration);
|
|
110
|
+
color: var(--link-hover-text-color);
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
//# sourceMappingURL=CatalogCard.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Filter = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Checkbox_1 = require("../ui/Checkbox");
|
|
10
|
+
function Filter({ filter }) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (!filter.parentUsed)
|
|
13
|
+
return null;
|
|
14
|
+
return (react_1.default.createElement(FilterGroup, { key: filter.property + filter.title },
|
|
15
|
+
react_1.default.createElement(FilterTitle, null,
|
|
16
|
+
filter.title,
|
|
17
|
+
" filter"),
|
|
18
|
+
filter.type === 'select' ? (react_1.default.createElement(StyledSelect, { onChange: (e) => filter.selectOption(e.target.value), value: ((_a = filter.selectedOptions.values().next()) === null || _a === void 0 ? void 0 : _a.value) || '' },
|
|
19
|
+
react_1.default.createElement("option", { key: "none", value: "" }, "All"),
|
|
20
|
+
filter.filteredOptions.map((value) => (react_1.default.createElement("option", { key: value.value, value: value.value },
|
|
21
|
+
value.value,
|
|
22
|
+
" (",
|
|
23
|
+
value.count,
|
|
24
|
+
")"))))) : (filter.filteredOptions.map((value) => {
|
|
25
|
+
const id = 'filter--' + filter.property + '--' + slug(value.value);
|
|
26
|
+
return (react_1.default.createElement(FilterValue, { key: id },
|
|
27
|
+
react_1.default.createElement(Checkbox_1.Checkbox, { type: "checkbox", id: id, checked: filter.selectedOptions.has(value.value), onChange: () => filter.toggleOption(value.value) }),
|
|
28
|
+
react_1.default.createElement("label", { htmlFor: id },
|
|
29
|
+
value.value,
|
|
30
|
+
" (",
|
|
31
|
+
value.count,
|
|
32
|
+
")")));
|
|
33
|
+
}))));
|
|
34
|
+
}
|
|
35
|
+
exports.Filter = Filter;
|
|
36
|
+
const FilterGroup = styled_components_1.default.div `
|
|
37
|
+
padding: 16px 0;
|
|
38
|
+
border-bottom: 1px solid var(--border-color);
|
|
39
|
+
|
|
40
|
+
&:last-of-type {
|
|
41
|
+
border-bottom: none;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const FilterTitle = styled_components_1.default.h4 `
|
|
45
|
+
font-size: 18px;
|
|
46
|
+
font-weight: var(--font-weight-bold);
|
|
47
|
+
margin: 0;
|
|
48
|
+
margin-bottom: 16px;
|
|
49
|
+
`;
|
|
50
|
+
const FilterValue = styled_components_1.default.label `
|
|
51
|
+
display: block;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
font-size: 16px;
|
|
54
|
+
margin: 8px 0;
|
|
55
|
+
|
|
56
|
+
input {
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const StyledSelect = styled_components_1.default.select `
|
|
61
|
+
border: 1px solid rgba(0, 0, 0, 0.23);
|
|
62
|
+
|
|
63
|
+
padding: var(--input-padding);
|
|
64
|
+
border-radius: var(--input-border-radius);
|
|
65
|
+
background-color: var(--input-background-color);
|
|
66
|
+
color: var(--text-color);
|
|
67
|
+
font-family: var(--input-font-family);
|
|
68
|
+
font-size: var(--input-font-size);
|
|
69
|
+
line-height: var(--input-line-height);
|
|
70
|
+
|
|
71
|
+
min-width: 200px;
|
|
72
|
+
outline-color: var(--color-primary-500);
|
|
73
|
+
transition: outline 0.25s ease;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
text-align: left;
|
|
76
|
+
appearance: none;
|
|
77
|
+
|
|
78
|
+
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");
|
|
79
|
+
background-repeat: no-repeat;
|
|
80
|
+
background-position: right 10px center;
|
|
81
|
+
background-size: 1em;
|
|
82
|
+
width: 100%;
|
|
83
|
+
`;
|
|
84
|
+
// TODO: import from portal
|
|
85
|
+
function slug(str) {
|
|
86
|
+
return str.replace(/\s/g, '-').toLowerCase();
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=Filter.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Tags = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Highlight_1 = require("../ui/Highlight");
|
|
10
|
+
function Tags({ tags }) {
|
|
11
|
+
return (react_1.default.createElement(TagsWrapper, null, tags.map((tag) => (react_1.default.createElement(Tag, { key: tag, className: 'tag-' + slug(tag) },
|
|
12
|
+
react_1.default.createElement(Highlight_1.Highlight, null, tag))))));
|
|
13
|
+
}
|
|
14
|
+
exports.Tags = Tags;
|
|
15
|
+
const TagsWrapper = styled_components_1.default.div `
|
|
16
|
+
margin-top: 16px;
|
|
17
|
+
`;
|
|
18
|
+
const Tag = styled_components_1.default.div `
|
|
19
|
+
display: inline-block;
|
|
20
|
+
background-color: #d3f4ef;
|
|
21
|
+
color: #000;
|
|
22
|
+
padding: 2px 5px;
|
|
23
|
+
border-radius: var(--border-radius);
|
|
24
|
+
margin-right: 5px;
|
|
25
|
+
margin-bottom: 5px;
|
|
26
|
+
font-size: 0.8em;
|
|
27
|
+
`;
|
|
28
|
+
// TODO: import from portal
|
|
29
|
+
function slug(str) {
|
|
30
|
+
return str.replace(/\s/g, '-').toLowerCase();
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Tags.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ReportDialog = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const Comment_1 = require("../Feedback/Comment");
|
|
33
|
+
const useSubmitFeedback_1 = require("../mocks/Feedback/useSubmitFeedback");
|
|
34
|
+
const ReportDialog = ({ location, settings, onSubmit, onCancel, }) => {
|
|
35
|
+
const { label } = settings;
|
|
36
|
+
const { submitFeedback } = (0, useSubmitFeedback_1.useSubmitFeedback)();
|
|
37
|
+
return (React.createElement(Wrapper, { className: "modal" },
|
|
38
|
+
React.createElement(Comment_1.Comment, { settings: { label, onCancel }, onSubmit: (value) => {
|
|
39
|
+
submitFeedback('problem', Object.assign(Object.assign({}, value), { location }));
|
|
40
|
+
onSubmit();
|
|
41
|
+
} })));
|
|
42
|
+
};
|
|
43
|
+
exports.ReportDialog = ReportDialog;
|
|
44
|
+
const Wrapper = styled_components_1.default.div `
|
|
45
|
+
font-family: var(--font-family-base);
|
|
46
|
+
position: fixed;
|
|
47
|
+
top: 0;
|
|
48
|
+
left: 0;
|
|
49
|
+
width: 100vw;
|
|
50
|
+
height: 100vh;
|
|
51
|
+
background: var(--modal-overlay-background-color);
|
|
52
|
+
z-index: 10000;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
|
|
57
|
+
& > * {
|
|
58
|
+
background: var(--modal-background-color);
|
|
59
|
+
box-shadow: var(--modal-box-shadow);
|
|
60
|
+
padding: 15px;
|
|
61
|
+
margin: 15px;
|
|
62
|
+
max-width: 500px;
|
|
63
|
+
max-height: 300px;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
//# sourceMappingURL=ReportDialog.js.map
|
package/lib/Feedback/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export { Rating } from '../Feedback/Rating';
|
|
|
2
2
|
export { Sentiment } from '../Feedback/Sentiment';
|
|
3
3
|
export { Comment } from '../Feedback/Comment';
|
|
4
4
|
export { Reasons } from '../Feedback/Reasons';
|
|
5
|
+
export { ReportDialog } from '../Feedback/ReportDialog';
|
|
6
|
+
export { useReportDialog } from '../Feedback/useReportDialog';
|
|
5
7
|
export * from './types';
|
package/lib/Feedback/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Reasons = exports.Comment = exports.Sentiment = exports.Rating = void 0;
|
|
17
|
+
exports.useReportDialog = exports.ReportDialog = exports.Reasons = exports.Comment = exports.Sentiment = exports.Rating = void 0;
|
|
18
18
|
var Rating_1 = require("../Feedback/Rating");
|
|
19
19
|
Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return Rating_1.Rating; } });
|
|
20
20
|
var Sentiment_1 = require("../Feedback/Sentiment");
|
|
@@ -23,5 +23,9 @@ var Comment_1 = require("../Feedback/Comment");
|
|
|
23
23
|
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return Comment_1.Comment; } });
|
|
24
24
|
var Reasons_1 = require("../Feedback/Reasons");
|
|
25
25
|
Object.defineProperty(exports, "Reasons", { enumerable: true, get: function () { return Reasons_1.Reasons; } });
|
|
26
|
+
var ReportDialog_1 = require("../Feedback/ReportDialog");
|
|
27
|
+
Object.defineProperty(exports, "ReportDialog", { enumerable: true, get: function () { return ReportDialog_1.ReportDialog; } });
|
|
28
|
+
var useReportDialog_1 = require("../Feedback/useReportDialog");
|
|
29
|
+
Object.defineProperty(exports, "useReportDialog", { enumerable: true, get: function () { return useReportDialog_1.useReportDialog; } });
|
|
26
30
|
__exportStar(require("./types"), exports);
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
package/lib/Feedback/types.d.ts
CHANGED
|
@@ -64,9 +64,11 @@ export type ReasonsProps = {
|
|
|
64
64
|
buttonText?: string;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
export type
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
export type ReportDialogProps = {
|
|
68
|
+
location: string;
|
|
69
|
+
onSubmit: () => void;
|
|
70
|
+
onCancel: () => void;
|
|
71
|
+
settings: {
|
|
70
72
|
label?: string;
|
|
71
73
|
};
|
|
72
74
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useReportDialog = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useReportDialog(reportSettings) {
|
|
6
|
+
const [isReportDialogShown, setIsReportDialogShown] = (0, react_1.useState)(false);
|
|
7
|
+
const isReportButtonShown = reportSettings.hide === false; // TODO: report temporary disabled by default
|
|
8
|
+
const showReportDialog = () => {
|
|
9
|
+
setIsReportDialogShown(true);
|
|
10
|
+
};
|
|
11
|
+
const hideReportDialog = () => {
|
|
12
|
+
setIsReportDialogShown(false);
|
|
13
|
+
};
|
|
14
|
+
const reportButtonProps = {
|
|
15
|
+
onClick: showReportDialog,
|
|
16
|
+
title: reportSettings.tooltipText || 'Report a problem',
|
|
17
|
+
};
|
|
18
|
+
const reportDialogProps = {
|
|
19
|
+
settings: {
|
|
20
|
+
label: reportSettings.label || 'What is wrong with a code?',
|
|
21
|
+
},
|
|
22
|
+
onSubmit: hideReportDialog,
|
|
23
|
+
onCancel: hideReportDialog,
|
|
24
|
+
};
|
|
25
|
+
return { isReportDialogShown, isReportButtonShown, reportButtonProps, reportDialogProps };
|
|
26
|
+
}
|
|
27
|
+
exports.useReportDialog = useReportDialog;
|
|
28
|
+
//# sourceMappingURL=useReportDialog.js.map
|
|
@@ -29,35 +29,23 @@ const styled_components_1 = __importStar(require("styled-components"));
|
|
|
29
29
|
const ClipboardService_1 = require("../../utils/ClipboardService");
|
|
30
30
|
const useThemeConfig_1 = require("../../hooks/useThemeConfig");
|
|
31
31
|
const Feedback_1 = require("../../Feedback");
|
|
32
|
-
const useSubmitFeedback_1 = require("../../mocks/Feedback/useSubmitFeedback");
|
|
33
|
-
const useReportDialog_1 = require("../../hooks/useReportDialog");
|
|
34
32
|
function CodeSample({ rawContent, highlighted, language }) {
|
|
35
33
|
const langClassName = language ? `language-${language}` : '';
|
|
36
|
-
const { codeSnippet: { copy = {}, report = {
|
|
37
|
-
const { submitFeedback } = (0, useSubmitFeedback_1.useSubmitFeedback)();
|
|
34
|
+
const { codeSnippet: { copy = {}, report = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
38
35
|
const [isCopied, setIsCopied] = (0, react_1.useState)(false);
|
|
39
|
-
const
|
|
36
|
+
const { isReportDialogShown, isReportButtonShown, reportButtonProps, reportDialogProps } = (0, Feedback_1.useReportDialog)(report);
|
|
40
37
|
const copyCode = (code) => {
|
|
41
38
|
ClipboardService_1.ClipboardService.copyCustom(code);
|
|
42
39
|
setIsCopied(true);
|
|
43
|
-
setTimeout(() => setIsCopied(false), copy.toasterDuration ||
|
|
40
|
+
setTimeout(() => setIsCopied(false), copy.toasterDuration || 1500);
|
|
44
41
|
};
|
|
45
42
|
return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" },
|
|
46
43
|
react_1.default.createElement(CodeSampleButtonContainer, null,
|
|
47
44
|
!copy.hide && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
48
45
|
!isCopied && (react_1.default.createElement(Button, { onClick: () => copyCode(rawContent), title: copy.tooltipText || 'Copy to clipboard' }, copy.buttonText || 'Copy')),
|
|
49
46
|
isCopied && react_1.default.createElement(DoneIndicator, null, copy.toasterText || 'Copied!'))),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
react_1.default.createElement(Feedback_1.Comment, { settings: {
|
|
53
|
-
label: report.label || 'What is wrong with a code?',
|
|
54
|
-
onCancel: () => {
|
|
55
|
-
hideDialog();
|
|
56
|
-
},
|
|
57
|
-
}, onSubmit: (value) => {
|
|
58
|
-
submitFeedback('problem', Object.assign(Object.assign({}, value), { location: rawContent }));
|
|
59
|
-
hideDialog();
|
|
60
|
-
} })))),
|
|
47
|
+
isReportButtonShown && react_1.default.createElement(Button, Object.assign({}, reportButtonProps), "Report"),
|
|
48
|
+
isReportDialogShown && react_1.default.createElement(Feedback_1.ReportDialog, Object.assign({}, reportDialogProps, { location: rawContent }))),
|
|
61
49
|
react_1.default.createElement("pre", { className: langClassName },
|
|
62
50
|
react_1.default.createElement("code", { className: langClassName, dangerouslySetInnerHTML: { __html: highlighted } }))));
|
|
63
51
|
}
|
|
@@ -226,25 +214,4 @@ const Wrapper = styled_components_1.default.div `
|
|
|
226
214
|
${darkStyleTokens};
|
|
227
215
|
}
|
|
228
216
|
`;
|
|
229
|
-
const ReportDialog = styled_components_1.default.div `
|
|
230
|
-
position: fixed;
|
|
231
|
-
top: 0;
|
|
232
|
-
left: 0;
|
|
233
|
-
width: 100vw;
|
|
234
|
-
height: 100vh;
|
|
235
|
-
background: var(--modal-overlay-background-color);
|
|
236
|
-
z-index: 10000;
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
justify-content: center;
|
|
240
|
-
|
|
241
|
-
& > * {
|
|
242
|
-
background: var(--modal-background-color);
|
|
243
|
-
box-shadow: var(--modal-box-shadow);
|
|
244
|
-
padding: 15px;
|
|
245
|
-
margin: 15px;
|
|
246
|
-
max-width: 500px;
|
|
247
|
-
max-height: 300px;
|
|
248
|
-
}
|
|
249
|
-
`;
|
|
250
217
|
//# sourceMappingURL=CodeSample.js.map
|
package/lib/Sidebar/ArrowBack.js
CHANGED
|
@@ -7,12 +7,12 @@ exports.ArrowBack = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const Arrow = ({ className }) => (react_1.default.createElement("span", { "data-component-name": "Sidebar/ArrowBack" },
|
|
10
|
-
react_1.default.createElement("svg", { fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 10", width: "
|
|
10
|
+
react_1.default.createElement("svg", { fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 10", width: "10px", height: "10px", className: className },
|
|
11
11
|
react_1.default.createElement("path", { d: "M2.414 5l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L2.414 5z" }),
|
|
12
12
|
react_1.default.createElement("path", { d: "M2 5a1 1 0 011-1h8a1 1 0 110 2H3a1 1 0 01-1-1z" }))));
|
|
13
13
|
exports.ArrowBack = (0, styled_components_1.default)(Arrow) `
|
|
14
14
|
fill: var(--sidebar-back-button-icon-color);
|
|
15
|
-
margin-right: calc(var(--sidebar-spacing-unit)
|
|
15
|
+
margin-right: calc(var(--sidebar-spacing-unit));
|
|
16
16
|
|
|
17
17
|
background-image: var(--sidebar-back-button-icon);
|
|
18
18
|
background-repeat: no-repeat;
|