Skip to content

Commit de73e03

Browse files
authored
feat: Add production URL to Demo component (#1)
1 parent d755a42 commit de73e03

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"scripts": {
2525
"build": "babel --delete-dir-on-start --ignore '**/*.spec.js' --env-name cjs -d dist/ src/",
2626
"prepare": "npm run build",
27-
"test": "echo \"Error: no test specified\" && exit 1",
27+
"test": "true",
2828
"posttest": "npm run format",
2929
"slides:start": "mdx-deck ./examples/example.mdx",
3030
"slides:build": "mdx-deck build ./examples/example.mdx",

src/components/Demo.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* @jsx jsx */
22
import * as React from "react";
3+
import PropTypes from "prop-types";
34
import { jsx, Box } from "theme-ui";
45

5-
export default ({ src }) => {
6+
function Demo({ src, prodSrc }) {
67
return (
78
<Box sx={{ position: "relative" }}>
89
<Box
@@ -20,9 +21,16 @@ export default ({ src }) => {
2021
}}
2122
/>
2223
<iframe
23-
src={src}
24+
src={prodSrc && process.env.NODE_ENV === "production" ? prodSrc : src}
2425
style={{ border: "none", width: "100vw", height: "100vh" }}
2526
/>
2627
</Box>
2728
);
29+
}
30+
31+
Demo.propTypes = {
32+
src: PropTypes.string.isRequired,
33+
prodSrc: PropTypes.string,
2834
};
35+
36+
export default Demo;

0 commit comments

Comments
 (0)