@redocly/theme 0.56.0-next.9 → 0.56.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.
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/Button.js +2 -1
- package/lib/components/Button/ButtonGroup.d.ts +12 -0
- package/lib/components/Button/ButtonGroup.js +38 -0
- package/lib/components/Button/variables.js +32 -5
- package/lib/components/Catalog/Catalog.d.ts +1 -1
- package/lib/components/Catalog/CatalogCardView/CatalogCard.js +2 -2
- package/lib/components/Catalog/CatalogSelector.d.ts +1 -1
- package/lib/components/Catalog/CatalogSelector.js +4 -3
- package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
- package/lib/components/CodeBlock/CodeBlock.d.ts +16 -6
- package/lib/components/CodeBlock/CodeBlock.js +2 -2
- package/lib/components/CodeBlock/CodeBlockControls.d.ts +4 -3
- package/lib/components/CodeBlock/CodeBlockControls.js +8 -5
- package/lib/components/CodeBlock/CodeBlockDropdown.d.ts +3 -0
- package/lib/components/CodeBlock/CodeBlockDropdown.js +35 -0
- package/lib/components/CodeBlock/CodeBlockTabs.d.ts +2 -2
- package/lib/components/CodeBlock/CodeBlockTabs.js +18 -9
- package/lib/components/CodeBlock/variables.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +1 -0
- package/lib/components/Dropdown/DropdownMenu.js +4 -0
- package/lib/components/Dropdown/variables.js +1 -0
- package/lib/components/Footer/FooterItem.js +4 -7
- package/lib/components/Footer/variables.js +2 -2
- package/lib/components/Markdown/Markdown.js +9 -9
- package/lib/components/Markdown/styles/headingAnchor.js +0 -1
- package/lib/components/Menu/MenuItem.js +5 -5
- package/lib/components/Menu/variables.js +1 -1
- package/lib/components/Navbar/NavbarItem.js +8 -39
- package/lib/components/Navbar/variables.js +2 -2
- package/lib/components/PageActions/PageActions.d.ts +6 -0
- package/lib/components/PageActions/PageActions.js +104 -0
- package/lib/components/PageActions/PageActionsMenuItem.d.ts +7 -0
- package/lib/components/PageActions/PageActionsMenuItem.js +58 -0
- package/lib/components/PageActions/variables.d.ts +1 -0
- package/lib/components/PageActions/variables.dark.d.ts +1 -0
- package/lib/components/PageActions/variables.dark.js +9 -0
- package/lib/components/PageActions/variables.js +37 -0
- package/lib/components/TableOfContent/TableOfContent.js +15 -12
- package/lib/components/Tags/CounterTag.d.ts +1 -1
- package/lib/components/Tags/HttpTag.d.ts +1 -1
- package/lib/core/constants/common.d.ts +4 -0
- package/lib/core/constants/common.js +5 -1
- package/lib/core/contexts/CodeSnippetContext.d.ts +7 -0
- package/lib/core/contexts/CodeSnippetContext.js +23 -0
- package/lib/core/contexts/index.d.ts +1 -0
- package/lib/core/contexts/index.js +1 -0
- package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +1 -0
- package/lib/core/hooks/__mocks__/use-theme-hooks.js +1 -0
- package/lib/core/hooks/code-walkthrough/use-renderable-files.d.ts +1 -2
- package/lib/core/hooks/code-walkthrough/use-renderable-files.js +2 -2
- package/lib/core/hooks/index.d.ts +1 -0
- package/lib/core/hooks/index.js +1 -0
- package/lib/core/hooks/use-active-heading.d.ts +7 -2
- package/lib/core/hooks/use-active-heading.js +160 -23
- package/lib/core/hooks/use-codeblock-tabs-controls.d.ts +2 -2
- package/lib/core/hooks/use-codeblock-tabs-controls.js +6 -6
- package/lib/core/hooks/use-local-state.d.ts +1 -0
- package/lib/core/hooks/use-local-state.js +32 -0
- package/lib/core/hooks/use-page-actions.d.ts +2 -0
- package/lib/core/hooks/use-page-actions.js +101 -0
- package/lib/core/hooks/use-theme-hooks.js +2 -0
- package/lib/core/styles/dark.js +2 -0
- package/lib/core/styles/global.js +2 -0
- package/lib/core/types/hooks.d.ts +2 -1
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.js +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/page-actions.d.ts +15 -0
- package/lib/core/types/page-actions.js +3 -0
- package/lib/core/types/sidebar.d.ts +1 -0
- package/lib/core/utils/enhanced-smoothstep.d.ts +5 -0
- package/lib/core/utils/enhanced-smoothstep.js +15 -0
- package/lib/core/utils/get-file-icon.d.ts +3 -2
- package/lib/core/utils/get-file-icon.js +109 -29
- package/lib/core/utils/icon-resolver.d.ts +28 -0
- package/lib/core/utils/icon-resolver.js +52 -0
- package/lib/core/utils/index.d.ts +4 -1
- package/lib/core/utils/index.js +4 -1
- package/lib/core/utils/lang-to-name.d.ts +1 -0
- package/lib/core/utils/lang-to-name.js +37 -0
- package/lib/core/utils/{text-transform.js → string.js} +1 -1
- package/lib/ext/configure.d.ts +1 -1
- package/lib/icons/CDNIcon/CDNIcon.d.ts +14 -0
- package/lib/icons/CDNIcon/CDNIcon.js +48 -0
- package/lib/icons/ChatGptIcon/ChatGptIcon.d.ts +9 -0
- package/lib/icons/ChatGptIcon/ChatGptIcon.js +22 -0
- package/lib/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.d.ts +9 -0
- package/lib/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.js +23 -0
- package/lib/icons/ClaudeIcon/ClaudeIcon.d.ts +9 -0
- package/lib/icons/ClaudeIcon/ClaudeIcon.js +22 -0
- package/lib/icons/GenericIcon/GenericIcon.d.ts +11 -0
- package/lib/icons/GenericIcon/GenericIcon.js +61 -0
- package/lib/icons/MarkdownFullIcon/MarkdownFullIcon.d.ts +9 -0
- package/lib/icons/MarkdownFullIcon/MarkdownFullIcon.js +23 -0
- package/lib/icons/NoneIcon/NoneIcon.d.ts +9 -0
- package/lib/icons/NoneIcon/NoneIcon.js +17 -0
- package/lib/icons/types.d.ts +6 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/layouts/CodeWalkthroughLayout.js +2 -2
- package/lib/layouts/DocumentationLayout.js +14 -10
- package/lib/markdoc/components/Cards/CardIcon.js +7 -19
- package/lib/markdoc/components/CodeGroup/CodeGroup.d.ts +4 -0
- package/lib/markdoc/components/CodeGroup/CodeGroup.js +72 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +7 -4
- package/lib/markdoc/components/Heading/Heading.d.ts +2 -1
- package/lib/markdoc/components/Heading/Heading.js +21 -3
- package/lib/markdoc/components/Icon/Icon.d.ts +3 -0
- package/lib/markdoc/components/Icon/Icon.js +29 -0
- package/lib/markdoc/components/Tabs/Tab.d.ts +2 -1
- package/lib/markdoc/components/Tabs/Tab.js +5 -2
- package/lib/markdoc/components/Tabs/Tabs.d.ts +1 -1
- package/lib/markdoc/components/Tabs/variables.js +2 -0
- package/lib/markdoc/components/default.d.ts +2 -0
- package/lib/markdoc/components/default.js +2 -0
- package/lib/markdoc/default.js +4 -0
- package/lib/markdoc/tags/card.js +1 -1
- package/lib/markdoc/tags/code-group.d.ts +2 -0
- package/lib/markdoc/tags/code-group.js +23 -0
- package/lib/markdoc/tags/code-snippet.js +1 -1
- package/lib/markdoc/tags/icon.d.ts +2 -0
- package/lib/markdoc/tags/icon.js +16 -0
- package/lib/markdoc/tags/tab.js +1 -0
- package/package.json +3 -3
- package/src/components/Button/Button.tsx +3 -2
- package/src/components/Button/ButtonGroup.tsx +53 -0
- package/src/components/Button/variables.ts +32 -5
- package/src/components/Catalog/Catalog.tsx +1 -1
- package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +1 -1
- package/src/components/Catalog/CatalogSelector.tsx +3 -1
- package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
- package/src/components/CodeBlock/CodeBlock.tsx +14 -5
- package/src/components/CodeBlock/CodeBlockControls.tsx +14 -6
- package/src/components/CodeBlock/CodeBlockDropdown.tsx +53 -0
- package/src/components/CodeBlock/CodeBlockTabs.tsx +29 -20
- package/src/components/CodeBlock/variables.ts +1 -1
- package/src/components/Dropdown/Dropdown.tsx +1 -0
- package/src/components/Dropdown/DropdownMenu.tsx +4 -0
- package/src/components/Dropdown/variables.ts +1 -0
- package/src/components/Footer/FooterItem.tsx +5 -12
- package/src/components/Footer/variables.ts +2 -2
- package/src/components/Markdown/Markdown.tsx +3 -3
- package/src/components/Markdown/styles/headingAnchor.ts +0 -1
- package/src/components/Menu/MenuItem.tsx +5 -5
- package/src/components/Menu/variables.ts +1 -1
- package/src/components/Navbar/NavbarItem.tsx +8 -17
- package/src/components/Navbar/variables.ts +2 -2
- package/src/components/PageActions/PageActions.tsx +110 -0
- package/src/components/PageActions/PageActionsMenuItem.tsx +73 -0
- package/src/components/PageActions/variables.dark.ts +6 -0
- package/src/components/PageActions/variables.ts +34 -0
- package/src/components/TableOfContent/TableOfContent.tsx +33 -36
- package/src/core/constants/common.ts +4 -0
- package/src/core/contexts/CodeSnippetContext.tsx +31 -0
- package/src/core/contexts/index.ts +1 -0
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
- package/src/core/hooks/code-walkthrough/use-renderable-files.ts +3 -4
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/use-active-heading.ts +199 -28
- package/src/core/hooks/use-codeblock-tabs-controls.ts +8 -8
- package/src/core/hooks/use-local-state.ts +30 -0
- package/src/core/hooks/use-page-actions.ts +115 -0
- package/src/core/hooks/use-theme-hooks.ts +2 -0
- package/src/core/styles/dark.ts +2 -1
- package/src/core/styles/global.ts +2 -0
- package/src/core/types/hooks.ts +2 -0
- package/src/core/types/index.ts +1 -0
- package/src/core/types/l10n.ts +12 -0
- package/src/core/types/page-actions.ts +18 -0
- package/src/core/types/sidebar.ts +1 -0
- package/src/core/utils/enhanced-smoothstep.ts +14 -0
- package/src/core/utils/get-file-icon.tsx +94 -0
- package/src/core/utils/icon-resolver.ts +57 -0
- package/src/core/utils/index.ts +4 -1
- package/src/core/utils/lang-to-name.ts +35 -0
- package/src/ext/configure.ts +1 -1
- package/src/icons/CDNIcon/CDNIcon.tsx +47 -0
- package/src/icons/ChatGptIcon/ChatGptIcon.tsx +23 -0
- package/src/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.tsx +24 -0
- package/src/icons/ClaudeIcon/ClaudeIcon.tsx +23 -0
- package/src/icons/GenericIcon/GenericIcon.tsx +69 -0
- package/src/icons/MarkdownFullIcon/MarkdownFullIcon.tsx +24 -0
- package/src/icons/NoneIcon/NoneIcon.tsx +17 -0
- package/src/icons/types.ts +7 -0
- package/src/index.ts +6 -0
- package/src/layouts/CodeWalkthroughLayout.tsx +1 -1
- package/src/layouts/DocumentationLayout.tsx +23 -13
- package/src/markdoc/components/Cards/CardIcon.tsx +6 -21
- package/src/markdoc/components/CodeGroup/CodeGroup.tsx +78 -0
- package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +7 -4
- package/src/markdoc/components/Heading/Heading.tsx +22 -3
- package/src/markdoc/components/Icon/Icon.tsx +16 -0
- package/src/markdoc/components/Tabs/Tab.tsx +6 -1
- package/src/markdoc/components/Tabs/Tabs.tsx +1 -1
- package/src/markdoc/components/Tabs/variables.ts +2 -0
- package/src/markdoc/components/default.ts +2 -0
- package/src/markdoc/default.ts +4 -0
- package/src/markdoc/tags/card.ts +1 -1
- package/src/markdoc/tags/code-group.ts +21 -0
- package/src/markdoc/tags/code-snippet.ts +1 -1
- package/src/markdoc/tags/icon.ts +14 -0
- package/src/markdoc/tags/tab.ts +1 -0
- package/src/core/utils/get-file-icon.ts +0 -42
- /package/lib/core/utils/{text-transform.d.ts → string.d.ts} +0 -0
- /package/src/core/utils/{text-transform.ts → string.ts} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { CDNIcon } from '@redocly/theme/icons/CDNIcon/CDNIcon';
|
|
4
|
+
|
|
5
|
+
// extension to icon name
|
|
6
|
+
const fileIconMap: Record<string, string> = {
|
|
7
|
+
yaml: 'yaml',
|
|
8
|
+
yml: 'yaml',
|
|
9
|
+
json: 'json',
|
|
10
|
+
js: 'javascript',
|
|
11
|
+
ts: 'typescript',
|
|
12
|
+
css: 'css',
|
|
13
|
+
html: 'html',
|
|
14
|
+
jsx: 'react',
|
|
15
|
+
tsx: 'react',
|
|
16
|
+
md: 'markdown',
|
|
17
|
+
graphql: 'graphql',
|
|
18
|
+
gql: 'graphql',
|
|
19
|
+
py: 'python',
|
|
20
|
+
sh: 'console',
|
|
21
|
+
xsh: 'console',
|
|
22
|
+
nu: 'console',
|
|
23
|
+
java: 'java',
|
|
24
|
+
ps: 'powershell',
|
|
25
|
+
php: 'php_elephant',
|
|
26
|
+
go: 'go',
|
|
27
|
+
ruby: 'ruby',
|
|
28
|
+
swift: 'swift',
|
|
29
|
+
kotlin: 'kotlin',
|
|
30
|
+
rust: 'rust',
|
|
31
|
+
scala: 'scala',
|
|
32
|
+
elixir: 'elixir',
|
|
33
|
+
dart: 'dart',
|
|
34
|
+
http: 'http',
|
|
35
|
+
rest: 'http',
|
|
36
|
+
c: 'c',
|
|
37
|
+
h: 'c',
|
|
38
|
+
hpp: 'c',
|
|
39
|
+
cc: 'c',
|
|
40
|
+
cpp: 'c',
|
|
41
|
+
cxx: 'c',
|
|
42
|
+
'c++': 'c',
|
|
43
|
+
sql: 'database',
|
|
44
|
+
hbs: 'handlebars',
|
|
45
|
+
cs: 'csharp',
|
|
46
|
+
csx: 'csharp',
|
|
47
|
+
csharp: 'csharp',
|
|
48
|
+
markdoc: 'markdoc',
|
|
49
|
+
mdoc: 'markdoc',
|
|
50
|
+
mdx: 'mdx',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// code block language to icon name, only for those when code extension is not available
|
|
54
|
+
const languageIconMap: Record<string, string> = {
|
|
55
|
+
bash: 'console',
|
|
56
|
+
python: 'python',
|
|
57
|
+
java: 'java',
|
|
58
|
+
graphql: 'graphql',
|
|
59
|
+
javascript: 'javascript',
|
|
60
|
+
typescript: 'typescript',
|
|
61
|
+
react: 'react',
|
|
62
|
+
markdown: 'markdown',
|
|
63
|
+
php: 'php_elephant',
|
|
64
|
+
ruby: 'ruby',
|
|
65
|
+
swift: 'swift',
|
|
66
|
+
kotlin: 'kotlin',
|
|
67
|
+
rust: 'rust',
|
|
68
|
+
scala: 'scala',
|
|
69
|
+
elixir: 'elixir',
|
|
70
|
+
dart: 'dart',
|
|
71
|
+
csharp: 'csharp',
|
|
72
|
+
objectivec: 'c',
|
|
73
|
+
perl: 'perl',
|
|
74
|
+
sql: 'database',
|
|
75
|
+
xml: 'xml',
|
|
76
|
+
vim: 'vim',
|
|
77
|
+
lua: 'lua',
|
|
78
|
+
zsh: 'console',
|
|
79
|
+
fish: 'console',
|
|
80
|
+
powershell: 'console',
|
|
81
|
+
handlebars: 'handlebars',
|
|
82
|
+
markdoc: 'markdoc',
|
|
83
|
+
mdx: 'mdx',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export function getFileIconByExt(ext: string) {
|
|
87
|
+
const iconName = fileIconMap[ext] || 'document';
|
|
88
|
+
return <CDNIcon name={iconName} pack="code" mode="background" />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function getFileIconByLanguage(language: string) {
|
|
92
|
+
const iconName = fileIconMap[language] || languageIconMap[language] || 'document';
|
|
93
|
+
return <CDNIcon name={iconName} pack="code" mode="background" />;
|
|
94
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type ResolvedIcon =
|
|
2
|
+
| { type: 'link'; value: string }
|
|
3
|
+
| { type: 'font-awesome'; name: string; style: string }
|
|
4
|
+
| { type: 'invalid'; reason: string };
|
|
5
|
+
|
|
6
|
+
const FA_ICON_STYLES = ['solid', 'regular', 'duotone', 'brands'] as string[];
|
|
7
|
+
const FA_ICON_NAME_PATTERN = /^[a-z0-9-]+$/i;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolves an icon value from configuration into a structured object.
|
|
11
|
+
*
|
|
12
|
+
* Supports:
|
|
13
|
+
* - URLs (absolute or relative paths to image files)
|
|
14
|
+
* - Font Awesome icons in formats:
|
|
15
|
+
* - "solid camera" (style + name)
|
|
16
|
+
* - "camera" (name only, default style: 'regular')
|
|
17
|
+
*
|
|
18
|
+
* @param icon - The icon string from config.
|
|
19
|
+
* @returns A structured object describing the icon:
|
|
20
|
+
* - type: 'url' | 'font-awesome' | 'invalid'
|
|
21
|
+
* - value: for URLs
|
|
22
|
+
* - name and style: for Font Awesome icons
|
|
23
|
+
* - reason: for invalid entries
|
|
24
|
+
*/
|
|
25
|
+
export function resolveIcon(icon?: string): ResolvedIcon {
|
|
26
|
+
if (!icon || typeof icon !== 'string') {
|
|
27
|
+
return { type: 'invalid', reason: 'Icon must be a non-empty string' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const trimmed = icon.trim();
|
|
31
|
+
const isLink =
|
|
32
|
+
trimmed.match(/\.(svg|png|jpg|jpeg|gif|ico|webp)$/) || /^https?:\/\//.test(trimmed);
|
|
33
|
+
|
|
34
|
+
if (isLink) {
|
|
35
|
+
return { type: 'link', value: trimmed };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const [first, second] = trimmed.split(/\s+/);
|
|
39
|
+
|
|
40
|
+
if (first) {
|
|
41
|
+
if (second) {
|
|
42
|
+
// Format: "style name" (e.g., "solid camera")
|
|
43
|
+
if (FA_ICON_STYLES.includes(first) && FA_ICON_NAME_PATTERN.test(second)) {
|
|
44
|
+
return { type: 'font-awesome', style: first, name: second };
|
|
45
|
+
} else {
|
|
46
|
+
return { type: 'invalid', reason: 'Unrecognized icon format' };
|
|
47
|
+
}
|
|
48
|
+
} else if (!FA_ICON_STYLES.includes(first) && FA_ICON_NAME_PATTERN.test(first)) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'font-awesome',
|
|
51
|
+
name: first,
|
|
52
|
+
style: 'regular',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { type: 'invalid', reason: 'Unrecognized icon format' };
|
|
57
|
+
}
|
package/src/core/utils/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './color';
|
|
|
9
9
|
export * from './urls';
|
|
10
10
|
export * from './js-utils';
|
|
11
11
|
export * from './tags-parser';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './string';
|
|
13
13
|
export * from './dom';
|
|
14
14
|
export * from './markdoc';
|
|
15
15
|
export * from './attribute-parser';
|
|
@@ -33,3 +33,6 @@ export * from './replace-inputs-with-value';
|
|
|
33
33
|
export * from './find-closest-common-directory';
|
|
34
34
|
export * from './get-user-agent';
|
|
35
35
|
export * from './parse-style-string';
|
|
36
|
+
export * from './lang-to-name';
|
|
37
|
+
export * from './enhanced-smoothstep';
|
|
38
|
+
export * from './icon-resolver';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { capitalize } from './string';
|
|
2
|
+
|
|
3
|
+
const languages = {
|
|
4
|
+
js: 'JavaScript',
|
|
5
|
+
ts: 'TypeScript',
|
|
6
|
+
jsx: 'React',
|
|
7
|
+
tsx: 'React',
|
|
8
|
+
html: 'HTML',
|
|
9
|
+
css: 'CSS',
|
|
10
|
+
sh: 'Shell',
|
|
11
|
+
java: 'Java',
|
|
12
|
+
py: 'Python',
|
|
13
|
+
graphql: 'GraphQL',
|
|
14
|
+
gql: 'GraphQL',
|
|
15
|
+
yaml: 'YAML',
|
|
16
|
+
yml: 'YAML',
|
|
17
|
+
json: 'JSON',
|
|
18
|
+
md: 'Markdown',
|
|
19
|
+
markdown: 'Markdown',
|
|
20
|
+
mermaid: 'Mermaid',
|
|
21
|
+
php: 'PHP',
|
|
22
|
+
javascript: 'JavaScript',
|
|
23
|
+
typescript: 'TypeScript',
|
|
24
|
+
react: 'React',
|
|
25
|
+
mdoc: 'Markdoc',
|
|
26
|
+
'objective-c': 'Objective-C',
|
|
27
|
+
objectivec: 'Objective-C',
|
|
28
|
+
sql: 'SQL',
|
|
29
|
+
xml: 'XML',
|
|
30
|
+
csharp: 'C#',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function langToName(lang: string) {
|
|
34
|
+
return languages[lang as keyof typeof languages] || capitalize(lang);
|
|
35
|
+
}
|
package/src/ext/configure.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { CDNIconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
import { ICONS_CDN_URL } from '@redocly/theme/core/constants';
|
|
8
|
+
|
|
9
|
+
const Icon = (props: CDNIconProps) => {
|
|
10
|
+
const { name, type, pack, mode, color, ...rest } = props;
|
|
11
|
+
const cdnUrl = ICONS_CDN_URL[pack || 'font-awesome'];
|
|
12
|
+
const typeSegment = pack === 'code' ? '' : type ? type + '/' : 'regular/';
|
|
13
|
+
|
|
14
|
+
const styleProps =
|
|
15
|
+
mode === 'background'
|
|
16
|
+
? {
|
|
17
|
+
backgroundImage: `url(${cdnUrl}/${typeSegment}${name}.svg)`,
|
|
18
|
+
backgroundRepeat: 'no-repeat',
|
|
19
|
+
backgroundPosition: 'center',
|
|
20
|
+
backgroundSize: 'contain',
|
|
21
|
+
}
|
|
22
|
+
: {
|
|
23
|
+
backgroundColor: color ? getCssColorVariable(color) : 'currentColor',
|
|
24
|
+
maskImage: `url(${cdnUrl}/${typeSegment}${name}.svg)`,
|
|
25
|
+
maskRepeat: 'no-repeat',
|
|
26
|
+
maskPosition: 'center',
|
|
27
|
+
maskSize: 'contain',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<svg
|
|
32
|
+
{...rest}
|
|
33
|
+
style={{
|
|
34
|
+
...styleProps,
|
|
35
|
+
display: 'inline-block',
|
|
36
|
+
verticalAlign: 'middle',
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const CDNIcon = styled(Icon).attrs(() => ({
|
|
43
|
+
'data-component-name': 'icons/CDNIcon/CDNIcon',
|
|
44
|
+
}))<CDNIconProps>`
|
|
45
|
+
height: ${({ size }) => size || 'var(--icon-height, 1em)'};
|
|
46
|
+
width: ${({ size }) => size || 'var(--icon-width, 1em)'};
|
|
47
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M6.74887 6.55188V5.54033C6.74887 5.45514 6.78085 5.39123 6.85535 5.34869L8.88914 4.17742C9.16598 4.01771 9.49608 3.94322 9.83676 3.94322C11.1145 3.94322 11.9238 4.93348 11.9238 5.98758C11.9238 6.06209 11.9238 6.14729 11.9131 6.23248L9.80481 4.99731C9.67705 4.92281 9.54923 4.92281 9.42147 4.99731L6.74887 6.55188ZM11.4978 10.4916V8.0745C11.4978 7.9254 11.4339 7.81892 11.3061 7.7444L8.63354 6.18983L9.50666 5.68935C9.58118 5.64681 9.64509 5.64681 9.71961 5.68935L11.7534 6.86061C12.3391 7.20138 12.733 7.9254 12.733 8.62811C12.733 9.43732 12.2539 10.1827 11.4978 10.4915V10.4916ZM6.12066 8.36206L5.24754 7.85099C5.17304 7.80845 5.14106 7.74451 5.14106 7.65932V5.31682C5.14106 4.17753 6.01418 3.315 7.19612 3.315C7.64339 3.315 8.05856 3.4641 8.41003 3.73029L6.31241 4.94418C6.18468 5.01868 6.12077 5.12515 6.12077 5.27428V8.36214L6.12066 8.36206ZM8.00002 9.4481L6.74887 8.74537V7.25473L8.00002 6.55199L9.25109 7.25473V8.74537L8.00002 9.4481ZM8.80393 12.6851C8.35668 12.6851 7.9415 12.536 7.59004 12.2698L9.68764 11.0559C9.81539 10.9814 9.8793 10.8749 9.8793 10.7258V7.63795L10.7631 8.14902C10.8376 8.19156 10.8696 8.25547 10.8696 8.34069V10.6832C10.8696 11.8225 9.98578 12.685 8.80393 12.685V12.6851ZM6.28037 10.3106L4.24657 9.1394C3.66089 8.7986 3.26698 8.07461 3.26698 7.37188C3.26698 6.55199 3.75678 5.8173 4.51273 5.50849V7.93618C4.51273 8.08528 4.57667 8.19176 4.7044 8.26628L7.36642 9.81016L6.49329 10.3106C6.4188 10.3532 6.35486 10.3532 6.28037 10.3106ZM6.16331 12.0569C4.96009 12.0569 4.0763 11.1518 4.0763 10.0338C4.0763 9.94859 4.08697 9.86339 4.09756 9.7782L6.19518 10.9921C6.32291 11.0666 6.45075 11.0666 6.57849 10.9921L9.25109 9.44821V10.4598C9.25109 10.545 9.21913 10.6089 9.14461 10.6514L7.11084 11.8227C6.83398 11.9824 6.50388 12.0569 6.1632 12.0569H6.16331ZM8.80393 13.3239C10.0923 13.3239 11.1677 12.4082 11.4127 11.1943C12.6052 10.8855 13.3719 9.7675 13.3719 8.62822C13.3719 7.88283 13.0525 7.15884 12.4775 6.63707C12.5307 6.41345 12.5627 6.18983 12.5627 5.96632C12.5627 4.4437 11.3275 3.3043 9.90067 3.3043C9.61325 3.3043 9.33639 3.34684 9.05953 3.44273C8.58031 2.97421 7.92013 2.67609 7.19612 2.67609C5.90773 2.67609 4.83236 3.59175 4.58736 4.80564C3.39482 5.11446 2.62817 6.23248 2.62817 7.37176C2.62817 8.11715 2.94757 8.84115 3.52258 9.36291C3.46934 9.58653 3.43738 9.81016 3.43738 10.0337C3.43738 11.5563 4.67256 12.6957 6.09937 12.6957C6.38682 12.6957 6.66368 12.6531 6.94054 12.5573C7.41965 13.0258 8.07982 13.3239 8.80393 13.3239Z" />
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const ChatGptIcon = styled(Icon).attrs(() => ({
|
|
15
|
+
'data-component-name': 'icons/ChatGptIcon/ChatGptIcon',
|
|
16
|
+
}))<IconProps>`
|
|
17
|
+
path {
|
|
18
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
height: ${({ size }) => size || '16px'};
|
|
22
|
+
width: ${({ size }) => size || '16px'};
|
|
23
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M7 10.707L4.5 8.2065L5.2065 7.5L7 9.293L10.7925 5.5L11.5 6.2075L7 10.707Z" />
|
|
11
|
+
<path d="M8 1C6.61553 1 5.26216 1.41054 4.11101 2.17971C2.95987 2.94888 2.06266 4.04213 1.53285 5.32122C1.00303 6.6003 0.86441 8.00776 1.13451 9.36563C1.4046 10.7235 2.07129 11.9708 3.05026 12.9497C4.02922 13.9287 5.2765 14.5954 6.63437 14.8655C7.99224 15.1356 9.3997 14.997 10.6788 14.4672C11.9579 13.9373 13.0511 13.0401 13.8203 11.889C14.5895 10.7378 15 9.38447 15 8C15 6.14348 14.2625 4.36301 12.9497 3.05025C11.637 1.7375 9.85652 1 8 1ZM8 14C6.81332 14 5.65328 13.6481 4.66658 12.9888C3.67989 12.3295 2.91085 11.3925 2.45673 10.2961C2.0026 9.19974 1.88378 7.99334 2.11529 6.82946C2.3468 5.66557 2.91825 4.59647 3.75736 3.75736C4.59648 2.91824 5.66558 2.3468 6.82946 2.11529C7.99335 1.88378 9.19975 2.0026 10.2961 2.45672C11.3925 2.91085 12.3295 3.67988 12.9888 4.66658C13.6481 5.65327 14 6.81331 14 8C14 9.5913 13.3679 11.1174 12.2426 12.2426C11.1174 13.3679 9.5913 14 8 14Z" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const CheckmarkOutlineIcon = styled(Icon).attrs(() => ({
|
|
16
|
+
'data-component-name': 'icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon',
|
|
17
|
+
}))<IconProps>`
|
|
18
|
+
path {
|
|
19
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
height: ${({ size }) => size || '16px'};
|
|
23
|
+
width: ${({ size }) => size || '16px'};
|
|
24
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M4.03188 9.88255L6.60172 8.62367L6.64494 8.51434L6.60172 8.45352H6.47649L6.04701 8.43042L4.57865 8.39577L3.3052 8.34957L2.07142 8.29182L1.761 8.23408L1.46997 7.89915L1.49996 7.73207L1.761 7.57884L2.13492 7.60733L2.96126 7.65661L4.2012 7.7313L5.10074 7.77749L6.43328 7.89838H6.64494L6.67492 7.82369L6.60261 7.77749L6.54616 7.7313L5.26301 6.97212L3.87402 6.16983L3.14646 5.70785L2.75313 5.47379L2.5547 5.25435L2.46916 4.77544L2.82633 4.43204L3.30608 4.46052L3.42866 4.48901L3.91459 4.81548L4.95258 5.5169L6.30805 6.38849L6.50648 6.53248L6.58585 6.4832L6.59555 6.44855L6.50648 6.31843L5.76921 5.15503L4.98256 3.9716L4.63245 3.48114L4.53985 3.18702C4.50722 3.06614 4.48341 2.9645 4.48341 2.84054L4.88996 2.35855L5.11485 2.29541L5.65721 2.35855L5.88562 2.53179L6.22251 3.20473L6.7684 4.26419L7.61502 5.70477L7.86284 6.1321L7.99512 6.52786L8.04451 6.64874H8.13005V6.57944L8.19972 5.76791L8.32848 4.77159L8.45371 3.48961L8.49692 3.1285L8.70152 2.69579L9.10807 2.46172L9.42556 2.59415L9.6866 2.92061L9.65044 3.13158L9.49523 4.01241L9.19097 5.39217L8.99254 6.31612H9.10807L9.24036 6.20062L9.77567 5.58004L10.6752 4.59835L11.0721 4.20875L11.5351 3.77834L11.8323 3.57354H12.394L12.8076 4.1102L12.6224 4.66456L12.0439 5.30517L11.5642 5.84799L10.8763 6.65644L10.4468 7.3032L10.4865 7.35479L10.5888 7.34632L12.1427 7.05759L12.9822 6.92515L13.9841 6.77501L14.4374 6.9598L14.4868 7.14767L14.3086 7.53188L13.2371 7.76287L11.9804 7.9823L10.109 8.36882L10.0861 8.38345L10.1126 8.41194L10.9556 8.48123L11.3163 8.49817H12.1991L13.843 8.6052L14.2725 8.85312L14.53 9.15649L14.4868 9.38747L13.8253 9.68159L12.9329 9.4968L10.8498 9.06409L10.1355 8.90856H10.0367V8.96014L10.632 9.46832L11.7229 10.3284L13.089 11.4371L13.1586 11.7112L12.9831 11.9276L12.7979 11.9045L11.5977 11.116L11.1347 10.7611L10.0861 9.99035H10.0164V10.0712L10.2581 10.3799L11.5342 12.0546L11.6003 12.5682L11.5077 12.7352L11.177 12.8361L10.8137 12.7784L10.0667 11.8629L9.29592 10.8319L8.67418 9.90796L8.59834 9.94569L8.23147 13.3959L8.0595 13.5722L7.66264 13.7046L7.33193 13.4852L7.15644 13.1302L7.33193 12.4288L7.54359 11.5133L7.71556 10.7857L7.87077 9.88178L7.96337 9.5815L7.9572 9.56148L7.88136 9.56995L7.10088 10.5054L5.91385 11.906L4.97463 12.7837L4.74974 12.8615L4.35994 12.6852L4.3961 12.3703L4.61393 12.09L5.91385 10.6463L6.69785 9.75166L7.20406 9.23502L7.20053 9.16033H7.17055L3.71792 11.1176L3.10324 11.1869L2.83867 10.9705L2.8713 10.6155L2.99653 10.5001L4.03452 9.87639L4.031 9.87947L4.03188 9.88255Z" />
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const ClaudeIcon = styled(Icon).attrs(() => ({
|
|
15
|
+
'data-component-name': 'icons/ClaudeIcon/ClaudeIcon',
|
|
16
|
+
}))<IconProps>`
|
|
17
|
+
path {
|
|
18
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
height: ${({ size }) => size || '16px'};
|
|
22
|
+
width: ${({ size }) => size || '16px'};
|
|
23
|
+
`;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { CDNIcon } from '@redocly/theme/icons/CDNIcon/CDNIcon';
|
|
5
|
+
import { resolveIcon } from '@redocly/theme/core/utils';
|
|
6
|
+
import { InlineSvg } from '@redocly/theme/markdoc/components/InlineSvg/InlineSvg';
|
|
7
|
+
import { Image } from '@redocly/theme/components/Image/Image';
|
|
8
|
+
|
|
9
|
+
export interface GenericIconProps {
|
|
10
|
+
icon: string | React.ReactNode;
|
|
11
|
+
srcSet?: string;
|
|
12
|
+
rawContent?: string;
|
|
13
|
+
size?: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function GenericIcon({
|
|
20
|
+
icon,
|
|
21
|
+
srcSet,
|
|
22
|
+
rawContent,
|
|
23
|
+
size,
|
|
24
|
+
color,
|
|
25
|
+
alt,
|
|
26
|
+
className,
|
|
27
|
+
}: GenericIconProps) {
|
|
28
|
+
if (srcSet) {
|
|
29
|
+
return <Image srcSet={srcSet} alt={alt} className={className} />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const resolvedIcon = icon && typeof icon === 'string' ? resolveIcon(icon) : null;
|
|
33
|
+
const iconComponent = rawContent ? (
|
|
34
|
+
<IconSvg fileRawContent={rawContent} className={className} />
|
|
35
|
+
) : resolvedIcon?.type === 'link' ? (
|
|
36
|
+
<IconImg src={resolvedIcon.value} alt={alt} className={className} />
|
|
37
|
+
) : resolvedIcon?.type === 'font-awesome' ? (
|
|
38
|
+
<CDNIcon
|
|
39
|
+
name={resolvedIcon.name}
|
|
40
|
+
type={resolvedIcon.style}
|
|
41
|
+
size={size}
|
|
42
|
+
color={color}
|
|
43
|
+
className={className}
|
|
44
|
+
/>
|
|
45
|
+
) : (
|
|
46
|
+
icon
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return iconComponent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const IconImg = styled.img`
|
|
53
|
+
width: var(--icon-width, 16px);
|
|
54
|
+
height: var(--icon-height, 16px);
|
|
55
|
+
display: inline-block;
|
|
56
|
+
object-fit: cover;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const IconSvg = styled(InlineSvg)`
|
|
60
|
+
width: var(--icon-width, 16px);
|
|
61
|
+
height: var(--icon-height, 16px);
|
|
62
|
+
display: inline-block;
|
|
63
|
+
|
|
64
|
+
svg {
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
fill: var(--icon-color, currentColor);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M15.2308 4.17188C15.2308 3.95614 15.0586 3.78125 14.8462 3.78125H1.15385C0.941429 3.78125 0.769231 3.95614 0.769231 4.17188V11.8281C0.769231 12.0439 0.941429 12.2188 1.15385 12.2188H14.8462C15.0586 12.2188 15.2308 12.0439 15.2308 11.8281V4.17188ZM16 11.8281C16 12.4753 15.4834 13 14.8462 13H1.15385C0.516595 13 0 12.4753 0 11.8281V4.17188C0 3.52467 0.516595 3 1.15385 3H14.8462C15.4834 3 16 3.52467 16 4.17188V11.8281Z" />
|
|
11
|
+
<path d="M2.30769 10.6562V5.34375H3.84615L5.38462 7.29688L6.92308 5.34375H8.46154V10.6562H6.92308V7.60938L5.38462 9.5625L3.84615 7.60938V10.6562H2.30769ZM11.9231 10.6562L9.61539 8.07812H11.1538V5.34375H12.6923V8.07812H14.2308L11.9231 10.6562Z" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const MarkdownFullIcon = styled(Icon).attrs(() => ({
|
|
16
|
+
'data-component-name': 'icons/MarkdownFullIcon/MarkdownFullIcon',
|
|
17
|
+
}))<IconProps>`
|
|
18
|
+
path {
|
|
19
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
height: ${({ size }) => size || '16px'};
|
|
23
|
+
width: ${({ size }) => size || '16px'};
|
|
24
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
const Icon = (props: IconProps) => (
|
|
7
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
8
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const NoneIcon = styled(Icon).attrs(() => ({
|
|
13
|
+
'data-component-name': 'icons/NoneIcon/NoneIcon',
|
|
14
|
+
}))<IconProps>`
|
|
15
|
+
height: ${({ size }) => size || '16px'};
|
|
16
|
+
width: ${({ size }) => size || '16px'};
|
|
17
|
+
`;
|
package/src/icons/types.ts
CHANGED
|
@@ -5,3 +5,10 @@ export type IconProps = {
|
|
|
5
5
|
size?: string;
|
|
6
6
|
className?: string;
|
|
7
7
|
} & React.SVGProps<SVGSVGElement>;
|
|
8
|
+
|
|
9
|
+
export type CDNIconProps = IconProps & {
|
|
10
|
+
name: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
pack?: 'font-awesome' | 'code'; // default is font-awesome, code is for vscode icons
|
|
13
|
+
mode?: 'mask' | 'background'; // default is mask, background allows to keep original colors
|
|
14
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from '@redocly/theme/ext/configure';
|
|
|
4
4
|
|
|
5
5
|
/* Components */
|
|
6
6
|
export * from '@redocly/theme/components/Button/Button';
|
|
7
|
+
export * from '@redocly/theme/components/Button/ButtonGroup';
|
|
7
8
|
export * from '@redocly/theme/components/JsonViewer/JsonViewer';
|
|
8
9
|
export * from '@redocly/theme/components/Tag/Tag';
|
|
9
10
|
export * from '@redocly/theme/components/TableOfContent/TableOfContent';
|
|
@@ -25,6 +26,7 @@ export * from '@redocly/theme/components/Tags/HttpTag';
|
|
|
25
26
|
export * from '@redocly/theme/components/Tags/CounterTag';
|
|
26
27
|
export * from '@redocly/theme/components/VersionPicker/VersionPicker';
|
|
27
28
|
export * from '@redocly/theme/components/Marker/Marker';
|
|
29
|
+
export * from '@redocly/theme/components/PageActions/PageActions';
|
|
28
30
|
/* Buttons */
|
|
29
31
|
export * from '@redocly/theme/components/Buttons/CopyButton';
|
|
30
32
|
export * from '@redocly/theme/components/Buttons/EditPageButton';
|
|
@@ -171,7 +173,9 @@ export * from '@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon';
|
|
|
171
173
|
export * from '@redocly/theme/icons/AddIcon/AddIcon';
|
|
172
174
|
export * from '@redocly/theme/icons/BookmarkAddIcon/BookmarkAddIcon';
|
|
173
175
|
export * from '@redocly/theme/icons/SpinnerIcon/SpinnerIcon';
|
|
176
|
+
export * from '@redocly/theme/icons/ChatGptIcon/ChatGptIcon';
|
|
174
177
|
export * from '@redocly/theme/icons/CopyIcon/CopyIcon';
|
|
178
|
+
export * from '@redocly/theme/icons/ClaudeIcon/ClaudeIcon';
|
|
175
179
|
export * from '@redocly/theme/icons/CleanIcon/CleanIcon';
|
|
176
180
|
export * from '@redocly/theme/icons/GraphqlIcon/GraphqlIcon';
|
|
177
181
|
export * from '@redocly/theme/icons/DeselectIcon/DeselectIcon';
|
|
@@ -237,6 +241,7 @@ export * from '@redocly/theme/icons/LinkIcon/LinkIcon';
|
|
|
237
241
|
export * from '@redocly/theme/icons/LaunchIcon/LaunchIcon';
|
|
238
242
|
export * from '@redocly/theme/icons/MinimizeIcon/MinimizeIcon';
|
|
239
243
|
export * from '@redocly/theme/icons/MaximizeIcon/MaximizeIcon';
|
|
244
|
+
export * from '@redocly/theme/icons/MarkdownFullIcon/MarkdownFullIcon';
|
|
240
245
|
export * from '@redocly/theme/icons/DocumentBlankIcon/DocumentBlankIcon';
|
|
241
246
|
export * from '@redocly/theme/icons/WarningSquareIcon/WarningSquareIcon';
|
|
242
247
|
export * from '@redocly/theme/icons/MenuIcon/MenuIcon';
|
|
@@ -275,6 +280,7 @@ export * from '@redocly/theme/icons/RabbitMQIcon/RabbitMQIcon';
|
|
|
275
280
|
export * from '@redocly/theme/icons/CurveAutoColonIcon/CurveAutoColonIcon';
|
|
276
281
|
export * from '@redocly/theme/icons/AiStarsIcon/AiStarsIcon';
|
|
277
282
|
export * from '@redocly/theme/icons/AiStarsGradientIcon/AiStarsGradientIcon';
|
|
283
|
+
export * from '@redocly/theme/icons/GenericIcon/GenericIcon';
|
|
278
284
|
/* Layouts */
|
|
279
285
|
export * from '@redocly/theme/layouts/RootLayout';
|
|
280
286
|
export * from '@redocly/theme/layouts/PageLayout';
|
|
@@ -3,7 +3,7 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
|
|
6
|
-
import { breakpoints } from '@redocly/theme/core';
|
|
6
|
+
import { breakpoints } from '@redocly/theme/core/utils';
|
|
7
7
|
|
|
8
8
|
export type CodeWalkthroughLayoutProps = React.PropsWithChildren<{
|
|
9
9
|
className?: string;
|
|
@@ -10,6 +10,12 @@ import { PageNavigation } from '@redocly/theme/components/PageNavigation/PageNav
|
|
|
10
10
|
import { LastUpdated } from '@redocly/theme/components/LastUpdated/LastUpdated';
|
|
11
11
|
import { Breadcrumbs as ThemeBreadcrumbs } from '@redocly/theme/components/Breadcrumbs/Breadcrumbs';
|
|
12
12
|
|
|
13
|
+
import {
|
|
14
|
+
CodeSnippetContext,
|
|
15
|
+
CODE_GROUP_SNIPPET_NAME_KEY,
|
|
16
|
+
} from '../core/contexts/CodeSnippetContext';
|
|
17
|
+
import { useLocalState } from '../core/hooks/use-local-state';
|
|
18
|
+
|
|
13
19
|
type DocumentationLayoutProps = {
|
|
14
20
|
tableOfContent: React.ReactNode;
|
|
15
21
|
feedback: React.ReactNode;
|
|
@@ -38,20 +44,24 @@ export function DocumentationLayout({
|
|
|
38
44
|
const { editPage: themeEditPage } = config || {};
|
|
39
45
|
const mergedConf = editPage ? { ...themeEditPage, ...editPage } : undefined;
|
|
40
46
|
|
|
47
|
+
const [activeSnippetName, setActiveSnippetName] = useLocalState(CODE_GROUP_SNIPPET_NAME_KEY, '');
|
|
48
|
+
|
|
41
49
|
return (
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
<CodeSnippetContext.Provider value={{ activeSnippetName, setActiveSnippetName }}>
|
|
51
|
+
<LayoutWrapper data-component-name="Layout/DocumentationLayout" className={className}>
|
|
52
|
+
<ContentWrapper withToc={!config?.toc?.hide}>
|
|
53
|
+
<Breadcrumbs />
|
|
54
|
+
<LayoutTop>
|
|
55
|
+
{lastModified && <LastUpdated lastModified={new Date(lastModified)} />}
|
|
56
|
+
{mergedConf && <EditPageButton to={mergedConf.to} />}
|
|
57
|
+
</LayoutTop>
|
|
58
|
+
{children}
|
|
59
|
+
<LayoutBottom>{feedback}</LayoutBottom>
|
|
60
|
+
<PageNavigation nextPage={nextPage} prevPage={prevPage} />
|
|
61
|
+
</ContentWrapper>
|
|
62
|
+
{tableOfContent}
|
|
63
|
+
</LayoutWrapper>
|
|
64
|
+
</CodeSnippetContext.Provider>
|
|
55
65
|
);
|
|
56
66
|
}
|
|
57
67
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { GenericIcon } from '@redocly/theme/icons/GenericIcon/GenericIcon';
|
|
5
5
|
|
|
6
6
|
export type CardIconProps = {
|
|
7
7
|
variant?: string;
|
|
@@ -13,31 +13,16 @@ export type CardIconProps = {
|
|
|
13
13
|
export function CardIcon({ variant, src, rawContent, position }: CardIconProps) {
|
|
14
14
|
return (
|
|
15
15
|
<CardIconWrapper $variant={variant} $position={position}>
|
|
16
|
-
|
|
16
|
+
<GenericIcon icon={src} rawContent={rawContent} />
|
|
17
17
|
</CardIconWrapper>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const CardImg = styled.img`
|
|
22
|
-
width: var(--card-icon-width);
|
|
23
|
-
height: var(--card-icon-height);
|
|
24
|
-
display: inline-block;
|
|
25
|
-
object-fit: cover;
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
const CardSvg = styled(InlineSvg)`
|
|
29
|
-
width: var(--card-icon-width);
|
|
30
|
-
height: var(--card-icon-height);
|
|
31
|
-
display: inline-block;
|
|
32
|
-
|
|
33
|
-
svg {
|
|
34
|
-
width: 100%;
|
|
35
|
-
height: 100%;
|
|
36
|
-
fill: var(--card-icon-color);
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
21
|
const CardIconWrapper = styled.div<{ $variant?: string; $position?: string }>`
|
|
22
|
+
--icon-width: var(--card-icon-width);
|
|
23
|
+
--icon-height: var(--card-icon-height);
|
|
24
|
+
--icon-color: var(--card-icon-color);
|
|
25
|
+
|
|
41
26
|
display: flex;
|
|
42
27
|
align-self: ${({ $position }) => ($position ? $position : 'auto')};
|
|
43
28
|
justify-content: center;
|