Add open in Codepen
This commit is contained in:
BIN
docs/464d45b6c0aa745a9d68e563688b3354.png
Normal file
BIN
docs/464d45b6c0aa745a9d68e563688b3354.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
docs/6a92da93c8b31945626bd085895f2309.png
Normal file
BIN
docs/6a92da93c8b31945626bd085895f2309.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
9
docs/a4a44c59f0a5b432531e0c4e83a00cf4.css
Normal file
9
docs/a4a44c59f0a5b432531e0c4e83a00cf4.css
Normal file
File diff suppressed because one or more lines are too long
30
docs/a4a44c59f0a5b432531e0c4e83a00cf4.js
Normal file
30
docs/a4a44c59f0a5b432531e0c4e83a00cf4.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
72
src/css/components/buttons.scss
Normal file
72
src/css/components/buttons.scss
Normal file
@ -0,0 +1,72 @@
|
||||
.btn {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
font-weight: bold;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
color: #8385aa;
|
||||
white-space: nowrap;
|
||||
border: 1px solid #c8cbf2;
|
||||
border-radius: 2px;
|
||||
vertical-align: middle;
|
||||
line-height: 2;
|
||||
padding: 0 0.5rem;
|
||||
margin-right: 0.5rem;
|
||||
transition: all 0.1s ease-out;
|
||||
outline: 0;
|
||||
|
||||
&.is-large {
|
||||
font-size: 0.95rem;
|
||||
border-radius: 0.2rem;
|
||||
|
||||
.feather {
|
||||
top: -2px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.feather {
|
||||
vertical-align: middle;
|
||||
margin-right: 0.25rem;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
button.btn {
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
margin-bottom: 1rem;
|
||||
margin-right: 1rem;
|
||||
background: white;
|
||||
|
||||
&:hover {
|
||||
background: #8385aa;
|
||||
border-color: #8385aa;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.focus-visible:focus {
|
||||
box-shadow: 0 0 0 0.25rem transparentize(#8385aa, 0.5);
|
||||
}
|
||||
|
||||
&:active {
|
||||
box-shadow: inset 0 0.1rem 0.1rem 0.1rem rgba(0, 0, 0, 0.2);
|
||||
background: darken(#8385aa, 10);
|
||||
border-color: darken(#8385aa, 10);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: #7983ff;
|
||||
border-color: #7983ff;
|
||||
color: white;
|
||||
|
||||
&.focus-visible:focus {
|
||||
box-shadow: 0 0 0 0.25rem transparentize(#7983ff, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,3 +5,4 @@
|
||||
@import './components/snippet.scss';
|
||||
@import './components/back-to-top-button.scss';
|
||||
@import './components/tags.scss';
|
||||
@import './components/buttons.scss';
|
||||
|
||||
25
src/js/components/CodepenCopy.js
Normal file
25
src/js/components/CodepenCopy.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { selectAll } from '../deps/utils'
|
||||
|
||||
const snippets = selectAll('.snippet')
|
||||
snippets.forEach(snippet => {
|
||||
var codepenForm = document.createElement('form');
|
||||
codepenForm.action = 'https://codepen.io/pen/define';
|
||||
codepenForm.method = 'POST';
|
||||
codepenForm.target = '_blank';
|
||||
var codepenInput = document.createElement('input');
|
||||
codepenInput.type = 'hidden';
|
||||
codepenInput.name = 'data';
|
||||
var codepenButton = document.createElement('button');
|
||||
codepenButton.classList = 'btn is-large codepen-btn';
|
||||
codepenButton.innerHTML = 'View on Codepen';
|
||||
var css = snippet.querySelector('pre code.lang-css');
|
||||
var html = snippet.querySelector('pre code.lang-html');
|
||||
var js = snippet.querySelector('pre code.lang-js');
|
||||
css = css ? css.textContent : '';
|
||||
html = html ? html.textContent : '';
|
||||
js = js ? js.textContent : '';
|
||||
codepenInput.value = '{"title":"'+snippet.querySelector('h3 > span').textContent+'", "html":"'+html+'" , "css":"'+css+'" , "js":"'+js+'" }';
|
||||
codepenForm.appendChild(codepenInput);
|
||||
codepenForm.appendChild(codepenButton);
|
||||
snippet.appendChild(codepenForm);
|
||||
});
|
||||
@ -17,3 +17,4 @@ import Sidebar from './components/Sidebar'
|
||||
import BackToTopButton from './components/BackToTopButton'
|
||||
import Tag from './components/Tag'
|
||||
import Snippet from './components/Snippet'
|
||||
import CodepenCopy from './components/CodepenCopy'
|
||||
|
||||
Reference in New Issue
Block a user