@redocly/theme 0.0.0-beta-20240223133421 → 0.0.0-beta-20240227165736

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.
@@ -38,11 +38,11 @@ function CodeBlockControls({ children, className, title, controls, tabs, }) {
38
38
  title && react_1.default.createElement(Title, null, title),
39
39
  tabs && react_1.default.createElement(FileTabs, null),
40
40
  react_1.default.createElement(ControlsWrapper, null,
41
- report && !((_a = report === null || report === void 0 ? void 0 : report.props) === null || _a === void 0 ? void 0 : _a.hide) ? (react_1.default.createElement(Button_1.Button, Object.assign({ "data-cy": "report-button", "data-testid": "report-button", icon: controlsType === 'icon' ? react_1.default.createElement(WarningSquareIcon_1.WarningSquareIcon, { size: "18px" }) : undefined, size: "small", variant: "ghost" }, report.props), controlsType != 'icon' && (((_b = report.props) === null || _b === void 0 ? void 0 : _b.buttonText) || 'Report'))) : null,
42
- expand && !((_c = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.expand) === null || _c === void 0 ? void 0 : _c.hide) ? (react_1.default.createElement(Button_1.Button, { "data-cy": "expand-all", "data-testid": "expand-all", icon: controlsType === 'icon' ? react_1.default.createElement(MaximizeIcon_1.MaximizeIcon, null) : undefined, onClick: expand === null || expand === void 0 ? void 0 : expand.onClick, size: "small", variant: "ghost" }, controlsType !== 'icon' && (expand === null || expand === void 0 ? void 0 : expand.label) ? expand.label : 'Expand all')) : null,
43
- collapse && !((_d = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _d === void 0 ? void 0 : _d.hide) ? (react_1.default.createElement(Button_1.Button, { "data-cy": "collapse-all", "data-testid": "collapse-all", icon: controlsType === 'icon' ? react_1.default.createElement(MinimizeIcon_1.MinimizeIcon, null) : undefined, onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick, size: "small", variant: "ghost" }, controlsType !== 'icon' && (expand === null || expand === void 0 ? void 0 : expand.label) ? expand.label : 'Collapse all')) : null,
44
- select ? (react_1.default.createElement(Button_1.Button, { "data-cy": "select-all", "data-testid": "select-all", icon: controlsType === 'icon' ? react_1.default.createElement(SelectIcon_1.SelectIcon, null) : undefined, onClick: select === null || select === void 0 ? void 0 : select.onClick, size: "small", variant: "ghost" }, controlsType !== 'icon' && (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
45
- deselect ? (react_1.default.createElement(Button_1.Button, { "data-cy": "clear-all", "data-testid": "clear-all", icon: controlsType === 'icon' ? react_1.default.createElement(DeselectIcon_1.DeselectIcon, null) : undefined, onClick: deselect === null || deselect === void 0 ? void 0 : deselect.onClick, size: "small", variant: "ghost" }, controlsType !== 'icon' && (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? deselect.label : 'Clear all')) : null,
41
+ report && !((_a = report === null || report === void 0 ? void 0 : report.props) === null || _a === void 0 ? void 0 : _a.hide) ? (react_1.default.createElement(ControlButton, Object.assign({ variant: "ghost", size: "small", "data-cy": "report-button", "data-testid": "report-button", icon: controlsType === 'icon' ? react_1.default.createElement(WarningSquareIcon_1.WarningSquareIcon, { size: "18px" }) : undefined }, report.props), controlsType != 'icon' && (((_b = report.props) === null || _b === void 0 ? void 0 : _b.buttonText) || 'Report'))) : null,
42
+ expand && !((_c = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.expand) === null || _c === void 0 ? void 0 : _c.hide) ? (react_1.default.createElement(ControlButton, { variant: "ghost", size: "small", "data-cy": "expand-all", "data-testid": "expand-all", icon: controlsType === 'icon' ? react_1.default.createElement(MaximizeIcon_1.MaximizeIcon, null) : undefined, onClick: expand === null || expand === void 0 ? void 0 : expand.onClick }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Expand all'))) : null,
43
+ collapse && !((_d = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _d === void 0 ? void 0 : _d.hide) ? (react_1.default.createElement(ControlButton, { variant: "ghost", size: "small", "data-cy": "collapse-all", "data-testid": "collapse-all", icon: controlsType === 'icon' ? react_1.default.createElement(MinimizeIcon_1.MinimizeIcon, null) : undefined, onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick }, controlsType !== 'icon' && ((expand === null || expand === void 0 ? void 0 : expand.label) || 'Collapse all'))) : null,
44
+ select ? (react_1.default.createElement(ControlButton, { variant: "ghost", size: "small", "data-cy": "select-all", "data-testid": "select-all", icon: controlsType === 'icon' ? react_1.default.createElement(SelectIcon_1.SelectIcon, null) : undefined, onClick: select === null || select === void 0 ? void 0 : select.onClick }, controlsType !== 'icon' && (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
45
+ deselect ? (react_1.default.createElement(ControlButton, { variant: "ghost", size: "small", "data-cy": "clear-all", "data-testid": "clear-all", icon: controlsType === 'icon' ? react_1.default.createElement(DeselectIcon_1.DeselectIcon, null) : undefined, onClick: deselect === null || deselect === void 0 ? void 0 : deselect.onClick }, controlsType !== 'icon' && (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? deselect.label : 'Clear all')) : null,
46
46
  copy && !((_e = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.copy) === null || _e === void 0 ? void 0 : _e.hide) ? (react_1.default.createElement(CopyButton_1.CopyButton, { data: copy.data, "data-source": copy.dataSource, "data-hash": copy.dataHash, type: controlsType, toasterPlacement: copy.toasterPlacement, toasterDuration: copy.toasterDuration, buttonText: copy.label, onCopyClick: () => {
47
47
  copy === null || copy === void 0 ? void 0 : copy.onClick;
48
48
  telemetry.send('code_snippet_copied', {});
@@ -93,4 +93,9 @@ const CodeTabButton = (0, styled_components_1.default)(Button_1.Button) `
93
93
  border: none;
94
94
  }
95
95
  `;
96
+ const ControlButton = (0, styled_components_1.default)(Button_1.Button) `
97
+ & + & {
98
+ margin-left: 0;
99
+ }
100
+ `;
96
101
  //# sourceMappingURL=CodeBlockControls.js.map
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Comment = void 0;
30
- const React = __importStar(require("react"));
30
+ const react_1 = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
32
  const utils_1 = require("../../core/utils");
33
33
  const hooks_1 = require("../../core/hooks");
@@ -37,8 +37,10 @@ const Comment = ({ settings, onSubmit, onCancel, className, standAlone = true, }
37
37
  const { useTranslate } = (0, hooks_1.useThemeHooks)();
38
38
  const { translate } = useTranslate();
39
39
  const { label, submitText } = settings || {};
40
- const [text, setText] = React.useState('');
41
- const [submitValue, setSubmitValue] = React.useState('');
40
+ const [text, setText] = react_1.default.useState('');
41
+ const [submitValue, setSubmitValue] = react_1.default.useState('');
42
+ const modalRef = (0, react_1.useRef)(null);
43
+ (0, hooks_1.useOutsideClick)(modalRef, onCancel);
42
44
  const send = () => {
43
45
  if (!text)
44
46
  return;
@@ -53,18 +55,18 @@ const Comment = ({ settings, onSubmit, onCancel, className, standAlone = true, }
53
55
  }
54
56
  };
55
57
  if (submitValue) {
56
- return (React.createElement(StateWrapper, { className: className },
57
- React.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.submitText" }, submitText ||
58
+ return (react_1.default.createElement(StateWrapper, { className: className },
59
+ react_1.default.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.submitText" }, submitText ||
58
60
  translate('theme.feedback.settings.comment.submitText', 'Thank you for helping improve our documentation!')),
59
- React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
61
+ react_1.default.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
60
62
  }
61
- return (React.createElement(Wrapper, { "data-component-name": "Feedback/Comment", className: className, style: standAlone ? { width: '424px', padding: '16px 24px' } : { width: 'auto' } },
62
- React.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.label" }, label ||
63
+ return (react_1.default.createElement(Wrapper, { ref: modalRef, "data-component-name": "Feedback/Comment", className: className, style: standAlone ? { width: '424px', padding: '16px 24px' } : { width: 'auto' } },
64
+ react_1.default.createElement(Label, { "data-translation-key": "theme.feedback.settings.comment.label" }, label ||
63
65
  translate('theme.feedback.settings.comment.label', 'Please share your feedback with us.')),
64
- React.createElement(TextArea, { rows: 3, onChange: handleTextAreaChange }),
65
- standAlone && (React.createElement(ButtonsContainer, null,
66
- onCancel && (React.createElement(CancelButton, { "data-translation-key": "theme.feedback.settings.comment.cancel", onClick: onCancel, variant: "outlined" }, translate('theme.feedback.settings.comment.cancel', 'Cancel'))),
67
- React.createElement(SendButton, { "data-translation-key": "theme.feedback.settings.comment.send", onClick: send, variant: "primary" }, translate('theme.feedback.settings.comment.send', 'Send'))))));
66
+ react_1.default.createElement(TextArea, { rows: 3, onChange: handleTextAreaChange }),
67
+ standAlone && (react_1.default.createElement(ButtonsContainer, null,
68
+ onCancel && (react_1.default.createElement(CancelButton, { "data-translation-key": "theme.feedback.settings.comment.cancel", onClick: onCancel, variant: "outlined" }, translate('theme.feedback.settings.comment.cancel', 'Cancel'))),
69
+ react_1.default.createElement(SendButton, { "data-translation-key": "theme.feedback.settings.comment.send", onClick: send, variant: "primary" }, translate('theme.feedback.settings.comment.send', 'Send'))))));
68
70
  };
69
71
  exports.Comment = Comment;
70
72
  const Wrapper = styled_components_1.default.div `
@@ -1,3 +1,6 @@
1
- export declare const StatusCode: import("styled-components").StyledComponent<"button", any, {
1
+ /// <reference types="react" />
2
+ export declare const StatusCode: import("styled-components").StyledComponent<import("react").FC<import("../../index.js").ButtonProps>, any, import("../../index.js").ButtonProps & {
3
+ variant: "ghost";
4
+ } & {
2
5
  status: string;
3
- }, never>;
6
+ }, "variant">;
@@ -5,11 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StatusCode = void 0;
7
7
  const styled_components_1 = __importDefault(require("styled-components"));
8
- exports.StatusCode = styled_components_1.default.button `
9
- background: none;
10
- padding: 0;
11
- display: flex;
12
- align-items: center;
8
+ const theme_1 = require("../../index.js");
9
+ exports.StatusCode = (0, styled_components_1.default)(theme_1.Button).attrs(() => ({
10
+ variant: 'ghost',
11
+ })) `
12
+ gap: 0;
13
+ border: 0;
13
14
 
14
15
  &:before {
15
16
  display: inline-block;
@@ -1,2 +1,2 @@
1
1
  import type { MutableRefObject } from 'react';
2
- export declare function useOutsideClick(ref: MutableRefObject<HTMLElement | null>, handler: (event: MouseEvent | TouchEvent) => void): void;
2
+ export declare function useOutsideClick(ref: MutableRefObject<HTMLElement | null>, handler?: (event: MouseEvent | TouchEvent) => void): void;
@@ -5,7 +5,7 @@ const react_1 = require("react");
5
5
  function useOutsideClick(ref, handler) {
6
6
  (0, react_1.useEffect)(() => {
7
7
  const listener = (event) => {
8
- if (!ref.current || ref.current.contains(event.target)) {
8
+ if (!handler || !ref.current || ref.current.contains(event.target)) {
9
9
  return;
10
10
  }
11
11
  handler(event);
@@ -246,6 +246,13 @@ exports.darkMode = (0, styled_components_1.css) `
246
246
  --tab-bg-color-filled: var(--color-warm-grey-4); // @presenter Color
247
247
  --tab-content-color-disabled: var(--color-warm-grey-4); // @presenter Color
248
248
 
249
+ /**
250
+ * @tokens Dropdown Colors
251
+ * @presenter Color
252
+ */
253
+
254
+ --dropdown-content-color-default: var(--color-warm-grey-8); // @presenter Color
255
+
249
256
  /**
250
257
  * @tokens API Reference Schema Required styles
251
258
  */
@@ -16,6 +16,7 @@ exports.ChevronDownIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
16
16
  fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
17
17
  }
18
18
 
19
+ flex-shrink: 0;
19
20
  height: ${({ size }) => size || '16px'};
20
21
  width: ${({ size }) => size || '16px'};
21
22
  `;
@@ -16,6 +16,7 @@ exports.ChevronUpIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
16
16
  fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
17
17
  }
18
18
 
19
+ flex-shrink: 0;
19
20
  height: ${({ size }) => size || '16px'};
20
21
  width: ${({ size }) => size || '16px'};
21
22
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.0.0-beta-20240223133421",
3
+ "version": "0.0.0-beta-20240227165736",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -92,68 +92,68 @@ export function CodeBlockControls({
92
92
  {tabs && <FileTabs />}
93
93
  <ControlsWrapper>
94
94
  {report && !report?.props?.hide ? (
95
- <Button
95
+ <ControlButton
96
+ variant="ghost"
97
+ size="small"
96
98
  data-cy="report-button"
97
99
  data-testid="report-button"
98
100
  icon={controlsType === 'icon' ? <WarningSquareIcon size="18px" /> : undefined}
99
- size="small"
100
- variant="ghost"
101
101
  {...report.props}
102
102
  >
103
103
  {controlsType != 'icon' && (report.props?.buttonText || 'Report')}
104
- </Button>
104
+ </ControlButton>
105
105
  ) : null}
106
106
 
107
107
  {expand && !codeSnippet?.expand?.hide ? (
108
- <Button
108
+ <ControlButton
109
+ variant="ghost"
110
+ size="small"
109
111
  data-cy="expand-all"
110
112
  data-testid="expand-all"
111
113
  icon={controlsType === 'icon' ? <MaximizeIcon /> : undefined}
112
114
  onClick={expand?.onClick}
113
- size="small"
114
- variant="ghost"
115
115
  >
116
- {controlsType !== 'icon' && expand?.label ? expand.label : 'Expand all'}
117
- </Button>
116
+ {controlsType !== 'icon' && (expand?.label || 'Expand all')}
117
+ </ControlButton>
118
118
  ) : null}
119
119
 
120
120
  {collapse && !codeSnippet?.collapse?.hide ? (
121
- <Button
121
+ <ControlButton
122
+ variant="ghost"
123
+ size="small"
122
124
  data-cy="collapse-all"
123
125
  data-testid="collapse-all"
124
126
  icon={controlsType === 'icon' ? <MinimizeIcon /> : undefined}
125
127
  onClick={collapse?.onClick}
126
- size="small"
127
- variant="ghost"
128
128
  >
129
- {controlsType !== 'icon' && expand?.label ? expand.label : 'Collapse all'}
130
- </Button>
129
+ {controlsType !== 'icon' && (expand?.label || 'Collapse all')}
130
+ </ControlButton>
131
131
  ) : null}
132
132
 
133
133
  {select ? (
134
- <Button
134
+ <ControlButton
135
+ variant="ghost"
136
+ size="small"
135
137
  data-cy="select-all"
136
138
  data-testid="select-all"
137
139
  icon={controlsType === 'icon' ? <SelectIcon /> : undefined}
138
140
  onClick={select?.onClick}
139
- size="small"
140
- variant="ghost"
141
141
  >
142
142
  {controlsType !== 'icon' && select?.label ? select.label : 'Select all'}
143
- </Button>
143
+ </ControlButton>
144
144
  ) : null}
145
145
 
146
146
  {deselect ? (
147
- <Button
147
+ <ControlButton
148
+ variant="ghost"
149
+ size="small"
148
150
  data-cy="clear-all"
149
151
  data-testid="clear-all"
150
152
  icon={controlsType === 'icon' ? <DeselectIcon /> : undefined}
151
153
  onClick={deselect?.onClick}
152
- size="small"
153
- variant="ghost"
154
154
  >
155
155
  {controlsType !== 'icon' && deselect?.label ? deselect.label : 'Clear all'}
156
- </Button>
156
+ </ControlButton>
157
157
  ) : null}
158
158
 
159
159
  {copy && !codeSnippet?.copy?.hide ? (
@@ -229,3 +229,9 @@ const CodeTabButton = styled(Button)<{ active: boolean }>`
229
229
  border: none;
230
230
  }
231
231
  `;
232
+
233
+ const ControlButton = styled(Button)`
234
+ & + & {
235
+ margin-left: 0;
236
+ }
237
+ `;
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { breakpoints } from '@redocly/theme/core/utils';
5
- import { useThemeHooks } from '@redocly/theme/core/hooks';
5
+ import { useOutsideClick, useThemeHooks } from '@redocly/theme/core/hooks';
6
6
  import { RadioCheckButtonIcon } from '@redocly/theme/icons/RadioCheckButtonIcon/RadioCheckButtonIcon';
7
7
  import { Button } from '@redocly/theme/components/Button/Button';
8
8
 
@@ -29,6 +29,9 @@ export const Comment = ({
29
29
  const { label, submitText } = settings || {};
30
30
  const [text, setText] = React.useState('');
31
31
  const [submitValue, setSubmitValue] = React.useState('');
32
+ const modalRef = useRef<HTMLDivElement>(null);
33
+
34
+ useOutsideClick(modalRef, onCancel);
32
35
 
33
36
  const send = () => {
34
37
  if (!text) return;
@@ -61,6 +64,7 @@ export const Comment = ({
61
64
 
62
65
  return (
63
66
  <Wrapper
67
+ ref={modalRef}
64
68
  data-component-name="Feedback/Comment"
65
69
  className={className}
66
70
  style={standAlone ? { width: '424px', padding: '16px 24px' } : { width: 'auto' }}
@@ -1,10 +1,12 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const StatusCode = styled.button<{ status: string }>`
4
- background: none;
5
- padding: 0;
6
- display: flex;
7
- align-items: center;
3
+ import { Button } from '@redocly/theme';
4
+
5
+ export const StatusCode = styled(Button).attrs(() => ({
6
+ variant: 'ghost',
7
+ }))<{ status: string }>`
8
+ gap: 0;
9
+ border: 0;
8
10
 
9
11
  &:before {
10
12
  display: inline-block;
@@ -4,11 +4,11 @@ import type { MutableRefObject } from 'react';
4
4
 
5
5
  export function useOutsideClick(
6
6
  ref: MutableRefObject<HTMLElement | null>,
7
- handler: (event: MouseEvent | TouchEvent) => void,
7
+ handler?: (event: MouseEvent | TouchEvent) => void,
8
8
  ): void {
9
9
  useEffect(() => {
10
10
  const listener = (event: MouseEvent | TouchEvent) => {
11
- if (!ref.current || ref.current.contains(event.target as Node)) {
11
+ if (!handler || !ref.current || ref.current.contains(event.target as Node)) {
12
12
  return;
13
13
  }
14
14
  handler(event);
@@ -245,6 +245,13 @@ export const darkMode = css`
245
245
  --tab-bg-color-filled: var(--color-warm-grey-4); // @presenter Color
246
246
  --tab-content-color-disabled: var(--color-warm-grey-4); // @presenter Color
247
247
 
248
+ /**
249
+ * @tokens Dropdown Colors
250
+ * @presenter Color
251
+ */
252
+
253
+ --dropdown-content-color-default: var(--color-warm-grey-8); // @presenter Color
254
+
248
255
  /**
249
256
  * @tokens API Reference Schema Required styles
250
257
  */
@@ -18,6 +18,7 @@ export const ChevronDownIcon = styled(Icon).attrs(() => ({
18
18
  fill: ${({ color }) => getCssColorVariable(color)};
19
19
  }
20
20
 
21
+ flex-shrink: 0;
21
22
  height: ${({ size }) => size || '16px'};
22
23
  width: ${({ size }) => size || '16px'};
23
24
  `;
@@ -18,6 +18,7 @@ export const ChevronUpIcon = styled(Icon).attrs(() => ({
18
18
  fill: ${({ color }) => getCssColorVariable(color)};
19
19
  }
20
20
 
21
+ flex-shrink: 0;
21
22
  height: ${({ size }) => size || '16px'};
22
23
  width: ${({ size }) => size || '16px'};
23
24
  `;