@redocly/theme 0.6.4 → 0.7.0

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 (86) hide show
  1. package/lib/Feedback/Comment.d.ts +3 -0
  2. package/lib/Feedback/Comment.js +80 -0
  3. package/lib/Feedback/Rating.d.ts +3 -0
  4. package/lib/Feedback/Rating.js +82 -0
  5. package/lib/Feedback/Reasons.d.ts +3 -0
  6. package/lib/Feedback/Reasons.js +85 -0
  7. package/lib/Feedback/Sentiment.d.ts +3 -0
  8. package/lib/Feedback/Sentiment.js +79 -0
  9. package/lib/Feedback/Thumbs.d.ts +7 -0
  10. package/lib/Feedback/Thumbs.js +79 -0
  11. package/lib/Feedback/index.d.ts +5 -0
  12. package/lib/Feedback/index.js +27 -0
  13. package/lib/Feedback/types.d.ts +71 -0
  14. package/lib/Feedback/types.js +3 -0
  15. package/lib/Markdown/MarkdownLayout.d.ts +2 -1
  16. package/lib/Markdown/MarkdownLayout.js +8 -2
  17. package/lib/Markdown/Tabs/Tab.js +11 -5
  18. package/lib/Markdown/Tabs/Tabs.js +14 -5
  19. package/lib/Navbar/Navbar.js +6 -3
  20. package/lib/Pages/Forbidden.d.ts +2 -0
  21. package/lib/Pages/Forbidden.js +39 -0
  22. package/lib/Pages/NotFound.d.ts +2 -0
  23. package/lib/Pages/NotFound.js +39 -0
  24. package/lib/Pages/index.d.ts +1 -0
  25. package/lib/Pages/index.js +18 -0
  26. package/lib/Profile/LoginLink.d.ts +5 -0
  27. package/lib/Profile/LoginLink.js +30 -0
  28. package/lib/Profile/Profile.js +3 -1
  29. package/lib/Profile/UserProfile.d.ts +13 -0
  30. package/lib/Profile/UserProfile.js +82 -0
  31. package/lib/Profile/index.d.ts +4 -0
  32. package/lib/Profile/index.js +5 -1
  33. package/lib/Search/Autocomplete.d.ts +4 -1
  34. package/lib/Search/Autocomplete.js +19 -3
  35. package/lib/Search/ClearIcon.js +1 -1
  36. package/lib/Search/Input.js +1 -1
  37. package/lib/Search/Search.js +6 -1
  38. package/lib/Search/SearchIcon.js +1 -1
  39. package/lib/Search/ShortcutKey.d.ts +7 -0
  40. package/lib/Search/ShortcutKey.js +35 -0
  41. package/lib/config.d.ts +61 -0
  42. package/lib/config.js +19 -0
  43. package/lib/globalStyle.js +62 -0
  44. package/lib/index.d.ts +2 -0
  45. package/lib/index.js +2 -0
  46. package/lib/mocks/Link.js +1 -1
  47. package/lib/mocks/hooks/index.js +11 -1
  48. package/lib/mocks/search.js +18 -5
  49. package/lib/ui/Box.d.ts +2 -2
  50. package/lib/ui/Box.js +1 -0
  51. package/lib/ui/darkColors.js +5 -0
  52. package/package.json +9 -5
  53. package/src/Feedback/Comment.tsx +64 -0
  54. package/src/Feedback/Rating.tsx +107 -0
  55. package/src/Feedback/Reasons.tsx +81 -0
  56. package/src/Feedback/Sentiment.tsx +75 -0
  57. package/src/Feedback/Thumbs.tsx +116 -0
  58. package/src/Feedback/index.ts +5 -0
  59. package/src/Feedback/types.ts +63 -0
  60. package/src/Markdown/MarkdownLayout.tsx +10 -1
  61. package/src/Markdown/Tabs/Tab.tsx +11 -5
  62. package/src/Markdown/Tabs/Tabs.tsx +14 -5
  63. package/src/Navbar/Navbar.tsx +8 -3
  64. package/src/Pages/Forbidden.tsx +42 -0
  65. package/src/Pages/NotFound.tsx +42 -0
  66. package/src/Pages/index.ts +1 -0
  67. package/src/Profile/LoginLink.tsx +29 -0
  68. package/src/Profile/Profile.tsx +3 -1
  69. package/src/Profile/UserProfile.tsx +101 -0
  70. package/src/Profile/index.ts +4 -0
  71. package/src/Search/Autocomplete.tsx +26 -2
  72. package/src/Search/ClearIcon.tsx +1 -1
  73. package/src/Search/Input.tsx +1 -1
  74. package/src/Search/Search.tsx +3 -0
  75. package/src/Search/SearchIcon.tsx +1 -1
  76. package/src/Search/ShortcutKey.tsx +35 -0
  77. package/src/config.ts +23 -0
  78. package/src/globalStyle.ts +64 -0
  79. package/src/index.ts +2 -0
  80. package/src/mocks/Link.tsx +2 -1
  81. package/src/mocks/hooks/index.ts +11 -1
  82. package/src/mocks/search.ts +20 -5
  83. package/src/settings.yaml +2 -0
  84. package/src/types/portal/index.d.ts +1 -1
  85. package/src/ui/Box.tsx +5 -2
  86. package/src/ui/darkColors.tsx +5 -0
