Skip to content

Commit

Permalink
docs(examples): Generate HTML example with relative npm script
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasonny83 committed Sep 6, 2019
1 parent 4b4f023 commit 7a40bb4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
39 changes: 39 additions & 0 deletions example-html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>react-avataaars</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
<script src="../lib/react-avataaars.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const hash = 'type-anything-here';
const options: Options = {
accessories: 'wayfarers',
accessoriesChance: 100,
clothesColor: 'heather',
eyes: 'happy',
hairColor: 'blonde',
mouth: 'twinkle',
style: 'circle',
top: 'hat',
topChance: 100,
};

ReactDOM.render(
<div>
<h1>React Avataaars without npm 🎉</h1>
<ReactAvataaars.Avatar style={{width: 300}} className="Avatar" options={options} hash={hash} size="200" />
</div>,
document.getElementById('root'),
);
</script>
</body>
</html>
15 changes: 15 additions & 0 deletions example-html/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
html, body {
margin: 0;
padding: 0;
font-family: 'Roboto', Arial, sans-serif;
}

#root {
margin: 0 auto;
max-width: 600px;
text-align: center;
}

svg {
width: auto!important;
}
2 changes: 1 addition & 1 deletion example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Avatar, Options } from '../src/index';
import { Avatar, Options } from '../';
import './App.css';

export default class App extends React.Component {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"scripts": {
"build": "rimraf lib && webpack",
"postbuild": "es-check es5 lib/react-avataaars.js",
"preexample": "npm run build",
"example": "webpack-dev-server --config ./webpack.example.config.js --open",
"preexample-html": "npm run build",
"example-html": "open example-html/index.html",
Expand Down

0 comments on commit 7a40bb4

Please sign in to comment.