Skip to content

Commit

Permalink
Add the ability to overwrite the slide container, 0.11.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Feb 19, 2024
1 parent d7fd757 commit fa5802d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion examples/tokyo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nkzw/remdx-tokyo-example",
"description": "Beautiful Minimalist React & MDX Presentations",
"version": "0.10.0",
"version": "0.11.0",
"author": "Christoph Nakazawa <christoph.pojer@gmail.com>",
"private": true,
"repository": {
Expand Down
11 changes: 0 additions & 11 deletions examples/tokyo/slides.re.mdx.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-remdx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-remdx",
"description": "Beautiful Minimalist React & MDX Presentations",
"version": "0.10.0",
"version": "0.11.0",
"author": "Christoph Nakazawa <christoph.pojer@gmail.com>",
"repository": {
"type": "git",
Expand Down
11 changes: 0 additions & 11 deletions packages/create-remdx/template/slides.re.mdx.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/remdx/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare module '*.re.mdx' {
let slides: ReadonlyArray<import('./types.jsx').ReMDXSlide>;

export let Components: import('./types.jsx').MDXComponents | undefined;
export let Container: import('./types.jsx').SlideContainer | undefined;
export let Themes: import('./types.jsx').Themes | undefined;
export let Transitions:
| Record<string, import('./types.jsx').SlideTransition>
Expand Down
2 changes: 1 addition & 1 deletion packages/remdx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nkzw/remdx",
"description": "Beautiful Minimalist React & MDX Presentations",
"version": "0.10.0",
"version": "0.11.0",
"author": "Christoph Nakazawa <christoph.pojer@gmail.com>",
"repository": {
"type": "git",
Expand Down
10 changes: 7 additions & 3 deletions packages/remdx/src/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import {
} from 'react';
import { animated, useSpring } from 'react-spring';
import { useSwipeable } from 'react-swipeable';
import { SlideTransition } from '../types.tsx';
import { SlideContainer, SlideTransition } from '../types.tsx';
import { DeckContext } from './deck.tsx';
import { GOTO_FINAL_STEP } from './hooks/use-deck-state.tsx';
import { Transitions } from './transitions.tsx';

export default function Slide({
children,
className,
container: Container = ({ children, style }) => (
<div style={style}>{children}</div>
),
id,
image,
padding = 48,
Expand All @@ -25,6 +28,7 @@ export default function Slide({
}: {
children: ReactNode;
className?: string;
container?: SlideContainer;
id: number;
image?: string;
padding?: string | number;
Expand Down Expand Up @@ -226,7 +230,7 @@ export default function Slide({
}}
{...swipeHandler}
>
<div
<Container
style={{
display: 'flex',
flex: 1,
Expand All @@ -236,7 +240,7 @@ export default function Slide({
}}
>
<Suspense>{children}</Suspense>
</div>
</Container>
</div>
</animated.div>
);
Expand Down
9 changes: 8 additions & 1 deletion packages/remdx/src/slidesToComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ import Slide from './slide.tsx';
import { Transitions as DefaultTransitions } from './transitions.tsx';

export default async function slidesToComponent(module: Promise<ReMDXModule>) {
const { Components, Themes, Transitions, default: slides } = await module;
const {
Components,
Container,
Themes,
Transitions,
default: slides,
} = await module;
return (
<MDXProvider components={{ ...DefaultComponents, ...Components }}>
<Deck
slides={slides.map(({ Component, data }, index) => (
<Slide
container={Container}
id={index}
image={data?.image}
key={index}
Expand Down
23 changes: 16 additions & 7 deletions packages/remdx/types.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import type { MDXComponents as _MDXComponents } from 'mdx/types.js';
import { CSSProperties } from 'react';
import { CSSProperties, ReactNode } from 'react';

export type MDXComponents = _MDXComponents;

export type Themes = Record<string, CSSProperties>;

export type SlideTransition = {
export type SlideTransition = Readonly<{
enter?: CSSProperties;
from?: CSSProperties;
leave?: CSSProperties;
};
}>;

export type ReMDXSlide = {
export type SlideContainer = ({
children,
style,
}: {
children: JSX.Element;
style: CSSProperties;
}) => ReactNode;

export type ReMDXSlide = Readonly<{
Component: () => JSX.Element;
data: Record<string, string>;
};
}>;

export type ReMDXModule = {
export type ReMDXModule = Readonly<{
Components?: _MDXComponents;
Container?: SlideContainer;
Themes?: Themes;
Transitions?: Record<string, SlideTransition>;
default: ReadonlyArray<ReMDXSlide>;
};
}>;
2 changes: 1 addition & 1 deletion packages/vite-plugin-remdx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nkzw/vite-plugin-remdx",
"description": "Beautiful Minimalist React & MDX Presentations",
"version": "0.10.0",
"version": "0.11.0",
"author": "Christoph Nakazawa <christoph.pojer@gmail.com>",
"repository": {
"type": "git",
Expand Down

0 comments on commit fa5802d

Please sign in to comment.