Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 26 additions & 20 deletions docs/content/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ Array values can even be mixed to include sub-arrays (for multiple lines) and nu

_Note that each range will be considered as a step in your current slide's animation. Each range will be highlighted as you move forward or backwards on each step._

| Props | Type | Example | Default Props |
| ----------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| `children` | PropTypes.string | `let name = "Carlos"` | - |
| `highlightRanges` | PropTypes.arrayOf(PropTypes.number) or PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)) | `[1, 3]` or `[[6, 8], [10, 15]]` | - |
| `language` | PropTypes.string | `javascript` | - |
| `theme` | PropTypes.object or | [Prism Theme](https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/src/styles/prism/index.js) | vs-dark Theme Object |
| `showLineNumbers` | PropTypes.bool | `true`, `false` | `true` |
| Props | Type | Example | Default Props |
| ---------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| `children` | PropTypes.string | `let name = "Carlos"` | - |
| `highlightRanges` | PropTypes.arrayOf(PropTypes.number) or PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)) | `[1, 3]` or `[[6, 8], [10, 15]]` | - |
| `language` | PropTypes.string | `javascript` | - |
| `theme` | PropTypes.object or | [Prism Theme](https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/src/styles/prism/index.js) | vs-dark Theme Object |
| `showLineNumbers` | PropTypes.bool | `true`, `false` | `true` |
| [**`Layout`**](./props#layout) | | | |
| [**`Position`**](./props#position) | | | |

```jsx
import tomorrow from 'react-syntax-highlighter/dist/cjs/styles/prism/tomorrow';
Expand All @@ -250,10 +252,11 @@ import tomorrow from 'react-syntax-highlighter/dist/cjs/styles/prism/tomorrow';

FullScreen is a button that takes the presentation in and out of the browser's full screen mode. It can have a different color and be re-sized.

| Props | Type | Example |
| ------- | ---------------- | --------- |
| `size` | PropTypes.number | `23` |
| `color` | PropTypes.string | `#abc123` |
| Props | Type | Example |
| ---------------------------------- | ---------------- | --------- |
| `size` | PropTypes.number | `23` |
| `color` | PropTypes.string | `#abc123` |
| [**`Position`**](./props#position) | | |

## Image

Expand All @@ -269,11 +272,13 @@ Image is a component to display a picture within a slide. It is analogous to an

The Markdown components let you include a block of Markdown within a slide using `<Markdown />`, author a complete slide with Markdown using `<MarkdownSlide />`, or author a series of slides with Markdown using `<MarkdownSlides />`. Markdown tags get converted into Spectacle components. The `---` three dash marker when used inside `<MarkdownSlideSet />` is used to divide content into separate slides. Markdown also supports presenter notes using the `Notes:` marker. `<Markdown />` must be a child of `<Slide />` where `<MarkdownSlide />` and `<MarkdownSlideSet />` are children of `<Deck />`.

| Props | Type | Example |
| ------------------ | ----------------- | ----------------------------------------------------------------------------------- |
| `children` | PropTypes.string | `# Hi there` |
| `componentProps` | PropTypes.object | `<MarkdownSlide componentProps={{ color: 'purple' }}># I'm purple!</MarkdownSlide>` |
| `animateListItems` | PropTypes.boolean | `<MarkdownSlide animateListItems />` |
| Props | Type | Example |
| ---------------------------------- | ----------------- | ----------------------------------------------------------------------------------- |
| `children` | PropTypes.string | `# Hi there` |
| `componentProps` | PropTypes.object | `<MarkdownSlide componentProps={{ color: 'purple' }}># I'm purple!</MarkdownSlide>` |
| `animateListItems` | PropTypes.boolean | `<MarkdownSlide animateListItems />` |
| [**`Layout`**](./props#layout) | | |
| [**`Position`**](./props#position) | | |

```jsx
<Slide>
Expand Down Expand Up @@ -337,7 +342,8 @@ Notes is a component that only renders in Presenter mode as presenter notes. It

Progress is a component with no children that just shows dots for each slide in your deck. Visited and current slides are represented by a filled circle and future slides with just a stroke. The size and color are customizable.

| Props | Type | Example |
| ------- | ---------------- | --------- |
| `size` | PropTypes.number | `23` |
| `color` | PropTypes.string | `#abc123` |
| Props | Type | Example |
| ---------------------------------- | ---------------- | --------- |
| `size` | PropTypes.number | `23` |
| `color` | PropTypes.string | `#abc123` |
| [**`Position`**](./props#position) | | |
4 changes: 2 additions & 2 deletions docs/content/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const transition = {

## Layout

**Layout** props are used by [`Box`](./api-reference#box), [`FlexBox`](./api-reference#flex-box), [`Grid`](./api-reference#grid), [`Table`](./api-reference#table), [`TableHeader`](./api-reference#table-header), [`TableBody`](./api-reference#table-body), [`TableRow`](./api-reference#table-row), and [`TableCell`](./api-reference#table-cell).
**Layout** props are used by [`Box`](./api-reference#box), [`FlexBox`](./api-reference#flex-box), [`Grid`](./api-reference#grid), [`Table`](./api-reference#table), [`TableHeader`](./api-reference#table-header), [`TableBody`](./api-reference#table-body), [`TableRow`](./api-reference#table-row), [`TableCell`](./api-reference#table-cell), [`CodePane`](./api-reference#code-pane), and [`Markdown`](./api-reference#markdown-components).

| Name | PropType | Description | Example |
| ----------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
Expand Down Expand Up @@ -141,7 +141,7 @@ const transition = {

## Position

**Position** props are used by [`Box`](./api-reference#box), [`FlexBox`](./api-reference#flex-box), and [`Grid`](./api-reference#grid).
**Position** props are used by [`Box`](./api-reference#box), [`FlexBox`](./api-reference#flex-box), [`Grid`](./api-reference#grid), [`CodePane`](./api-reference#code-pane), [`FullScreen`](./api-reference#fullscreen), [`Progress`](./api-reference#progress), and [`Markdown`](./api-reference#markdown-components).

| Name | PropType | Description | Example |
| ---------- | ---------------- | ------------------------ | ---------- |
Expand Down
14 changes: 10 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ declare module 'spectacle' {
stepIndex?: number;
highlightRanges?: number | (number | number[])[];
showLineNumbers?: boolean;
}>;
}> &
StyledSystem.LayoutProps &
StyledSystem.PositionProps;

type TypographyProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -149,20 +151,24 @@ declare module 'spectacle' {
export const Progress: React.FC<{
color: string;
size: number;
}>;
}> &
StyledSystem.PositionProps;

export const FullScreen: React.FC<{
color: string;
size: number;
}>;
}> &
StyledSystem.PositionProps;

type MdComponentProps = { [key: string]: any };

export const Markdown: React.FC<{
animateListItems?: boolean;
children: React.ReactNode;
componentProps?: MdComponentProps;
}>;
}> &
StyledSystem.LayoutProps &
StyledSystem.PositionProps;

export const MarkdownSlide: React.FC<{
animateListItems?: boolean;
Expand Down
12 changes: 8 additions & 4 deletions src/components/code-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import propTypes from 'prop-types';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { useSteps } from '../hooks/use-steps';
import indentNormalizer from '../utils/indent-normalizer';
import { ThemeContext } from 'styled-components';
import styled, { ThemeContext } from 'styled-components';
import { compose, layout, position } from 'styled-system';
import dark from 'react-syntax-highlighter/dist/cjs/styles/prism/vs-dark';

const checkForNumberValues = ranges => {
Expand Down Expand Up @@ -50,6 +51,8 @@ const getStyleForLineNumber = (lineNumber, activeRange) => {
return { opacity: from <= lineNumber && lineNumber <= to ? 1 : 0.5 };
};

const Container = styled('div')(compose(position, layout));

const CodePane = React.forwardRef(
(
{
Expand All @@ -58,7 +61,8 @@ const CodePane = React.forwardRef(
showLineNumbers = true,
children: rawCodeString,
stepIndex,
theme: syntaxTheme = dark
theme: syntaxTheme = dark,
...props
},
ref
) => {
Expand Down Expand Up @@ -158,7 +162,7 @@ const CodePane = React.forwardRef(
return (
<>
{placeholder}
<div ref={ref}>
<Container ref={ref} {...props}>
<SyntaxHighlighter
customStyle={customStyle}
language={language}
Expand All @@ -170,7 +174,7 @@ const CodePane = React.forwardRef(
>
{children}
</SyntaxHighlighter>
</div>
</Container>
</>
);
}
Expand Down
19 changes: 11 additions & 8 deletions src/components/fullscreen.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import * as React from 'react';
import propTypes from 'prop-types';
import styled from 'styled-components';
import { position } from 'styled-system';

import { useToggleFullScreen } from '../hooks/use-full-screen';

const FullScreen = React.forwardRef((props, ref) => {
const Container = styled('div')`
@media print {
display: none;
}
`;
const Container = styled('div')`
${position}
@media print {
display: none;
}
`;

const FullScreen = React.forwardRef(({ size, color, ...props }, ref) => {
const toggleFullScreen = useToggleFullScreen();
return (
<Container
ref={ref}
className="spectacle-fullscreen-button"
onClick={toggleFullScreen}
style={{ pointerEvents: 'all' }}
{...props}
>
<svg width={props.size} height={props.size} viewBox="0 0 512 512">
<svg width={size} height={size} viewBox="0 0 512 512">
<path
fill={props.color}
fill={color}
d={
!!document.fullscreenElement || document.webkitIsFullScreen
? 'M64 371.2h76.795V448H192V320H64v51.2zm76.795-230.4H64V192h128V64h-51.205v76.8zM320 448h51.2v-76.8H448V320H320v128zm51.2-307.2V64H320v128h128v-51.2h-76.8z'
Expand Down
17 changes: 12 additions & 5 deletions src/components/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ import remarkRaw from 'rehype-raw';
import rehype2react from 'rehype-react';
import { isValidElementType } from 'react-is';
import { root as mdRoot } from 'mdast-builder';
import styled from 'styled-components';
import { compose, layout, position } from 'styled-system';
import mdxComponentMap from '../../utils/mdx-component-mapper';
import indentNormalizer from '../../utils/indent-normalizer';
import Notes from '../notes';
import { ListItem } from '../../index';
import { Appear } from '../appear';

const Container = styled('div')(compose(position, layout));

export const Markdown = React.forwardRef(
(
{
Expand All @@ -30,7 +34,8 @@ export const Markdown = React.forwardRef(
},
children: rawMarkdownText,
animateListItems = false,
componentProps
componentProps,
...props
},
ref
) => {
Expand Down Expand Up @@ -151,10 +156,12 @@ export const Markdown = React.forwardRef(
const { children, ...restProps } = templateProps;

return (
<TemplateComponent ref={ref} {...restProps}>
{children}
{noteElements}
</TemplateComponent>
<Container ref={ref} {...props}>
<TemplateComponent {...restProps}>
{children}
{noteElements}
</TemplateComponent>
</Container>
);
}
);
Expand Down
10 changes: 6 additions & 4 deletions src/components/progress.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import propTypes from 'prop-types';
import styled from 'styled-components';
import { position } from 'styled-system';
import { DeckContext } from './deck/deck';

export const Circle = styled('div')`
Expand All @@ -16,23 +17,24 @@ export const Circle = styled('div')`
`;

const Container = styled('div')`
${position}
@media print {
display: none;
}
`;

const Progress = React.forwardRef((props, ref) => {
const Progress = React.forwardRef(({ size, color, ...props }, ref) => {
const { slideCount, skipTo, activeView } = React.useContext(DeckContext);
return (
<Container ref={ref} className="spectacle-progress-indicator">
<Container ref={ref} className="spectacle-progress-indicator" {...props}>
{Array(slideCount)
.fill(0)
.map((_, idx) => (
<Circle
key={`progress-circle-${idx}`}
color={props.color}
color={color}
active={activeView.slideIndex === idx}
size={props.size}
size={size}
onClick={() =>
skipTo({
slideIndex: idx,
Expand Down