A Pen by Henry Blyth on CodePen.
Created
December 24, 2019 07:03
-
-
Save dai/cb57c5783912b33d87e7b93b63eb5d13 to your computer and use it in GitHub Desktop.
extendo fabuloso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button class="extendor" onclick="invert()">wow fab x</button> | |
<pre>[click the button for funsies]</pre> | |
<footer hidden> | |
<p>Dedicated to my late mum</p> | |
<p>She would always end her texts with a variant on "fab x" or "wow fab x"</p> | |
<p>💖💖💖</p> | |
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = 0; | |
function invert() { | |
document.body.classList.toggle('invert'); | |
count++; | |
if (count > 3) { | |
document.querySelectorAll('[hidden]').forEach(el => el.hidden = false); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin extendor($extend, $border: 0px) { | |
position: relative; | |
border-width: $border; | |
margin: $extend; | |
&, &::before, &::after { | |
transition: transform 100ms ease-in-out; | |
} | |
&::before, &::after { | |
content: ''; | |
position: absolute; | |
border: 0 solid transparent; | |
z-index: -1; | |
transition-property: border-width, top, left, bottom, right; | |
} | |
&::before { | |
top: -$border; | |
right: calc(100% + #{$border}); | |
bottom: -$border; | |
border-right-color: inherit; | |
} | |
&::after { | |
top: calc(100% + #{$border}); | |
left: -$border; | |
right: -$border; | |
border-top-color: inherit; | |
} | |
&:hover, &:focus { | |
&::before { | |
border-top-width: $extend; | |
border-right-width: $extend; | |
bottom: -($extend + $border); | |
} | |
&::after { | |
border-top-width: $extend; | |
border-right-width: $extend; | |
left: -($extend + $border); | |
} | |
} | |
&:active { | |
transform: translateX(-$border) translateY($border); | |
&, &::before, &::after { | |
transition-duration: 50ms; | |
} | |
&::before { | |
border-top-width: $extend - $border; | |
border-right-width: $extend - $border; | |
bottom: -$extend; | |
} | |
&::after { | |
border-top-width: $extend - $border; | |
border-right-width: $extend - $border; | |
left: -$extend; | |
} | |
} | |
} | |
.extendor { | |
padding: 10px; | |
display: inline-block; | |
@include extendor(6px, 2px); // odd total number can produce half-pixel rendering oddities | |
min-width: 100px; | |
min-height: 44px; | |
} | |
button { | |
appearance: none; | |
cursor: pointer; | |
color: inherit; | |
font-size: inherit; | |
margin: 1em 0; | |
background: none; | |
border-color: inherit; | |
border-style: solid; | |
} | |
body { | |
background-color: white; | |
color: black; | |
font-family: Helvetica, sans-serif; | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
align-items: center; | |
height: 500px; | |
&.invert { | |
background-color: black; | |
color: white; | |
} | |
} | |
* { | |
box-sizing: border-box; | |
} | |
[hidden] { | |
display: initial; | |
visibility: hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment