Skip to content

Commit

Permalink
Add copy to clipboard buttons for usage. Closes #305.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed Dec 16, 2016
1 parent 2be47f1 commit 0f700f1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,9 @@
"toml-loader": "^1.0.0",
"webpack": "^1.12.1",
"whatwg-fetch": "^0.11.0"
},
"dependencies": {
"react-clipboard-icon": "^0.2.1",
"react-clipboard.js": "^1.0.1"
}
}
38 changes: 36 additions & 2 deletions docs/web_modules/layouts/Usage/index.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,54 @@
.install {
display: block;
display: flex;
border: 1px solid #adebc2;
transition: 0.1s ease;
transition-property: border;
background: #fbfefc;

&:hover {
border-color: #40b97b;
}
}

.install a {
flex: 1;
font-size: 1em;
text-decoration: none;
padding: 10px;
color: #303030;
font-family: Menlo, Monaco, Consolas, monospace;
transition: 0.1s ease;
transition-property: border-right, background;
border-right: 1px solid #fbfefc;

&:before {
content: '$ ';
}

&:hover {
border-color: #40b97b;
background: #d6f5e0;
border-right: 1px solid #40b97b;
}
}

.install button {
border: none;
border-left: 1px solid #fbfefc;
flex: 0 100px;
cursor: pointer;
background: #fbfefc;
padding: 10px;
font-size: 1em;
font-variant: small-caps;
transition: 0.1s ease;
transition-property: border-left, background;

& svg {
vertical-align: middle;
}

&:hover {
background: #d6f5e0;
border-left: 1px solid #40b97b;
}
}
14 changes: 8 additions & 6 deletions docs/web_modules/layouts/Usage/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, {Component, PropTypes} from "react";
import Lowlight from 'react-lowlight';
import ClipboardButton from 'react-clipboard.js';
import ClipboardIcon from 'react-clipboard-icon';
import js from 'highlight.js/lib/languages/javascript';
import DangerousMarkdown from '../../DangerousMarkdown';
import BasicPage from "../BasicPage";
Expand Down Expand Up @@ -35,12 +37,12 @@ export default class Optimisations extends Component {
<DangerousMarkdown>
{wrapper.example}
</DangerousMarkdown>
<a
className={styles.install}
href={wrapper.source}
>
{wrapper.install}
</a>
<div className={styles.install}>
<a href={wrapper.source}>{wrapper.install}</a>
<ClipboardButton data-clipboard-text={wrapper.install}>
<ClipboardIcon /> Copy
</ClipboardButton>
</div>
{alternate}
</div>
);
Expand Down

0 comments on commit 0f700f1

Please sign in to comment.