@redocly/theme 0.8.1 → 0.8.3

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 (59) hide show
  1. package/lib/Button/Button.js +2 -2
  2. package/lib/Catalog/Filter.js +1 -3
  3. package/lib/Markdown/Admonition.d.ts +2 -1
  4. package/lib/Markdown/Admonition.js +2 -2
  5. package/lib/Profile/Profile.js +1 -1
  6. package/lib/ReferenceDocs/ClearButton.d.ts +8 -0
  7. package/lib/ReferenceDocs/ClearButton.js +48 -0
  8. package/lib/ReferenceDocs/DevOnboardingTryItSecurity.d.ts +3 -0
  9. package/lib/ReferenceDocs/DevOnboardingTryItSecurity.js +158 -0
  10. package/lib/ReferenceDocs/Dropdown.d.ts +28 -0
  11. package/lib/ReferenceDocs/Dropdown.js +150 -0
  12. package/lib/ReferenceDocs/TryItSecurityApps.d.ts +7 -0
  13. package/lib/ReferenceDocs/TryItSecurityApps.js +15 -0
  14. package/lib/ReferenceDocs/index.d.ts +1 -0
  15. package/lib/ReferenceDocs/index.js +18 -0
  16. package/lib/Sidebar/FooterWrapper.d.ts +3 -0
  17. package/lib/Sidebar/FooterWrapper.js +15 -0
  18. package/lib/Sidebar/HeaderWrapper.d.ts +3 -0
  19. package/lib/Sidebar/HeaderWrapper.js +15 -0
  20. package/lib/Sidebar/MenuContainer.d.ts +5 -3
  21. package/lib/Sidebar/MenuContainer.js +3 -2
  22. package/lib/Sidebar/MenuItemLabel.js +2 -2
  23. package/lib/Sidebar/Sidebar.d.ts +0 -1
  24. package/lib/Sidebar/Sidebar.js +1 -6
  25. package/lib/Sidebar/SidebarLayout.d.ts +4 -2
  26. package/lib/Sidebar/SidebarLayout.js +7 -28
  27. package/lib/Sidebar/index.d.ts +2 -0
  28. package/lib/Sidebar/index.js +2 -0
  29. package/lib/SourceCode/SourceCode.d.ts +3 -2
  30. package/lib/SourceCode/SourceCode.js +5 -5
  31. package/lib/globalStyle.js +9 -0
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +1 -0
  34. package/lib/mocks/hooks/index.d.ts +1 -1
  35. package/lib/mocks/hooks/index.js +3 -1
  36. package/lib/mocks/useGlobalData.d.ts +1 -0
  37. package/lib/mocks/useGlobalData.js +8 -0
  38. package/package.json +1 -1
  39. package/src/Button/Button.tsx +8 -4
  40. package/src/Catalog/Filter.tsx +1 -1
  41. package/src/Markdown/Admonition.tsx +3 -0
  42. package/src/Profile/Profile.tsx +1 -1
  43. package/src/ReferenceDocs/ClearButton.tsx +32 -0
  44. package/src/ReferenceDocs/DevOnboardingTryItSecurity.tsx +161 -0
  45. package/src/ReferenceDocs/Dropdown.tsx +202 -0
  46. package/src/ReferenceDocs/TryItSecurityApps.tsx +17 -0
  47. package/src/ReferenceDocs/index.ts +1 -0
  48. package/src/Sidebar/FooterWrapper.tsx +9 -0
  49. package/src/Sidebar/HeaderWrapper.tsx +9 -0
  50. package/src/Sidebar/MenuContainer.tsx +8 -3
  51. package/src/Sidebar/MenuItemLabel.tsx +2 -2
  52. package/src/Sidebar/Sidebar.tsx +1 -7
  53. package/src/Sidebar/SidebarLayout.tsx +12 -34
  54. package/src/Sidebar/index.ts +2 -0
  55. package/src/SourceCode/SourceCode.tsx +6 -0
  56. package/src/globalStyle.ts +9 -0
  57. package/src/index.ts +1 -0
  58. package/src/mocks/hooks/index.ts +2 -0
  59. package/src/mocks/useGlobalData.tsx +3 -0
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import { useGlobalData } from '@portal/hooks';
4
+
5
+ import { DevOnboardingTryItSecurity } from './DevOnboardingTryItSecurity';
6
+
7
+ export type TryItSecurityAppsProps = {
8
+ apiId?: string;
9
+ value?: string;
10
+ onChange: (newSecretKey: string) => void;
11
+ };
12
+
13
+ export function TryItSecurityApps(props: TryItSecurityAppsProps) {
14
+ const { hasDeveloperOnboarding } = useGlobalData() || {};
15
+
16
+ return hasDeveloperOnboarding && props.apiId ? <DevOnboardingTryItSecurity {...props} /> : null;
17
+ }
@@ -0,0 +1 @@
1
+ export * from './TryItSecurityApps';
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const FooterWrapper = styled.div.attrs(() => ({
4
+ 'data-component-name': 'Sidebar/FooterWrapper',
5
+ }))`
6
+ margin: var(--sidebar-offset-top) 0 var(--sidebar-spacing-unit) var(--sidebar-offset-left);
7
+ padding-top: var(--sidebar-spacing-unit);
8
+ border-top: solid 1px #daddde;
9
+ `;
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const HeaderWrapper = styled.div.attrs(() => ({
4
+ 'data-component-name': 'Sidebar/HeaderWrapper',
5
+ }))`
6
+ margin: var(--sidebar-offset-top) 0 0 var(--sidebar-offset-left);
7
+ padding-bottom: var(--sidebar-spacing-unit);
8
+ border-bottom: solid 1px #daddde;
9
+ `;
@@ -1,10 +1,15 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const MenuContainer = styled.div.attrs(() => ({
3
+ interface MenuContainerProps {
4
+ growContent?: boolean;
5
+ }
6
+
7
+ export const MenuContainer = styled.div.attrs<MenuContainerProps>(({ growContent }) => ({
4
8
  'data-component-name': 'Sidebar/MenuContainer',
5
- }))`
9
+ growContent: growContent === undefined ? true : growContent,
10
+ }))<MenuContainerProps>`
6
11
  position: relative;
7
12
  overflow-y: auto;
8
- flex-grow: 1;
13
+ flex-grow: ${({ growContent }) => (growContent ? 1 : 0)};
9
14
  padding-top: var(--sidebar-offset-top);
10
15
  `;
@@ -31,8 +31,8 @@ export const MenuItemLabel = styled.li.attrs(() => ({
31
31
  : null};
32
32
 
33
33
  :hover {
34
- color: var(--sidebar-item-active-color);
35
- background-color: var(--sidebar-item-active-background-color);
34
+ color: var(--sidebar-item-hover-color);
35
+ background-color: var(--sidebar-item-hover-background-color);
36
36
  }
37
37
 
38
38
  :empty {
@@ -1,7 +1,6 @@
1
1
  import styled from 'styled-components';
2
2
 
3
3
  interface SidebarProps {
4
- isNavbar: boolean;
5
4
  opened?: boolean;
6
5
  animate?: boolean;
7
6
  }
@@ -24,15 +23,10 @@ export const Sidebar = styled.aside.attrs(() => ({
24
23
  width: 100%;
25
24
  -webkit-font-smoothing: antialiased;
26
25
 
27
- ${({ isNavbar }) => `
28
- top: ${isNavbar ? 'var(--navbar-height)' : '0'};
29
- height: calc(100vh ${isNavbar ? '- var(--navbar-height)' : ''});
30
- `};
31
-
32
26
  ${({ opened, animate }) => `
33
27
  opacity: ${opened ? '1' : '0'};
34
28
  pointer-events: ${opened ? 'auto' : 'none'};
35
-
29
+
36
30
  & > * {
37
31
  transform: ${opened ? 'translate(0, 0)' : 'translate(0, 40px)'};
38
32
  transition: ${animate ? 'transform 0.65s ease, opacity 0.25s ease;' : 'none'};
@@ -2,13 +2,13 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { Sidebar } from '@theme/Sidebar/Sidebar';
5
+ import { FooterWrapper } from '@theme/Sidebar/FooterWrapper';
6
+ import { HeaderWrapper } from '@theme/Sidebar/HeaderWrapper';
5
7
  import { useMobileMenu } from '@theme/hooks/useMobileMenu';
6
8
  import { MobileSidebarButton } from '@theme/Sidebar/MobileSidebarButton';
7
9
  import { MenuContainer } from '@theme/Sidebar/MenuContainer';
8
10
  import { SidebarSearch } from '@theme/Search/SidebarSearch';
9
11
  import { useThemeConfig } from '@theme/hooks/useThemeConfig';
10
- import { ArrowBack } from '@theme/Sidebar/ArrowBack';
11
- import { Link } from '@portal/Link';
12
12
 
13
13
  interface SidebarLayoutProps {
14
14
  versions: React.ReactNode;
@@ -17,14 +17,17 @@ interface SidebarLayoutProps {
17
17
  label: string;
18
18
  slug: string;
19
19
  };
20
- isNavbar: boolean;
20
+ footer?: React.ReactNode;
21
+ header?: React.ReactNode;
22
+ growContent?: boolean;
21
23
  }
22
24
 
23
25
  export function SidebarLayout({
24
26
  versions,
25
27
  menu,
26
- backLink,
27
- isNavbar,
28
+ footer,
29
+ header,
30
+ growContent,
28
31
  }: SidebarLayoutProps): JSX.Element | null {
29
32
  const [isOpen, setIsOpen] = useMobileMenu();
30
33
  const toggleMenu = () => setIsOpen(!isOpen);
@@ -39,39 +42,14 @@ export function SidebarLayout({
39
42
  <MobileSidebarButton opened={isOpen} onClick={toggleMenu} />
40
43
 
41
44
  {!search?.hide && search?.placement === 'sidebar' ? <SidebarSearch /> : null}
42
- <Sidebar animate={true} opened={isOpen} isNavbar={isNavbar}>
43
- {(backLink && (
44
- <BackLinkWrapper>
45
- <Link to={backLink.slug}>
46
- <ArrowBack />
47
- Back to {backLink.label}
48
- </Link>
49
- </BackLinkWrapper>
50
- )) ||
51
- null}
45
+ <Sidebar animate={true} opened={isOpen}>
46
+ {header ? <HeaderWrapper>{header}</HeaderWrapper> : null}
52
47
  {versions}
53
- <MenuContainer>{menu}</MenuContainer>
48
+ <MenuContainer growContent={growContent}>{menu}</MenuContainer>
49
+ {footer ? <FooterWrapper>{footer}</FooterWrapper> : null}
54
50
  </Sidebar>
55
51
  </Wrapper>
56
52
  );
57
53
  }
58
54
 
59
- const BackLinkWrapper = styled.div`
60
- padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
61
- var(--sidebar-item-padding-horizontal)
62
- calc(var(--sidebar-offset-left) + var(--sidebar-item-padding-horizontal));
63
-
64
- a {
65
- color: var(--sidebar-back-button-text-color);
66
- font-size: var(--sidebar-back-button-font-size);
67
- font-family: var(--sidebar-back-button-font-family);
68
- text-decoration: none;
69
- &:hover {
70
- color: var(--sidebar-back-button-hover-text-color);
71
- }
72
- }
73
-
74
- border-bottom: 1px solid var(--sidebar-border-color);
75
- `;
76
-
77
55
  const Wrapper = styled.div``;
@@ -17,3 +17,5 @@ export * from '@theme/Sidebar/Separator';
17
17
  export * from '@theme/Sidebar/SeparatorItem';
18
18
  export * from '@theme/Sidebar/Sidebar';
19
19
  export * from '@theme/Sidebar/SidebarLayout';
20
+ export * from '@theme/Sidebar/FooterWrapper';
21
+ export * from '@theme/Sidebar/HeaderWrapper';
@@ -11,6 +11,7 @@ import { CopyButtonWrapper } from '@theme/CopyButton';
11
11
  interface CommonCodeProps {
12
12
  withLineNumbers?: boolean;
13
13
  startLineNumber?: number;
14
+ className?: string;
14
15
  }
15
16
 
16
17
  export interface SourceCodeProps extends CommonCodeProps {
@@ -49,11 +50,13 @@ export function Code({
49
50
  dataTestId,
50
51
  withLineNumbers,
51
52
  startLineNumber,
53
+ className,
52
54
  }: CodeProps): JSX.Element {
53
55
  const highlightedCode = highlight(source, lang);
54
56
 
55
57
  return (
56
58
  <PreformattedCodeBlock
59
+ className={className}
57
60
  dangerouslySetInnerHTML={{
58
61
  __html: withLineNumbers
59
62
  ? addLineNumbers(highlightedCode, startLineNumber)
@@ -73,6 +76,7 @@ export function SourceCode({
73
76
  dataTestId = 'source-code',
74
77
  withLineNumbers,
75
78
  startLineNumber,
79
+ className,
76
80
  }: SourceCodeProps): JSX.Element {
77
81
  const [sourceCode, setSourceCode] = useState<string>(source ?? '');
78
82
 
@@ -102,6 +106,7 @@ export function SourceCode({
102
106
  withLineNumbers={withLineNumbers}
103
107
  startLineNumber={startLineNumber}
104
108
  dataTestId={dataTestId}
109
+ className={className}
105
110
  />
106
111
  </SampleControlsWrap>
107
112
  )}
@@ -112,6 +117,7 @@ export function SourceCode({
112
117
  return (
113
118
  <Code
114
119
  dataTestId={dataTestId}
120
+ className={className}
115
121
  lang={lang}
116
122
  source={sourceCode}
117
123
  withLineNumbers={withLineNumbers}
@@ -884,6 +884,7 @@ const apiReferencePanels = css`
884
884
  .panel-request-samples,
885
885
  .panel-response-samples,
886
886
  .panel-callback-samples {
887
+ --text-color: var(--panel-samples-text-color);
887
888
  --panel-text-color: var(--panel-samples-text-color); // @presenter Color
888
889
  --panel-font-family-local: var(--panel-samples-font-family);
889
890
  --panel-font-size-local: var(--panel-samples-font-size);
@@ -2009,10 +2010,18 @@ export const styles = css`
2009
2010
  ${apiLogsTable}
2010
2011
  ${pages}
2011
2012
  ${modal}
2013
+
2014
+ --api-onboarding-table-text-color: #4e5356;
2015
+
2016
+ background-color: var(--background-color);
2017
+ color: var(--text-color);
2018
+ font-family: var(--font-family-base);
2012
2019
  }
2013
2020
 
2014
2021
  :root.dark {
2015
2022
  ${darkMode};
2023
+
2024
+ --api-onboarding-table-text-color: #ffffff;
2016
2025
  }
2017
2026
 
2018
2027
  :root.notransition * {
package/src/index.ts CHANGED
@@ -23,3 +23,4 @@ export * from './types/config';
23
23
  export * from './config';
24
24
  export * from './Pages';
25
25
  export * from './Markdown';
26
+ export * from './ReferenceDocs';
@@ -74,3 +74,5 @@ export function usePageSharedData<T = unknown>(_id: string): T {
74
74
  export function useCatalog(_items: ResolvedNavItem[], _config: CatalogConfig): FilteredCatalog {
75
75
  throw new Error('Mock not implemented yet.');
76
76
  }
77
+
78
+ export { useGlobalData } from '../useGlobalData';
@@ -0,0 +1,3 @@
1
+ export function useGlobalData(): Record<string, unknown> {
2
+ return {};
3
+ }