Skip to content

Instantly share code, notes, and snippets.

@qstudio
Last active Nov 13, 2020
Embed
What would you like to do?
// share-this https://github.com/MaxArt2501/share-this
// vars ##
$share-this-vertical-offset: -.25em !default;
$share-this-background: #333 !default;
$share-this-foreground: #fff !default;
$share-this-highlight-link: rgba(#fff, .25) !default;
$share-this-border-radius: .25em !default;
$share-this-arrow-size: .5em !default;
$share-this-sharer-width: 2.5em !default;
$share-this-sharer-height: 2.5em !default;
$share-this-sharer-padding: .5em !default;
$share-this-border-distance: 4em !default;
$share-this-animation-length: .3s !default;
$share-this-small-devices-max: 575px !default;
// mixins ##
@mixin share-this-transform($transformation...) {
-webkit-transform: $transformation;
-ms-transform: $transformation;
transform: $transformation;
}
@mixin share-this-animation($animation...) {
-webkit-animation: $animation;
animation: $animation;
}
@mixin share-this-filter($filter...) {
-webkit-filter: $filter;
filter: $filter;
}
@mixin share-this-on-bottom() {
&::before {
bottom: auto;
top: 100%;
border-width: 0 $share-this-arrow-size $share-this-arrow-size;
margin-top: 0;
}
> ul {
top: 100%;
transform: translateX(-50%);
margin: $share-this-arrow-size 0 0;
}
}
// scss ##
.share-this-popover {
max-width: $share-this-border-distance * 2;
pointer-events: none;
@include share-this-filter(drop-shadow(0 1px 3px rgba(0, 0, 0, .35)));
@include share-this-animation(share-this-intro $share-this-animation-length);
&::before {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
width: 0;
height: 0;
margin: $share-this-vertical-offset + $share-this-arrow-size (-$share-this-arrow-size);
border-width: $share-this-arrow-size $share-this-arrow-size 0;
border-style: solid;
border-color: $share-this-background transparent;
}
> ul {
pointer-events: auto;
list-style: none;
padding: 0.5rem;
margin: $share-this-vertical-offset - $share-this-arrow-size 0 0;
white-space: nowrap;
background: $share-this-background;
color: $share-this-foreground;
border-radius: $share-this-border-radius;
position: absolute;
left: 50%;
@include share-this-transform(translate(-50%, -100%));
> li {
display: inline-block;
width: $share-this-sharer-width;
height: $share-this-sharer-height;
line-height: 1em;
text-align: center;
> a {
display: inline-block;
width: 100%;
height: 100%;
color: inherit;
box-sizing: border-box;
padding: $share-this-sharer-padding;
&:hover, &:focus {
background: $share-this-highlight-link;
}
}
}
}
@media (pointer: coarse) {
font-size: 150%;
@include share-this-on-bottom();
}
@media (max-width: $share-this-small-devices-max) {
left: 0 !important;
right: 0 !important;
width: auto !important;
max-width: none;
@include share-this-on-bottom();
> ul {
left: 0;
width: 100%;
transform: none;
border-radius: 0;
text-align: center;
}
}
}
@-webkit-keyframes share-this-intro {
0% {
-webkit-transform: translateY(-3em);
opacity: 0;
}
80% {
-webkit-transform: translateY(.5em);
opacity: 1;
}
100% {
-webkit-transform: translateY(0);
}
}
@keyframes share-this-intro {
0% {
transform: translateY(-3em);
opacity: 0;
}
80% {
transform: translateY(.5em);
opacity: 1;
}
100% {
transform: translateY(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment