@redocly/theme 0.4.16 → 0.5.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.
Files changed (87) hide show
  1. package/lib/ApiOnboarding/AppCustomAttributes.d.ts +5 -0
  2. package/lib/ApiOnboarding/AppCustomAttributes.js +8 -0
  3. package/lib/ColorModeSwitcher/ColorModeSwitcher.js +23 -10
  4. package/lib/EditPageButton/EditPageButton.d.ts +1 -1
  5. package/lib/EditPageButton/EditPageButton.js +5 -1
  6. package/lib/Footer/Footer.js +2 -2
  7. package/lib/Footer/FooterColumn.js +1 -1
  8. package/lib/LastUpdated/LastUpdated.js +30 -7
  9. package/lib/Markdown/Admonition.js +3 -0
  10. package/lib/Markdown/CodeSample/CodeSample.js +14 -14
  11. package/lib/Markdown/MarkdownLayout.d.ts +1 -1
  12. package/lib/Markdown/MarkdownLayout.js +5 -1
  13. package/lib/Navbar/Navbar.js +2 -2
  14. package/lib/Navbar/NavbarItem.js +1 -1
  15. package/lib/PageNavigation/NextPageLink.js +30 -7
  16. package/lib/PageNavigation/PageNavigation.js +8 -3
  17. package/lib/PageNavigation/PreviousPageLink.js +4 -4
  18. package/lib/Sidebar/MenuLink.d.ts +3 -4
  19. package/lib/Sidebar/MenuLink.js +2 -6
  20. package/lib/Sidebar/SidebarLayout.js +2 -2
  21. package/lib/Sidebar/types/MenuStyle.js +0 -1
  22. package/lib/TableOfContent/TableOfContent.d.ts +0 -1
  23. package/lib/TableOfContent/TableOfContent.js +5 -7
  24. package/lib/config.d.ts +385 -0
  25. package/lib/config.js +113 -0
  26. package/lib/globalStyle.js +3 -5
  27. package/lib/hooks/index.d.ts +1 -0
  28. package/lib/hooks/index.js +1 -0
  29. package/lib/hooks/useActiveHeading.js +1 -1
  30. package/lib/hooks/useActiveSectionId.js +1 -1
  31. package/lib/hooks/useThemeConfig.d.ts +1 -0
  32. package/lib/hooks/useThemeConfig.js +6 -0
  33. package/lib/icons/ColorModeIcon/ColorModeIcon.js +3 -3
  34. package/lib/index.d.ts +2 -0
  35. package/lib/index.js +2 -0
  36. package/lib/mocks/Link.js +12 -2
  37. package/lib/mocks/hooks/index.d.ts +2 -5
  38. package/lib/mocks/hooks/index.js +22 -6
  39. package/lib/mocks/types.d.ts +0 -11
  40. package/lib/mocks/types.js +1 -0
  41. package/lib/types/config.d.ts +5 -0
  42. package/lib/types/config.js +3 -0
  43. package/lib/ui/index.d.ts +0 -1
  44. package/lib/ui/index.js +0 -1
  45. package/lib/utils/args-typecheck.js +1 -1
  46. package/package.json +30 -34
  47. package/src/ApiOnboarding/AppCustomAttributes.tsx +6 -0
  48. package/src/ColorModeSwitcher/ColorModeSwitcher.tsx +29 -12
  49. package/src/EditPageButton/EditPageButton.tsx +6 -2
  50. package/src/Footer/Footer.tsx +2 -2
  51. package/src/Footer/FooterColumn.tsx +7 -1
  52. package/src/LastUpdated/LastUpdated.tsx +8 -6
  53. package/src/Markdown/Admonition.tsx +3 -0
  54. package/src/Markdown/CodeSample/CodeSample.tsx +15 -16
  55. package/src/Markdown/MarkdownLayout.tsx +9 -3
  56. package/src/Navbar/Navbar.tsx +2 -2
  57. package/src/Navbar/NavbarItem.tsx +1 -1
  58. package/src/PageNavigation/NextPageLink.tsx +8 -5
  59. package/src/PageNavigation/PageNavigation.tsx +7 -3
  60. package/src/PageNavigation/PreviousPageLink.tsx +7 -4
  61. package/src/Sidebar/MenuLink.tsx +3 -8
  62. package/src/Sidebar/SidebarLayout.tsx +2 -2
  63. package/src/Sidebar/types/MenuStyle.ts +0 -1
  64. package/src/TableOfContent/TableOfContent.tsx +5 -7
  65. package/src/config.ts +130 -0
  66. package/src/globalStyle.ts +3 -5
  67. package/src/hooks/index.ts +1 -0
  68. package/src/hooks/useActiveHeading.ts +3 -1
  69. package/src/hooks/useActiveSectionId.ts +1 -1
  70. package/src/hooks/useThemeConfig.ts +1 -0
  71. package/src/icons/ColorModeIcon/ColorModeIcon.tsx +3 -3
  72. package/src/index.ts +3 -0
  73. package/src/mocks/Link.tsx +8 -2
  74. package/src/mocks/hooks/index.ts +22 -9
  75. package/src/mocks/types.ts +2 -11
  76. package/{settings.yaml → src/settings.yaml} +0 -0
  77. package/src/types/config.ts +5 -0
  78. package/src/types/portal/src/shared/constants.d.ts +0 -1
  79. package/src/types/portal/src/shared/types/nav.d.ts +3 -0
  80. package/src/ui/index.tsx +0 -1
  81. package/src/utils/args-typecheck.ts +1 -1
  82. package/lib/hooks/useDefaultThemeSettings.d.ts +0 -2
  83. package/lib/hooks/useDefaultThemeSettings.js +0 -10
  84. package/lib/ui/UniversalLink.d.ts +0 -17
  85. package/lib/ui/UniversalLink.js +0 -79
  86. package/src/hooks/useDefaultThemeSettings.ts +0 -7
  87. package/src/ui/UniversalLink.tsx +0 -97
