@redocly/theme 0.35.9 → 0.36.1

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.
@@ -2,4 +2,4 @@ import * as React from 'react';
2
2
  import type { FeedbackProps } from '../../types/portal/src/shared/types/feedback';
3
3
  export declare const Feedback: (props: FeedbackProps & {
4
4
  path?: string;
5
- }) => React.JSX.Element;
5
+ }) => React.JSX.Element | null;
@@ -35,10 +35,14 @@ const hooks_1 = require("../../hooks");
35
35
  const useSubmitFeedback_1 = require("../../mocks/Feedback/useSubmitFeedback");
36
36
  const telemetry_1 = require("../../mocks/telemetry");
37
37
  const Feedback = (props) => {
38
+ var _a;
38
39
  const { submitFeedback } = (0, useSubmitFeedback_1.useSubmitFeedback)();
39
40
  const { pathname } = (0, react_router_dom_1.useLocation)();
40
41
  const { feedback: themeFeedbackConf } = (0, hooks_1.useThemeConfig)();
41
- const feedbackConf = Object.assign(Object.assign({}, themeFeedbackConf), props);
42
+ const feedbackConf = Object.assign(Object.assign({}, themeFeedbackConf), { path: props === null || props === void 0 ? void 0 : props.path, type: (props === null || props === void 0 ? void 0 : props.type) || (themeFeedbackConf === null || themeFeedbackConf === void 0 ? void 0 : themeFeedbackConf.type), settings: (props === null || props === void 0 ? void 0 : props.settings) || (themeFeedbackConf === null || themeFeedbackConf === void 0 ? void 0 : themeFeedbackConf.settings) || {}, hide: (_a = props.hide) !== null && _a !== void 0 ? _a : themeFeedbackConf === null || themeFeedbackConf === void 0 ? void 0 : themeFeedbackConf.hide });
43
+ if (feedbackConf.hide) {
44
+ return null;
45
+ }
42
46
  const renderFeedbackComponent = () => {
43
47
  const { type, settings, path } = feedbackConf;
44
48
  switch (type) {
@@ -33,7 +33,7 @@ const Stars = ({ max = 5, onChange, value }) => {
33
33
  const [hovered, setHovered] = React.useState(value || 0);
34
34
  const stars = [];
35
35
  for (let index = 1; index <= max; index++) {
36
- stars.push(React.createElement(Star, { key: index, onClick: () => onChange(index), onMouseOver: () => setHovered(index), onMouseLeave: () => !value && setHovered(0) },
36
+ stars.push(React.createElement(Star, { "data-testid": `star-${index}`, key: index, onClick: () => onChange(index), onMouseOver: () => setHovered(index), onMouseLeave: () => !value && setHovered(0) },
37
37
  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" },
38
38
  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" },
39
39
  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" }))))));
@@ -10,4 +10,5 @@ export type SubmitFeedbackParams = {
10
10
  export type FeedbackProps = {
11
11
  type: FEEDBACK_TYPES;
12
12
  settings: (RatingProps | SentimentProps | CommentProps | MoodProps | ScaleProps)['settings'];
13
+ hide?: boolean;
13
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.35.9",
3
+ "version": "0.36.1",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -89,7 +89,7 @@
89
89
  "react-calendar": "4.2.1",
90
90
  "react-date-picker": "10.0.3",
91
91
  "timeago.js": "^4.0.2",
92
- "@redocly/config": "0.1.6"
92
+ "@redocly/config": "0.3.0"
93
93
  },
94
94
  "scripts": {
95
95
  "start": "npm-run-all --parallel storybook storybook:tokens:watch",
@@ -12,7 +12,17 @@ export const Feedback = (props: FeedbackProps & { path?: string }) => {
12
12
  const { submitFeedback } = useSubmitFeedback();
13
13
  const { pathname } = useLocation();
14
14
  const { feedback: themeFeedbackConf } = useThemeConfig();
15
- const feedbackConf = { ...themeFeedbackConf, ...props };
15
+ const feedbackConf = {
16
+ ...themeFeedbackConf,
17
+ path: props?.path,
18
+ type: props?.type || themeFeedbackConf?.type,
19
+ settings: props?.settings || themeFeedbackConf?.settings || {},
20
+ hide: props.hide ?? themeFeedbackConf?.hide,
21
+ };
22
+
23
+ if (feedbackConf.hide) {
24
+ return null;
25
+ }
16
26
 
17
27
  const renderFeedbackComponent = () => {
18
28
  const { type, settings, path } = feedbackConf;
@@ -15,6 +15,7 @@ export const Stars = ({ max = 5, onChange, value }: StarsProps): JSX.Element =>
15
15
  for (let index = 1; index <= max; index++) {
16
16
  stars.push(
17
17
  <Star
18
+ data-testid={`star-${index}`}
18
19
  key={index}
19
20
  onClick={() => onChange(index)}
20
21
  onMouseOver={() => setHovered(index)}
@@ -19,4 +19,5 @@ export type SubmitFeedbackParams = {
19
19
  export type FeedbackProps = {
20
20
  type: FEEDBACK_TYPES;
21
21
  settings: (RatingProps | SentimentProps | CommentProps | MoodProps | ScaleProps)['settings'];
22
+ hide?: boolean;
22
23
  };