Skip to content

Commit 9e75539

Browse files
committed
Printer mode
1 parent 520eeab commit 9e75539

File tree

8 files changed

+188
-12
lines changed

8 files changed

+188
-12
lines changed

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Exporting a totally sweet looking PDF from your totally sweet looking Spectacle
2727

2828
![http://i.imgur.com/t6GL5Oc.png](http://i.imgur.com/t6GL5Oc.png)
2929

30+
If you want to print your slides, and want a printer friendly version, simply repeat the above process but instead print from [http://localhost:3000/#/?export&print](http://localhost:3000/#/?export&print)
31+
3032
## Basic Concepts
3133

3234
### Main file

index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Presentation.contextTypes = {
2828
router: React.PropTypes.object
2929
}
3030

31-
Presentation = Context(Presentation, {styles: config.theme, flux: flux});
31+
Presentation = Context(Presentation, {styles: config.theme, print: config.print, flux: flux});
3232

3333
React.render(
3434
<Router history={new HashHistory}>

presentation/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ module.exports = {
22
width: 1000,
33
margin: 40,
44
theme: require('../themes/default/index'),
5+
print: require('../themes/default/print'),
56
html: require('../themes/default/html')
67
}

presentation/deck.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class extends React.Component {
3030
<Heading size={2} fit caps textColor="black">
3131
Where You Can Write Your Decks In JSX
3232
</Heading>
33-
<Link href="https://github.com/FormidableLabs/spectacle"><Text bold caps textColor="white">View on Github</Text></Link>
33+
<Link href="https://github.com/FormidableLabs/spectacle"><Text bold caps textColor="tertiary">View on Github</Text></Link>
3434
<Text textSize="1.5em" margin="20px 0px 0px" bold>Hit Your Right Arrow To Begin!</Text>
3535
</Slide>
3636
<Slide transition={['slide']} bgColor="black">
@@ -67,12 +67,12 @@ export default class extends React.Component {
6767
<Heading caps fit>Flexible Layouts</Heading>
6868
<Layout>
6969
<Fill>
70-
<Heading size={4} caps textColor="black" bgColor="white" margin={10}>
70+
<Heading size={4} caps textColor="secondary" bgColor="white" margin={10}>
7171
Left
7272
</Heading>
7373
</Fill>
7474
<Fill>
75-
<Heading size={4} caps textColor="black" bgColor="white" margin={10}>
75+
<Heading size={4} caps textColor="secondary" bgColor="white" margin={10}>
7676
Right
7777
</Heading>
7878
</Fill>
@@ -85,14 +85,14 @@ export default class extends React.Component {
8585
</BlockQuote>
8686
</Slide>
8787
<Slide transition={['slide', 'spin']} bgColor="primary">
88-
<Heading caps fit size={1} textColor="white">
88+
<Heading caps fit size={1} textColor="tertiary">
8989
Smooth
9090
</Heading>
91-
<Heading caps fit size={1} textColor="black">
91+
<Heading caps fit size={1} textColor="secondary">
9292
Combinable Transitions
9393
</Heading>
9494
</Slide>
95-
<Slide transition={['fade']} bgColor="black" textColor="primary" align="center middle">
95+
<Slide transition={['fade']} bgColor="secondary" textColor="primary" align="center middle">
9696
<List>
9797
<ListItem><Appear>Inline style based theme system</Appear></ListItem>
9898
<ListItem><Appear>Autofit text</Appear></ListItem>
@@ -103,12 +103,12 @@ export default class extends React.Component {
103103
</List>
104104
</Slide>
105105
<Slide transition={['slide']} bgColor="primary">
106-
<Heading size={1} caps fit textColor="white">
106+
<Heading size={1} caps fit textColor="tertiary">
107107
Your presentations are interactive
108108
</Heading>
109109
<Interactive/>
110110
</Slide>
111-
<Slide transition={['spin','slide']} bgColor="white">
111+
<Slide transition={['spin','slide']} bgColor="tertiary">
112112
<Heading size={1} caps fit textColor="primary">
113113
Made with love in Seattle by
114114
</Heading>

src/slide.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ const Slide = React.createClass({
3333
},
3434
render() {
3535
let exportMode = false;
36+
let printMode = false;
3637
if (this.context.router.state.location.query &&
3738
'export' in this.context.router.state.location.query) {
3839
exportMode = true;
40+
if ('print' in this.context.router.state.location.query) {
41+
printMode = true;
42+
}
3943
}
44+
let printStyles = printMode ? {
45+
backgroundColor: 'white',
46+
backgroundImage: 'none'
47+
} : {};
4048
let styles = {
4149
outer: {
4250
position: exportMode ? 'relative' : 'absolute',
@@ -60,7 +68,7 @@ const Slide = React.createClass({
6068
};
6169
return (
6270
<div className="spectacle-slide"
63-
style={[styles.outer, this.getStyles(), this.getTransitionStyles()]}>
71+
style={[styles.outer, this.getStyles(), this.getTransitionStyles(), printStyles]}>
6472
<div style={[styles.inner]}>
6573
<div ref="content"
6674
style={[styles.content, this.context.styles.components.content]}>

src/utils/context.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ function context(Component, params) {
1010
},
1111

1212
getChildContext() {
13-
return params;
13+
let styles = {};
14+
if (this.props.location.query && 'print' in this.props.location.query) {
15+
styles = params.print;
16+
} else {
17+
styles = params.styles;
18+
}
19+
return {
20+
styles: styles,
21+
flux: params.flux
22+
};
1423
},
1524

1625
render: function render() {

themes/default/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
display: 'inline-block'
3131
},
3232
quote: {
33-
borderLeft: '1px solid #f9c300',
33+
borderLeft: '1px solid ' + colors.primary,
3434
paddingLeft: 40,
3535
display: 'block',
3636
color: colors.primary,

themes/default/print.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
var colors = {
2+
primary: 'black',
3+
secondary: 'black',
4+
tertiary: 'black'
5+
};
6+
7+
var fonts = {
8+
primary: 'Open Sans Condensed',
9+
secondary: 'Lobster Two',
10+
tertiary: 'monospace'
11+
}
12+
13+
module.exports = {
14+
colors: colors,
15+
fonts: fonts,
16+
global: {
17+
body: {
18+
background: 'white',
19+
fontFamily: fonts.primary,
20+
fontWeight: 'normal',
21+
fontSize: '2em',
22+
color: 'black',
23+
overflow: 'hidden'
24+
},
25+
'.hljs': {
26+
background: 'white',
27+
color: 'black'
28+
},
29+
'.hljs span': {
30+
color: 'black !important'
31+
}
32+
},
33+
components: {
34+
blockquote: {
35+
textAlign: 'left',
36+
position: 'relative',
37+
display: 'inline-block'
38+
},
39+
quote: {
40+
borderLeft: '1px solid ' + colors.primary,
41+
paddingLeft: 40,
42+
display: 'block',
43+
color: 'black',
44+
fontSize: '4.9em',
45+
lineHeight: 1,
46+
fontWeight: 'bold',
47+
},
48+
cite: {
49+
color: 'black',
50+
display: 'block',
51+
clear: 'left',
52+
fontSize: '2em',
53+
marginTop: '1em'
54+
},
55+
content: {
56+
margin: 'auto'
57+
},
58+
codePane: {
59+
pre: {
60+
maxWidth: 800,
61+
margin: 'auto',
62+
fontSize: '1.5em',
63+
fontWeight: 'normal',
64+
fontFamily: fonts.tertiary
65+
},
66+
code: {
67+
textAlign: 'left',
68+
padding: 20,
69+
fontWeight: 'normal'
70+
}
71+
},
72+
code: {
73+
color: 'black',
74+
fontSize: '2.66em',
75+
fontFamily: fonts.tertiary,
76+
margin: '0.25em auto',
77+
backgroundColor: 'rgba(0,0,0,0.15)',
78+
padding: "0 10px",
79+
borderRadius: 3
80+
},
81+
heading: {
82+
h1: {
83+
color: 'black',
84+
fontSize: '7.05em',
85+
fontFamily: fonts.primary,
86+
lineHeight: 1,
87+
fontWeight: 'bold',
88+
margin: 0
89+
},
90+
h2: {
91+
color: 'black',
92+
fontSize: '5.88em',
93+
fontFamily: fonts.primary,
94+
lineHeight: 1,
95+
fontWeight: 'bold',
96+
margin: 0
97+
},
98+
h3: {
99+
color: 'black',
100+
fontSize: '4.9em',
101+
fontFamily: fonts.secondary,
102+
lineHeight: 1,
103+
fontWeight: 'bold',
104+
margin: '0.5em auto'
105+
},
106+
h4: {
107+
color: 'black',
108+
fontSize: '3.82em',
109+
fontFamily: fonts.primary,
110+
lineHeight: 1,
111+
fontWeight: 'bold',
112+
margin: '0.5em auto'
113+
},
114+
h5: {
115+
color: 'black',
116+
fontSize: '3.19em',
117+
fontFamily: fonts.primary,
118+
lineHeight: 1,
119+
fontWeight: 'bold',
120+
margin: '0.5em auto'
121+
},
122+
h6: {
123+
color: 'black',
124+
fontSize: '2.66em',
125+
fontFamily: fonts.primary,
126+
lineHeight: 1,
127+
fontWeight: 'bold',
128+
margin: '0.5em auto'
129+
}
130+
},
131+
image: {
132+
display: 'block',
133+
margin: '0.5em auto'
134+
},
135+
link: {
136+
textDecoration: 'none'
137+
},
138+
listItem: {
139+
fontSize: '2.66em'
140+
},
141+
list: {
142+
textAlign: 'left',
143+
listStylePosition: 'inside',
144+
padding: 0
145+
},
146+
s: {
147+
strikethrough: {}
148+
},
149+
text: {
150+
color: 'black',
151+
fontSize: '2.66em',
152+
fontFamily: fonts.primary,
153+
margin: '0.25em auto'
154+
}
155+
}
156+
}

0 commit comments

Comments
 (0)