@redocly/theme 0.9.7 → 0.9.9
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/Feedback/Comment.d.ts +1 -1
- package/lib/Feedback/Comment.js +2 -2
- package/lib/Feedback/Feedback.d.ts +5 -0
- package/lib/Feedback/Feedback.js +50 -0
- package/lib/Feedback/ReportDialog.js +2 -2
- package/lib/Feedback/index.d.ts +1 -0
- package/lib/Feedback/index.js +3 -1
- package/lib/Feedback/types.d.ts +1 -1
- package/lib/SamplesPanelControls/SamplesPanelControls.js +1 -0
- package/lib/Search/utils.js +4 -3
- package/lib/config.d.ts +1505 -508
- package/lib/config.js +27 -2
- package/lib/globalStyle.js +2 -2
- package/lib/ui/darkColors.js +1 -1
- package/package.json +2 -2
- package/src/Feedback/Comment.tsx +2 -2
- package/src/Feedback/Feedback.tsx +43 -0
- package/src/Feedback/ReportDialog.tsx +2 -1
- package/src/Feedback/index.ts +1 -0
- package/src/Feedback/types.ts +1 -1
- package/src/SamplesPanelControls/SamplesPanelControls.ts +1 -0
- package/src/Search/utils.tsx +4 -3
- package/src/config.ts +29 -3
- package/src/globalStyle.ts +2 -2
- package/src/types/portal/index.d.ts +1 -0
- package/src/types/portal/src/shared/types/feedback.d.ts +12 -0
- package/src/ui/darkColors.tsx +1 -1
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.
|
|
111
|
-
settings: zod_1.z
|
|
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()
|
package/lib/globalStyle.js
CHANGED
|
@@ -1195,7 +1195,7 @@ const code = (0, styled_components_1.css) `
|
|
|
1195
1195
|
--code-block-background-color: #323f4b; // @presenter Color
|
|
1196
1196
|
--code-block-border-color: var(--border-color); // @presenter Color
|
|
1197
1197
|
--code-block-border-radius: var(--border-radius-lg); // @presenter BorderRadius
|
|
1198
|
-
--code-block-max-height:
|
|
1198
|
+
--code-block-max-height: 50vh;
|
|
1199
1199
|
--code-block-word-break: initial;
|
|
1200
1200
|
|
|
1201
1201
|
/**
|
|
@@ -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
|
package/lib/ui/darkColors.js
CHANGED
|
@@ -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: #
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
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.
|
|
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",
|
package/src/Feedback/Comment.tsx
CHANGED
|
@@ -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
|
|
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
|
|
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
|
);
|
package/src/Feedback/index.ts
CHANGED
package/src/Feedback/types.ts
CHANGED
|
@@ -62,6 +62,7 @@ export const SampleControlsWrap = styled.div`
|
|
|
62
62
|
export const PreformattedCodeBlock = styled(CodeBlock.withComponent('pre'))`
|
|
63
63
|
overflow-x: auto;
|
|
64
64
|
margin: 0;
|
|
65
|
+
max-height: var(--code-block-max-height);
|
|
65
66
|
font-family: var(--code-font-family);
|
|
66
67
|
padding: 20px;
|
|
67
68
|
border-radius: var(--border-radius);
|
package/src/Search/utils.tsx
CHANGED
|
@@ -8,12 +8,13 @@ export const highlight = (text: string | string[]): JSX.Element | string => {
|
|
|
8
8
|
return (
|
|
9
9
|
<>
|
|
10
10
|
{pre}
|
|
11
|
-
<
|
|
11
|
+
<Highlight>{entry}</Highlight>
|
|
12
12
|
{suf}
|
|
13
13
|
</>
|
|
14
14
|
);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const
|
|
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.
|
|
119
|
-
settings: z
|
|
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?: {
|
package/src/globalStyle.ts
CHANGED
|
@@ -1205,7 +1205,7 @@ const code = css`
|
|
|
1205
1205
|
--code-block-background-color: #323f4b; // @presenter Color
|
|
1206
1206
|
--code-block-border-color: var(--border-color); // @presenter Color
|
|
1207
1207
|
--code-block-border-radius: var(--border-radius-lg); // @presenter BorderRadius
|
|
1208
|
-
--code-block-max-height:
|
|
1208
|
+
--code-block-max-height: 50vh;
|
|
1209
1209
|
--code-block-word-break: initial;
|
|
1210
1210
|
|
|
1211
1211
|
/**
|
|
@@ -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
|
|
@@ -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
|
+
}
|
package/src/ui/darkColors.tsx
CHANGED
|
@@ -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: #
|
|
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;
|