Skip to content

Commit 4615e93

Browse files
authored
Merge pull request #159 from FormidableLabs/fix/template-strings-docs
Fix issue with template strings, update docs and site
2 parents bdee2c2 + d0fd7ad commit 4615e93

File tree

18 files changed

+1870
-1625
lines changed

18 files changed

+1870
-1625
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
node_modules
2+
demo/out
23
lib
34
npm-debug.log.*
45
dist
56
.DS_Store
67
bundle-stats.html
78
.next
89
.out
9-
.history/
10+
.history/

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<p align="center"><img src="https://raw.githubusercontent.com/philpl/react-live/master/docs/logo.gif" width=250></p>
1+
<p align="center"><img src="https://user-images.githubusercontent.com/17658189/63178611-4e90d580-c042-11e9-875f-f2455148b9ae.png" width=250></p>
22
<h2 align="center">React Live</h2>
33
<p align="center">
4-
<strong>A production-focused playground for live editing React code</strong>
4+
<strong>A flexible playground for live editing React code</strong>
55
<br><br>
66
<a href="https://npmjs.com/package/react-live"><img src="https://img.shields.io/npm/dm/react-live.svg"></a>
77
<a href="https://npmjs.com/package/react-live"><img src="https://img.shields.io/npm/v/react-live.svg"></a>
@@ -18,6 +18,9 @@ It supports server-side rendering and comes in a tiny bundle.
1818

1919
The library is structured modularly and lets you style and compose its components freely.
2020

21+
22+
<p align="center"><img src="https://user-images.githubusercontent.com/17658189/63181897-1d67d380-c049-11e9-9dd2-7da2a3a57f05.gif" width=500></p>
23+
2124
## Usage
2225

2326
Install it with `npm install react-live` or `yarn add react-live` and try out this piece of JSX:
@@ -151,7 +154,7 @@ It supports these props, while passing any others through to the `children`:
151154
|---|---|---|
152155
|code|PropTypes.string|The code that should be rendered, apart from the user’s edits
153156
|scope|PropTypes.object|Accepts custom globals that the `code` can use
154-
|noInline|PropTypes.bool|Doesn’t evaluate and mount the inline code (Default: `false`)
157+
|noInline|PropTypes.bool|Doesn’t evaluate and mount the inline code (Default: `false`). Note: when using `noInline` whatever code you write must be a single expression (function, class component or some `jsx`) that can be returned immediately. If you'd like to render multiple components, use `noInline={true}`
155158
|transformCode|PropTypes.func|Accepts and returns the code to be transpiled, affording an opportunity to first transform it
156159
|language|PropTypes.string|What language you're writing for correct syntax highlighting. (Default: `jsx`)
157160
|disabled|PropTypes.bool|Disable editing on the `<LiveEditor />` (Default: `false`)

demo/components/Header.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
import React from 'react';
22
import styled from 'styled-components';
33
import * as polished from 'polished';
4-
5-
import { foreground, blue } from '../utils/colors';
6-
7-
const Image = styled.div`
8-
background-image: url(https://raw.githubusercontent.com/philpl/react-live/master/docs/logo.gif);
9-
background-size: cover;
10-
background-position: center;
11-
12-
width: ${polished.rem(160)};
13-
height: ${polished.rem(160)};
14-
border-radius: ${polished.rem(3)};
15-
`;
4+
import { ProjectBadge } from 'formidable-oss-badges';
5+
import { background, blue } from '../utils/colors';
166

