@redocly/theme 0.9.6 → 0.9.8

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/config.js CHANGED
@@ -107,8 +107,33 @@ exports.ThemeConfig = zod_1.z
107
107
  links: zod_1.z.array(LinksConfig).optional(),
108
108
  feedback: zod_1.z
109
109
  .object({
110
- type: zod_1.z.string().default('sentiment'),
111
- settings: zod_1.z.string().optional(),
110
+ type: zod_1.z.enum(['rating', 'sentiment', 'comment', 'reasons']).default('sentiment'),
111
+ settings: zod_1.z
112
+ .object({
113
+ label: zod_1.z.string().optional(),
114
+ submitText: zod_1.z.string().optional(),
115
+ max: zod_1.z.number().optional(),
116
+ buttonText: zod_1.z.string().optional(),
117
+ multi: zod_1.z.boolean().optional(),
118
+ items: zod_1.z.array(zod_1.z.string()).min(1).optional(),
119
+ reasons: zod_1.z
120
+ .object({
121
+ enable: zod_1.z.boolean().default(true),
122
+ multi: zod_1.z.boolean().optional(),
123
+ label: zod_1.z.string().optional(),
124
+ items: zod_1.z.array(zod_1.z.string()),
125
+ })
126
+ .optional(),
127
+ comment: zod_1.z
128
+ .object({
129
+ enable: zod_1.z.boolean().default(true),
130
+ label: zod_1.z.string().optional(),
131
+ likeLabel: zod_1.z.string().optional(),
132
+ dislikeLabel: zod_1.z.string().optional(),
133
+ })
134
+ .optional(),
135
+ })
136
+ .optional(),
112
137
  })
113
138
  .extend(HideConfig.shape)
114
139
  .strict()
@@ -1831,7 +1831,7 @@ const search = (0, styled_components_1.css) `
1831
1831
 
1832
1832
  --search-item-padding: 8px 24px;
1833
1833
  --search-item-text-color: var(--text-color-secondary); // @presenter Color
1834
- --search-item-title-text-color: var(--text-color); // @presenter Color
1834
+ --search-item-title-text-color: var(--text-color-secondary); // @presenter Color
1835
1835
  --search-item-background-color: transparent; // @presenter Color
1836
1836
  --search-item-active-text-color: var(--text-color-secondary); // @presenter Color
1837
1837
  --search-item-active-title-text-color: var(--text-color); // @presenter Color
@@ -48,7 +48,7 @@ exports.darkMode = (0, styled_components_1.css) `
48
48
  --button-hover-background-color: #2b4cc4;
49
49
  --button-hover-border-color: #2b4cc4;
50
50
  --search-popover-background-color: #1b2738;
51
- --search-highlight-text-color: #57a5fd;
51
+ --search-highlight-text-color: #ffff03;
52
52
  --search-item-active-background-color: #1f3559;
53
53
  --panel-try-it-nested-body-background-color: #263041;
54
54
  --panel-try-it-tabs-active-background-color: #11151d;
@@ -1,5 +1,4 @@
1
1
  export declare class ClipboardService {
2
- static isSupported(): boolean;
3
2
  static copyCustom(text: string): boolean;
4
3
  static selectElement(element: HTMLDivElement | null): void;
5
4
  }
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ClipboardService = void 0;
7
7
  const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
