@redocly/theme 0.6.4 → 0.6.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 (47) hide show
  1. package/lib/Feedback/Rating.d.ts +3 -0
  2. package/lib/Feedback/Rating.js +69 -0
  3. package/lib/Feedback/Sentiment.d.ts +3 -0
  4. package/lib/Feedback/Sentiment.js +55 -0
  5. package/lib/Feedback/Thumbs.d.ts +7 -0
  6. package/lib/Feedback/Thumbs.js +79 -0
  7. package/lib/Feedback/index.d.ts +3 -0
  8. package/lib/Feedback/index.js +23 -0
  9. package/lib/Feedback/types.d.ts +26 -0
  10. package/lib/Feedback/types.js +3 -0
  11. package/lib/Markdown/MarkdownLayout.d.ts +2 -1
  12. package/lib/Markdown/MarkdownLayout.js +8 -2
  13. package/lib/Navbar/Navbar.js +3 -2
  14. package/lib/Profile/LoginLink.d.ts +5 -0
  15. package/lib/Profile/LoginLink.js +30 -0
  16. package/lib/Profile/Profile.js +3 -1
  17. package/lib/Profile/UserProfile.d.ts +13 -0
  18. package/lib/Profile/UserProfile.js +82 -0
  19. package/lib/Profile/index.d.ts +4 -0
  20. package/lib/Profile/index.js +5 -1
  21. package/lib/config.d.ts +53 -0
  22. package/lib/config.js +18 -0
  23. package/lib/globalStyle.js +4 -0
  24. package/lib/index.d.ts +1 -0
  25. package/lib/index.js +1 -0
  26. package/lib/mocks/hooks/index.js +6 -0
  27. package/lib/ui/Box.d.ts +2 -2
  28. package/lib/ui/Box.js +1 -0
  29. package/package.json +2 -2
  30. package/src/Feedback/Rating.tsx +79 -0
  31. package/src/Feedback/Sentiment.tsx +36 -0
  32. package/src/Feedback/Thumbs.tsx +116 -0
  33. package/src/Feedback/index.ts +3 -0
  34. package/src/Feedback/types.ts +29 -0
  35. package/src/Markdown/MarkdownLayout.tsx +10 -1
  36. package/src/Navbar/Navbar.tsx +3 -2
  37. package/src/Profile/LoginLink.tsx +29 -0
  38. package/src/Profile/Profile.tsx +3 -1
  39. package/src/Profile/UserProfile.tsx +101 -0
  40. package/src/Profile/index.ts +4 -0
  41. package/src/config.ts +19 -0
  42. package/src/globalStyle.ts +5 -0
  43. package/src/index.ts +1 -0
  44. package/src/mocks/hooks/index.ts +6 -0
  45. package/src/settings.yaml +2 -0
  46. package/src/types/portal/index.d.ts +1 -1
  47. package/src/ui/Box.tsx +5 -2
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { RatingProps } from '../Feedback';
3
+ export declare const Rating: ({ settings, onSubmit }: RatingProps) => JSX.Element;
@@ -0,0 +1,69 @@
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.Rating = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Rating = ({ settings, onSubmit }) => {
33
+ const { label, max, submitText } = settings || {};
34
+ const [submitValue, setSubmitValue] = React.useState(0);
35
+ if (submitValue) {
36
+ return (React.createElement(RatingWidget, null,
37
+ React.createElement(Label, null, submitText || 'Thank you for helping improve our documentation!')));
38
+ }
39
+ return (React.createElement(RatingWidget, null,
40
+ React.createElement(Label, null, label || 'How helpful was this page?'),
41
+ React.createElement(Stars, { max: max || 5, onSubmit: (value) => {
42
+ setSubmitValue(value);
43
+ onSubmit(value);
44
+ } })));
45
+ };
46
+ exports.Rating = Rating;
47
+ const Stars = ({ max, onSubmit }) => {
48
+ const [hovered, setHovered] = React.useState(0);
49
+ const stars = [];
50
+ for (let index = 1; index <= max; index++) {
51
+ stars.push(React.createElement(Star, { key: index, onClick: () => onSubmit(index), onMouseOver: () => setHovered(index), onMouseLeave: () => setHovered(0) },
52
+ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20" }, hovered < index ? (React.createElement("g", { fill: "#e8c002" },
53
+ React.createElement("path", { d: "M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7zm-10 6.9-3.76 2.27 1-4.28L3.5 8.5h4.61L10 4.6l1.9 3.9h4.6l-3.73 3.4 1 4.28z" }))) : (React.createElement("g", { fill: "#e8c002" },
54
+ React.createElement("path", { d: "M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7z" }))))));
55
+ }
56
+ return React.createElement(React.Fragment, null, stars);
57
+ };
58
+ const RatingWidget = styled_components_1.default.div `
59
+ display: flex;
60
+ align-items: center;
61
+ `;
62
+ const Star = styled_components_1.default.span `
63
+ cursor: pointer;
64
+ `;
65
+ const Label = styled_components_1.default.h3 `
66
+ margin-right: 15px;
67
+ font-family: var(--font-family-base);
68
+ `;
69
+ //# sourceMappingURL=Rating.js.map
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { SentimentProps } from '../Feedback';
3
+ export declare const Sentiment: ({ settings, onSubmit }: SentimentProps) => JSX.Element;
@@ -0,0 +1,55 @@
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.Sentiment = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Thumbs_1 = require("./Thumbs");
33
+ const Sentiment = ({ settings, onSubmit }) => {
34
+ const { label } = settings || {};
35
+ return (React.createElement(Wrapper, null,
36
+ React.createElement(Label, null, label || 'Was this page helpful?'),
37
+ React.createElement(Vote, { onClick: () => onSubmit(1) },
38
+ React.createElement(Thumbs_1.ThumbUp, { text: "Yes" })),
39
+ React.createElement(Vote, { onClick: () => onSubmit(-1) },
40
+ React.createElement(Thumbs_1.ThumbDown, null))));
41
+ };
42
+ exports.Sentiment = Sentiment;
43
+ const Wrapper = styled_components_1.default.div `
44
+ font-family: var(--font-family-base);
45
+ display: flex;
46
+ align-items: center;
47
+ `;
48
+ const Label = styled_components_1.default.h3 `
49
+ margin-right: 15px;
50
+ `;
51
+ const Vote = styled_components_1.default.div `
52
+ cursor: pointer;
53
+ margin: 0 10px;
54
+ `;
55
+ //# sourceMappingURL=Sentiment.js.map
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const ThumbUp: ({ text }: {
3
+ text?: string | undefined;
4
+ }) => JSX.Element;
5
+ export declare const ThumbDown: ({ text }: {
6
+ text?: string | undefined;
7
+ }) => JSX.Element;
@@ -0,0 +1,79 @@
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.ThumbDown = exports.ThumbUp = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const ThumbUp = ({ text }) => (React.createElement(Wrapper, { style: { alignItems: 'normal' } },
33
+ React.createElement(Icon, null,
34
+ React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 512 512" },
35
+ React.createElement("g", null,
36
+ React.createElement("g", null,
37
+ React.createElement("g", null,
38
+ React.createElement("path", { d: "M495.736,290.773C509.397,282.317,512,269.397,512,260.796c0-22.4-18.253-47.462-42.667-47.462H349.918\n c-4.284-0.051-25.651-1.51-25.651-25.6c0-4.71-3.814-8.533-8.533-8.533s-8.533,3.823-8.533,8.533\n c0,33.749,27.913,42.667,42.667,42.667h119.467c14.182,0,25.6,16.631,25.6,30.396c0,4.437,0,17.946-26.53,20.855\n c-4.506,0.495-7.834,4.42-7.586,8.951c0.239,4.523,3.985,8.064,8.516,8.064c14.114,0,25.6,11.486,25.6,25.6\n s-11.486,25.6-25.6,25.6h-17.067c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c14.114,0,25.6,11.486,25.6,25.6\n s-11.486,25.6-25.6,25.6h-25.6c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c8.934,0,17.067,8.132,17.067,17.067\n c0,8.61-8.448,17.067-17.067,17.067h-128c-35.627,0-48.444-7.074-63.292-15.258c-12.553-6.921-26.786-14.763-54.963-18.79\n c-4.668-0.674-8.994,2.577-9.66,7.236c-0.666,4.668,2.569,8.994,7.236,9.66c25.105,3.584,37.325,10.325,49.152,16.845\n c15.497,8.542,31.505,17.374,71.526,17.374h128c17.869,0,34.133-16.273,34.133-34.133c0-6.229-1.775-12.134-4.83-17.229\n c21.794-1.877,38.963-20.224,38.963-42.505c0-10.829-4.062-20.736-10.735-28.271C500.42,358.212,512,342.571,512,324.267\n C512,310.699,505.634,298.59,495.736,290.773z" }),
39
+ React.createElement("path", { d: "M76.8,443.733c9.412,0,17.067-7.654,17.067-17.067S86.212,409.6,76.8,409.6c-9.412,0-17.067,7.654-17.067,17.067\n S67.388,443.733,76.8,443.733z" }),
40
+ React.createElement("path", { d: "M179.2,247.467c25.353,0,57.429-28.297,74.3-45.167c36.634-36.634,36.634-82.167,36.634-151.1\n c0-5.342,3.191-8.533,8.533-8.533c29.508,0,42.667,13.158,42.667,42.667v102.4c0,4.71,3.814,8.533,8.533,8.533\n s8.533-3.823,8.533-8.533v-102.4c0-39.083-20.659-59.733-59.733-59.733c-14.831,0-25.6,10.769-25.6,25.6\n c0,66.978,0,107.401-31.633,139.034C216.661,215.006,192.811,230.4,179.2,230.4c-4.719,0-8.533,3.823-8.533,8.533\n S174.481,247.467,179.2,247.467z" }),
41
+ React.createElement("path", { d: "M145.067,213.333H8.533c-4.719,0-8.533,3.823-8.533,8.533v256c0,4.71,3.814,8.533,8.533,8.533h136.533\n c4.719,0,8.533-3.823,8.533-8.533v-256C153.6,217.156,149.786,213.333,145.067,213.333z M136.533,469.333H17.067V230.4h119.467\n V469.333z" })))))),
42
+ React.createElement("span", null, text || 'Yes')));
43
+ exports.ThumbUp = ThumbUp;
44
+ const ThumbDown = ({ text }) => (React.createElement(Wrapper, { style: { alignItems: 'end' } },
45
+ React.createElement(Icon, null,
46
+ React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 512 512" },
47
+ React.createElement("g", null,
48
+ React.createElement("g", null,
49
+ React.createElement("g", null,
50
+ React.createElement("path", { d: "M76.8,247.467c9.412,0,17.067-7.654,17.067-17.067c0-9.412-7.654-17.067-17.067-17.067\n\t\t\t\tc-9.412,0-17.067,7.654-17.067,17.067C59.733,239.812,67.388,247.467,76.8,247.467z" }),
51
+ React.createElement("path", { d: "M495.736,221.227C505.634,213.41,512,201.301,512,187.733c0-18.295-11.58-33.946-27.802-39.996\n\t\t\t\tc6.673-7.535,10.735-17.434,10.735-28.271c0-22.281-17.169-40.627-38.963-42.505c3.055-5.094,4.83-10.999,4.83-17.229\n\t\t\t\tc0-17.86-16.265-34.133-34.133-34.133h-128c-40.021,0-56.03,8.832-71.526,17.374c-11.827,6.519-24.047,13.261-49.152,16.845\n\t\t\t\tc-4.668,0.666-7.902,4.992-7.236,9.66c0.666,4.659,4.949,7.885,9.66,7.236c28.177-4.028,42.411-11.87,54.963-18.79\n\t\t\t\tc14.848-8.183,27.665-15.258,63.292-15.258h128c8.619,0,17.067,8.456,17.067,17.067c0,8.934-8.132,17.067-17.067,17.067\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533h25.6c14.114,0,25.6,11.486,25.6,25.6s-11.486,25.6-25.6,25.6\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533c0,4.71,3.814,8.533,8.533,8.533h17.067c14.114,0,25.6,11.486,25.6,25.6\n\t\t\t\ts-11.486,25.6-25.6,25.6c-4.531,0-8.277,3.541-8.516,8.064c-0.247,4.531,3.081,8.457,7.586,8.951\n\t\t\t\tc26.53,2.91,26.53,16.418,26.53,20.847c0,13.773-11.418,30.404-25.6,30.404H349.867c-14.763,0-42.667,8.917-42.667,42.667\n\t\t\t\tc0,4.71,3.814,8.533,8.533,8.533s8.533-3.823,8.533-8.533c0-24.09,21.367-25.549,25.6-25.6h119.467\n\t\t\t\tc24.414,0,42.667-25.054,42.667-47.471C512,242.603,509.397,229.683,495.736,221.227z" }),
52
+ React.createElement("path", { d: "M349.867,315.733c-4.719,0-8.533,3.823-8.533,8.533v102.4c0,29.508-13.158,42.667-42.667,42.667\n\t\t\t\tc-5.342,0-8.533-3.192-8.533-8.533c0-68.932,0-114.466-36.634-151.1c-16.87-16.87-48.947-45.167-74.3-45.167\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c13.611,0,37.461,15.394,62.234,40.166\n\t\t\t\tc31.633,31.633,31.633,72.055,31.633,139.034c0,14.831,10.769,25.6,25.6,25.6c39.074,0,59.733-20.651,59.733-59.733v-102.4\n\t\t\t\tC358.4,319.556,354.586,315.733,349.867,315.733z" }),
53
+ React.createElement("path", { d: "M145.067,25.6H8.533C3.814,25.6,0,29.423,0,34.133v256c0,4.71,3.814,8.533,8.533,8.533h136.533\n\t\t\t\tc4.719,0,8.533-3.823,8.533-8.533v-256C153.6,29.423,149.786,25.6,145.067,25.6z M136.533,281.6H17.067V42.667h119.467V281.6z" })))))),
54
+ React.createElement("span", null, text || 'No')));
55
+ exports.ThumbDown = ThumbDown;
56
+ const Wrapper = styled_components_1.default.div `
57
+ font-family: var(--font-family-base);
58
+ display: flex;
59
+ color: var(--color-primary-500);
60
+ &:hover {
61
+ color: var(--color-primary-600);
62
+ svg {
63
+ > g {
64
+ fill: var(--color-primary-600);
65
+ }
66
+ }
67
+ }
68
+ `;
69
+ const Icon = styled_components_1.default.div `
70
+ width: 18px;
71
+ height: 18px;
72
+ margin-right: 5px;
73
+ > svg {
74
+ > g {
75
+ fill: var(--color-primary-500);
76
+ }
77
+ }
78
+ `;
79
+ //# sourceMappingURL=Thumbs.js.map
@@ -0,0 +1,3 @@
1
+ export { Rating } from './Rating';
2
+ export { Sentiment } from './Sentiment';
3
+ export * from './types';
@@ -0,0 +1,23 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Sentiment = exports.Rating = void 0;
18
+ var Rating_1 = require("./Rating");
19
+ Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return Rating_1.Rating; } });
20
+ var Sentiment_1 = require("./Sentiment");
21
+ Object.defineProperty(exports, "Sentiment", { enumerable: true, get: function () { return Sentiment_1.Sentiment; } });
22
+ __exportStar(require("./types"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,26 @@
1
+ export type RatingProps = {
2
+ onSubmit: (value: number) => void;
3
+ settings?: {
4
+ label?: string;
5
+ max?: number;
6
+ submitText?: string;
7
+ };
8
+ };
9
+ export type SentimentProps = {
10
+ onSubmit: (value: -1 | 1) => void;
11
+ settings?: {
12
+ label?: string;
13
+ };
14
+ };
15
+ export type CommentProps = {
16
+ onSubmit: (value: string) => void;
17
+ settings?: {
18
+ label?: string;
19
+ };
20
+ };
21
+ export type ProblemProps = {
22
+ onSubmit: (value: string, location: string) => void;
23
+ settings?: {
24
+ label?: string;
25
+ };
26
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  type MarkdownLayoutProps = {
3
3
  tableOfContent: React.ReactNode;
4
4
  markdownWrapper: React.ReactNode;
5
+ feedback: React.ReactNode;
5
6
  editPage?: {
6
7
  to: string;
7
8
  text: string;
@@ -10,5 +11,5 @@ type MarkdownLayoutProps = {
10
11
  /** String in ISO format */
11
12
  lastModified?: string | null;
12
13
  };
13
- export declare function MarkdownLayout({ tableOfContent, markdownWrapper, editPage, lastModified, }: MarkdownLayoutProps): JSX.Element;
14
+ export declare function MarkdownLayout({ tableOfContent, markdownWrapper, feedback, editPage, lastModified, }: MarkdownLayoutProps): JSX.Element;
14
15
  export {};
@@ -12,16 +12,17 @@ const PageNavigation_1 = require("../PageNavigation/PageNavigation");
12
12
  const EditPageButton_1 = require("../EditPageButton");
13
13
  const LastUpdated_1 = require("../LastUpdated/LastUpdated");
14
14
  const hooks_1 = require("../hooks");
15
- function MarkdownLayout({ tableOfContent, markdownWrapper, editPage, lastModified, }) {
15
+ function MarkdownLayout({ tableOfContent, markdownWrapper, feedback, editPage, lastModified, }) {
16
16
  const { markdown } = (0, hooks_1.useThemeConfig)();
17
17
  const { editPage: themeEditPage } = markdown || {};
18
- const mergedConf = editPage ? Object.assign(Object.assign({}, editPage), themeEditPage) : undefined;
18
+ const mergedConf = editPage ? Object.assign(Object.assign({}, themeEditPage), editPage) : undefined;
19
19
  return (react_1.default.createElement(PageWrapper_1.PageWrapper, { "data-component-name": "Markdown/MarkdownLayout" },
20
20
  react_1.default.createElement(ContainerWrapper_1.ContainerWrapper, { withToc: true },
21
21
  react_1.default.createElement(LayoutTop, null,
22
22
  lastModified && react_1.default.createElement(LastUpdated_1.LastUpdated, { lastModified: new Date(lastModified) }),
23
23
  mergedConf && (react_1.default.createElement(EditPageButton_1.EditPageButton, { text: mergedConf.text, to: mergedConf.to, icon: mergedConf.icon }))),
24
24
  markdownWrapper,
25
+ react_1.default.createElement(LayoutBottom, null, feedback),
25
26
  react_1.default.createElement(PageNavigation_1.PageNavigation, null)),
26
27
  tableOfContent));
27
28
  }
@@ -31,4 +32,9 @@ const LayoutTop = styled_components_1.default.div `
31
32
  justify-content: space-between;
32
33
  flex-flow: row nowrap;
33
34
  `;
35
+ const LayoutBottom = (0, styled_components_1.default)(LayoutTop) `
36
+ > * {
37
+ margin: 25px 5px;
38
+ }
39
+ `;
34
40
  //# sourceMappingURL=MarkdownLayout.js.map
@@ -14,8 +14,9 @@ const ColorModeSwitcher_1 = require("../ColorModeSwitcher/ColorModeSwitcher");
14
14
  const useThemeConfig_1 = require("../hooks/useThemeConfig");
15
15
  function Navbar({ menu, logo, search, profile }) {
16
16
  const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)(false);
17
- const { search: searchSettings, navbar } = (0, useThemeConfig_1.useThemeConfig)();
17
+ const { search: searchSettings, navbar, userProfile: userProfileSettings } = (0, useThemeConfig_1.useThemeConfig)();
18
18
  const hideSearch = (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.hide) || ((searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) && (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) !== 'navbar');
19
+ const hideUserProfile = userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.hide;
19
20
  if (navbar === null || navbar === void 0 ? void 0 : navbar.hide) {
20
21
  return null;
21
22
  }
@@ -28,7 +29,7 @@ function Navbar({ menu, logo, search, profile }) {
28
29
  logo,
29
30
  react_1.default.createElement(Navbar_1.NavbarMenu, { menuItems: menu }),
30
31
  hideSearch ? null : search,
31
- profile,
32
+ hideUserProfile ? null : profile,
32
33
  react_1.default.createElement(ColorModeSwitcher_1.ColorModeSwitcher, null))));
33
34
  }
34
35
  exports.Navbar = Navbar;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export interface LoginLinkProps {
3
+ href: string;
4
+ }
5
+ export declare function LoginLink({ href }: LoginLinkProps): JSX.Element;
@@ -0,0 +1,30 @@
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.LoginLink = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const useThemeConfig_1 = require("../hooks/useThemeConfig");
10
+ function LoginLink({ href }) {
11
+ const { userProfile } = (0, useThemeConfig_1.useThemeConfig)();
12
+ return react_1.default.createElement(StyledLink, { href: href }, (userProfile === null || userProfile === void 0 ? void 0 : userProfile.loginLabel) || 'Login');
13
+ }
14
+ exports.LoginLink = LoginLink;
15
+ const StyledLink = styled_components_1.default.a.attrs(() => ({
16
+ 'data-component-name': 'Profile/LoginLink',
17
+ })) `
18
+ display: inline-block;
19
+ color: var(--navbar-text-color);
20
+ text-decoration: none;
21
+ padding: 0 var(--navbar-item-padding-horizontal);
22
+ text-align: center;
23
+ line-height: 1;
24
+ font-size: var(--navbar-item-font-size);
25
+ font-weight: var(--navbar-item-font-weight);
26
+ &:hover {
27
+ color: var(--navbar-item-hover-text-color);
28
+ }
29
+ `;
30
+ //# sourceMappingURL=LoginLink.js.map
@@ -42,7 +42,9 @@ function ProfileComponent({ name, imageUrl, onClick, color }) {
42
42
  react_1.default.createElement("span", null, avatarLetters))));
43
43
  }
