Skip to content

Instantly share code, notes, and snippets.

@benhowes
Created March 23, 2016 15:24
Show Gist options
  • Save benhowes/762dbaa2bf3e5795f4a4 to your computer and use it in GitHub Desktop.
Save benhowes/762dbaa2bf3e5795f4a4 to your computer and use it in GitHub Desktop.
SCSS version of the LESS styles
$prefixClass: rc-slider;
$disabledColor: #ccc;
$border-radius-base: 6px;
$primary-color: #2db7f5;
$tooltip-color: #fff;
$tooltip-bg: tint(#666, 4%);
$tooltip-arrow-width: 4px;
$tooltip-distance: $tooltip-arrow-width+4;
$tooltip-arrow-color: $tooltip-bg;
$ease-out-quint : cubic-bezier(0.23, 1, 0.32, 1);
$ease-in-quint : cubic-bezier(0.755, 0.05, 0.855, 0.06);
@mixin borderBox() {
box-sizing: border-box;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); // remove tap highlight color for mobile safari
* {
box-sizing: border-box;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); // remove tap highlight color for mobile safari
}
}
.#{$prefixClass} {
position: relative;
height: 4px;
width: 100%;
border-radius: $border-radius-base;
background-color: #e9e9e9;
@include borderBox();
&-track {
position: absolute;
left: 0;
height: 4px;
border-radius: $border-radius-base;
background-color: tint($primary-color, 60%);
z-index: 1;
}
&-handle {
position: absolute;
margin-left: -7px;
margin-top: -5px;
width: 14px;
height: 14px;
cursor: pointer;
border-radius: 50%;
border: solid 2px tint($primary-color, 50%);
background-color: #fff;
z-index: 2;
&:hover {
border-color: tint($primary-color, 20%);
}
&-active {
&:active {
border-color: tint($primary-color, 20%);
box-shadow: 0 0 5px tint($primary-color, 20%);
}
}
}
&-mark {
position: absolute;
top: 10px;
left: 0;
width: 100%;
font-size: 12px;
z-index: 3;
}
&-mark-text {
position: absolute;
display: inline-block;
vertical-align: middle;
text-align: center;
cursor: pointer;
color: #999;
&-active {
color: #666;
}
}
&-step {
position: absolute;
width: 100%;
height: 4px;
background: transparent;
z-index: 1;
}
&-dot {
position: absolute;
top: -2px;
margin-left: -4px;
width: 8px;
height: 8px;
border: 2px solid #e9e9e9;
background-color: #fff;
cursor: pointer;
border-radius: 50%;
vertical-align: middle;
&:first-child {
margin-left: -4px;
}
&:last-child {
margin-left: -4px;
}
&-active {
border-color: tint($primary-color, 50%);
}
}
&-disabled {
background-color: #e9e9e9;
.#{$prefixClass}-track {
background-color: $disabledColor;
}
.#{$prefixClass}-handle, .#{$prefixClass}-dot {
border-color: $disabledColor;
background-color: #fff;
cursor: not-allowed;
}
.#{$prefixClass}-mark-text, .#{$prefixClass}-dot {
cursor: not-allowed!important;
}
}
}
@mixin motion-common() {
animation-duration: 0.3s;
animation-fill-mode: both;
display: block !important;
}
@mixin make-motion($className, $keyframeName) {
.#{$className}-enter, .#{$className}-appear {
@include motion-common();
animation-play-state: paused;
}
.#{$className}-leave {
@include motion-common();
animation-play-state: paused;
}
.#{$className}-enter.#{$className}-enter-active, .#{$className}-appear.#{$className}-appear-active {
animation-name: "#{$keyframeName}In";
animation-play-state: running;
}
.#{$className}-leave.#{$className}-leave-active {
animation-name: "#{$keyframeName}Out";
animation-play-state: running;
}
}
@mixin zoom-motion($className, $keyframeName) {
@include make-motion($className, $keyframeName);
.#{$className}-enter, .#{$className}-appear {
transform: scale(0, 0); // need this by yiminghe
animation-timing-function: $ease-out-quint;
}
.#{$className}-leave {
animation-timing-function: $ease-in-quint;
}
}
@include zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDown);
#{keyframes} rcSliderTooltipZoomDownIn {
0% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
100% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
}
#{keyframes} rcSliderTooltipZoomDownOut {
0% {
transform-origin: 50% 100%;
transform: scale(1, 1);
}
100% {
opacity: 0;
transform-origin: 50% 100%;
transform: scale(0, 0);
}
}
.rc-tooltip {
position: absolute;
left: -9999px;
top: -9999px;
z-index: 4;
visibility: visible;
@include borderBox();
&-hidden {
display: none;
}
&-placement-top {
padding: $tooltip-arrow-width 0 $tooltip-distance 0;
}
&-inner {
padding: 6px 2px;
min-width: 24px;
height: 24px;
font-size: 12px;
line-height: 1;
color: $tooltip-color;
text-align: center;
text-decoration: none;
background-color: $tooltip-bg;
border-radius: $border-radius-base;
box-shadow: 0 0 4px #d9d9d9;
}
&-arrow {
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
&-placement-top &-arrow {
bottom: $tooltip-distance - $tooltip-arrow-width;
left: 50%;
margin-left: -$tooltip-arrow-width;
border-width: $tooltip-arrow-width $tooltip-arrow-width 0;
border-top-color: $tooltip-arrow-color;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment