Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convert mdx components in web app to mdx-components package #1423

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
cca6e41
feat(mdx-components): add caption component
alisonjoseph Oct 6, 2022
05f0090
feat(web-app): remove caption mdx component
alisonjoseph Oct 6, 2022
4557f5f
feat(web-app): remove caption
alisonjoseph Oct 6, 2022
7b1c457
feat(mdx-components): add accordion component
alisonjoseph Oct 6, 2022
a187e26
feat(mdx-components): add global MdxComponent helper interface
jharvey10 Oct 6, 2022
416b049
feat(web-app): remove accordion component
alisonjoseph Oct 6, 2022
8126e5e
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
alisonjoseph Oct 6, 2022
25d4ffe
feat(mdx-components): update accordion
alisonjoseph Oct 6, 2022
50c4ec2
fix(mdx-components): update caption class name, add some docs
jharvey10 Oct 6, 2022
e63ddd6
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
alisonjoseph Oct 6, 2022
9f39f0b
fix(mdx-components): add optional types to accordion className prop
jharvey10 Oct 6, 2022
5f71087
fix(mdx-components): adjust packaging includes/excludes
jharvey10 Oct 6, 2022
79981a5
fix(mdx-components): correct typings of MdxComponent
jharvey10 Oct 6, 2022
6be5907
fix(mdx-components): re-export carbon accordion item
jharvey10 Oct 6, 2022
93be93f
feat(mdx-components): convert video component
jharvey10 Oct 6, 2022
771a571
feat(mdx-components): add aside component
alisonjoseph Oct 7, 2022
b9a31c6
feat(web-app): remove aside component
alisonjoseph Oct 7, 2022
036b15d
feat(mdx-components): add card-group
alisonjoseph Oct 7, 2022
4acca8c
feat(web-app): remove card-group
alisonjoseph Oct 7, 2022
3d8920a
feat(mdx-components): add divider
alisonjoseph Oct 10, 2022
fa7c3f6
feat(web-app): remove divider from web app
alisonjoseph Oct 10, 2022
5bda2ad
feat(mdx-components): add do dont
alisonjoseph Oct 10, 2022
ccb77b0
feat(web-app): remove do dont
alisonjoseph Oct 10, 2022
cb24708
feat(mdx-components): migrate GifPlayer component into mdx-components
francinelucca Oct 10, 2022
e03db03
feat(mdx-components): add grid
alisonjoseph Oct 11, 2022
8dc48ef
feat(web-app): remove grid transform
alisonjoseph Oct 11, 2022
10b21d5
fix(mdx-components): accordion size prop
alisonjoseph Oct 11, 2022
901ee9d
wip: comment out grid
alisonjoseph Oct 11, 2022
ad1ac09
fix(mdx-components): update accordion styles
alisonjoseph Oct 11, 2022
e6523a8
build: scope nextjs eslint config to web-app
jharvey10 Oct 11, 2022
e7ed2a8
feat(mdx-components): add use match media
alisonjoseph Oct 11, 2022
52de720
wip: fix grid
alisonjoseph Oct 11, 2022
63937e6
refactor(mdx-components): move media query functions to utils module
jharvey10 Oct 11, 2022
74269d8
docs(mdx-components): fix typo
jharvey10 Oct 11, 2022
853d0fd
feat(mdx-components): migrate paragraph and pageDescription components
francinelucca Oct 11, 2022
ec9fed0
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 11, 2022
8919ec1
feat(mdx-components): migrate Profile component
francinelucca Oct 11, 2022
a725f08
feat(mdx-components): convert title
jharvey10 Oct 11, 2022
5255fba
feat(web-app): remove title component
jharvey10 Oct 11, 2022
7f57a51
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
jharvey10 Oct 11, 2022
3ad4a3f
feat(mdx-components): add art direction
alisonjoseph Oct 12, 2022
9535e4f
feat(web-app): remove art direction
alisonjoseph Oct 12, 2022
5e3c82b
fix: imports
alisonjoseph Oct 12, 2022
8d40847
feat(mdx-components): add column
alisonjoseph Oct 12, 2022
58832b5
feat(mdx-components): add row
alisonjoseph Oct 12, 2022
d2a2418
feat(mdx-components): migrate resource card
francinelucca Oct 12, 2022
2206c06
fix: col and row errors
alisonjoseph Oct 12, 2022
5e72dcf
feat(mdx-components): migrate image wrapper component
francinelucca Oct 12, 2022
d6cca9a
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 12, 2022
3351b1d
feat(mdx-components): migrate MiniCard
francinelucca Oct 12, 2022
9a4b99b
feat: migrate article card
andreancardona Oct 12, 2022
bdf7281
feat: inline notification mdx
andreancardona Oct 13, 2022
007eeba
fix(mdx-components): nest gifPlayer classes
francinelucca Oct 13, 2022
4cbe939
feat(mdx-components): group cards
alisonjoseph Oct 13, 2022
de6d856
fix(mdx-components): column component missing props
alisonjoseph Oct 13, 2022
bb3e29d
fix(mdx-components): column component missing props
alisonjoseph Oct 13, 2022
2597588
feat(mdx-components): add storybook demo
alisonjoseph Oct 14, 2022
2da677f
feat(web-app): remove storybook demo
alisonjoseph Oct 14, 2022
f6b3ee2
Update packages/mdx-components/src/main/storybook-demo/storybook-demo…
alisonjoseph Oct 14, 2022
67ef95f
feat(mdx-components): add card story doc improvements
alisonjoseph Oct 14, 2022
73d4e75
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 14, 2022
e1e81ee
feat(mdx-components): migrate headings markdown comps
francinelucca Oct 14, 2022
9c1debc
feat: preview component
andreancardona Oct 16, 2022
90e49fb
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
andreancardona Oct 16, 2022
7862dc0
wip: merge
alisonjoseph Oct 17, 2022
0ef4644
wip: merge
alisonjoseph Oct 17, 2022
5872093
feat(mdx-components): migrate blockquote
francinelucca Oct 17, 2022
6838e44
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 17, 2022
988d21e
fix(web-app): import headings from mdx-components
francinelucca Oct 17, 2022
e4c2aa5
fix(mdx-components): add mdx guidance to headings SB
francinelucca Oct 17, 2022
6c9abce
feat(mdx-components): migrate PageTable component
francinelucca Oct 17, 2022
41af551
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 17, 2022
c0986e0
fix(web-app): pull paragraph and pagedescription from mdx-components pkg
francinelucca Oct 17, 2022
6ceed2e
fix(mdx-components): add typing to storybook-demo variants prop
jharvey10 Oct 17, 2022
462443f
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
jharvey10 Oct 17, 2022
da89576
feat: ul ol and li markdown
andreancardona Oct 17, 2022
a606f6d
fix: merge conflict
andreancardona Oct 17, 2022
8bb3557
feat(mdx-components): add typeweight
alisonjoseph Oct 18, 2022
55a648d
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
alisonjoseph Oct 18, 2022
d37bc38
feat: organize storybook
alisonjoseph Oct 18, 2022
f6cd7e3
feat: organize storybook
alisonjoseph Oct 18, 2022
a1d6d9e
feat(mdx-components): add Link component
francinelucca Oct 18, 2022
e264ee7
fix(web-app): pull Link component from mdx-components package
francinelucca Oct 18, 2022
b0c251f
feat: organize storybook
alisonjoseph Oct 18, 2022
7083586
test(mdx-components): fix ts-node file loading in ava tests
jharvey10 Oct 18, 2022
f19ab87
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
jharvey10 Oct 18, 2022
37b5930
Merge branch 'main' into 1103-convert-mdx-components-in-web-app-to-md…
alisonjoseph Oct 18, 2022
c0ba44a
feat(mdx-components): add new NonScalarNode utility type
jharvey10 Oct 18, 2022
f020a75
feat(mdx-components): add noanchor prop to h2
alisonjoseph Oct 19, 2022
b91cb05
feat(web-app): component cleanup
alisonjoseph Oct 19, 2022
08c33ae
feat(mdx-components): add typescaletable
alisonjoseph Oct 19, 2022
d32993c
feat(web-app): remove typescaletable
alisonjoseph Oct 19, 2022
7792da5
feat(mdx-components): convert tabs component
jharvey10 Oct 19, 2022
870ca6a
feat(web-app): remove tabs component
jharvey10 Oct 19, 2022
036182b
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
jharvey10 Oct 19, 2022
b7edb60
feat(mdx-components): add Code component
francinelucca Oct 19, 2022
98eca88
fix(web-app): use Code component from mdx-components pckg
francinelucca Oct 19, 2022
6d7996e
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
francinelucca Oct 19, 2022
b0a7128
feat: color grid and color palette convert
andreancardona Oct 24, 2022
4af51b1
Merge branch '1103-convert-mdx-components-in-web-app-to-mdx-component…
andreancardona Oct 24, 2022
e546b80
feat: status indicator mdx
andreancardona Oct 25, 2022
0f6bcdb
Merge branch 'main' of github.com:carbon-design-system/carbon-platfor…
francinelucca Nov 7, 2022
a5f5672
fix(mdx-components): remove one-off components migrations
francinelucca Nov 8, 2022
509ea8b
fix(web-app): reintroduce one-off components
francinelucca Nov 8, 2022
4361c5b
fix(web-app): reintroduce deleted stories
francinelucca Nov 8, 2022
ab06ad8
fix(mdx-components): fix broken build and minor sb media fixes
francinelucca Nov 8, 2022
59fc52a
fix(web-app): export colorblock from mdx components
francinelucca Nov 8, 2022
237ea6e
fix(mdx-components): add test for migrated comps, fix some props
francinelucca Nov 9, 2022
2c54c63
fix(web-app): export one-off carbon components from web app
francinelucca Nov 9, 2022
206119a
fix(web-app): incorrect import
francinelucca Nov 9, 2022
011cb66
fix(mdx-components): more test coverage
francinelucca Nov 10, 2022
a99ce90
deps(mdx-components): hoist @carbon/react to base workspace
jharvey10 Nov 10, 2022
7d08eb4
test(mdx-components): add more unit tests
jharvey10 Nov 10, 2022
5d03be4
fix(mdx-components): address some proptype warnings
francinelucca Nov 10, 2022
3df4995
test(mdx-components): update snapshots
jharvey10 Nov 11, 2022
73ffd8e
fix(mdx-components): visual consistency fixes and remove some warnings
jharvey10 Nov 11, 2022
7101c0a
fix(mdx-components): visual component fixes
jharvey10 Nov 11, 2022
ecde8ff
test(mdx-components): update unit test snapshots
jharvey10 Nov 11, 2022
0ae750c
fix(mdx-components): remove title styles from index.scss
jharvey10 Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/mdx-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
"homepage": "https://github.com/carbon-design-system/carbon-platform#readme",
"type": "module",
"files": [
"./dist/main/**/*"
],
"exports": {
".": "./dist/main/index.js",
"./styles": "./dist/main/index.css"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
@use '@carbon/react/scss/type' as type;
@use '@carbon/react/scss/theme' as theme;

.accordion {
@use '../utils' as *;

.#{with-prefix('accordion')} {
margin-top: spacing.$spacing-06;
color: theme.$text-primary;
}

// override carbon, accordion right spacing
.accordion :global(.cds--accordion__content) {
.#{with-prefix('accordion')} :global(.cds--accordion__content) {
padding-right: spacing.$spacing-10;
}

// override carbon, title font and spacing
.accordion :global(.cds--accordion__title) {
.#{with-prefix('accordion')} :global(.cds--accordion__title) {
@include type.type-style('heading-02');
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Accordion, AccordionItem } from '@/components/accordion'
import { Accordion, AccordionItem } from '../../../dist/main/index'

const stories = {
title: 'MDX/Accordion',
export default {
title: 'Components/Accordion',
component: Accordion,
subcomponents: { AccordionItem }
}

export default stories

const Template = (args) => (
<Accordion {...args}>
<AccordionItem title="Title 1">Content Section</AccordionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@
*/

import { Accordion as CarbonAccordion, Column, Grid } from '@carbon/react'
import clsx from 'clsx'
import { clsx } from 'clsx'
import PropTypes from 'prop-types'
import React from 'react'

import styles from './accordion.module.scss'
import { MdxComponent } from '../interfaces.js'
import { withPrefix } from '../utils.js'

interface AccordionProps {
className?: string | null
}

/**
* The `<Accordion>` and `<AccordionItem>` components are used together to display a list of content
* sections that can be toggled open by clicking the respective title of each section.
*/
const Accordion = ({ className, ...rest }) => (
const Accordion: MdxComponent<AccordionProps> = ({ className, ...rest }) => (
<Grid narrow>
<Column sm={4} md={8} lg={8}>
<CarbonAccordion size="xl" {...rest} className={clsx(className, styles.accordion)} />
<CarbonAccordion size="xl" {...rest} className={clsx(className, withPrefix('accordion'))} />
</Column>
</Grid>
)
Expand All @@ -30,4 +36,5 @@ Accordion.propTypes = {
className: PropTypes.string
}

export { AccordionProps }
export default Accordion
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import PropTypes from 'prop-types'
import React from 'react'
import slugifyCjs from 'slugify'

import { MdxComponent } from '../interfaces.js'
import { withPrefix } from '../utils.js'

const slugify = slugifyCjs.default

interface AnchorLinkProps {
to?: string
to?: string | null
children: string
}

const AnchorLink = ({ to, children }: AnchorLinkProps) => {
const AnchorLink: MdxComponent<AnchorLinkProps> = ({ to, children }) => {
const href = to || `#${slugify(children, { lower: true })}`

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { clsx } from 'clsx'
import PropTypes from 'prop-types'
import React, { Children, ReactNode } from 'react'

import { MdxComponent } from '../interfaces.js'
import { withPrefix } from '../utils.js'

interface AnchorLinksProps {
small?: boolean
small?: boolean | null
children: ReactNode
}

Expand All @@ -25,7 +26,7 @@ interface AnchorLinksProps {
* For most pages, we recommend starting with a `PageDescription` followed by `AnchorLinks` if the
* content is long enough.
*/
const AnchorLinks = ({ children, small }: AnchorLinksProps) => {
const AnchorLinks: MdxComponent<AnchorLinksProps> = ({ children, small }) => {
const isColumn = Children.count(children) > 9
const classNames = clsx({
[withPrefix('list--small')]: small,
Expand All @@ -46,6 +47,10 @@ const AnchorLinks = ({ children, small }: AnchorLinksProps) => {
}

AnchorLinks.propTypes = {
/**
* A set of links to be rendered as part of this AnchorLinks component.
*/
children: PropTypes.node,
/**
* Display small font size.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@use '@carbon/react/scss/theme' as theme;
@use '@carbon/react/scss/type' as type;

.aside {
@use '../utils' as *;

.#{with-prefix('aside')} {
@include type.type-style('body-01');

position: relative;
Expand Down Expand Up @@ -49,6 +51,6 @@
}
}

.aside--no-rule::before {
.#{with-prefix('aside--no-rule')}::before {
content: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/
import { Column, Grid } from '@carbon/react'

import Aside from '@/components/aside'
import { Aside } from '../../../dist/main/index'

const stories = {
title: 'MDX/Aside',
export default {
title: 'Components/Aside',
component: Aside,
argTypes: {
children: {
Expand All @@ -21,8 +21,6 @@ const stories = {
}
}

export default stories

const Template = (args) => (
<Grid>
<Column lg={4}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
*/

import { Column, Grid } from '@carbon/react'
import clsx from 'clsx'
import { clsx } from 'clsx'
import PropTypes from 'prop-types'
import React, { ReactNode } from 'react'

import styles from './aside.module.scss'
import { MdxComponent } from '../interfaces.js'
import { withPrefix } from '../utils.js'

interface AsideProps {
children: ReactNode
className?: string | null
hideRule?: boolean | null
}

/**
* The `<Aside>` component is a wrapper component that adds styling to make the text display
* smaller than the default body text with a one column offset. It is designed to be used on
* the side of the page within grid components. Add an aria-label for a11y.
*/
const Aside = ({ children, className, hideRule, ...rest }) => {
const asideClasses = clsx(styles.aside, className, {
[styles['aside--no-rule']]: !!hideRule
const Aside: MdxComponent<AsideProps> = ({ children, className, hideRule, ...rest }) => {
const asideClasses = clsx(withPrefix('aside'), className, {
[withPrefix('aside--no-rule')]: !!hideRule
})

return (
Expand All @@ -32,8 +40,6 @@ const Aside = ({ children, className, hideRule, ...rest }) => {
)
}

export default Aside

Aside.propTypes = {
/**
* Child of the Aside.
Expand All @@ -50,3 +56,6 @@ Aside.propTypes = {
*/
hideRule: PropTypes.bool
}

export { AsideProps }
export default Aside
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
@use '@carbon/react/scss/type' as type;
@use '@carbon/react/scss/theme' as theme;

.container {
@use '../utils' as *;

.#{with-prefix('caption-container')} {
margin-top: spacing.$spacing-05;
}

.caption,
.caption p,
.caption div {
.#{with-prefix('caption')},
.#{with-prefix('caption')} p,
.#{with-prefix('caption')} div {
@include type.type-style('body-short-01');

margin-top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import Caption from '@/components/caption'
import { Caption } from '../../../dist/main/index'

const stories = {
title: 'MDX/Caption',
component: Caption
export default {
title: 'Components/Caption',
component: Caption,
argTypes: {}
}

export default stories

const Template = (args) => (
<Caption {...args}>Lorem ipsum dolor sit amet Lorem Lorem Lorem Lorem Lorem Lorem ipsum.</Caption>
)
Expand Down
38 changes: 38 additions & 0 deletions packages/mdx-components/src/main/caption/caption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright IBM Corp. 2022, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Column, Grid } from '@carbon/react'
import { clsx } from 'clsx'
import PropTypes from 'prop-types'
import React, { ReactNode } from 'react'

import { MdxComponent } from '../interfaces.js'
import { withPrefix } from '../utils.js'

interface CaptionProps {
children: ReactNode
className?: string | null
}

/**
* The `<Caption>` component is typically used below images or videos.
*/
const Caption: MdxComponent<CaptionProps> = ({ children, className }) => (
<Grid className={clsx(className, withPrefix('caption-container'))}>
<Column sm={4} md={6} lg={6}>
<p className={withPrefix('caption')}>{children}</p>
</Column>
</Grid>
)

Caption.propTypes = {
children: PropTypes.node,
className: PropTypes.string
}

export { CaptionProps }
export default Caption
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
/*
* Copyright IBM Corp. 2022, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

@use '@carbon/react/scss/theme' as theme;
@use '@carbon/react/scss/breakpoint' as breakpoint;

@use '../utils' as *;

// Sets gray border on the top of cards at the smallest breakpoint and removes the margin set by the <Column> in the Grid component.
.card-group [class*='column'] {
.#{with-prefix('card-group')} [class*='column'] {
border-top: 1px solid theme.$border-subtle;
margin-bottom: 0;
}

.card-group [class*='column']:first-child {
.#{with-prefix('card-group')} [class*='column']:first-child {
border-top: 0 solid transparent;
}

// Borders for cards at the medium breakpoint
.card-group [class*='column']:nth-child(-n + 2) {
.#{with-prefix('card-group')} [class*='column']:nth-child(-n + 2) {
@include breakpoint.breakpoint('md') {
border-top: 0 solid transparent;
}
}

.card-group [class*='column']:nth-child(even) {
.#{with-prefix('card-group')} [class*='column']:nth-child(even) {
@include breakpoint.breakpoint('md') {
box-shadow: -1px 0 0 0 theme.$border-subtle;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright IBM Corp. 2022, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Column } from '@carbon/react'

import { CardGroup } from '../../../dist/main/index'

export default {
title: 'Components/CardGroup',
component: CardGroup,
argTypes: {
children: {
control: false
},
className: {
control: false
}
}
}

const Template = () => (
<CardGroup>
<Column lg={4}>TODO: Add ResourceCard</Column>
<Column lg={4}>TODO: Add ResourceCard</Column>
<Column lg={4}>TODO: Add ResourceCard</Column>
<Column lg={4}>TODO: Add ResourceCard</Column>
</CardGroup>
)

export const Default = Template.bind({})
Default.args = {}
Loading