-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add base custom layout in Markdown Support (#1289)
- Loading branch information
1 parent
1add746
commit 6153f1a
Showing
18 changed files
with
1,234 additions
and
2,523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
strict-peer-dependencies=false | ||
prefer-workspace-packages=true | ||
auto-install-peers=false | ||
|
||
# Docusaurus has some phantom dependencies, so specifically hoist those. | ||
public-hoist-pattern[]=@docusaurus/theme-classic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"broadcast-channel": "https://esm.sh/v121/broadcast-channel@^[email protected]", | ||
"history": "https://esm.sh/v121/history@^[email protected]", | ||
"kbar": "https://esm.sh/v121/[email protected][email protected]", | ||
"lodash.clonedeep": "https://esm.sh/v121/lodash.clonedeep@^[email protected]", | ||
"mdast-builder": "https://esm.sh/v121/mdast-builder@^[email protected]", | ||
"mdast-zone": "https://esm.sh/v121/mdast-zone@^[email protected]", | ||
"merge-anything": "https://esm.sh/v121/merge-anything@^[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/spectacle/src/components/markdown/markdown-layout-containers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { FlexBox } from '../layout-primitives'; | ||
|
||
export const Columns = ({ children }: PropsWithChildren) => ( | ||
<FlexBox flexDirection="row" alignItems="start" flex={1}> | ||
{children} | ||
</FlexBox> | ||
); | ||
|
||
export const Center = ({ children }: PropsWithChildren) => ( | ||
<FlexBox justifyContent="center" alignItems="center" height="100%"> | ||
{children} | ||
</FlexBox> | ||
); | ||
|
||
export const hasLayoutConfig = | ||
(layoutKey: string) => (config?: Record<string, string>) => | ||
config && 'layout' in config && config.layout === layoutKey; |
35 changes: 35 additions & 0 deletions
35
packages/spectacle/src/components/markdown/markdown-slide-renderer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Slide from '../slide/slide'; | ||
import React from 'react'; | ||
import { Markdown } from './markdown'; | ||
import { MarkdownSlideProps } from './markdown-types'; | ||
import { Center, Columns, hasLayoutConfig } from './markdown-layout-containers'; | ||
|
||
export const MarkdownSlide = ({ | ||
children, | ||
componentMap, | ||
animateListItems = false, | ||
componentProps = {}, | ||
slideConfig, | ||
template: propTemplate, | ||
...rest | ||
}: MarkdownSlideProps) => { | ||
let template = propTemplate; | ||
|
||
if (hasLayoutConfig('columns')(slideConfig)) template = { default: Columns }; | ||
if (hasLayoutConfig('center')(slideConfig)) template = { default: Center }; | ||
|
||
return ( | ||
<Slide {...rest}> | ||
<Markdown | ||
{...{ | ||
componentMap, | ||
template, | ||
animateListItems, | ||
componentProps, | ||
children, | ||
slideConfig | ||
}} | ||
/> | ||
</Slide> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
packages/spectacle/src/components/markdown/markdown-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MarkdownComponentMap } from '../../utils/mdx-component-mapper'; | ||
import { ElementType } from 'react'; | ||
|
||
export type MdComponentProps = { [key: string]: any }; | ||
|
||
export type CommonMarkdownProps = { | ||
animateListItems?: boolean; | ||
componentProps?: MdComponentProps; | ||
children: string; | ||
}; | ||
|
||
export type MarkdownSlideProps = CommonMarkdownProps & | ||
MapAndTemplate & { slideConfig?: Record<string, string> }; | ||
|
||
export type MarkdownSlideSetProps = CommonMarkdownProps & { | ||
slideProps?: Partial<MarkdownSlideProps>[]; | ||
}; | ||
|
||
export type MapAndTemplate = { | ||
componentMap?: MarkdownComponentMap; | ||
template?: { | ||
default: ElementType; | ||
getPropsForAST?: Function; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6153f1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
spectacle-docs-website – ./
spectacle-website-mu.vercel.app
spectacle-docs-website-git-main-formidable-labs.vercel.app
spectacle-docs-website-formidable-labs.vercel.app