44
44
  exports.Profile = (0, react_1.memo)(ProfileComponent);
45
- const ProfileWrapper = styled_components_1.default.div `
45
+ const ProfileWrapper = styled_components_1.default.div.attrs(() => ({
46
+ 'data-component-name': 'Profile/Profile',
47
+ })) `
46
48
  display: flex;
47
49
  align-items: center;
48
50
  cursor: pointer;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export interface UserProfileProps {
3
+ userInfo: {
4
+ isAuthenticated: boolean;
5
+ name: string;
6
+ picture: string;
7
+ logoutDisabled?: boolean;
8
+ };
9
+ handleLogout: (logoutRedirect?: string) => void;
10
+ hasDeveloperOnboarding?: boolean;
11
+ hasApiLogs?: boolean;
12
+ }
13
+ export declare function UserProfile({ userInfo, handleLogout, hasDeveloperOnboarding, hasApiLogs, }: UserProfileProps): JSX.Element;
@@ -0,0 +1,82 @@
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.UserProfile = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Link_1 = require("../mocks/Link");
33
+ const Profile_1 = require("../Profile/Profile");
34
+ const Tooltip_1 = require("../Tooltip/Tooltip");
35
+ const useThemeConfig_1 = require("../hooks/useThemeConfig");
36
+ function UserProfile({ userInfo, handleLogout, hasDeveloperOnboarding = false, hasApiLogs = false, }) {
37
+ const [isOpened, setIsOpened] = (0, react_1.useState)(false);
38
+ const { userProfile: userProfileSettings } = (0, useThemeConfig_1.useThemeConfig)();
39
+ const logoutRedirect = (userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.logoutRedirect) || '/';
40
+ return (react_1.default.createElement(StyledTooltip, { isOpen: isOpened, withArrow: false, className: "copy-button", placement: "bottom", width: "100%", tip: react_1.default.createElement(StyledUl, null,
41
+ hasDeveloperOnboarding ? (react_1.default.createElement(Link_1.Link, { to: "/apps" },
42
+ react_1.default.createElement(StyledLi, null, "My Apps"))) : null,
43
+ hasApiLogs ? (react_1.default.createElement(Link_1.Link, { to: "/api-logs" },
44
+ react_1.default.createElement(StyledLi, null, "API logs"))) : null,
45
+ react_1.default.createElement(StyledLi, { onClick: () => handleLogout(logoutRedirect) }, (userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.logoutLabel) || 'Log out')) },
46
+ react_1.default.createElement(Profile_1.Profile, { name: userInfo.name, imageUrl: userInfo.picture, onClick: userInfo.logoutDisabled ? undefined : () => setIsOpened(!isOpened) })));
47
+ }
48
+ exports.UserProfile = UserProfile;
49
+ const StyledTooltip = (0, styled_components_1.default)(Tooltip_1.Tooltip) `
50
+ > span {
51
+ padding: 0;
52
+ }
53
+ `;
54
+ const StyledUl = styled_components_1.default.ul `
55
+ margin: 0;
56
+ padding: 0;
57
+ list-style: none;
58
+ text-align: left;
59
+ background-color: var(--search-modal-background);
60
+ color: var(--search-modal-text-color);
61
+ min-width: 100px;
62
+ a {
63
+ text-decoration: none;
64
+ &:hover {
65
+ color: inherit;
66
+ }
67
+ &:visited {
68
+ color: inherit;
69
+ }
70
+ }
71
+ `;
72
+ const StyledLi = styled_components_1.default.li `
73
+ cursor: pointer;
74
+ font-size: 16px;
75
+ list-style: none;
76
+ padding: 15px 20px;
77
+ transition: background-color 0.25s ease 0s;
78
+ &:hover {
79
+ background-color: rgba(0, 0, 0, 0.1);
80
+ }
81
+ `;
82
+ //# sourceMappingURL=UserProfile.js.map
@@ -1,2 +1,6 @@
1
1
  export { Profile } from './Profile';