@@ -7,6 +7,7 @@ import { Autocomplete } from '@theme/Search/Autocomplete';
7
7
  import { ClearIcon } from '@theme/Search/ClearIcon';
8
8
  import { SearchIcon } from '@theme/Search/SearchIcon';
9
9
  import { SearchItem } from '@theme/Search/SearchItem';
10
+ import { useThemeConfig } from '@theme/hooks';
10
11
 
11
12
  interface OperationParameter {
12
13
  name: string | string[];
@@ -29,6 +30,7 @@ interface SearchDocument {
29
30
  export function Search(): JSX.Element {
30
31
  const history = usePreloadHistory();
31
32
  const { query, setQuery, items } = useFuseSearch();
33
+ const themeSettings = useThemeConfig();
32
34
 
33
35
  // TODO: ask somebody about typings
34
36
  const navigate = (item: SearchDocument) => history.push(item.url);
@@ -40,6 +42,7 @@ export function Search(): JSX.Element {
40
42
  change={setQuery}
41
43
  select={navigate}
42
44
  placeholder="Search the docs"
45
+ keyShortcuts={themeSettings?.search?.shortcuts ?? ['/']}
43
46
  renderItem={(item) => <SearchItem key={item.id} item={item} />}
44
47
  >
45
48
  {(isOpen, reset) => (isOpen ? <ClearIcon onClick={reset} /> : <SearchIcon />)}
@@ -24,7 +24,7 @@ export const SearchIcon = styled(Icon).attrs(() => ({
24
24
  cursor: pointer;
25
25
  width: 1em;
26
26
  height: 1em;
27
- right: 1em;
27
+ left: 0.8em;
28
28
  fill: var(--search-input-text-color);
29
29
  z-index: -1;
30
30
 
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ interface ShortcutKeyProps {
5
+ keyShortcuts?: string | string[];
6
+ }
7
+
8
+ export function ShortcutKey(props: ShortcutKeyProps): JSX.Element {
9
+ let mainShortcutKey: string | null | undefined = null;
10
+
11
+ if (props.keyShortcuts) {
12
+ if (Array.isArray(props.keyShortcuts)) {
13
+ mainShortcutKey = props.keyShortcuts[0];
14
+ } else {
15
+ mainShortcutKey = props.keyShortcuts;
16
+ }
17
+ }
18
+
19
+ mainShortcutKey = mainShortcutKey?.toUpperCase();
20
+
21
+ return <Wrapper>{mainShortcutKey}</Wrapper>;
22
+ }
23
+
24
+ export const Wrapper = styled.div`
25
+ position: absolute;
26
+ cursor: pointer;
27
+ font-size: 0.8em;
28
+ height: 2em;
29
+ line-height: 2em;
30
+ right: 1em;
31
+ fill: var(--search-input-text-color);
32
+ color: var(--search-input-placeholder-color);
33
+ opacity: 0.5;
34
+ z-index: -1;
35
+ `;
package/src/config.ts CHANGED
@@ -81,9 +81,20 @@ export const ThemeConfig = z
81
81
  .optional(),
82
82
  links: z.array(LinksConfig).optional(),
83
83
 
84
+ feedback: z
85
+ .object({
86
+ type: z.string().default('sentiment'),
87
+ settings: z.string().optional(),
88
+ })
89
+ .extend(HideConfig.shape)
90
+ .strict()
91
+ .default({})
92
+ .optional(),
93
+
84
94
  search: z
85
95
  .object({
86
96
  placement: z.string().default('navbar').optional(),
97
+ shortcuts: z.array(z.string()).default(['/']).optional(),
87
98
  })
88
99
  .extend(HideConfig.shape)
89
100
  .strict()
@@ -159,6 +170,15 @@ export const ThemeConfig = z
159
170
  .optional(),
160
171
  openapi: z.object({}).passthrough().optional(),
161
172
  graphql: z.object({}).passthrough().optional(),
173
+ userProfile: z
174
+ .object({
175
+ loginLabel: z.string().default('Login').optional(),
176
+ logoutLabel: z.string().default('Logout').optional(),
177
+ logoutRedirect: z.string().default('/').optional(),
178
+ })
179
+ .extend(HideConfig.shape)
180
+ .optional()
181
+ .default({}),
162
182
  })
163
183
  .passthrough()
164
184
  .default({});
@@ -176,4 +196,7 @@ export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 's
176
196
  }[];
177
197
  devLogin?: boolean;
178
198
  };
199
+ search?: {
200
+ shortcuts?: string[];
201
+ };
179
202
  };
@@ -1804,6 +1804,16 @@ const markdown = css`
1804
1804
  --md-numbered-list-number-padding: 0 5px; // @presenter Spacing
1805
1805
 
1806
1806
  // @tokens End
1807
+
1808
+ /**
1809
+ * @tokens Markdown Tabs
1810
+ */
1811
+
1812
+ --md-tabs-tab-text-color: var(--color-emphasis-600); // @presenter Color
1813
+ --md-tabs-active-tab-border-color: var(--text-color); // @presenter Color
1814
+ --md-tabs-hover-tab-border-color: var(--text-color-secondary); // @presenter Color
1815
+
1816
+ // @tokens End
1807
1817
  `;
1808
1818
 
1809
1819
  const search = css`
@@ -1903,6 +1913,58 @@ const tile = css`
1903
1913
  --thin-tile-background-color: var(--color-secondary-50);
1904
1914
  `;
1905
1915
 
1916
+ const apiLogsTable = css`
1917
+ --api-logs-row-hover-background-color: var(--color-secondary-300);
1918
+ `
1919
+
1920
+ const pages = css`
1921
+ /**
1922
+ * @tokens 404 Page
1923
+ * @presenter Color
1924
+ */
1925
+
1926
+ --page-404-font-family: var(--font-family-base); // @presenter FontFamily
1927
+
1928
+ --page-404-header-text-color: #000;
1929
+ --page-404-header-font-size: 14em; // @presenter FontSize
1930
+ --page-404-header-font-weight: 600; // @presenter FontWeight
1931
+ --page-404-header-line-height: 1.2; // @presenter LineHeight
1932
+ --page-404-header-margin: 0; // @presenter Spacing
1933
+
1934
+ --page-404-description-text-color: #000;
1935
+ --page-404-description-font-size: 2em; // @presenter FontSize
1936
+ --page-404-description-font-weight: 400; // @presenter FontWeight
1937
+ --page-404-description-line-height: 1; // @presenter LineHeight
1938
+ --page-404-description-margin: 0; // @presenter Spacing
1939
+
1940
+ --page-404-button-margin: 4em; // @presenter Spacing
1941
+
1942
+ // @tokens End
1943
+
1944
+ /**
1945
+ * @tokens 403 Page
1946
+ * @presenter Color
1947
+ */
1948
+
1949
+ --page-403-font-family: var(--font-family-base); // @presenter FontFamily
1950
+
1951
+ --page-403-header-text-color: #000;
1952
+ --page-403-header-font-size: 14em; // @presenter FontSize
1953
+ --page-403-header-font-weight: 600; // @presenter FontWeight
1954
+ --page-403-header-line-height: 1.2; // @presenter LineHeight
1955
+ --page-403-header-margin: 0; // @presenter Spacing
1956
+
1957
+ --page-403-description-text-color: #000;
1958
+ --page-403-description-font-size: 2em; // @presenter FontSize
1959
+ --page-403-description-font-weight: 400; // @presenter FontWeight
1960
+ --page-403-description-line-height: 1; // @presenter LineHeight
1961
+ --page-403-description-margin: 0; // @presenter Spacing
1962
+
1963
+ --page-403-button-margin: 4em; // @presenter Spacing
1964
+
1965
+ // @tokens End
1966
+ `
1967
+
1906
1968
  export const styles = css`
1907
1969
  :root {
1908
1970
  ${baseColors}
@@ -1931,6 +1993,8 @@ export const styles = css`
1931
1993
  ${lastUpdated}
1932
1994
  ${tile}
1933
1995
  ${loadProgressBar}
1996
+ ${apiLogsTable}
1997
+ ${pages}
1934
1998
  }
1935
1999
 
1936
2000
  :root.dark {
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export * from './Tooltip';
10
10
  export * from './SourceCode';
11
11
  export * from './Panel';
12
12
  export * from './icons';
13
+ export * from './Feedback';
13
14
  export * from './hooks';
14
15
  export * from './utils';
15
16
  export * from './globalStyle';
@@ -20,3 +21,4 @@ export * from './ColorModeSwitcher';
20
21
  export * from './Sidebar';
21
22
  export * from './types/config';
22
23
  export * from './config';
24
+ export * from './Pages';
@@ -11,6 +11,7 @@ export function Link(props: any): JSX.Element {
11
11
  external: _4,
12
12
  ...filteredProps
13
13
  } = props;
14
+
14
15
  // We omit "active" property to avoid "Warning: Received `false` for a non-boolean attribute `active`."
15
- return <a href={filteredProps.to} {...filteredProps} />;
16
+ return <a href={filteredProps.to} ref={filteredProps.innerRef} {...filteredProps} />;
16
17
  }
@@ -8,7 +8,11 @@ interface PageLink {
8
8
 
9
9
  export function useThemeConfig<T extends Record<string, unknown>>(): T & ThemeUIConfig {
10
10
  return {
11
- search: { hide: false, placement: 'navbar' },
11
+ search: {
12
+ hide: false,
13
+ placement: 'navbar',
14
+ shortcuts: ['ctrl+f', 'cmd+k', '/'],
15
+ },
12
16
  markdown: {
13
17
  toc: { depth: 3, header: 'Table of contents', hide: false },
14
18
  lastUpdatedBlock: { hide: false, format: 'timeago', locale: 'en-US' },
@@ -32,6 +36,12 @@ export function useThemeConfig<T extends Record<string, unknown>>(): T & ThemeUI
32
36
  colorMode: {
33
37
  modes: ['light', 'dark'],
34
38
  },
39
+ feedback: {
40
+ type: 'sentiment',
41
+ },
42
+ userProfile: {
43
+ hide: false,
44
+ },
35
45
  } as ThemeUIConfig as T & ThemeUIConfig;
36
46
  }
37
47
 
@@ -1,3 +1,5 @@
1
+ import { useState } from 'react';
2
+
1
3
  interface OperationParameter {
2
4
  name: string | string[];
3
5
  description: string | string[];
@@ -21,11 +23,24 @@ export function useFuseSearch(): {
21
23
  setQuery: (val: string) => void;
22
24
  items: SearchDocument[];
23
25
  } {
26
+ const [query, setQuery] = useState('');
27
+
24
28
  return {
25
- query: '',
26
- setQuery(val: string) {
27
- this.query = val;
28
- },
29
- items: [],
29
+ query,
30
+ setQuery,
31
+ items: [
32
+ {
33
+ id: '1',
34
+ url: '#someUrl1',
35
+ title: 'Some Dummy Result Item 1',
36
+ text: 'Some sample search text',
37
+ },
38
+ {
39
+ id: '2',
40
+ url: '#someUrl2',
41
+ title: 'Some Dummy Result Item 2',
42
+ text: 'Some sample search text 2',
43
+ },
44
+ ],
30
45
  };
31
46
  }
package/src/settings.yaml CHANGED
@@ -25,3 +25,5 @@ colorMode:
25
25
  - 'dark'
26
26
  lastUpdatedBlock:
27
27
  hide: false
28
+ userProfile:
29
+ hide: false
@@ -1,2 +1,2 @@
1
1
  export * from './src/shared/types/nav';
2
- export type { MdHeading } from './src/shared/types/markdown';
2
+ export type { MdHeading } from './src/shared/types/markdown';
package/src/ui/Box.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { space, position, flex, textAlign, color, border, layout } from 'styled-system';
1
+ import { space, position, flex, textAlign, color, border, layout, grid } from 'styled-system';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import type {
@@ -9,6 +9,7 @@ import type {
9
9
  PositionProps,
10
10
  FlexProps,
11
11
  BordersProps,
12
+ GridProps,
12
13
  } from 'styled-system';
13
14
 
14
15
  export interface BoxProps
@@ -18,7 +19,8 @@ export interface BoxProps
18
19
  FlexProps,
19
20
  TextAlignProps,
20
21
  ColorProps,
21
- BordersProps {}
22
+ BordersProps,
23
+ GridProps {}
22
24
 
23
25
  export const Box = styled.div.attrs(() => ({
24
26
  'data-component-name': 'ui/Box',
@@ -31,4 +33,5 @@ export const Box = styled.div.attrs(() => ({
31
33
  ${textAlign}
32
34
  ${color}
33
35
  ${border}
36
+ ${grid}
34
37
  `;
@@ -59,8 +59,13 @@ export const darkMode = css`
59
59
  --copy-button-tooltip-background-color: var(--tooltip-background-color);
60
60
  --tooltip-text-color: #fff;
61
61
  --md-table-head-background-color: var(--color-secondary-300);
62
+ --md-tabs-hover-tab-border-color: var(--color-secondary-500);
62
63
  --wide-tile-background-color: #000000;
63
64
  --thin-tile-background-color: #000000;
65
+ --page-404-header-text-color: #fff;
66
+ --page-404-description-text-color: #fff;
67
+ --page-403-header-text-color: #fff;
68
+ --page-403-description-text-color: #fff;
64
69
 
65
70
  background-color: var(--background-color);
66
71
  color: var(--text-color);