@redocly/theme-experimental 0.74.2-pingfed.3 → 0.81.2-rc.2
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/markdoc/Cards/Card.stories.tsx +37 -0
- package/markdoc/Cards/Card.tsx +55 -0
- package/markdoc/Cards/CardsBlock.tsx +10 -0
- package/markdoc/Cards/__tests__/Card.test.tsx +63 -0
- package/markdoc/Cards/__tests__/CardsBlock.test.tsx +12 -0
- package/markdoc/Cards/index.ts +2 -0
- package/markdoc/CodeStep/CodeStep.tsx +1 -1
- package/markdoc/components.tsx +1 -0
- package/markdoc/schema.ts +15 -0
- package/package.json +9 -9
- package/src/layouts/CodeGuide/CodeDemo.tsx +1 -1
- package/src/layouts/CodeGuide/CodeGuide.tsx +4 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
import { Card } from './Card';
|
|
6
|
+
|
|
7
|
+
type Story = StoryObj<typeof Card>;
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Card> = {
|
|
10
|
+
title: 'Components/Card',
|
|
11
|
+
component: Card,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
title: 'Card Links',
|
|
19
|
+
links: {
|
|
20
|
+
type: 'group' as const,
|
|
21
|
+
label: 'Card Links',
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
type: 'link' as const,
|
|
25
|
+
link: '#1',
|
|
26
|
+
label: 'Link 1',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'link' as const,
|
|
30
|
+
link: '#2',
|
|
31
|
+
label: 'Link 2',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
render: (args) => <Card {...args} />,
|
|
37
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Link } from '@redocly/theme/components/Link/Link';
|
|
4
|
+
import { H3 } from '@redocly/theme/components/Typography/H3';
|
|
5
|
+
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
6
|
+
|
|
7
|
+
import type { ResolvedNavItem } from '@redocly/theme/core/types';
|
|
8
|
+
|
|
9
|
+
export interface CardProps {
|
|
10
|
+
title?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
links: ResolvedNavItem;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Card(props: CardProps): JSX.Element {
|
|
17
|
+
const { useTranslate } = useThemeHooks();
|
|
18
|
+
const { translate } = useTranslate();
|
|
19
|
+
return (
|
|
20
|
+
<CardWrapper data-component-name="Cards/Card" className={props.className}>
|
|
21
|
+
{props.icon && <img src={props?.icon} alt={props?.title} />}
|
|
22
|
+
{props.title && <H3>{props.title}</H3>}
|
|
23
|
+
{props.links.items && (
|
|
24
|
+
<CardLinksList>
|
|
25
|
+
{props.links.items.map((item) => (
|
|
26
|
+
<li key={item.label}>
|
|
27
|
+
<Link to={item.link as string}>
|
|
28
|
+
{translate(item.labelTranslationKey, item.label)}
|
|
29
|
+
</Link>
|
|
30
|
+
</li>
|
|
31
|
+
))}
|
|
32
|
+
</CardLinksList>
|
|
33
|
+
)}
|
|
34
|
+
</CardWrapper>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const CardWrapper = styled.div`
|
|
39
|
+
border-radius: 10px;
|
|
40
|
+
box-shadow: 0 10px 30px 0 rgba(35, 35, 35, 0.1);
|
|
41
|
+
padding: 20px;
|
|
42
|
+
margin: 0 20px 20px 0;
|
|
43
|
+
min-width: 25%;
|
|
44
|
+
font-family: var(--font-family-base);
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const CardLinksList = styled.ul`
|
|
48
|
+
list-style-type: none;
|
|
49
|
+
margin: 0;
|
|
50
|
+
padding: 0;
|
|
51
|
+
|
|
52
|
+
li {
|
|
53
|
+
margin-bottom: 10px;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const CardsBlock = styled.div.attrs<{ className?: string }>(({ className }) => ({
|
|
4
|
+
'data-component-name': 'Cards/CardsBlock',
|
|
5
|
+
className,
|
|
6
|
+
}))`
|
|
7
|
+
display: flex;
|
|
8
|
+
padding: 20px 0;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Card } from '../Card';
|
|
4
|
+
import { renderWithRouter } from '../../../../../tests/utils/';
|
|
5
|
+
|
|
6
|
+
jest.mock('@redocly/theme/hooks/useThemeHooks');
|
|
7
|
+
|
|
8
|
+
const links = {
|
|
9
|
+
type: 'group' as const,
|
|
10
|
+
label: 'Card Links',
|
|
11
|
+
items: [
|
|
12
|
+
{
|
|
13
|
+
type: 'link' as const,
|
|
14
|
+
link: '#1',
|
|
15
|
+
label: 'Link 1',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'link' as const,
|
|
19
|
+
link: '#2',
|
|
20
|
+
label: 'Link 2',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('Card', () => {
|
|
26
|
+
const props = {
|
|
27
|
+
title: 'Example Card',
|
|
28
|
+
icon: 'example.png',
|
|
29
|
+
links,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
it('renders', () => {
|
|
33
|
+
const { container } = renderWithRouter(<Card title="Card Links" links={links} />);
|
|
34
|
+
|
|
35
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders the title when provided', () => {
|
|
39
|
+
const screen = renderWithRouter(<Card {...props} />);
|
|
40
|
+
expect(screen.getByText('Example Card')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('renders the icon when provided', () => {
|
|
44
|
+
const screen = renderWithRouter(<Card {...props} />);
|
|
45
|
+
expect(screen.getByAltText('Example Card')).toHaveAttribute('src', 'example.png');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('renders the links when provided', () => {
|
|
49
|
+
const screen = renderWithRouter(<Card {...props} />);
|
|
50
|
+
expect(screen.getByText('Link 1')).toHaveAttribute('href', '/#1');
|
|
51
|
+
expect(screen.getByText('Link 2')).toHaveAttribute('href', '/#2');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('does not render the title when not provided', () => {
|
|
55
|
+
const { container } = renderWithRouter(<Card links={props.links} />);
|
|
56
|
+
expect(container.querySelector('h3')).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('does not render the icon when not provided', () => {
|
|
60
|
+
const { container } = renderWithRouter(<Card title={props.title} links={props.links} />);
|
|
61
|
+
expect(container.querySelector('img')).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { CardsBlock } from '../CardsBlock';
|
|
5
|
+
|
|
6
|
+
describe('CardsBlock', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const { container } = render(<CardsBlock></CardsBlock>);
|
|
9
|
+
|
|
10
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -57,7 +57,7 @@ const Wrapper = styled.div<{ active: boolean }>`
|
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
border-left: 3px solid;
|
|
59
59
|
border-left-color: ${({ active }) => (active ? 'var(--color-primary-base)' : 'transparent')};
|
|
60
|
-
background-color: ${({ active }) => (active ? 'var(--bg-raised)' : 'transparent')};
|
|
60
|
+
background-color: ${({ active }) => (active ? 'var(--bg-color-raised)' : 'transparent')};
|
|
61
61
|
border-top: 1px solid #cbccd1;
|
|
62
62
|
cursor: pointer;
|
|
63
63
|
|
package/markdoc/components.tsx
CHANGED
package/markdoc/schema.ts
CHANGED
|
@@ -6,3 +6,18 @@ export const codeStep: Schema = {
|
|
|
6
6
|
},
|
|
7
7
|
render: 'CodeStep',
|
|
8
8
|
};
|
|
9
|
+
|
|
10
|
+
export const card: Schema = {
|
|
11
|
+
attributes: {
|
|
12
|
+
title: { type: String, required: false },
|
|
13
|
+
icon: { type: String, required: false },
|
|
14
|
+
links: { type: String },
|
|
15
|
+
},
|
|
16
|
+
selfClosing: true,
|
|
17
|
+
render: 'Card',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const cardsBlock: Schema = {
|
|
21
|
+
attributes: {},
|
|
22
|
+
render: 'CardsBlock',
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme-experimental",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.2-rc.2",
|
|
4
4
|
"description": "Experimental UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme-experimental",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@types/lodash.throttle": "4.1.9",
|
|
45
45
|
"@types/node": "18.19.3",
|
|
46
46
|
"@types/prismjs": "1.26.3",
|
|
47
|
-
"@types/react": "18.2.
|
|
48
|
-
"@types/react-dom": "18.2.
|
|
47
|
+
"@types/react": "18.2.79",
|
|
48
|
+
"@types/react-dom": "18.2.25",
|
|
49
49
|
"@types/styled-components": "5.1.34",
|
|
50
50
|
"@types/styled-system": "5.1.22",
|
|
51
51
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
@@ -58,32 +58,32 @@
|
|
|
58
58
|
"jest-when": "3.6.0",
|
|
59
59
|
"json-schema-to-ts": "2.7.2",
|
|
60
60
|
"lodash.throttle": "4.1.1",
|
|
61
|
-
"npm-run-
|
|
61
|
+
"npm-run-all2": "5.0.2",
|
|
62
62
|
"react-refresh": "0.14.0",
|
|
63
63
|
"react-router-dom": "6.21.1",
|
|
64
|
+
"rimraf": "5.0.5",
|
|
64
65
|
"storybook": "7.6.4",
|
|
65
66
|
"storybook-addon-pseudo-states": "2.1.2",
|
|
66
67
|
"storybook-design-token": "3.0.0-beta.6",
|
|
67
68
|
"styled-components": "5.3.11",
|
|
68
69
|
"styled-system": "5.1.5",
|
|
69
|
-
"ts-jest": "29.1.
|
|
70
|
+
"ts-jest": "29.1.2",
|
|
70
71
|
"ts-node": "10.9.1",
|
|
71
72
|
"ts-node-dev": "2.0.0",
|
|
72
73
|
"tsc-alias": "1.8.3",
|
|
73
74
|
"tsconfig-paths": "4.2.0",
|
|
74
75
|
"tsconfig-paths-webpack-plugin": "3.5.2",
|
|
75
76
|
"typescript": "5.2.2",
|
|
76
|
-
"webpack": "5.88.2"
|
|
77
|
-
"@redocly/portal-types": "1.2.1"
|
|
77
|
+
"webpack": "5.88.2"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@redocly/theme": "^0.
|
|
80
|
+
"@redocly/theme": "^0.81.2-rc.2"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"start": "npm-run-all --parallel storybook storybook:tokens:watch",
|
|
84
84
|
"watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
|
|
85
85
|
"ts:check": "tsc --noEmit --skipLibCheck",
|
|
86
|
-
"clean": "
|
|
86
|
+
"clean": "rimraf lib",
|
|
87
87
|
"compile": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
88
88
|
"build": "npm run clean && npm run compile",
|
|
89
89
|
"storybook": "storybook dev -p 6007",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { CodeBlock } from '@redocly/theme/components/CodeBlock/CodeBlock';
|
|
3
4
|
|
|
4
|
-
import { CodeBlock } from '@theme/components/CodeBlock/CodeBlock';
|
|
5
5
|
import { CodeGuideContext, useCodeGuideHighlightLines } from '@portal/CodeGuide';
|
|
6
6
|
|
|
7
7
|
export function CodeDemo() {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { Markdown } from '@redocly/theme/components/Markdown/Markdown';
|
|
3
4
|
|
|
4
|
-
import { CodeDemo } from '@theme/layouts/CodeGuide/CodeDemo';
|
|
5
|
-
import { MarkdownWrapper } from '@theme/components/Markdown/MarkdownWrapper';
|
|
6
5
|
import { CodeGuideProvider } from '@portal/CodeGuide';
|
|
7
6
|
|
|
7
|
+
import { CodeDemo } from './CodeDemo';
|
|
8
|
+
|
|
8
9
|
export default function CodeGuide(props: React.PropsWithChildren<any>) {
|
|
9
10
|
const {
|
|
10
11
|
pageProps: { codeGuideFiles },
|
|
@@ -20,7 +21,7 @@ export default function CodeGuide(props: React.PropsWithChildren<any>) {
|
|
|
20
21
|
return (
|
|
21
22
|
<CodeGuideProvider initialState={initialState}>
|
|
22
23
|
<Wrapper data-component-name="layouts/CodeGuide">
|
|
23
|
-
<
|
|
24
|
+
<Markdown>{children}</Markdown>
|
|
24
25
|
<div>
|
|
25
26
|
<StickyPosition>
|
|
26
27
|
<CodeDemo />
|