Skip to content

Commit 4fbe1b3

Browse files
authored
Merge pull request #4 from component-driven/feat-slide-bh
Support background image for Primary and Secondary slides
2 parents e066c9a + 3644f45 commit 4fbe1b3

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

examples/example.mdx

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ export const theme = { ...myTheme };
88

99
</Footer>
1010

11-
<Cover
12-
title="Deck Name"
13-
author="Andrey Okonetchnikov"
14-
/>
11+
<Cover title="Deck Name" author="Andrey Okonetchnikov" />
1512

1613
---
1714

18-
<Primary>
15+
<Primary imgSrc="//source.unsplash.com/-K6JMRMj4x4/2560x1920" sx={{ backgroundBlendMode: "multiply" }}>
1916

2017
# Primary slide
2118

2219
</Primary>
2320

2421
---
2522

26-
<Secondary>
23+
<Secondary imgSrc={require("./assets/colorsnapper.png")}>
2724

2825
## Secondary slide
2926

@@ -72,22 +69,21 @@ This is paragraph with `inline` code
7269

7370
```jsx
7471
function Code({ children, language, inline = false }) {
75-
if (typeof children !== "string") {
76-
return (
77-
<pre style={{ color: "firebrick" }}>
78-
Code: `children` must be a string
79-
</pre>
80-
);
81-
}
82-
return (
83-
<Prism {...codeTheme} useInlineStyles language={language}>
84-
{children.replace(/\t/, " ")}
85-
</Prism>
86-
);
72+
if (typeof children !== "string") {
73+
return (
74+
<pre style={{ color: "firebrick" }}>
75+
Code: `children` must be a string
76+
</pre>
77+
);
78+
}
79+
return (
80+
<Prism {...codeTheme} useInlineStyles language={language}>
81+
{children.replace(/\t/, " ")}
82+
</Prism>
83+
);
8784
}
8885
```
8986

90-
9187
</SplitTitle>
9288
<ThatGuy />
9389

@@ -109,11 +105,11 @@ function Code({ children, language, inline = false }) {
109105

110106
---
111107

112-
<Code language="jsx">{require('raw-loader!./assets/codeExample.txt')}</Code>
108+
<Code language="jsx">{require("raw-loader!./assets/codeExample.txt")}</Code>
113109

114110
---
115111

116-
<LiveCode code={require('raw-loader!./assets/codeExample.txt')} />
112+
<LiveCode code={require("raw-loader!./assets/codeExample.txt")} />
117113

118114
---
119115

@@ -122,9 +118,9 @@ function Code({ children, language, inline = false }) {
122118
---
123119

124120
<Figure
125-
src={require('./assets/component-driven.svg')}
126-
alt="Component-driven Logo"
127-
caption={
128-
<a href="https://component-driven.io">https://component-driven.io</a>
129-
}
121+
src={require("./assets/component-driven.svg")}
122+
alt="Component-driven Logo"
123+
caption={
124+
<a href="https://component-driven.io">https://component-driven.io</a>
125+
}
130126
/>

src/layouts/Primary.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
import React from 'react';
2-
import { Invert } from 'mdx-deck';
1+
import React from "react";
2+
import {Invert} from "mdx-deck";
33

4-
export default props => <Invert bg="primary" {...props} />;
4+
export default ({ children, imgSrc, sx, ...props }) => (
5+
<Invert
6+
sx={{
7+
backgroundColor: "primary",
8+
backgroundSize: "cover",
9+
backgroundImage: `url(${imgSrc})`,
10+
backgroundPosition: "center",
11+
backgroundBlendMode: "multiply",
12+
...sx,
13+
}}
14+
{...props}
15+
>
16+
{children}
17+
</Invert>
18+
);

src/layouts/Secondary.jsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import React from "react";
2-
import { Color } from "mdx-deck";
2+
import {Invert} from "mdx-deck";
33

4-
export default (props) => (
5-
<Color bg="secondary" color="background" {...props} />
6-
);
4+
export default ({children, imgSrc, sx,...props}) => <Invert sx={{
5+
backgroundColor: "secondary",
6+
backgroundSize: "cover",
7+
backgroundImage: `url(${imgSrc})`,
8+
backgroundPosition: "center",
9+
backgroundBlendMode: "multiply",
10+
...sx,
11+
}} {...props}>
12+
{children}
13+
</Invert>;

0 commit comments

Comments
 (0)