Skip to content

Commit d220493

Browse files
authored
docs update (#406)
1 parent 6fbb0ee commit d220493

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ReactJS based Presentation Library
2222
- [Main file](#main-file)
2323
- [Themes](#themes)
2424
- [createTheme(colors, fonts)](#createthemecolors-fonts)
25+
- [FAQ](#faq)
2526
- [Tag API](#tag-api)
2627
- [Main Tags](#main-tags)
2728
- [Deck](#deck)
@@ -34,6 +35,8 @@ ReactJS based Presentation Library
3435
- [Fill](#fill)
3536
- [Markdown Tag](#markdown-tag)
3637
- [Markdown](#markdown)
38+
- [Magic Tag](#magic-tag)
39+
- [Magic](#magic)
3740
- [Element Tags](#element-tags)
3841
- [Appear](#appear)
3942
- [BlockQuote, Quote and Cite (Base)](#blockquote-quote-and-cite-base)
@@ -284,7 +287,7 @@ import createTheme from "spectacle/lib/themes/default";
284287

285288
Or create your own based upon the source.
286289

287-
`index.js` is what you would edit in order to create a custom theme of your own, using ReactJS style inline style objects.
290+
`index.js` is what you would edit in order to create a custom theme of your own, using object based styles.
288291

289292
You will want to edit `index.html` to include any web fonts or additional CSS that your theme requires.
290293

@@ -305,6 +308,43 @@ const theme = createTheme({
305308

306309
The returned theme object can then be passed to the `Deck` tag via the `theme` prop, and will override the default styles.
307310

311+
<a name="faq"></a>
312+
## FAQ
313+
314+
_How can I easily style the base components for my presentation?_
315+
316+
Historically, custom styling in Spectacle has meant screwing with a theme file, or using gross `!important` overrides. We fixed that. Spectacle is now driven by [emotion](github.com/emotion-js/emotion), so you can bring your own styling library, whether its emotion itself, or something like styled-components or glamorous. For example, if you want to create a custom Heading style:
317+
318+
```javascript
319+
import styled from 'styled-components';
320+
import { Heading } from 'spectacle';
321+
322+
const CustomHeading = styled(Heading)`
323+
font-size: 1.2em;
324+
color: papayawhip;
325+
`;
326+
```
327+
328+
_How can I separate my slides into other files?_
329+
330+
Until this release, you would have to do some array shenanigans, but now you can just wrap those slides with an element that has a special prop:
331+
332+
```javascript
333+
// mySlides.js
334+
export default class mySlides extends Component {
335+
render() {
336+
return (
337+
<div hasSlideChildren>
338+
<Slide>1</Slide>
339+
<Slide>2</Slide>
340+
<Slide>3</Slide>
341+
</div>
342+
)
343+
}
344+
}
345+
346+
```
347+
308348
<a name="tag-api"></a>
309349
## Tag API
310350

@@ -350,6 +390,11 @@ The slide tag represents each slide in the presentation. Giving a slide tag an `
350390
|transitionOut|PropTypes.array|Specifies the slide transition when the slide exits. Accepts the same values as transition.|
351391
|transitionDuration| PropTypes.number| Accepts integer value in milliseconds for slide transition duration.
352392

393+
<a name="wrapping-slides"></a>
394+
##### Wrapping Slides
395+
396+
If you author your slides in another file or want any kind of grouping that requires one additional level of nesting, you can add a `hasSlideChildren` prop to their parent element. This lets Spectacle identify that it is a wrapper, and will disregard the heirarchy instead opting to read the child slides as if the wrapper was not present.
397+
353398
<a name="transition-function"></a>
354399
##### Transition Function
355400
Spectacle now supports defining custom transitions. The function prototype is `(transitioning: boolean, forward: boolean) => Object`. The `transitioning` param is true when the slide enters and exits. The `forward` param is `true` when the slide is entering, `false` when the slide is exiting. The function returns a style object. You can mix string-based transitions and functions. Styles provided when `transitioning` is `false` will appear during the lifecyle of the slide. An example is shown below:
@@ -453,6 +498,29 @@ Markdown generated tags aren't prop configurable, and instead render with your t
453498
|---|---|---|
454499
|source|PropTypes.string| Markdown source |
455500

501+
<a name="magic-tag"></a>
502+
### Magic Tag
503+
504+
<a name="Magic"></a>
505+
#### Magic
506+
507+
> NOTE: The Magic tag uses the Web Animations API. If you use the Magic tag and want it to work places other than Chrome, you will need to include the polyfill [https://github.com/web-animations/web-animations-js](https://github.com/web-animations/web-animations-js)
508+
509+
The Magic Tag is a new experimental feature that attempts to recreate Magic Move behavior that slide authors might be accustomed to coming from Keynote. It wraps slides, and transitions between positional values for child elements. This means that if you have two similar strings, we will transition common characters to their new positions. This does not transition on non positional values such as slide background color or font size.
510+
511+
Using Magic is pretty simple, you just wrap your slides with it, and it transitions between them:
512+
513+
```javascript
514+
<Magic>
515+
<Slide><Heading>First Heading</Heading></Slide>
516+
<Slide><Heading>Second Heading</Heading></Slide>
517+
</Magic>
518+
```
519+
520+
Transitioning between similar states will vary based upon the input content. It will look better when there are more common elements. An upcoming patch will allow for custom keys, which will provide greater control over which elements are identified as common for reuse.
521+
522+
Until then, feedback is very welcome, as this is a non-trivial feature and we anticipate iterating on the behind the scenes mechanics of how it works, so that we can accommodate most use cases.
523+
456524
<a name="element-tags"></a>
457525
### Element Tags
458526

@@ -490,6 +558,8 @@ This tag displays a styled, highlighted code preview. I prefer putting my code s
490558
|lang|PropTypes.string| Prism compatible language name. i.e: 'javascript' |
491559
|source| PropTypes.string| String of code to be shown |
492560

561+
If you want to change the theme used here, you can include a prism theme in index.html via a script tag. CodePane and Playground both use the prism library under the hood, which has several themes that are available to include.
562+
493563
<a name="code-base"></a>
494564
#### Code (Base)
495565

@@ -622,7 +692,7 @@ Unordered lists:
622692
<a name="s-base"></a>
623693
#### S (Base)
624694
625-
The `S` tag is used to add inline styling to a piece of text, such as underline or strikethrough.
695+
The `S` tag is used to add styling to a piece of text, such as underline or strikethrough.
626696
627697
|Name|PropType|Description|
628698
|---|---|---|

0 commit comments

Comments
 (0)