2
2
  export type { ProfileProps } from './Profile';
3
+ export { LoginLink } from './LoginLink';
4
+ export type { LoginLinkProps } from './LoginLink';
5
+ export { UserProfile } from './UserProfile';
6
+ export type { UserProfileProps } from './UserProfile';
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Profile = void 0;
3
+ exports.UserProfile = exports.LoginLink = exports.Profile = void 0;
4
4
  var Profile_1 = require("./Profile");
5
5
  Object.defineProperty(exports, "Profile", { enumerable: true, get: function () { return Profile_1.Profile; } });
6
+ var LoginLink_1 = require("./LoginLink");
7
+ Object.defineProperty(exports, "LoginLink", { enumerable: true, get: function () { return LoginLink_1.LoginLink; } });
8
+ var UserProfile_1 = require("./UserProfile");
9
+ Object.defineProperty(exports, "UserProfile", { enumerable: true, get: function () { return UserProfile_1.UserProfile; } });
6
10
  //# sourceMappingURL=index.js.map
package/lib/config.d.ts CHANGED
@@ -228,6 +228,20 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
228
228
  title?: string | undefined;
229
229
  href: string;
230
230
  }>, "many">>;
231
+ feedback: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
232
+ type: z.ZodDefault<z.ZodString>;
233
+ settings: z.ZodOptional<z.ZodString>;
234
+ }, {
235
+ hide: z.ZodOptional<z.ZodBoolean>;
236
+ }>, "strict", z.ZodTypeAny, {
237
+ hide?: boolean | undefined;
238
+ settings?: string | undefined;
239
+ type: string;
240
+ }, {
241
+ type?: string | undefined;
242
+ hide?: boolean | undefined;
243
+ settings?: string | undefined;
244
+ }>>>;
231
245
  search: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
232
246
  placement: z.ZodOptional<z.ZodDefault<z.ZodString>>;
233
247
  }, {
@@ -415,6 +429,23 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
415
429
  }>>>;
416
430
  openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
417
431
  graphql: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
432
+ userProfile: z.ZodDefault<z.ZodOptional<z.ZodObject<z.extendShape<{
433
+ loginLabel: z.ZodOptional<z.ZodDefault<z.ZodString>>;
434
+ logoutLabel: z.ZodOptional<z.ZodDefault<z.ZodString>>;
435
+ logoutRedirect: z.ZodOptional<z.ZodDefault<z.ZodString>>;
436
+ }, {
437
+ hide: z.ZodOptional<z.ZodBoolean>;
438
+ }>, "strip", z.ZodTypeAny, {
439
+ hide?: boolean | undefined;
440
+ loginLabel?: string | undefined;
441
+ logoutLabel?: string | undefined;
442
+ logoutRedirect?: string | undefined;
443
+ }, {
444
+ hide?: boolean | undefined;
445
+ loginLabel?: string | undefined;
446
+ logoutLabel?: string | undefined;
447
+ logoutRedirect?: string | undefined;
448
+ }>>>;
418
449
  }, "passthrough", z.ZodTypeAny, {
419
450
  imports?: string[] | undefined;
420
451
  logo?: {
@@ -480,6 +511,11 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
480
511
  title?: string | undefined;
481
512
  href: string;
482
513
  }[] | undefined;
514
+ feedback?: {
515
+ hide?: boolean | undefined;
516
+ settings?: string | undefined;
517
+ type: string;
518
+ } | undefined;
483
519
  search?: {
484
520
  hide?: boolean | undefined;
485
521
  placement?: string | undefined;
@@ -527,6 +563,12 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
527
563
  text: string;
528
564
  };
529
565
  };