177
const SubTitle = styled.h2`
188
font-size: ${polished.modularScale(1)};
19-
font-weight: bold;
9+
font-weight: normal;
2010
color: ${blue};
2111
margin: 0;
22-
margin-left: ${polished.rem(30)};
12+
margin-left: ${polished.rem(20)};
2313
letter-spacing: ${polished.rem(0.3)};
2414
line-height: 1.5;
2515
@@ -29,12 +19,16 @@ const SubTitle = styled.h2`
2919
}
3020
`;
3121

22+
const StyledProjectBadge = styled(ProjectBadge)`
23+
height: 230px;
24+
`;
25+
3226
const Title = styled.h1`
3327
font-weight: normal;
3428
font-size: ${polished.modularScale(4)};
3529
line-height: 1.1;
3630
margin: 0;
37-
margin-left: ${polished.rem(25)};
31+
margin-left: ${polished.rem(20)};
3832
3933
@media (max-width: 600px) {
4034
margin-left: 0;
@@ -58,14 +52,14 @@ const TitleRow = styled.div`
5852
`;
5953

6054
const Description = styled.div`
61-
margin: ${polished.rem(80)};
55+
margin: ${polished.rem(50)};
6256
text-align: center;
6357
font-size: ${polished.modularScale(1)};
6458
color: ${blue};
6559
line-height: 1.5;
6660
6761
@media (max-width: 600px) {
68-
margin: ${polished.rem(80)} 0;
62+
margin: ${polished.rem(50)} 0;
6963
}
7064
`;
7165

@@ -76,7 +70,7 @@ const Button = styled.a`
7670
text-decoration: none;
7771
border-radius: ${polished.rem(3)};
7872
background: ${blue};
79-
color: ${foreground};
73+
color: ${background};
8074
margin: ${polished.rem(30)} 0;
8175
`;
8276

@@ -88,13 +82,15 @@ const Container = styled.div`
8882
const Header = () => (
8983
<Container>
9084
<TitleRow>
91-
<Image />
85+
<StyledProjectBadge
86+
color="#f677e1"
87+
abbreviation="Rl"
88+
description="React Live"
89+
/>
9290

9391
<div>
9492
<Title>React Live</Title>
95-
<SubTitle>
96-
A production-focused playground for live editing React code 📡
97-
</SubTitle>
93+
<SubTitle>A flexible playground for live editing React code</SubTitle>
9894
</div>
9995
</TitleRow>
10096

demo/components/LiveEdit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import styled, { css } from 'styled-components';
33
import * as polished from 'polished';
44
import { foreground, red, lightGrey } from '../utils/colors';
5+
import { reactLiveHome } from '../utils/theme';
56
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
67

78
const StyledProvider = styled(LiveProvider)`
@@ -73,7 +74,7 @@ const StyledError = styled(LiveError)`
7374
`;
7475

7576
const LiveEdit = ({ noInline, code }) => (
76-
<StyledProvider code={code} noInline={noInline}>
77+
<StyledProvider code={code} noInline={noInline} theme={reactLiveHome}>
7778
<LiveWrapper>
7879
<StyledEditor>
7980
<LiveEditor />

demo/next.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ module.exports = {
99
};
1010

1111
return config;
12-
}
12+
},
13+
exportPathMap: () => ({
14+
'/': { page: '/' }
15+
})
1316
};

demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"license": "MIT",
66
"scripts": {
77
"dev": "node server.js",
8-
"build": "next build",
8+
"build": "next build && next export",
99
"start": "NODE_ENV=production node server.js"
1010
},
1111
"dependencies": {
1212
"babel-plugin-polished": "^1.0.3",
1313
"babel-plugin-styled-components": "^1.5.0",
1414
"express": "^4.15.2",
15+
"formidable-oss-badges": "^0.2.1",
1516
"lru-cache": "^4.0.2",
1617
"module-alias": "^2.0.0",
1718
"next": "^5.0.0",

demo/pages/_document.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Document, { Head, Main, NextScript } from 'next/document';
22
import { ServerStyleSheet } from 'styled-components';
3+
import { background } from '../utils/colors';
34

45
const resetStyles = `
56
*,::after,::before{background-repeat:no-repeat;box-sizing:inherit}::after,::before{text-decoration:inherit;vertical-align:inherit}html{box-sizing:border-box;cursor:default;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}article,aside,footer,header,nav,section{display:block}body{margin:0}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}nav ol,nav ul{list-style:none}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}::-moz-selection{background-color:#b3d4fc;color:#000;text-shadow:none}::selection{background-color:#b3d4fc;color:#000;text-shadow:none}audio,canvas,iframe,img,svg,video{vertical-align:middle}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg{fill:currentColor}svg:not(:root){overflow:hidden}table{border-collapse:collapse}button,input,optgroup,select,textarea{margin:0}button,input,select,textarea{background-color:transparent;color:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto;resize:vertical}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template{display:none}[tabindex],a,area,button,input,label,select,summary,textarea{-ms-touch-action:manipulation;touch-action:manipulation}[hidden]{display:none}[aria-busy=true]{cursor:progress}[aria-controls]{cursor:pointer}[aria-hidden=false][hidden]:not(:focus){clip:rect(0,0,0,0);display:inherit;position:absolute}[aria-disabled]{cursor:default}
@@ -38,7 +39,7 @@ const mainStyles = `
3839
font-style: normal;
3940
padding: 0;
4041
margin: 0;
41-
background: #282a36;
42+
background: ${background};
4243
color: #f8f8f2;
4344
}
4445

demo/pages/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22
import styled from 'styled-components';
33
import * as polished from 'polished';
4+
import { foreground } from '../utils/colors';
45

56
import Header from '../components/Header';
67
import LiveEdit from '../components/LiveEdit';
@@ -15,8 +16,9 @@ const Container = styled.div`
1516
`;
1617

1718
const Description = styled.p`
18-
color: white;
19-
margin-bottom: ${polished.rem(10)};
19+
color: ${foreground};
20+
font-size: ${polished.modularScale(1)};
21+
margin-bottom: ${polished.rem(20)};
2022
margin-top: ${polished.rem(50)};
2123
`;
2224

demo/server.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

demo/utils/colors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as polished from 'polished';
22

3-
export const background = '#282a36';
3+
export const background = '#42374a';
44
export const foreground = '#f8f8f2';
55
export const red = '#ff5555';
66

7-
export const blue = polished.lighten(0.1, '#6272a4');
8-
export const lightGrey = polished.darken(0.05, '#282a36');
7+
export const blue = polished.lighten(0.1, '#d1b0dd');
8+
export const lightGrey = polished.darken(0.06, '#42374a');

0 commit comments

Comments
 (0)