@redocly/theme 0.1.23 → 0.1.26

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 (98) hide show
  1. package/Cards/Card.d.ts +8 -0
  2. package/Cards/Card.js +25 -0
  3. package/Cards/CardsBlock.d.ts +3 -0
  4. package/Cards/CardsBlock.js +15 -0
  5. package/CodeBlock/CodeBlock.d.ts +3 -1
  6. package/CodeBlock/CodeBlock.js +3 -1
  7. package/CopyButton/CopyButton.js +1 -1
  8. package/Footer/Footer.js +1 -1
  9. package/JsonViewer/JsonViewer.d.ts +6 -2
  10. package/JsonViewer/JsonViewer.js +3 -1
  11. package/Markdown/{StyledMarkdown.d.ts → MarkdownWrapper.d.ts} +1 -1
  12. package/Markdown/{StyledMarkdown.js → MarkdownWrapper.js} +3 -3
  13. package/Markdown/index.d.ts +1 -1
  14. package/Markdown/index.js +1 -1
  15. package/Navbar/Navbar.js +1 -1
  16. package/OperationBadge/OperationBadge.d.ts +2 -1
  17. package/OperationBadge/OperationBadge.js +1 -0
  18. package/PageNavigation/NextPageLink.js +9 -3
  19. package/PageNavigation/PreviousPageLink.js +9 -3
  20. package/Panel/CodePanel.d.ts +5 -1
  21. package/Panel/CodePanel.js +3 -1
  22. package/Panel/ContentPanel.d.ts +5 -1
  23. package/Panel/ContentPanel.js +3 -1
  24. package/Panel/Panel.d.ts +3 -1
  25. package/Panel/Panel.js +3 -1
  26. package/Panel/PanelBody.d.ts +3 -1
  27. package/Panel/PanelBody.js +3 -1
  28. package/Panel/PanelComponent.js +1 -1
  29. package/Panel/PanelHeader.d.ts +3 -1
  30. package/Panel/PanelHeader.js +3 -1
  31. package/Panel/PanelHeaderTitle.d.ts +3 -1
  32. package/Panel/PanelHeaderTitle.js +3 -1
  33. package/SamplesPanelControls/SamplesPanelControls.d.ts +6 -2
  34. package/SamplesPanelControls/SamplesPanelControls.js +3 -1
  35. package/Search/ClearIcon.d.ts +3 -1
  36. package/Search/ClearIcon.js +3 -1
  37. package/Search/SearchIcon.d.ts +3 -1
  38. package/Search/SearchIcon.js +3 -1
  39. package/Search/SidebarSearch.d.ts +3 -1
  40. package/Search/SidebarSearch.js +3 -1
  41. package/Sidebar/ApiCallItem.d.ts +2 -1
  42. package/Sidebar/MenuContainer.d.ts +3 -1
  43. package/Sidebar/MenuContainer.js +3 -1
  44. package/Sidebar/SeparatorItem.d.ts +2 -0
  45. package/Sidebar/SeparatorItem.js +3 -1
  46. package/SidebarLogo/SidebarLogo.js +1 -1
  47. package/SourceCode/SourceCode.js +2 -2
  48. package/Tooltip/Tooltip.js +1 -1
  49. package/Typography/CompactTypography.d.ts +2 -6
  50. package/Typography/H1.js +1 -1
  51. package/Typography/H2.js +1 -1
  52. package/Typography/H3.js +1 -1
  53. package/Typography/SectionHeader.d.ts +3 -1
  54. package/Typography/SectionHeader.js +3 -1
  55. package/Typography/Typography.d.ts +14 -7
  56. package/Typography/Typography.js +31 -8
  57. package/globalStyle.js +1 -1
  58. package/icons/ShelfIcon/ShelfIcon.d.ts +3 -1
  59. package/icons/ShelfIcon/ShelfIcon.js +3 -1
  60. package/mocks/hooks/index.d.ts +9 -0
  61. package/mocks/hooks/index.js +16 -1
  62. package/package.json +1 -1
  63. package/src/Cards/Card.tsx +49 -0
  64. package/src/Cards/CardsBlock.tsx +9 -0
  65. package/src/CodeBlock/CodeBlock.ts +3 -1
  66. package/src/CopyButton/CopyButton.tsx +6 -1
  67. package/src/Footer/Footer.tsx +2 -2
  68. package/src/JsonViewer/JsonViewer.tsx +3 -1
  69. package/src/Markdown/{StyledMarkdown.tsx → MarkdownWrapper.tsx} +2 -2
  70. package/src/Markdown/index.ts +1 -1
  71. package/src/Navbar/Navbar.tsx +2 -2
  72. package/src/OperationBadge/OperationBadge.ts +1 -0
  73. package/src/PageNavigation/NextPageLink.tsx +16 -7
  74. package/src/PageNavigation/PreviousPageLink.tsx +16 -7
  75. package/src/Panel/CodePanel.ts +3 -1
  76. package/src/Panel/ContentPanel.ts +3 -1
  77. package/src/Panel/Panel.ts +3 -1
  78. package/src/Panel/PanelBody.ts +3 -1
  79. package/src/Panel/PanelComponent.tsx +1 -0
  80. package/src/Panel/PanelHeader.ts +3 -1
  81. package/src/Panel/PanelHeaderTitle.ts +3 -1
  82. package/src/SamplesPanelControls/SamplesPanelControls.ts +3 -1
  83. package/src/Search/ClearIcon.tsx +3 -1
  84. package/src/Search/SearchIcon.tsx +3 -1
  85. package/src/Search/SidebarSearch.tsx +3 -1
  86. package/src/Sidebar/MenuContainer.tsx +3 -1
  87. package/src/Sidebar/SeparatorItem.tsx +3 -1
  88. package/src/SidebarLogo/SidebarLogo.tsx +5 -1
  89. package/src/SourceCode/SourceCode.tsx +9 -2
  90. package/src/Tooltip/Tooltip.tsx +1 -0
  91. package/src/Typography/H1.ts +1 -1
  92. package/src/Typography/H2.ts +1 -1
  93. package/src/Typography/H3.ts +1 -1
  94. package/src/Typography/SectionHeader.ts +3 -1
  95. package/src/Typography/Typography.ts +25 -17
  96. package/src/globalStyle.ts +4 -0
  97. package/src/icons/ShelfIcon/ShelfIcon.tsx +3 -1
  98. package/src/mocks/hooks/index.ts +21 -0
