Skip to content
Prev Previous commit
Next Next commit
Add class and style to components
  • Loading branch information
pomber committed Jun 23, 2022
commit e3ae28167d4bbd8030acfd7845288e3542078020
7 changes: 6 additions & 1 deletion packages/mdx/src/mdx-client/scrollycoding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ export function Scrollycoding({
codeConfig,
presetConfig,
start = 0,
className,
style,
...rest
}: {
children: React.ReactNode
editorSteps: EditorStep[]
codeConfig: EditorProps["codeConfig"]
start?: number
presetConfig?: PresetConfig
className?: string
style?: React.CSSProperties
}) {
const stepsChildren = React.Children.toArray(children)

Expand Down Expand Up @@ -58,7 +62,8 @@ export function Scrollycoding({
<section
className={`ch-scrollycoding ${
presetConfig ? "ch-scrollycoding-with-preview" : ""
}`}
} ${className || ""}`}
style={style}
>
<div className="ch-scrollycoding-content">
<Scroller onStepChange={onStepChange}>
Expand Down
9 changes: 8 additions & 1 deletion packages/mdx/src/mdx-client/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ const SectionContext = React.createContext<{

export function Section({
children,
className,
style,
...props
}: {
children: React.ReactNode
className?: string
style?: React.CSSProperties
}) {
const [state, setState] = React.useState<any>(props)

Expand All @@ -45,7 +49,10 @@ export function Section({
const { selectedId, ...rest } = state

return (
<section>
<section
className={`ch-section ${className || ""}`}
style={style}
>
<SectionContext.Provider
value={{
props: rest,
Expand Down
7 changes: 6 additions & 1 deletion packages/mdx/src/mdx-client/slideshow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export function Slideshow({
codeConfig,
presetConfig,
code,
className,
style,
...rest
}: {
children: React.ReactNode
editorSteps: EditorStep[]
codeConfig: EditorProps["codeConfig"]
presetConfig?: PresetConfig
code?: EditorProps["codeConfig"]
className?: string
style?: React.CSSProperties
}) {
const stepsChildren = React.Children.toArray(children)

Expand All @@ -42,7 +46,8 @@ export function Slideshow({
<div
className={`ch-slideshow ${
presetConfig ? "ch-slideshow-with-preview" : ""
}`}
} ${className || ""}`}
style={style}
>
<div className="ch-slideshow-slide">
<InnerCode
Expand Down
11 changes: 8 additions & 3 deletions packages/mdx/src/mdx-client/spotlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export function Spotlight({
codeConfig,
start = 0,
presetConfig,
className,
style,
...rest
}: {
children: React.ReactNode
editorSteps: EditorStep[]
codeConfig: EditorProps["codeConfig"]
start?: number
presetConfig?: PresetConfig
className?: string
style?: React.CSSProperties
}) {
const stepsChildren = React.Children.toArray(children)

Expand All @@ -38,10 +42,11 @@ export function Spotlight({
stepsChildren[0] as React.ReactElement

return (
<div
<section
className={`ch-spotlight ${
presetConfig ? "ch-spotlight-with-preview" : ""
}`}
} ${className || ""}`}
style={style}
>
<div className="ch-spotlight-tabs">
{headerElement?.props?.children ? (
Expand Down Expand Up @@ -83,6 +88,6 @@ export function Spotlight({
/>
)}
</div>
</div>
</section>
)
}
1 change: 1 addition & 0 deletions packages/mdx/src/remark/transform.section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async function transformSection(
name: "CH.Section",
props: props as any,
addConfigProp: true,
appendProps: true,
})
} else {
toJSX(node, { name: "div", props: {} })
Expand Down