566
+ userProfile: {
567
+ hide?: boolean | undefined;
568
+ loginLabel?: string | undefined;
569
+ logoutLabel?: string | undefined;
570
+ logoutRedirect?: string | undefined;
571
+ };
530
572
  }, {
531
573
  imports?: string[] | undefined;
532
574
  logo?: {
@@ -592,6 +634,11 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
592
634
  title?: string | undefined;
593
635
  href: string;
594
636
  }[] | undefined;
637
+ feedback?: {
638
+ type?: string | undefined;
639
+ hide?: boolean | undefined;
640
+ settings?: string | undefined;
641
+ } | undefined;
595
642
  search?: {
596
643
  hide?: boolean | undefined;
597
644
  placement?: string | undefined;
@@ -639,6 +686,12 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
639
686
  } | undefined;
640
687
  openapi?: {} | undefined;
641
688
  graphql?: {} | undefined;
689
+ userProfile?: {
690
+ hide?: boolean | undefined;
691
+ loginLabel?: string | undefined;
692
+ logoutLabel?: string | undefined;
693
+ logoutRedirect?: string | undefined;
694
+ } | undefined;
642
695
  }>>;
643
696
  export type ThemeConfig = z.infer<typeof ThemeConfig>;
644
697
  export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 'scripts'> & {
package/lib/config.js CHANGED
@@ -74,6 +74,15 @@ exports.ThemeConfig = zod_1.z
74
74
  })
75
75
  .optional(),
76
76
  links: zod_1.z.array(LinksConfig).optional(),
77
+ feedback: zod_1.z
78
+ .object({
79
+ type: zod_1.z.string().default('sentiment'),
80
+ settings: zod_1.z.string().optional(),
81
+ })
82
+ .extend(HideConfig.shape)
83
+ .strict()
84
+ .default({})
85
+ .optional(),
77
86
  search: zod_1.z
78
87
  .object({
79
88
  placement: zod_1.z.string().default('navbar').optional(),
@@ -151,6 +160,15 @@ exports.ThemeConfig = zod_1.z
151
160
  .optional(),
152
161
  openapi: zod_1.z.object({}).passthrough().optional(),
153
162
  graphql: zod_1.z.object({}).passthrough().optional(),
163
+ userProfile: zod_1.z
164
+ .object({
165
+ loginLabel: zod_1.z.string().default('Login').optional(),
166
+ logoutLabel: zod_1.z.string().default('Logout').optional(),
167
+ logoutRedirect: zod_1.z.string().default('/').optional(),
168
+ })
169
+ .extend(HideConfig.shape)
170
+ .optional()
171
+ .default({}),
154
172
  })
155
173
  .passthrough()
156
174
  .default({});