@@ -1,97 +0,0 @@
1
- import * as React from 'react';
2
- import { useLocation } from 'react-router-dom';
3
- import styled from 'styled-components';
4
-
5
- import type { LinkProps } from 'react-router-dom';
6
-
7
- import { isUrl } from '@theme/utils/isUrl';
8
- import { Link } from '@portal/Link';
9
-
10
- const StyledExternalLink = styled.a`
11
- &.external-url {
12
- position: relative;
13
-
14
- :after {
15
- content: '';
16
- display: inline-block;
17
- position: absolute;
18
- background: var(--text-color);
19
- mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' version='1.1' x='0' y='0' viewBox='0 0 100 125' enable-background='new 0 0 100 100' xml:space='preserve'%3E%3Cpath d='M-408.2-318.5 98.6 4.8c0-0.1 0-0.2-0.1-0.3 0-0.1-0.1-0.2-0.1-0.3 0-0.1 0-0.1-0.1-0.2 0 0 0-0.1 0-0.1 0-0.1-0.1-0.2-0.2-0.3 0-0.1-0.1-0.2-0.2-0.3 -0.1-0.1-0.1-0.2-0.2-0.3C97.7 2.9 97.6 2.8 97.5 2.7c-0.1-0.1-0.2-0.2-0.3-0.3 -0.1-0.1-0.1-0.1-0.2-0.2 -0.1-0.1-0.2-0.2-0.3-0.2 -0.1-0.1-0.2-0.1-0.2-0.2 -0.1-0.1-0.2-0.1-0.3-0.2 -0.1 0-0.2-0.1-0.3-0.1 0 0-0.1 0-0.1-0.1 -0.1 0-0.2 0-0.2-0.1 -0.1 0-0.2-0.1-0.3-0.1 -0.1 0-0.2-0.1-0.4-0.1 -0.1 0-0.2 0-0.3 0 -0.1 0-0.3 0-0.4 0 -0.1 0-0.1 0-0.2 0L63.8 1.3c-2.5 0-4.6 2.1-4.6 4.6 0 2.5 2.1 4.6 4.6 4.5l19.3-0.1 -29.8 30.2c-1.1 1.1-1.5 2.7-1.2 4.1 0.2 0.9 0.6 1.7 1.3 2.4 0.9 0.9 2.1 1.3 3.2 1.3 1.2 0 2.3-0.5 3.2-1.4l0 0 29.8-30.2 0.1 19.3c0 2.5 2.1 4.6 4.6 4.5 1.3 0 2.4-0.5 3.2-1.4 0.8-0.8 1.3-2 1.3-3.2L98.7 5.7c0-0.1 0-0.1 0-0.2 0-0.1 0-0.2 0-0.4C98.6 5 98.6 4.9 98.6 4.8zM6.5 83.3c0 5.7 4.6 10.4 10.4 10.4l55.6 0.1c5.7 0 10.4-4.6 10.4-10.4l-0.1-40.8h6.1v40.8c0 9-7.3 16.3-16.3 16.3l-56.4-0.1c-8.6 0-15.6-7-15.6-15.6L0.6 27.8c0-9 7.3-16.3 16.3-16.3l41.1-0.1v6.1L17 17.5c-5.7 0-10.4 4.6-10.4 10.4L6.5 83.3z'/%3E%3C/svg%3E");
20
- mask-repeat: no-repeat;
21
- width: 10px;
22
- height: 10px;
23
- top: 50%;
24
- right: -15px;
25
- transform: translateY(-50%);
26
- }
27
- }
28
- `;
29
-
30
- // TODO: We're using our own Link component so probably filtering is not necessary here.
31
- // filter out unnecessary props
32
- const propsList = [
33
- 'color',
34
- 'size',
35
- 'variant',
36
- 'bgColor',
37
- 'bgImage',
38
- 'disableArrow',
39
- 'withIcon',
40
- 'maxWidth',
41
- 'inversed',
42
- 'transparent',
43
- 'large',
44
- ];
45
-
46
- export const withPropsFilter =
47
- (filterList: string[]) => (WrappedComponent: React.FunctionComponent) =>
48
- function WithPropsFilter(props: React.PropsWithChildren<object>): JSX.Element {
49
- const filteredProps = Object.fromEntries(
50
- Object.entries(props).filter(([key]) => !filterList.includes(key)),
51
- );
52
-
53
- return <WrappedComponent {...filteredProps} />;
54
- };
55
-
56
- export interface PortalLinkProps<TState> extends LinkProps<TState> {
57
- activeClassName?: string;
58
- activeStyle?: object;
59
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
60
- partiallyActive?: boolean;
61
- replace?: boolean;
62
- state?: TState;
63
- to: string;
64
- }
65
-
66
- export interface UniversalLinkProps extends Partial<PortalLinkProps<object>> {
67
- external?: boolean;
68
- ref?: any;
69
- }
70
-
71
- export const UniversalLink = withPropsFilter(propsList)((props: UniversalLinkProps) => {
72
- return (typeof props.to === 'string' && (isUrl(props.to) || props.to.startsWith('mailto:'))) ||
73
- props.external ? (
74
- <StyledExternalLink
75
- style={props.style}
76
- href={props.to}
77
- target={props.target || (props.external && '_blank') || '_self'}
78
- className={`${props.external ? 'external-url' : ''} ${props.className}`}
79
- rel={props.rel}
80
- data-cy={`universalLink-${
81
- typeof props.children === 'string' ? props.children : 'with-nested-jsx'
82
- }`}
83
- >
84
- {props.children}
85
- </StyledExternalLink>
86
- ) : props.to == null ? (
87
- <a onClick={props.onClick} className={props.className} style={props.style}>
88
- {props.children}
89
- </a>
90
- ) : (
91
- <Link
92
- {...props}
93
- to={props.to}
94
- state={{ previousPath: useLocation()?.pathname, ...props.state }}
95
- />
96
- );
97
- });