@chayns-components/devalue-slider
Version:
A slider to devalue something.
265 lines (256 loc) • 9.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createThumbVariants = exports.TrackText = exports.TrackBackground = exports.Track = exports.ThumbIconContainer = exports.ThumbIcon = exports.Thumb = exports.THUMB_ICON_VARIANTS = exports.Container = void 0;
var _react = require("motion/react");
var _styledComponents = _interopRequireDefault(require("styled-components"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const Container = exports.Container = (0, _styledComponents.default)(_react.motion.div)``;
const Track = exports.Track = (0, _styledComponents.default)(_react.motion.div)`
user-select: none;
position: relative;
z-index: 3;
height: ${({
$height
}) => $height}px;
border-radius: ${({
$height
}) => $height / 2}px;
background-color: ${({
$backgroundColor
}) => $backgroundColor};
`;
const TrackBackground = exports.TrackBackground = (0, _styledComponents.default)(_react.motion.div)`
position: absolute;
width: 100%;
height: 100%;
border-radius: ${({
$height
}) => $height / 2}px;
z-index: 2;
`;
const Thumb = exports.Thumb = (0, _styledComponents.default)(_react.motion.div)`
height: ${({
$size
}) => $size}px;
width: ${({
$size
}) => $size}px;
border-radius: 50%;
background-color: white;
left: ${({
$size,
$trackHeight
}) => ($trackHeight - $size - 2) / 2}px;
bottom: ${({
$size,
$trackHeight
}) => ($trackHeight - $size - 2) / 2 + 1}px;
position: absolute;
z-index: 3;
box-shadow: rgba(0, 0, 0, 0.2) 1px 1px 2px 0;
`;
const TrackText = exports.TrackText = (0, _styledComponents.default)(_react.motion.div)`
position: absolute;
line-height: 1.15;
font-size: ${({
$baseFontSize
}) => $baseFontSize}px;
font-weight: 700;
color: ${({
$color
}) => $color};
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
white-space: nowrap;
text-overflow: ellipsis;
z-index: 1;
font-family:
Roboto Regular,
sans-serif;
@font-face {
font-family: 'Roboto Regular';
font-style: normal;
font-weight: normal;
src:
local('Roboto Regular'),
local('Roboto Regular'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.ttf)
format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Regular';
font-style: italic;
font-weight: normal;
src:
local('Roboto Regular Italic'),
local('Roboto Regular-Italic'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.ttf) format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Regular';
font-style: normal;
font-weight: bold;
src:
local('Roboto Regular Bold'),
local('Roboto Regular-Bold'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.ttf) format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Regular';
font-style: italic;
font-weight: bold;
src:
local('Roboto Regular Bold Italic'),
local('Roboto Regular-BoldItalic'),
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff2)
format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff)
format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.ttf)
format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Bold';
font-style: normal;
font-weight: normal;
src:
local('Roboto Bold'),
local('Roboto Bold'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.ttf) format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Bold';
font-style: italic;
font-weight: normal;
src:
local('Roboto Bold Italic'),
local('Roboto Bold-Italic'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.ttf) format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Bold';
font-style: normal;
font-weight: bold;
src:
local('Roboto Bold Bold'),
local('Roboto Bold-Bold'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.ttf) format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
@font-face {
font-family: 'Roboto Bold';
font-style: italic;
font-weight: bold;
src:
local('Roboto Bold Bold Italic'),
local('Roboto Bold-BoldItalic'),
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff2) format('woff2'),
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff) format('woff'),
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.ttf)
format('truetype'),
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.svg) format('svg');
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
}
`;
const ThumbIconContainer = exports.ThumbIconContainer = _styledComponents.default.div`
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
`;
const ThumbIcon = exports.ThumbIcon = (0, _styledComponents.default)(_react.motion.i).attrs(({
icon
}) => ({
className: `react-chayns-icon ${icon}`
}))`
font-size: 22px;
z-index: 1;
color: black;
padding: 5px;
`;
const createThumbVariants = ({
thumbSize,
trackWidth,
scaleFactor
}) => ({
base: {
x: 0,
backgroundColor: 'white',
transition: {
duration: 0.2
}
},
completed: {
x: (trackWidth - thumbSize * scaleFactor) / 2,
backgroundColor: 'transparent',
boxShadow: 'none',
transition: {
duration: 0.3
}
},
leaving: {
scale: [1, 2.4, 1],
boxShadow: 'none'
}
});
exports.createThumbVariants = createThumbVariants;
const THUMB_ICON_VARIANTS = exports.THUMB_ICON_VARIANTS = {
base: {
x: [0, 8, 0, 8, 0],
transition: {
duration: 1,
ease: 'easeInOut',
repeat: Infinity,
repeatDelay: 5
}
},
dragging: {
x: 0
},
completed: {
opacity: 1,
transition: {
duration: 0
}
},
leaving: {
opacity: 1,
scale: [1, 2.4, 1],
transition: {
duration: 0.4,
ease: 'easeInOut'
}
}
};
//# sourceMappingURL=Slider.styles.js.map