Improve snippet

This commit is contained in:
Jeremy Thomas 2017-10-09 15:38:12 +01:00
parent 8d6a0a43dc
commit c4c3c32a83
5 changed files with 112 additions and 53 deletions

View File

@ -143,19 +143,11 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
}); });
<<<<<<< HEAD
const $highlightShows = getAll('.highlight .bd-show');
$highlightShows.forEach($el => {
$el.addEventListener('click', () => {
$el.parentNode.parentNode.classList.remove('bd-is-more-clipped');
=======
const $highlightShows = getAll('.bd-highlight-clipped .bd-show'); const $highlightShows = getAll('.bd-highlight-clipped .bd-show');
$highlightShows.forEach($el => { $highlightShows.forEach($el => {
$el.addEventListener('click', () => { $el.addEventListener('click', () => {
$el.parentNode.classList.remove('bd-is-clipped'); $el.parentNode.classList.remove('bd-is-clipped');
>>>>>>> Add show code
}); });
}); });
} }

View File

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

View File

@ -11637,14 +11637,6 @@ html.route-index #carbon {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
.bd-example + .bd-highlight-clipped {
margin-top: -1.5rem;
}
.bd-example + .bd-highlight-clipped:not(:last-child) {
margin-bottom: 1.5rem;
}
.bd-snippet { .bd-snippet {
border: 1px solid #ffdd57; border: 1px solid #ffdd57;
margin-top: 2rem; margin-top: 2rem;
@ -11680,14 +11672,22 @@ html.route-index #carbon {
.bd-snippet-code.bd-is-more.bd-is-more-clipped .highlight .bd-show { .bd-snippet-code.bd-is-more.bd-is-more-clipped .highlight .bd-show {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;
======= =======
======= =======
=======
>>>>>>> Improve snippet
======= =======
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;
=======
display: -webkit-box;
display: -ms-flexbox;
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet >>>>>>> Improve snippet
>>>>>>> Improve snippet >>>>>>> Improve snippet
display: flex; display: flex;
@ -11866,8 +11866,16 @@ html.route-index #carbon {
======= =======
======= =======
align-items: stretch; align-items: stretch;
<<<<<<< HEAD
>>>>>>> Add love data >>>>>>> Add love data
<<<<<<< HEAD
>>>>>>> Add love data >>>>>>> Add love data
=======
=======
border-radius: 5px;
border-top-left-radius: 0;
>>>>>>> Improve snippet
>>>>>>> Improve snippet
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
@ -12002,6 +12010,7 @@ html.route-index #carbon {
======= =======
======= =======
align-items: stretch; align-items: stretch;
<<<<<<< HEAD
>>>>>>> Use link instead of primary >>>>>>> Use link instead of primary
<<<<<<< HEAD <<<<<<< HEAD
>>>>>>> Use link instead of primary >>>>>>> Use link instead of primary
@ -12047,8 +12056,17 @@ html.route-index #carbon {
======= =======
align-items: stretch; align-items: stretch;
>>>>>>> Add love data >>>>>>> Add love data
<<<<<<< HEAD
>>>>>>> Add love data >>>>>>> Add love data
<<<<<<< HEAD
>>>>>>> Add love data >>>>>>> Add love data
=======
=======
=======
border-radius: 0 5px 5px 0;
>>>>>>> Improve snippet
>>>>>>> Improve snippet
>>>>>>> Improve snippet
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
@ -12181,6 +12199,7 @@ html.route-index #carbon {
.highlight .bd-show { .highlight .bd-show {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -12222,6 +12241,8 @@ html.route-index #carbon {
======= =======
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
>>>>>>> Improve snippet
=======
>>>>>>> Improve snippet >>>>>>> Improve snippet
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -12257,6 +12278,8 @@ html.route-index #carbon {
.bd-highlight-clipped .bd-show { .bd-highlight-clipped .bd-show {
======= =======
>>>>>>> Improve snippet
=======
>>>>>>> Improve snippet >>>>>>> Improve snippet
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -12295,44 +12318,38 @@ html.route-index #carbon {
} }
.bd-highlight-clipped .bd-show { .bd-highlight-clipped .bd-show {
=======
>>>>>>> Improve snippet
bottom: 0; bottom: 0;
left: 0; left: 0;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
align-items: center; align-items: center;
background-color: rgba(0, 0, 0, 0.9); background-color: rgba(245, 245, 245, 0.7);
background-image: linear-gradient(transparent, transparent 90%, black);
border: none; border: none;
color: white; color: rgba(0, 0, 0, 0.5);
cursor: pointer; cursor: pointer;
display: none; display: none;
font-size: 1rem; font-size: 0.75rem;
justify-content: center; justify-content: center;
opacity: 0.7;
width: 100%; width: 100%;
} }
.bd-highlight-clipped .bd-show strong { .highlight .bd-show strong {
color: currentColor; color: currentColor;
font-weight: 600; font-weight: 600;
} }
.bd-highlight-clipped .bd-show:hover { .highlight .bd-show:hover {
opacity: 0.8; background-color: rgba(255, 221, 87, 0.8);
color: rgba(0, 0, 0, 0.7);
} }
.bd-highlight-clipped .highlight.bd-is-clipped { @media screen and (min-width: 769px), print {
height: 4em; .highlight pre {
overflow: hidden; white-space: pre-wrap;
} }
.bd-highlight-clipped .highlight.bd-is-clipped pre {
overflow: hidden;
}
.bd-highlight-clipped .highlight.bd-is-clipped .bd-show {
display: flex;
} }
@media screen and (min-width: 769px), print { @media screen and (min-width: 769px), print {

File diff suppressed because one or more lines are too long

View File

@ -114,14 +114,19 @@ document.addEventListener('DOMContentLoaded', function () {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
>>>>>>> Add show code >>>>>>> Add show code
======= =======
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
>>>>>>> Improve snippet
=======
======= =======
>>>>>>> Add show code >>>>>>> Add show code
>>>>>>> Add show code >>>>>>> Add show code
=======
>>>>>>> Improve snippet
var $parent = $el.parentNode; var $parent = $el.parentNode;
if ($parent && $parent.classList.contains('bd-is-more')) { if ($parent && $parent.classList.contains('bd-is-more')) {
var showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>'; var showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>';
@ -136,6 +141,7 @@ document.addEventListener('DOMContentLoaded', function () {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
>>>>>>> Add show code >>>>>>> Add show code
======= =======
@ -153,6 +159,8 @@ document.addEventListener('DOMContentLoaded', function () {
======= =======
<<<<<<< HEAD <<<<<<< HEAD
======= =======
>>>>>>> Improve snippet
=======
======= =======
>>>>>>> Improve snippet >>>>>>> Improve snippet
>>>>>>> Improve snippet >>>>>>> Improve snippet
@ -171,14 +179,28 @@ document.addEventListener('DOMContentLoaded', function () {
>>>>>>> Improve snippet >>>>>>> Improve snippet
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
=======
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet
var $parent = $el.parentNode; var $parent = $el.parentNode;
if ($parent && $parent.className == 'bd-highlight-clipped') { if ($parent && $parent.classList.contains('bd-is-more')) {
var showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>'; 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); $el.insertAdjacentHTML('beforeend', showEl);
<<<<<<< HEAD
>>>>>>> Add show code >>>>>>> Add show code
<<<<<<< HEAD
>>>>>>> Add show code >>>>>>> Add show code
<<<<<<< HEAD
>>>>>>> Add show code >>>>>>> Add show code
=======
=======
=======
} else if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
$el.insertAdjacentHTML('beforeend', expandEl);
>>>>>>> Improve snippet
>>>>>>> Improve snippet
>>>>>>> Improve snippet
} }
itemsProcessed++; itemsProcessed++;
@ -214,10 +236,15 @@ document.addEventListener('DOMContentLoaded', function () {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
>>>>>>> Add show code >>>>>>> Add show code
=======
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet
var $highlightShows = getAll('.highlight .bd-show'); var $highlightShows = getAll('.highlight .bd-show');
$highlightShows.forEach(function ($el) { $highlightShows.forEach(function ($el) {
@ -233,6 +260,7 @@ document.addEventListener('DOMContentLoaded', function () {
======= =======
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
>>>>>>> Add show code >>>>>>> Add show code
======= =======
@ -241,6 +269,12 @@ document.addEventListener('DOMContentLoaded', function () {
======= =======
>>>>>>> Add show code >>>>>>> Add show code
>>>>>>> Add show code >>>>>>> Add show code
=======
=======
>>>>>>> Add show code
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet
var $highlightShows = getAll('.highlight .bd-show'); var $highlightShows = getAll('.highlight .bd-show');
$highlightShows.forEach(function ($el) { $highlightShows.forEach(function ($el) {
@ -249,6 +283,7 @@ document.addEventListener('DOMContentLoaded', function () {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
======= =======
@ -263,6 +298,8 @@ document.addEventListener('DOMContentLoaded', function () {
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
>>>>>>> Add show code >>>>>>> Add show code
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet >>>>>>> Improve snippet
======= =======
======= =======
@ -273,6 +310,9 @@ document.addEventListener('DOMContentLoaded', function () {
$el.parentNode.classList.remove('bd-is-clipped'); $el.parentNode.classList.remove('bd-is-clipped');
>>>>>>> Add show code >>>>>>> Add show code
>>>>>>> Add show code >>>>>>> Add show code
=======
>>>>>>> Improve snippet
>>>>>>> Improve snippet
}); });
}); });
} }