@octaviaflow/mdx-components 1.1.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.
- package/README.md +215 -0
- package/components/_utils.scss +18 -0
- package/components/accordion/_accordion.scss +35 -0
- package/components/accordion/accordion.stories.jsx +33 -0
- package/components/accordion/accordion.tsx +55 -0
- package/components/anchor-links/_anchor-links.scss +67 -0
- package/components/anchor-links/anchor-link.tsx +50 -0
- package/components/anchor-links/anchor-links.stories.jsx +51 -0
- package/components/anchor-links/anchor-links.tsx +73 -0
- package/components/art-direction/art-direction.stories.jsx +44 -0
- package/components/art-direction/art-direction.tsx +63 -0
- package/components/art-direction/desktop.jpg +0 -0
- package/components/art-direction/mobile.jpg +0 -0
- package/components/art-direction/tablet.jpg +0 -0
- package/components/article-card/_article-card.scss +98 -0
- package/components/article-card/article-card.stories.jsx +59 -0
- package/components/article-card/article-card.tsx +208 -0
- package/components/article-card/article06.png +0 -0
- package/components/aside/_aside.scss +56 -0
- package/components/aside/aside.stories.jsx +50 -0
- package/components/aside/aside.tsx +72 -0
- package/components/caption/_caption.scss +30 -0
- package/components/caption/caption.stories.jsx +33 -0
- package/components/caption/caption.tsx +47 -0
- package/components/card-group/_card-group.scss +44 -0
- package/components/card-group/card-group.stories.jsx +85 -0
- package/components/card-group/card-group.tsx +65 -0
- package/components/card-group/sketch-icon.png +0 -0
- package/components/code/_code.scss +110 -0
- package/components/code/code.stories.jsx +32 -0
- package/components/code/code.tsx +71 -0
- package/components/code/inline-code.tsx +55 -0
- package/components/code/path.tsx +56 -0
- package/components/divider/_divider.scss +67 -0
- package/components/divider/divider.stories.jsx +74 -0
- package/components/divider/divider.tsx +54 -0
- package/components/do-dont/_do-dont.scss +191 -0
- package/components/do-dont/do-dont-row.tsx +51 -0
- package/components/do-dont/do-dont.stories.jsx +53 -0
- package/components/do-dont/do-dont.tsx +161 -0
- package/components/do-dont/light-theme.jpg +0 -0
- package/components/gif-player/_gif-player.scss +64 -0
- package/components/gif-player/cloud.gif +0 -0
- package/components/gif-player/cloud.jpg +0 -0
- package/components/gif-player/gif-player.stories.jsx +45 -0
- package/components/gif-player/gif-player.tsx +150 -0
- package/components/grid-transform/_grid.scss +13 -0
- package/components/grid-transform/column.tsx +102 -0
- package/components/grid-transform/grid.stories.jsx +72 -0
- package/components/grid-transform/grid.tsx +52 -0
- package/components/grid-transform/row.tsx +92 -0
- package/components/image-wrapper/_image-wrapper.scss +32 -0
- package/components/image-wrapper/accordion-style-3.png +0 -0
- package/components/image-wrapper/image-wrapper.stories.jsx +40 -0
- package/components/image-wrapper/image-wrapper.tsx +56 -0
- package/components/index.scss +31 -0
- package/components/inline-notification/_inline-notification.scss +29 -0
- package/components/inline-notification/inline-notification.stories.jsx +67 -0
- package/components/inline-notification/inline-notification.tsx +98 -0
- package/components/interfaces.ts +31 -0
- package/components/link/_link.scss +13 -0
- package/components/link/link.stories.jsx +36 -0
- package/components/link/link.tsx +51 -0
- package/components/markdown/_markdown.scss +140 -0
- package/components/markdown/autolink-header/_autolink-header.scss +57 -0
- package/components/markdown/autolink-header/autolink-header.tsx +107 -0
- package/components/markdown/blockquote.stories.jsx +38 -0
- package/components/markdown/blockquote.tsx +53 -0
- package/components/markdown/h1.tsx +92 -0
- package/components/markdown/h2.tsx +85 -0
- package/components/markdown/h3.tsx +72 -0
- package/components/markdown/h4.tsx +73 -0
- package/components/markdown/h5.tsx +59 -0
- package/components/markdown/h6.tsx +59 -0
- package/components/markdown/headings.stories.jsx +52 -0
- package/components/markdown/li.tsx +55 -0
- package/components/markdown/ol.stories.jsx +47 -0
- package/components/markdown/ol.tsx +93 -0
- package/components/markdown/p.stories.jsx +36 -0
- package/components/markdown/p.tsx +65 -0
- package/components/markdown/ul.stories.jsx +46 -0
- package/components/markdown/ul.tsx +93 -0
- package/components/mini-card/_mini-card.scss +55 -0
- package/components/mini-card/mini-card.stories.jsx +72 -0
- package/components/mini-card/mini-card.tsx +132 -0
- package/components/page-description/_page-description.scss +38 -0
- package/components/page-description/page-description.stories.jsx +36 -0
- package/components/page-description/page-description.tsx +61 -0
- package/components/page-table/_page-table.scss +51 -0
- package/components/page-table/page-table.stories.jsx +56 -0
- package/components/page-table/page-table.tsx +88 -0
- package/components/preview/_preview.scss +16 -0
- package/components/preview/preview.stories.jsx +41 -0
- package/components/preview/preview.tsx +80 -0
- package/components/resource-card/_resource-card.scss +165 -0
- package/components/resource-card/resource-card.stories.jsx +100 -0
- package/components/resource-card/resource-card.tsx +201 -0
- package/components/storybook-demo/_storybook-demo.scss +57 -0
- package/components/storybook-demo/storybook-demo.stories.jsx +70 -0
- package/components/storybook-demo/storybook-demo.tsx +190 -0
- package/components/tabs/_tabs.scss +98 -0
- package/components/tabs/select.tsx +60 -0
- package/components/tabs/tab-list.tsx +48 -0
- package/components/tabs/tab.tsx +125 -0
- package/components/tabs/tabs.stories.jsx +54 -0
- package/components/tabs/tabs.tsx +78 -0
- package/components/title/title.stories.jsx +43 -0
- package/components/title/title.tsx +47 -0
- package/components/utils.ts +102 -0
- package/components/video/_video.scss +89 -0
- package/components/video/local-poster.jpeg +0 -0
- package/components/video/local-video.mp4 +0 -0
- package/components/video/video.stories.jsx +45 -0
- package/components/video/video.tsx +255 -0
- package/es/index.js +71714 -0
- package/index.ts +59 -0
- package/lib/index.js +71767 -0
- package/package.json +64 -0
- package/telemetry.yml +21 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { Column, Grid } from "@octaviaflow/react";
|
|
18
|
+
import { clsx } from "clsx";
|
|
19
|
+
import PropTypes from "prop-types";
|
|
20
|
+
import React, { ReactNode } from "react";
|
|
21
|
+
|
|
22
|
+
import { MdxComponent } from "../interfaces";
|
|
23
|
+
import { withPrefix } from "../utils";
|
|
24
|
+
|
|
25
|
+
interface CaptionProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
className?: string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The `<Caption>` component is typically used below images or videos.
|
|
32
|
+
*/
|
|
33
|
+
export const Caption: MdxComponent<CaptionProps> = ({
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
}) => (
|
|
37
|
+
<Grid className={clsx(className, withPrefix("caption-container"))}>
|
|
38
|
+
<Column sm={4} md={6} lg={6}>
|
|
39
|
+
<p className={withPrefix("caption")}>{children}</p>
|
|
40
|
+
</Column>
|
|
41
|
+
</Grid>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
Caption.propTypes = {
|
|
45
|
+
children: PropTypes.node as unknown as React.Validator<React.ReactNode>,
|
|
46
|
+
className: PropTypes.string,
|
|
47
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@use '@carbon/react/scss/breakpoint' as breakpoint;
|
|
9
|
+
@use '@carbon/react/scss/theme' as theme;
|
|
10
|
+
@use '@carbon/react/scss/spacing' as spacing;
|
|
11
|
+
|
|
12
|
+
@use '../utils' as *;
|
|
13
|
+
|
|
14
|
+
.#{with-prefix('card-group')} {
|
|
15
|
+
margin-block-start: spacing.$spacing-07;
|
|
16
|
+
|
|
17
|
+
.#{with-prefix('header')} + & {
|
|
18
|
+
margin-block-start: spacing.$spacing-06;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Sets gray border on the inset-block-start of cards at the smallest breakpoint and
|
|
23
|
+
// removes the margin set by the <Column> in the Grid component.
|
|
24
|
+
.#{with-prefix('card-group')} [class*='column'] {
|
|
25
|
+
border-block-start: 1px solid theme.$border-subtle;
|
|
26
|
+
margin-block-end: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.#{with-prefix('card-group')} [class*='column']:first-child {
|
|
30
|
+
border-block-start: 0 solid transparent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Borders for cards at the medium breakpoint
|
|
34
|
+
.#{with-prefix('card-group')} [class*='column']:nth-child(-n + 2) {
|
|
35
|
+
@include breakpoint.breakpoint('md') {
|
|
36
|
+
border-block-start: 0 solid transparent;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.#{with-prefix('card-group')} [class*='column']:nth-child(even) {
|
|
41
|
+
@include breakpoint.breakpoint('md') {
|
|
42
|
+
box-shadow: -1px 0 0 0 theme.$border-subtle;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright IBM Corp. 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { Column } from "@carbon/react";
|
|
18
|
+
|
|
19
|
+
import { CardGroup } from "./card-group";
|
|
20
|
+
import { ResourceCard } from "../resource-card/resource-card";
|
|
21
|
+
import sketchIconPng from "./sketch-icon.png";
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
title: "Components/MDX Components/Cards/CardGroup",
|
|
25
|
+
component: CardGroup,
|
|
26
|
+
argTypes: {
|
|
27
|
+
children: {
|
|
28
|
+
control: false,
|
|
29
|
+
},
|
|
30
|
+
className: {
|
|
31
|
+
control: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const Template = (args) => (
|
|
37
|
+
<CardGroup>
|
|
38
|
+
<Column lg={4}>
|
|
39
|
+
<ResourceCard
|
|
40
|
+
subTitle="With subtitle"
|
|
41
|
+
title="Title"
|
|
42
|
+
aspectRatio="2:1"
|
|
43
|
+
actionIcon="arrowRight"
|
|
44
|
+
href="https://www.carbondesignsystem.com"
|
|
45
|
+
{...args}
|
|
46
|
+
>
|
|
47
|
+
<img src={sketchIconPng} alt="sketch" />
|
|
48
|
+
</ResourceCard>
|
|
49
|
+
</Column>
|
|
50
|
+
<Column lg={4}>
|
|
51
|
+
<ResourceCard
|
|
52
|
+
subTitle="With subtitle"
|
|
53
|
+
title="Title"
|
|
54
|
+
href="https://www.carbondesignsystem.com"
|
|
55
|
+
{...args}
|
|
56
|
+
>
|
|
57
|
+
<img src={sketchIconPng} alt="sketch" />
|
|
58
|
+
</ResourceCard>
|
|
59
|
+
</Column>
|
|
60
|
+
<Column lg={4}>
|
|
61
|
+
<ResourceCard
|
|
62
|
+
title="Title"
|
|
63
|
+
aspectRatio="2:1"
|
|
64
|
+
actionIcon="arrowRight"
|
|
65
|
+
href="https://www.carbondesignsystem.com"
|
|
66
|
+
{...args}
|
|
67
|
+
>
|
|
68
|
+
<img src={sketchIconPng} alt="sketch" />
|
|
69
|
+
</ResourceCard>
|
|
70
|
+
</Column>
|
|
71
|
+
<Column lg={4}>
|
|
72
|
+
<ResourceCard
|
|
73
|
+
subTitle="With subtitle"
|
|
74
|
+
title="Title"
|
|
75
|
+
href="https://www.carbondesignsystem.com"
|
|
76
|
+
{...args}
|
|
77
|
+
>
|
|
78
|
+
<img src={sketchIconPng} alt="sketch" />
|
|
79
|
+
</ResourceCard>
|
|
80
|
+
</Column>
|
|
81
|
+
</CardGroup>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
export const Default = Template.bind({});
|
|
85
|
+
Default.args = {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
import { Column, Grid } from "@octaviaflow/react";
|
|
17
|
+
import { clsx } from "clsx";
|
|
18
|
+
import PropTypes from "prop-types";
|
|
19
|
+
import React, { ReactNode } from "react";
|
|
20
|
+
|
|
21
|
+
import { MdxComponent } from "../interfaces";
|
|
22
|
+
import { mediaQueries, useMatchMedia, withPrefix } from "../utils";
|
|
23
|
+
|
|
24
|
+
interface CardGroupProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
className?: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The `<CardGroup>` component is used in lieu of a `<Grid>` container
|
|
31
|
+
* when laying out a set of `<ResourceCard>` components on a page. It
|
|
32
|
+
* allows the cards to align in a grid at 8 columns at medium and
|
|
33
|
+
* above breakpoints, and set the grid to condensed at the small
|
|
34
|
+
* breakpoint.
|
|
35
|
+
*/
|
|
36
|
+
export const CardGroup: MdxComponent<CardGroupProps> = ({
|
|
37
|
+
children,
|
|
38
|
+
className,
|
|
39
|
+
...rest
|
|
40
|
+
}) => {
|
|
41
|
+
const isSm = useMatchMedia(mediaQueries.sm);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Grid
|
|
45
|
+
className={clsx(className, withPrefix("card-group"))}
|
|
46
|
+
condensed={isSm}
|
|
47
|
+
{...rest}
|
|
48
|
+
>
|
|
49
|
+
<Column lg={8} md={8} sm={4}>
|
|
50
|
+
<Grid condensed>{children}</Grid>
|
|
51
|
+
</Column>
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
CardGroup.propTypes = {
|
|
57
|
+
/**
|
|
58
|
+
* Provide the contents of your `Card`.
|
|
59
|
+
*/
|
|
60
|
+
children: PropTypes.node as unknown as React.Validator<React.ReactNode>,
|
|
61
|
+
/**
|
|
62
|
+
* Optional container class name.
|
|
63
|
+
*/
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@use '@carbon/react/scss/spacing' as spacing;
|
|
9
|
+
@use '@carbon/react/scss/type' as type;
|
|
10
|
+
@use '@carbon/react/scss/theme' as theme;
|
|
11
|
+
@use '@carbon/react/scss/motion' as motion;
|
|
12
|
+
|
|
13
|
+
@use '../utils' as *;
|
|
14
|
+
|
|
15
|
+
// override carbon inline code snippet styles
|
|
16
|
+
.ods--snippet--inline {
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: none;
|
|
19
|
+
background-color: theme.$layer-accent;
|
|
20
|
+
vertical-align: baseline;
|
|
21
|
+
|
|
22
|
+
code {
|
|
23
|
+
font-size: 0.875rem;
|
|
24
|
+
letter-spacing: normal;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.#{with-prefix('code')} {
|
|
29
|
+
.ods--popover-content,
|
|
30
|
+
.ods--popover-caret {
|
|
31
|
+
// Override carbon tooltip colors
|
|
32
|
+
background: theme.$layer-accent-01;
|
|
33
|
+
color: theme.$text-primary;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// scoped to div code to override global reset styles
|
|
38
|
+
.#{with-prefix('code')}.ods--snippet--multi {
|
|
39
|
+
margin-block-start: spacing.$spacing-07;
|
|
40
|
+
max-inline-size: none;
|
|
41
|
+
|
|
42
|
+
.ods--snippet-container {
|
|
43
|
+
// override carbon snippet container inline-size
|
|
44
|
+
inline-size: 100%;
|
|
45
|
+
// override carbon snippet minimum block-size
|
|
46
|
+
/* stylelint-disable-next-line declaration-no-important */
|
|
47
|
+
min-block-size: auto !important;
|
|
48
|
+
|
|
49
|
+
pre {
|
|
50
|
+
// remove prism-added tabindex border around code blocks
|
|
51
|
+
outline: none;
|
|
52
|
+
// override carbon snippet pre padding
|
|
53
|
+
padding-block-end: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
code {
|
|
58
|
+
@include type.type-style('code-02');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.#{with-prefix('path-container')} {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
background: theme.$layer-01;
|
|
67
|
+
block-size: 3rem;
|
|
68
|
+
border-block-end: 1px solid theme.$border-subtle;
|
|
69
|
+
inline-size: 100%;
|
|
70
|
+
margin-block-start: spacing.$spacing-07;
|
|
71
|
+
padding-inline: spacing.$spacing-05 spacing.$spacing-03;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.#{with-prefix('path-container')} + .#{with-prefix('code')} {
|
|
75
|
+
margin-block-start: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.#{with-prefix('path')} {
|
|
79
|
+
@include type.type-style('code-02');
|
|
80
|
+
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
color: theme.$text-primary;
|
|
83
|
+
text-overflow: ellipsis;
|
|
84
|
+
white-space: nowrap;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.#{with-prefix('icon')} {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
background: transparent;
|
|
93
|
+
block-size: 32px;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
font-size: 0;
|
|
96
|
+
inline-size: 32px;
|
|
97
|
+
outline-offset: -2px;
|
|
98
|
+
transition: background motion.$duration-fast-02;
|
|
99
|
+
@media screen and (prefers-reduced-motion: reduce) {
|
|
100
|
+
transition: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:hover {
|
|
104
|
+
background-color: theme.$layer-hover-01;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
svg {
|
|
108
|
+
fill: theme.$icon-primary;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright IBM Corp. 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from "react";
|
|
18
|
+
import { Code } from "./code";
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: "Components/MDX Components/Markdown/Code",
|
|
22
|
+
component: Code,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Template = (args) => (
|
|
26
|
+
<Code {...args}>
|
|
27
|
+
<code>const a = 16</code>
|
|
28
|
+
</Code>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const Default = Template.bind({});
|
|
32
|
+
Default.args = {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
import { CodeSnippet, Column, Grid, Theme } from "@octaviaflow/react";
|
|
17
|
+
import { clsx } from "clsx";
|
|
18
|
+
import PropTypes from "prop-types";
|
|
19
|
+
import React, { ReactElement, ReactPortal } from "react";
|
|
20
|
+
|
|
21
|
+
import { MdxComponent, NonScalarNode } from "../interfaces";
|
|
22
|
+
import { withPrefix } from "../utils";
|
|
23
|
+
import { Path } from "./path";
|
|
24
|
+
|
|
25
|
+
interface CodeProps {
|
|
26
|
+
children: Exclude<NonScalarNode, Array<ReactElement | ReactPortal>>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* For MDX files, steer away from using JSX components
|
|
31
|
+
* for code in favor of standard markdown syntax.
|
|
32
|
+
*
|
|
33
|
+
*````
|
|
34
|
+
* ```
|
|
35
|
+
* const a = 16;
|
|
36
|
+
* ```
|
|
37
|
+
*````
|
|
38
|
+
*/
|
|
39
|
+
export const Code: MdxComponent<CodeProps> = ({ children }) => {
|
|
40
|
+
const code = children.props.children;
|
|
41
|
+
const path = children.props.path;
|
|
42
|
+
const src = children.props.src;
|
|
43
|
+
const language = children.props.className || "language-plain";
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Grid condensed>
|
|
47
|
+
<Column sm={4} md={8} lg={8}>
|
|
48
|
+
<Theme theme={"g100"}>
|
|
49
|
+
{path && (
|
|
50
|
+
<Path src={src} path={path}>
|
|
51
|
+
{children}
|
|
52
|
+
</Path>
|
|
53
|
+
)}
|
|
54
|
+
|
|
55
|
+
<CodeSnippet
|
|
56
|
+
type="multi"
|
|
57
|
+
feedback="Copied!"
|
|
58
|
+
className={clsx(withPrefix("code"), language)}
|
|
59
|
+
>
|
|
60
|
+
{code}
|
|
61
|
+
</CodeSnippet>
|
|
62
|
+
</Theme>
|
|
63
|
+
</Column>
|
|
64
|
+
</Grid>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
Code.propTypes = {
|
|
69
|
+
/** Provide the contents of Code */
|
|
70
|
+
children: PropTypes.element.isRequired,
|
|
71
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
import { CodeSnippet } from "@octaviaflow/react";
|
|
17
|
+
import { clsx } from "clsx";
|
|
18
|
+
import PropTypes from "prop-types";
|
|
19
|
+
import React, { ReactElement, ReactPortal } from "react";
|
|
20
|
+
|
|
21
|
+
import { MdxComponent, NonScalarNode } from "../interfaces";
|
|
22
|
+
import { withPrefix } from "../utils";
|
|
23
|
+
|
|
24
|
+
interface CodeProps {
|
|
25
|
+
children: Exclude<NonScalarNode, Array<ReactElement | ReactPortal>>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* For MDX files, steer away from using JSX components
|
|
30
|
+
* for code in favor of standard markdown syntax.
|
|
31
|
+
*
|
|
32
|
+
*````
|
|
33
|
+
* ```
|
|
34
|
+
* const a = 16;
|
|
35
|
+
* ```
|
|
36
|
+
*````
|
|
37
|
+
*/
|
|
38
|
+
export const InlineCode: MdxComponent<CodeProps> = ({ children }) => {
|
|
39
|
+
const language = children?.props?.className || "language-plain";
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<CodeSnippet
|
|
43
|
+
type="inline"
|
|
44
|
+
feedback="Copied!"
|
|
45
|
+
className={clsx(withPrefix("code"), language)}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</CodeSnippet>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
InlineCode.propTypes = {
|
|
53
|
+
/** Provide the contents of Code */
|
|
54
|
+
children: PropTypes.element.isRequired,
|
|
55
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright OctaviaFlow
|
|
3
|
+
* Author: Vishal Kumar
|
|
4
|
+
* Created: 11/November/2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
import { Launch } from "@octaviaflow/icons-react";
|
|
17
|
+
import PropTypes from "prop-types";
|
|
18
|
+
import React, { ReactNode } from "react";
|
|
19
|
+
|
|
20
|
+
import { MdxComponent } from "../interfaces";
|
|
21
|
+
import { withPrefix } from "../utils";
|
|
22
|
+
|
|
23
|
+
interface PathProps {
|
|
24
|
+
src?: string | null;
|
|
25
|
+
path?: string | null;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Path: MdxComponent<PathProps> = ({ src, path }) => {
|
|
30
|
+
if (!path) return null;
|
|
31
|
+
return (
|
|
32
|
+
<div className={withPrefix("path-container")}>
|
|
33
|
+
<span className={withPrefix("path")}>{path}</span>
|
|
34
|
+
|
|
35
|
+
{src && (
|
|
36
|
+
<a
|
|
37
|
+
target="_blank"
|
|
38
|
+
rel="noopener noreferrer"
|
|
39
|
+
title="View source"
|
|
40
|
+
className={withPrefix("icon")}
|
|
41
|
+
href={src}
|
|
42
|
+
>
|
|
43
|
+
<Launch title="View source" />
|
|
44
|
+
</a>
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
Path.propTypes = {
|
|
51
|
+
children: PropTypes.node as unknown as React.Validator<React.ReactNode>,
|
|
52
|
+
/** Provide path */
|
|
53
|
+
path: PropTypes.string,
|
|
54
|
+
/** Provide src link */
|
|
55
|
+
src: PropTypes.string,
|
|
56
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OctaviaFlow 2022, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@use '@carbon/react/scss/spacing' as spacing;
|
|
9
|
+
@use '@carbon/react/scss/theme' as theme;
|
|
10
|
+
@use '@carbon/react/scss/breakpoint' as breakpoint;
|
|
11
|
+
|
|
12
|
+
@use '../utils' as *;
|
|
13
|
+
|
|
14
|
+
.#{with-prefix('divider')} {
|
|
15
|
+
position: relative;
|
|
16
|
+
margin-block-start: spacing.$spacing-09;
|
|
17
|
+
padding-block-start: spacing.$spacing-06;
|
|
18
|
+
|
|
19
|
+
@include breakpoint.breakpoint(md) {
|
|
20
|
+
margin-block-start: spacing.$spacing-10;
|
|
21
|
+
padding-block-start: spacing.$spacing-07;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@include breakpoint.breakpoint(lg) {
|
|
25
|
+
margin-inline-end: -(spacing.$spacing-05);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&::after {
|
|
29
|
+
position: absolute;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
background: theme.$border-strong;
|
|
32
|
+
block-size: 1px;
|
|
33
|
+
content: '';
|
|
34
|
+
inline-size: calc(100% - 2rem);
|
|
35
|
+
inset-block-start: 0;
|
|
36
|
+
inset-inline-start: 1rem;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.#{with-prefix('divider--empty')} {
|
|
41
|
+
padding: 0;
|
|
42
|
+
block-size: 1px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.#{with-prefix('divider--empty')} + div {
|
|
46
|
+
margin-block-start: spacing.$spacing-06;
|
|
47
|
+
|
|
48
|
+
@include breakpoint.breakpoint(md) {
|
|
49
|
+
margin-block-start: spacing.$spacing-07;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.#{with-prefix('divider')} > [class*='grid'] {
|
|
54
|
+
margin-block-start: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.#{with-prefix('divider')} > [class*='grid'] > *:not(:first-child) {
|
|
58
|
+
margin-block-start: spacing.$spacing-06;
|
|
59
|
+
|
|
60
|
+
@include breakpoint.breakpoint(lg) {
|
|
61
|
+
margin-block-start: 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.#{with-prefix('divider')} [class*='column'] > *:first-child {
|
|
66
|
+
margin-block-start: 0;
|
|
67
|
+
}
|