Skip to content

Commit

Permalink
feat(examples): add web example to lorem-ipsum (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
n8chur committed May 31, 2019
1 parent 12797c8 commit eee18f8
Show file tree
Hide file tree
Showing 17 changed files with 391 additions and 3 deletions.
25 changes: 25 additions & 0 deletions examples/lorem-ipsum/examples/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/dist
/public/diez

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
43 changes: 43 additions & 0 deletions examples/lorem-ipsum/examples/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Lorem Ipsum

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

`webpack` overrides are courtesy of [`react-app-rewired`](https://github.com/timarney/react-app-rewired).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

### `yarn build`

Builds the app for production to the `build` folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
21 changes: 21 additions & 0 deletions examples/lorem-ipsum/examples/web/config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {join} = require('path');
const {DefinePlugin} = require('webpack');
const WriteFileWebpackPlugin = require('write-file-webpack-plugin');

module.exports = function override(config, env) {
config.plugins.push(
new CopyWebpackPlugin([{
from: join(__dirname, '..', '..', 'build', 'diez-lorem-ipsum-web', 'static'),
to: join(__dirname, 'public', 'diez'),
}]),
new DefinePlugin({
'process.env.DIEZ_SERVER_URL': JSON.stringify('/diez'),
}),
new WriteFileWebpackPlugin(),
);

config.output.futureEmitAssets = false;

return config;
}
35 changes: 35 additions & 0 deletions examples/lorem-ipsum/examples/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "lorem_ipsum",
"version": "10.0.0-alpha.0",
"private": true,
"dependencies": {
"diez-lorem-ipsum": "link:../../build/diez-lorem-ipsum-web",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.0"
},
"devDependencies": {
"react-app-rewired": "^2.1.3",
"write-file-webpack-plugin": "^4.5.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.
38 changes: 38 additions & 0 deletions examples/lorem-ipsum/examples/web/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions examples/lorem-ipsum/examples/web/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
108 changes: 108 additions & 0 deletions examples/lorem-ipsum/examples/web/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React from 'react';
import {DesignSystem} from 'diez-lorem-ipsum';
import styles from './App.module.css';

const Masthead = ({backgroundColor, backgroundImage}) => (
<div
className={styles.masthead}
style={{
backgroundColor: backgroundColor,
backgroundImage: backgroundImage,
}}
/>
);

const Icon = ({src, icon, marginLeft}) => (
<img
src={src}
alt="logo"
className={styles.icon}
style={{
marginLeft: marginLeft,
}}
/>
);

const Title = ({style, text}) => (
<h2 style={style}>
{text}
</h2>
);

const Caption = ({style, text}) => (
<h3 style={style}>
{text}
</h3>
);

class Animation extends React.Component {
componentDidMount () {
this.props.lottie.mount(this.refs.animation);
}

render () {
return (
<div
className={styles.animation}
ref="animation"
/>
);
}
}

export default class App extends React.PureComponent {
static defaultProps = {ds: new DesignSystem()};

render () {
const {ds} = this.props;

return (
<div className={styles.wrapper}>
<Masthead
backgroundColor={ds.colors.darkBackground.toString()}
backgroundImage={`url(${ds.images.masthead.url})`}
/>
<div
className={styles.contentContainer}
style={{
backgroundColor: ds.colors.lightBackground.toString(),
}}
>
<div className={styles.content}>
<Icon
src={ds.images.logo.url}
marginLeft={ds.layoutValues.contentMargin.left}
/>
<div
className={styles.innerContent}
style={{
paddingTop: ds.layoutValues.contentMargin.top,
paddingRight: ds.layoutValues.contentMargin.right,
paddingBottom: ds.layoutValues.contentMargin.bottom,
paddingLeft: ds.layoutValues.contentMargin.left,
}}
>
<Title
style={{
...ds.typographs.heading1.css,
marginBottom: ds.layoutValues.spacingSmall
}}
text={ds.strings.title}
/>
<Caption
style={{
...ds.typographs.caption.css,
marginBottom: ds.layoutValues.spacingSmall
}}
text={ds.strings.caption}
/>
<div className={styles.animationContainer}>
<Animation lottie={ds.loadingAnimation}/>
</div>
</div>
</div>
</div>
</div>
);
}
}
48 changes: 48 additions & 0 deletions examples/lorem-ipsum/examples/web/src/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.wrapper {
display: flex;
flex-direction: column;
height: 100vh;
}

.masthead {
height: 194px;
}

.contentContainer {
flex-grow: 1;
flex-direction: column;
display: flex;
align-items: center;
}

.content {
width: 684px;
max-width: 100%;
flex-grow: 1;
flex-direction: column;
display: flex;
}

.innerContent {
flex-direction: column;
display: flex;
flex-grow: 1;
}

.icon {
transform: translate(0, -50%);
position: absolute;
}

.animationContainer {
height: 100%;
flex-grow: 1;
display: flex;
align-items: center;
justify-content: center;
}

.animation {
width: 174px;
height: 165px;
}
19 changes: 19 additions & 0 deletions examples/lorem-ipsum/examples/web/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

h1, h2, h3, h4, h5 {
margin: 0;
font-weight: normal;
}
6 changes: 6 additions & 0 deletions examples/lorem-ipsum/examples/web/src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));
3 changes: 2 additions & 1 deletion examples/lorem-ipsum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"build-android": "diez compile -t android",
"build-ios": "diez compile -t ios --cocoapods"
"build-ios": "diez compile -t ios --cocoapods",
"build-web": "diez compile -t web"
}
}
1 change: 1 addition & 0 deletions examples/poodle-surf/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down

0 comments on commit eee18f8

Please sign in to comment.