Add show code

This commit is contained in:
Jeremy Thomas 2017-10-09 12:27:08 +01:00
parent 4f5cc9c0ed
commit 720ed45121
7 changed files with 1034 additions and 2612 deletions

View File

@ -103,12 +103,19 @@ document.addEventListener('DOMContentLoaded', () => {
if ($highlights.length > 0) {
$highlights.forEach($el => {
const copy = '<button class="button is-small bd-copy">Copy</button>';
const expand = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copy);
const copyEl = '<button class="button is-small bd-copy">Copy</button>';
const expandEl = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copyEl);
if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
$el.insertAdjacentHTML('beforeend', expand);
$el.insertAdjacentHTML('beforeend', expandEl);
}
const $parent = $el.parentNode;
if ($parent && $parent.className == 'bd-highlight-clipped') {
const showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>';
$el.classList.add('bd-is-clipped');
$el.insertAdjacentHTML('beforeend', showEl);
}
itemsProcessed++;
@ -138,6 +145,14 @@ document.addEventListener('DOMContentLoaded', () => {
$el.parentNode.firstElementChild.style.maxHeight = 'none';
});
});
const $highlightShows = getAll('.bd-highlight-clipped .bd-show');
$highlightShows.forEach($el => {
$el.addEventListener('click', () => {
$el.parentNode.classList.remove('bd-is-clipped');
});
});
}
new Clipboard('.bd-copy', {

View File

@ -40,6 +40,10 @@
margin-top: -1.5rem
&:not(:last-child)
margin-bottom: 1.5rem
& + .bd-highlight-clipped
margin-top: -1.5rem
&:not(:last-child)
margin-bottom: 1.5rem
// Snippet
.bd-snippet
@ -171,6 +175,33 @@ $structure-invert: $danger-invert
pre
white-space: pre-wrap
.bd-highlight-clipped
.bd-show
+overlay
align-items: center
background-color: rgba(#000, 0.9)
background-image: linear-gradient(rgba(#000, 0), rgba(#000, 0) 90%, rgba(#000, 1))
border: none
color: $white
cursor: pointer
display: none
font-size: $size-6
justify-content: center
opacity: 0.7
width: 100%
strong
color: currentColor
font-weight: $weight-semibold
&:hover
opacity: 0.8
.highlight.bd-is-clipped
height: 4em
overflow: hidden
pre
overflow: hidden
.bd-show
display: flex
+tablet
.section:not(.is-fullwidth) > .bd-example:not(.is-fullwidth)
margin-left: 1.5rem

File diff suppressed because it is too large Load Diff

View File

@ -427,122 +427,45 @@ doc-subtab: hero
</div>
</section>
<section class="section is-fullwidth">
<div class="bd-example">
<section class="hero is-primary is-medium">
<div class="hero-head">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-primary is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</header>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">
Title
</p>
<p class="subtitle">
Subtitle
</p>
</div>
</div>
<div class="hero-foot">
<nav class="tabs">
<div class="container">
<ul>
<li class="is-active">
<a>Overview</a>
</li>
<li>
<a>Modifiers</a>
</li>
<li>
<a>Grid</a>
</li>
<li>
<a>Elements</a>
</li>
<li>
<a>Components</a>
</li>
<li>
<a>Layout</a>
</li>
</ul>
</div>
</nav>
</div>
</section>
</div>
{% highlight html %}
{% capture heroNavbarA %}
<section class="hero is-primary is-medium">
<!-- Hero header: will stick at the top -->
<!-- Hero head: will stick at the top -->
<div class="hero-head">
<header class="nav">
<nav class="navbar">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="images/bulma-type-white.png" alt="Logo">
<div class="navbar-brand">
<a class="navbar-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-primary is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
<span class="navbar-burger burger" data-target="navbarMenuHeroA">
<span></span>
<span></span>
<span></span>
</span>
</div>
<div id="navbarMenuHeroA" class="navbar-menu">
<div class="navbar-end">
<a class="navbar-item is-active">
Home
</a>
<a class="navbar-item">
Examples
</a>
<a class="navbar-item">
Documentation
</a>
<span class="navbar-item">
<a class="button is-primary is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</div>
</header>
</nav>
</div>
<!-- Hero content: will be in the middle -->
@ -573,299 +496,181 @@ doc-subtab: hero
</nav>
</div>
</section>
{% endhighlight %}
{% endcapture %}
{% capture heroNavbarB %}
<section class="hero is-info is-large">
<div class="hero-head">
<nav class="navbar">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
<span class="navbar-burger burger" data-target="navbarMenuHeroB">
<span></span>
<span></span>
<span></span>
</span>
</div>
<div id="navbarMenuHeroB" class="navbar-menu">
<div class="navbar-end">
<a class="navbar-item is-active">
Home
</a>
<a class="navbar-item">
Examples
</a>
<a class="navbar-item">
Documentation
</a>
<span class="navbar-item">
<a class="button is-info is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</div>
</nav>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">
Title
</p>
<p class="subtitle">
Subtitle
</p>
</div>
</div>
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active">
<a>Overview</a>
</li>
<li>
<a>Modifiers</a>
</li>
<li>
<a>Grid</a>
</li>
<li>
<a>Elements</a>
</li>
<li>
<a>Components</a>
</li>
<li>
<a>Layout</a>
</li>
</ul>
</div>
</nav>
</div>
</section>
{% endcapture %}
{% capture heroNavbarC %}
<section class="hero is-success is-fullheight">
<!-- Hero head: will stick at the top -->
<div class="hero-head">
<header class="navbar">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
<span class="navbar-burger burger" data-target="navbarMenuHeroC">
<span></span>
<span></span>
<span></span>
</span>
</div>
<div id="navbarMenuHeroC" class="navbar-menu">
<div class="navbar-end">
<a class="navbar-item is-active">
Home
</a>
<a class="navbar-item">
Examples
</a>
<a class="navbar-item">
Documentation
</a>
<span class="navbar-item">
<a class="button is-success is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</div>
</header>
</div>
<!-- Hero content: will be in the middle -->
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">
Title
</h1>
<h2 class="subtitle">
Subtitle
</h2>
</div>
</div>
<!-- Hero footer: will stick at the bottom -->
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active"><a>Overview</a></li>
<li><a>Modifiers</a></li>
<li><a>Grid</a></li>
<li><a>Elements</a></li>
<li><a>Components</a></li>
<li><a>Layout</a></li>
</ul>
</div>
</nav>
</div>
</section>
{% endcapture %}
<section class="section is-fullwidth">
<div class="bd-example">
{{ heroNavbarA }}
</div>
<div class="bd-highlight-clipped">
{% highlight html %}{{ heroNavbarA }}{% endhighlight %}
</div>
<div class="bd-example">
<section class="hero is-info is-large">
<div class="hero-head">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-info is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</header>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">
Title
</p>
<p class="subtitle">
Subtitle
</p>
</div>
</div>
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active">
<a>Overview</a>
</li>
<li>
<a>Modifiers</a>
</li>
<li>
<a>Grid</a>
</li>
<li>
<a>Elements</a>
</li>
<li>
<a>Components</a>
</li>
<li>
<a>Layout</a>
</li>
</ul>
</div>
</nav>
</div>
</section>
{{ heroNavbarB }}
</div>
{% highlight html %}
<section class="hero is-info is-large">
<!-- Hero header: will stick at the top -->
<div class="hero-head">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-info is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</header>
<div class="bd-highlight-clipped">
{% highlight html %}{{ heroNavbarB }}{% endhighlight %}
</div>
<!-- Hero content: will be in the middle -->
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">
Title
</h1>
<h2 class="subtitle">
Subtitle
</h2>
</div>
<div class="bd-example">
{{ heroNavbarC }}
</div>
<!-- Hero footer: will stick at the bottom -->
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active"><a>Overview</a></li>
<li><a>Modifiers</a></li>
<li><a>Grid</a></li>
<li><a>Elements</a></li>
<li><a>Components</a></li>
<li><a>Layout</a></li>
</ul>
</div>
</nav>
<div class="bd-highlight-clipped">
{% highlight html %}{{ heroNavbarC }}{% endhighlight %}
</div>
</section>
{% endhighlight %}
<div class="bd-example is-fullwidth">
<section class="hero is-success is-fullheight">
<div class="hero-head">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="{{ site.url }}/images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-success is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</header>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">
Title
</p>
<p class="subtitle">
Subtitle
</p>
</div>
</div>
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active">
<a>Overview</a>
</li>
<li>
<a>Modifiers</a>
</li>
<li>
<a>Grid</a>
</li>
<li>
<a>Elements</a>
</li>
<li>
<a>Components</a>
</li>
<li>
<a>Layout</a>
</li>
</ul>
</div>
</nav>
</div>
</section>
</div>
{% highlight html %}
<section class="hero is-success is-fullheight">
<!-- Hero header: will stick at the top -->
<div class="hero-head">
<header class="nav">
<div class="container">
<div class="nav-left">
<a class="nav-item">
<img src="images/bulma-type-white.png" alt="Logo">
</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
<a class="nav-item is-active">
Home
</a>
<a class="nav-item">
Examples
</a>
<a class="nav-item">
Documentation
</a>
<span class="nav-item">
<a class="button is-success is-inverted">
<span class="icon">
<i class="fa fa-github"></i>
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</header>
</div>
<!-- Hero content: will be in the middle -->
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">
Title
</h1>
<h2 class="subtitle">
Subtitle
</h2>
</div>
</div>
<!-- Hero footer: will stick at the bottom -->
<div class="hero-foot">
<nav class="tabs is-boxed is-fullwidth">
<div class="container">
<ul>
<li class="is-active"><a>Overview</a></li>
<li><a>Modifiers</a></li>
<li><a>Grid</a></li>
<li><a>Elements</a></li>
<li><a>Components</a></li>
<li><a>Layout</a></li>
</ul>
</div>
</nav>
</div>
</section>
{% endhighlight %}
</section>

View File

@ -105,12 +105,19 @@ document.addEventListener('DOMContentLoaded', function () {
if ($highlights.length > 0) {
$highlights.forEach(function ($el) {
var copy = '<button class="button is-small bd-copy">Copy</button>';
var expand = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copy);
var copyEl = '<button class="button is-small bd-copy">Copy</button>';
var expandEl = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copyEl);
if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
$el.insertAdjacentHTML('beforeend', expand);
$el.insertAdjacentHTML('beforeend', expandEl);
}
var $parent = $el.parentNode;
if ($parent && $parent.className == 'bd-highlight-clipped') {
var showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>';
$el.classList.add('bd-is-clipped');
$el.insertAdjacentHTML('beforeend', showEl);
}
itemsProcessed++;
@ -140,6 +147,14 @@ document.addEventListener('DOMContentLoaded', function () {
$el.parentNode.firstElementChild.style.maxHeight = 'none';
});
});
var $highlightShows = getAll('.bd-highlight-clipped .bd-show');
$highlightShows.forEach(function ($el) {
$el.addEventListener('click', function () {
$el.parentNode.classList.remove('bd-is-clipped');
});
});
}
new Clipboard('.bd-copy', {

View File

@ -196,12 +196,12 @@ a.navbar-item,
.navbar-link
&:hover,
&.is-active
background-color: transparent
background-color: transparent !important
.navbar-item.has-dropdown
&.is-active,
&.is-hoverable:hover
.navbar-link
background-color: transparent
background-color: transparent !important
.navbar-dropdown
a.navbar-item
&:hover

View File

@ -5,9 +5,8 @@
display: flex
flex-direction: column
justify-content: space-between
.nav
.navbar
background: none
box-shadow: 0 1px 0 rgba($border, 0.3)
.tabs
ul
border-bottom: none
@ -28,16 +27,17 @@
a:not(.button),
strong
color: $color-invert
.nav
box-shadow: 0 1px 0 rgba($color-invert, 0.2)
.nav-menu
+mobile
.navbar-menu
+touch
background-color: $color
a.nav-item,
.nav-item a:not(.button)
.navbar-item,
.navbar-link
color: rgba($color-invert, 0.7)
a.navbar-item,
.navbar-link
&:hover,
&.is-active
background-color: darken($color, 5%)
color: $color-invert
.tabs
a
@ -66,21 +66,21 @@
$gradient-bottom-right: lighten(saturate(adjust-hue($color, 10deg), 5%), 5%)
background-image: linear-gradient(141deg, $gradient-top-left 0%, $color 71%, $gradient-bottom-right 100%)
+mobile
.nav-menu
.navbar-menu
background-image: linear-gradient(141deg, $gradient-top-left 0%, $color 71%, $gradient-bottom-right 100%)
// Responsiveness
+mobile
.nav-toggle
span
background-color: $color-invert
&:hover
background-color: rgba($black, 0.1)
&.is-active
span
background-color: $color-invert
.nav-menu
.nav-item
border-top-color: rgba($color-invert, 0.2)
// +mobile
// .nav-toggle
// span
// background-color: $color-invert
// &:hover
// background-color: rgba($black, 0.1)
// &.is-active
// span
// background-color: $color-invert
// .nav-menu
// .nav-item
// border-top-color: rgba($color-invert, 0.2)
// Sizes
&.is-small
.hero-body