8
8
  class ClipboardService {
9
- static isSupported() {
10
- return typeof navigator !== 'undefined' && !!navigator.clipboard;
11
- }
12
9
  static copyCustom(text) {
13
10
  return (0, copy_to_clipboard_1.default)(text);
14
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "Shared UI components lib",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -69,7 +69,7 @@
69
69
  "@types/node": "^18.11.18",
70
70
  "@types/prismjs": "^1.26.0",
71
71
  "@types/react": "^17.0.43",
72
- "@types/react-dom": "^17.0.14",
72
+ "@types/react-dom": "^17.0.11",
73
73
  "@types/styled-components": "^5.1.26",
74
74
  "@types/styled-system": "^5.1.13",
75
75
  "@typescript-eslint/eslint-plugin": "^5.23.0",
@@ -41,12 +41,7 @@ function CopyButtonWrapperComponent({
41
41
 
42
42
  const renderCopyButton = (placement: TooltipProps['placement'] = 'top'): JSX.Element => {
43
43
  return (
44
- <Tooltip
45
- className="copy-button"
46
- tip={ClipboardService.isSupported() ? 'Copied' : 'Not supported in your browser'}
47
- isOpen={tooltip.isOpened}
48
- placement={placement}
49
- >
44
+ <Tooltip className="copy-button" tip="Copied" isOpen={tooltip.isOpened} placement={placement}>
50
45
  <SamplesControlButton onClick={copy} data-cy={dataTestId}>
51
46
  Copy
52
47
  </SamplesControlButton>
@@ -4,8 +4,8 @@ import styled from 'styled-components';
4
4
  import { Button } from '@theme/Button/Button';
5
5
  import type { CommentProps } from '@theme/Feedback';
6
6
 
7
- export const Comment = ({ settings, onSubmit }: CommentProps): JSX.Element => {
8
- const { label, submitText, onCancel } = settings || {};
7
+ export const Comment = ({ settings, onSubmit, onCancel }: CommentProps): JSX.Element => {
8
+ const { label, submitText } = settings || {};
9
9
  const [text, setText] = React.useState('');
10
10
  const [submitValue, setSubmitValue] = React.useState('');
11
11
 
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+
3
+ import type { FeedbackProps } from '@redocly/theme/src/types/portal';
4
+
5
+ import { Rating, Sentiment, Comment } from '@theme/Feedback';
6
+ import { useThemeConfig } from '@theme/hooks';
7
+ import { useSubmitFeedback } from '@portal/Feedback/useSubmitFeedback';
8
+
9
+ export const Feedback = (props: FeedbackProps & { path?: string }) => {
10
+ const { submitFeedback } = useSubmitFeedback();
11
+ const { feedback: themeFeedbackConf } = useThemeConfig();
12
+ const feedbackConf = { ...themeFeedbackConf, ...props };
13
+
14
+ const { type, settings, path } = feedbackConf;
15
+ switch (type) {
16
+ case 'rating':
17
+ return (
18
+ <Rating
19
+ settings={settings}
20
+ onSubmit={(values) => submitFeedback({ type: 'rating', values, path })}
21
+ />
22
+ );
23
+ case 'sentiment':
24
+ return (
25
+ <Sentiment
26
+ settings={settings}
27
+ onSubmit={(values) => submitFeedback({ type: 'sentiment', values, path })}
28
+ />
29
+ );
30
+ case 'comment':
31
+ return (
32
+ <Comment
33
+ settings={settings}
34
+ onSubmit={(values) => submitFeedback({ type: 'comment', values, path })}
35
+ />
36
+ );
37
+ default:
38
+ console.log(`No feedback with type ${type}!`);
39
+ break;
40
+ }
41
+
42
+ return <></>;
43
+ };
@@ -17,11 +17,12 @@ export const ReportDialog = ({
17
17
  return (
18
18
  <Wrapper className="modal">
19
19
  <Comment
20
- settings={{ label, onCancel }}
20
+ settings={{ label }}
21
21
  onSubmit={(value) => {
22
22
  submitFeedback('problem', { ...value, location });
23
23
  onSubmit();
24
24
  }}
25
+ onCancel={onCancel}
25
26
  />
26
27
  </Wrapper>
27
28
  );
@@ -1,3 +1,4 @@
1
+ export { Feedback } from '@theme/Feedback/Feedback';
1
2
  export { Rating } from '@theme/Feedback/Rating';
2
3
  export { Sentiment } from '@theme/Feedback/Sentiment';
3
4
  export { Comment } from '@theme/Feedback/Comment';
@@ -38,10 +38,10 @@ export type SentimentProps = {
38
38
 
39
39
  export type CommentProps = {
40
40
  onSubmit: (value: { comment: string }) => void;
41
+ onCancel?: () => unknown;
41
42
  settings?: {
42
43
  label?: string;
43
44
  submitText?: string;
44
- onCancel?: () => unknown;
45
45
  };
46
46
  };
47
47
 
@@ -144,5 +144,5 @@ const Overlay = styled.div`
144
144
 
145
145
  const Message = styled.div`
146
146
  padding: 24px;
147
- color: var(--text-color);
147
+ color: var(--search-item-title-text-color);
148
148
  `;
@@ -8,12 +8,13 @@ export const highlight = (text: string | string[]): JSX.Element | string => {
8
8
  return (
9
9
  <>
10
10
  {pre}
11
- <Strong>{entry}</Strong>
11
+ <Highlight>{entry}</Highlight>
12
12
  {suf}
13
13
  </>
14
14
  );
15
15
  };
16
16
 
17
- const Strong = styled.strong`
18
- color: var(--search-highlight-text-color);
17
+ const Highlight = styled.span`
18
+ background-color: var(--search-highlight-text-color);
19
+ color: var(--color-emphasis-900);
19
20
  `;
package/src/config.ts CHANGED
@@ -115,8 +115,33 @@ export const ThemeConfig = z
115
115
 
116
116
  feedback: z
117
117
  .object({
118
- type: z.string().default('sentiment'),
119
- settings: z.string().optional(),
118
+ type: z.enum(['rating', 'sentiment', 'comment', 'reasons']).default('sentiment'),
119
+ settings: z
120
+ .object({
121
+ label: z.string().optional(),
122
+ submitText: z.string().optional(),
123
+ max: z.number().optional(),
124
+ buttonText: z.string().optional(),
125
+ multi: z.boolean().optional(),
126
+ items: z.array(z.string()).min(1).optional(),
127
+ reasons: z
128
+ .object({
129
+ enable: z.boolean().default(true),
130
+ multi: z.boolean().optional(),
131
+ label: z.string().optional(),
132
+ items: z.array(z.string()),
133
+ })
134
+ .optional(),
135
+ comment: z
136
+ .object({
137
+ enable: z.boolean().default(true),
138
+ label: z.string().optional(),
139
+ likeLabel: z.string().optional(),
140
+ dislikeLabel: z.string().optional(),
141
+ })
142
+ .optional(),
143
+ })
144
+ .optional(),
120
145
  })
121
146
  .extend(HideConfig.shape)
122
147
  .strict()
@@ -200,7 +225,8 @@ export const ThemeConfig = z
200
225
  .default({});
201
226
 
202
227
  export type ThemeConfig = z.infer<typeof ThemeConfig>;
203
- export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 'scripts'> & {
228
+ // export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 'scripts'> & {
229
+ export type ThemeUIConfig = ThemeConfig & {
204
230
  navbar?: any; // TODO
205
231
  footer?: any; // TODO
206
232
  auth?: {
@@ -1852,7 +1852,7 @@ const search = css`
1852
1852
 
1853
1853
  --search-item-padding: 8px 24px;
1854
1854
  --search-item-text-color: var(--text-color-secondary); // @presenter Color
1855
- --search-item-title-text-color: var(--text-color); // @presenter Color
1855
+ --search-item-title-text-color: var(--text-color-secondary); // @presenter Color
1856
1856
  --search-item-background-color: transparent; // @presenter Color
1857
1857
  --search-item-active-text-color: var(--text-color-secondary); // @presenter Color
1858
1858
  --search-item-active-title-text-color: var(--text-color); // @presenter Color
@@ -1,2 +1,3 @@
1
1
  export * from './src/shared/types/nav';
2
+ export * from './src/shared/types/feedback';
2
3
  export type { MdHeading } from './src/shared/types/markdown';
@@ -0,0 +1,12 @@
1
+ import type { RatingProps, SentimentProps, CommentProps } from '@theme/Feedback';
2
+
3
+ declare enum FEEDBACK_TYPES {
4
+ RATING = 'rating',
5
+ SENTIMENT = 'sentiment',
6
+ COMMENT = 'comment',
7
+ }
8
+
9
+ export declare type FeedbackProps = {
10
+ type: FEEDBACK_TYPES;
11
+ settings: (RatingProps | SentimentProps | CommentProps)['settings'];
12
+ }
@@ -46,7 +46,7 @@ export const darkMode = css`
46
46
  --button-hover-background-color: #2b4cc4;
47
47
  --button-hover-border-color: #2b4cc4;
48
48
  --search-popover-background-color: #1b2738;
49
- --search-highlight-text-color: #57a5fd;
49
+ --search-highlight-text-color: #ffff03;
50
50
  --search-item-active-background-color: #1f3559;
51
51
  --panel-try-it-nested-body-background-color: #263041;
52
52
  --panel-try-it-tabs-active-background-color: #11151d;
@@ -1,9 +1,5 @@
1
1
  import copy from 'copy-to-clipboard';
2
2
  export class ClipboardService {
3
- static isSupported(): boolean {
4
- return typeof navigator !== 'undefined' && !!navigator.clipboard;
5
- }
6
-
7
3
  static copyCustom(text: string): boolean {
8
4
  return copy(text);
9
5
  }