@@ -4,7 +4,9 @@ import { PanelHeader } from '@theme/Panel/PanelHeader';
4
4
  import { PanelBody } from '@theme/Panel/PanelBody';
5
5
  import { PanelComponent } from '@theme/Panel/PanelComponent';
6
6
 
7
- export const Panel = styled(PanelComponent)`
7
+ export const Panel = styled(PanelComponent).attrs(() => ({
8
+ 'data-component-name': 'Panel/Panel',
9
+ }))`
8
10
  border-radius: var(--panels-border-radius);
9
11
 
10
12
  ${PanelHeader} + ${PanelBody} {
@@ -18,7 +18,9 @@ interface PanelBodyProps {
18
18
  hidden?: boolean;
19
19
  }
20
20
 
21
- export const PanelBody = styled.div<PanelBodyProps>`
21
+ export const PanelBody = styled.div.attrs(() => ({
22
+ 'data-component-name': 'Panel/PanelBody',
23
+ }))<PanelBodyProps>`
22
24
  ${({ animate }) => animate && showPanelAnimation};
23
25
  ${({ hidden }) => hidden && 'visibility: hidden'};
24
26
 
@@ -44,6 +44,7 @@ export function PanelComponent({
44
44
  data-cy={
45
45
  typeof header === 'string' ? ('panel-' + header).replace(/ /g, '-').toLowerCase() : null
46
46
  }
47
+ data-component-name="Panel/PanelComponent"
47
48
  >
48
49
  {header &&
49
50
  (typeof header === 'function' ? (
@@ -7,7 +7,9 @@ export interface PanelHeaderProps {
7
7
  toggle?: (e: BaseSyntheticEvent) => void;
8
8
  }
9
9
 
10
- export const PanelHeader = styled.div<PanelHeaderProps>`
10
+ export const PanelHeader = styled.div.attrs(() => ({
11
+ 'data-component-name': 'Panel/PanelHeader',
12
+ }))<PanelHeaderProps>`
11
13
  position: relative;
12
14
  z-index: 1;
13
15
  display: flex;
@@ -1,6 +1,8 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const PanelHeaderTitle = styled.span`
3
+ export const PanelHeaderTitle = styled.span.attrs(() => ({
4
+ 'data-component-name': 'Panel/PanelHeaderTitle',
5
+ }))`
4
6
  line-height: 1;
5
7
  margin-right: 5px;
6
8
  font-weight: 700;
@@ -2,7 +2,9 @@ import styled from 'styled-components';
2
2
 
3
3
  import { CodeBlock } from '@theme/CodeBlock';
4
4
 
5
- export const SamplesControlButton = styled.button`
5
+ export const SamplesControlButton = styled.button.attrs(() => ({
6
+ 'data-component-name': 'SamplesPanelControls/SamplesPanelControls',
7
+ }))`
6
8
  background-color: var(--samples-panel-controls-background-color);
7
9
  border: 0;
8
10
  outline: 0;
@@ -15,7 +15,9 @@ const Icon = (props: SVGProps<SVGSVGElement>) => (
15
15
  </svg>
16
16
  );
17
17
 
18
- export const ClearIcon = styled(Icon)`
18
+ export const ClearIcon = styled(Icon).attrs(() => ({
19
+ 'data-component-name': 'Search/ClearIcon',
20
+ }))`
19
21
  position: absolute;
20
22
  cursor: pointer;
21
23
  width: 0.5em;
@@ -15,7 +15,9 @@ const Icon = (props: SVGProps<SVGSVGElement>) => (
15
15
  </svg>
16
16
  );
17
17
 
18
- export const SearchIcon = styled(Icon)`
18
+ export const SearchIcon = styled(Icon).attrs(() => ({
19
+ 'data-component-name': 'Search/SearchIcon',
20
+ }))`
19
21
  position: absolute;
20
22
  cursor: pointer;
21
23
  width: 1em;
@@ -3,7 +3,9 @@ import styled from 'styled-components';
3
3
  import { Search } from '@theme/Search/Search';
4
4
  import { Popover } from '@theme/Search/Popover';
5
5
 
6
- export const SidebarSearch = styled(Search)`
6
+ export const SidebarSearch = styled(Search).attrs(() => ({
7
+ 'data-component-name': 'Search/SidebarSearch',
8
+ }))`
7
9
  --search-input-text-color: var(--sidebar-item-active-color);
8
10
 
9
11
  ${Popover} {
@@ -1,6 +1,8 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const MenuContainer = styled.div`
3
+ export const MenuContainer = styled.div.attrs(() => ({
4
+ 'data-component-name': 'Sidebar/MenuContainer',
5
+ }))`
4
6
  position: relative;
5
7
  overflow-y: auto;
6
8
  flex-grow: 1;
@@ -2,7 +2,9 @@ import styled from 'styled-components';
2
2
 
3
3
  import { MenuItemLabel } from '@theme/Sidebar/MenuItemLabel';
4
4
 
5
- export const SeparatorItem = styled(MenuItemLabel)`
5
+ export const SeparatorItem = styled(MenuItemLabel).attrs(() => ({
6
+ 'data-component-name': 'Sidebar/SeparatorItem',
7
+ }))`
6
8
  cursor: default;
7
9
  font-weight: var(--font-weight-bold);
8
10
  color: var(--sidebar-separator-label-color);
@@ -23,7 +23,11 @@ export function SidebarLogo({
23
23
  const logo = <LogoImgEl src={imageUrl} alt={altText || 'logo'} />;
24
24
 
25
25
  return (
26
- <LogoWrap data-cy={dataTestId} style={{ backgroundColor }}>
26
+ <LogoWrap
27
+ data-cy={dataTestId}
28
+ style={{ backgroundColor }}
29
+ data-component-name="SidebarLogo/SidebarLogo"
30
+ >
27
31
  {href ? <Link href={href}>{logo}</Link> : logo}
28
32
  </LogoWrap>
29
33
  );
@@ -56,7 +56,7 @@ export function SourceCode({
56
56
  const _source = source || externalSource?.sample?.get?.(externalSource) || '';
57
57
  if (withCopyButton) {
58
58
  return (
59
- <CopyButtonWrapper data={source}>
59
+ <CopyButtonWrapper data={source} data-component-name="SourceCode/SourceCode">
60
60
  {({ renderCopyButton }) => (
61
61
  <SampleControlsWrap>
62
62
  <SampleControls data-cy="copy-button">{renderCopyButton()}</SampleControls>
@@ -67,5 +67,12 @@ export function SourceCode({
67
67
  );
68
68
  }
69
69
 
70
- return <Code dataTestId={dataTestId} lang={lang} source={_source} />;
70
+ return (
71
+ <Code
72
+ dataTestId={dataTestId}
73
+ lang={lang}
74
+ source={_source}
75
+ data-component-name="SourceCode/SourceCode"
76
+ />
77
+ );
71
78
  }
@@ -50,6 +50,7 @@ export function TooltipComponent({
50
50
  onMouseLeave={isControlled ? undefined : handleLeave}
51
51
  onClick={isControlled ? undefined : handleLeave}
52
52
  className={`tooltip-${className}`}
53
+ data-component-name="Tooltip/Tooltip"
53
54
  >
54
55
  {children}
55
56
  {isOpened && (
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { typography } from '@theme/utils';
4
4
 
5
5
  export const H1 = styled.h1.attrs(() => ({
6
- 'data-component-name': 'Headings/H1',
6
+ 'data-component-name': 'Typography/H1',
7
7
  }))`
8
8
  color: var(--color-content);
9
9
  margin: 0 0 25px;
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { typography } from '@theme/utils';
4
4
 
5
5
  export const H2 = styled.h2.attrs(() => ({
6
- 'data-component-name': 'Headings/H2',
6
+ 'data-component-name': 'Typography/H2',
7
7
  }))`
8
8
  color: var(--color-content);
9
9
  margin: 0 0 20px;
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { typography } from '@theme/utils';
4
4
 
5
5
  export const H3 = styled.h3.attrs(() => ({
6
- 'data-component-name': 'Headings/H3',
6
+ 'data-component-name': 'Typography/H3',
7
7
  }))`
8
8
  color: var(--color-content);
9
9
 
@@ -1,6 +1,8 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const SectionHeader = styled.h2`
3
+ export const SectionHeader = styled.h2.attrs(() => ({
4
+ 'data-component-name': 'Typography/SectionHeader',
5
+ }))`
4
6
  color: var(--h-color);
5
7
  font-size: 1.75em;
6
8
  font-weight: var(--font-weight-regular);
@@ -1,21 +1,29 @@
1
1
  import styled from 'styled-components';
2
- import { color, typography as typographySystem, TypographyProps } from 'styled-system';
3
2
 
4
- export const Typography = styled.p.attrs(() => ({
3
+ export interface TypographyProps {
4
+ color?: string;
5
+ fontFamily?: string;
6
+ fontSize?: string;
7
+ fontStyle?: string;
8
+ fontWeight?: string;
9
+ lineHeight?: string;
10
+ letterSpacing?: string;
11
+ marginBottom?: string;
12
+ marginTop?: string;
13
+ textAlign?: string;
14
+ }
15
+
16
+ export const Typography = styled.div.attrs(() => ({
5
17
  'data-component-name': 'Typography/Typography',
6
- }))<
7
- TypographyProps & {
8
- color?: string;
9
- mt?: string;
10
- mb?: string;
11
- }
12
- >`
13
- font-size: var(--font-size-base);
14
- font-family: var(--font-family-base);
15
- line-height: var(--line-height-base);
16
- color: var(--color-content);
17
- ${color};
18
- margin-top: ${({ mt }) => mt || '1em'};
19
- margin-bottom: ${({ mb }) => mb || '1em'};
20
- ${typographySystem}
18
+ }))<TypographyProps>`
19
+ color: ${({ color }) => color || 'var(--color-content)'};
20
+ font-family: ${({ fontFamily }) => fontFamily || 'var(--font-family-base)'};
21
+ font-size: ${({ fontSize }) => fontSize || 'var(--font-size-base)'};
22
+ font-style: ${({ fontStyle }) => fontStyle};
23
+ font-weight: ${({ fontWeight }) => fontWeight || 'var(--font-weight-regular)'};
24
+ line-height: ${({ lineHeight }) => lineHeight || 'var(--line-height-base)'};
25
+ letter-spacing: ${({ letterSpacing }) => letterSpacing};
26
+ margin-bottom: ${({ marginBottom }) => marginBottom};
27
+ margin-top: ${({ marginTop }) => marginTop};
28
+ text-align: ${({ textAlign }) => textAlign};
21
29
  `;
@@ -182,6 +182,10 @@ const typography = css`
182
182
  const headingsTypography = css`
183
183
  // --h-{css-property-name} is fallback for h1...h6
184
184
 
185
+ * {
186
+ box-sizing: border-box;
187
+ }
188
+
185
189
  /**
186
190
  * @tokens Typography headings font
187
191
  */
@@ -32,7 +32,9 @@ const IntShelfIcon = ({ className, style }: ShelfIconProps): JSX.Element => (
32
32
  </svg>
33
33
  );
34
34
 
35
- export const ShelfIcon = styled(IntShelfIcon)`
35
+ export const ShelfIcon = styled(IntShelfIcon).attrs(() => ({
36
+ 'data-component-name': 'icons/ShelfIcon/ShelfIcon',
37
+ }))`
36
38
  ${({ size = '9px', float = '', direction, color }) => css`
37
39
  height: ${size};
38
40
  width: ${size};
@@ -3,6 +3,12 @@ interface RawTheme {
3
3
  settings?: any;
4
4
  }
5
5
 
6
+ interface PageLink {
7
+ label: string;
8
+ link: string;
9
+ type: 'link';
10
+ }
11
+
6
12
  export function useThemeSettings(name: string): RawTheme['settings'] {
7
13
  return {
8
14
  name,
@@ -15,3 +21,18 @@ export function useThemeSettings(name: string): RawTheme['settings'] {
15
21
  },
16
22
  };
17
23
  }
24
+
25
+ export function useSidebarSiblingsData(): { nextPage: PageLink; prevPage: PageLink } {
26
+ return {
27
+ nextPage: {
28
+ type: 'link',
29
+ label: 'Page',
30
+ link: '#next',
31
+ },
32
+ prevPage: {
33
+ type: 'link',
34
+ label: 'Page',
35
+ link: '#prev',
36
+ },
37
+ };
38
+ }