Skip to content

Commit

Permalink
fix(slider): Slider imports (#222)
Browse files Browse the repository at this point in the history
- Made slider value label optional
  • Loading branch information
hachiojidev authored Mar 16, 2021
1 parent 9bd6b01 commit ed2d693
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@commitlint/config-conventional": "^11.0.0",
"@pancakeswap-libs/eslint-config-pancake": "0.1.0",
"@rollup/plugin-typescript": "^8.2.0",
"@rollup/plugin-url": "^6.0.0",
"@storybook/addon-a11y": "^6.1.18",
"@storybook/addon-actions": "^6.1.18",
"@storybook/addon-essentials": "^6.1.18",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typescript from "@rollup/plugin-typescript";
import url from "@rollup/plugin-url";
import pkg from "./package.json";

export default {
Expand All @@ -7,5 +8,5 @@ export default {
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "es" },
],
plugins: [typescript()],
plugins: [url(), typescript()],
};
3 changes: 1 addition & 2 deletions src/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const Slider: React.FC<SliderProps> = ({ min, max, value, onValueChanged, valueL
isCurrentValueMaxValue={isCurrentValueMaxValue}
/>
</BunnySlider>

<SliderLabel progress={labelOffset}>{valueLabel}</SliderLabel>
{valueLabel && <SliderLabel progress={labelOffset}>{valueLabel}</SliderLabel>}
</SliderContainer>
);
};
Expand Down
14 changes: 5 additions & 9 deletions src/components/Slider/styles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { InputHTMLAttributes } from "react";
import styled from "styled-components";
import { Box } from "../Box";

// Using require instead of import to avoid trouble with TS bunding and SVG types
/* eslint-disable @typescript-eslint/no-var-requires */
const bunnyHead = require("./svg/bunnyhead-main.svg");
const bunnyHeadMax = require("./svg/bunnyhead-max.svg");
/* eslint-enable @typescript-eslint/no-var-requires */
import bunnyHeadMain from "./svg/bunnyhead-main.svg";
import bunnyHeadMax from "./svg/bunnyhead-max.svg";

export const SliderContainer = styled(Box)`
position: relative;
Expand Down Expand Up @@ -44,7 +40,7 @@ export const StyledInput = styled.input<StyledInputProps>`
::-webkit-slider-thumb {
-webkit-appearance: none;
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHead)});
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHeadMain)});
width: 24px;
height: 32px;
cursor: pointer;
Expand All @@ -57,7 +53,7 @@ export const StyledInput = styled.input<StyledInputProps>`
}
::-moz-range-thumb {
-webkit-appearance: none;
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHead)});
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHeadMain)});
width: 24px;
height: 32px;
cursor: pointer;
Expand All @@ -73,7 +69,7 @@ export const StyledInput = styled.input<StyledInputProps>`
}
::-ms-thumb {
-webkit-appearance: none;
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHead)});
background-image: url(${({ isCurrentValueMaxValue }) => (isCurrentValueMaxValue ? bunnyHeadMax : bunnyHeadMain)});
width: 24px;
height: 32px;
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Slider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default interface SliderProps extends BoxProps {
max: number;
value: number;
onValueChanged: (newValue: number) => void;
valueLabel: string;
valueLabel?: string;
}
File renamed without changes.
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,15 @@
"@rollup/pluginutils" "^3.1.0"
resolve "^1.17.0"

"@rollup/plugin-url@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-url/-/plugin-url-6.0.0.tgz#20fbc8cda9bc5f0c31d7225f633002ce73e920b0"
integrity sha512-UHGyoo3EbLufCZtXon/baNf75PAYT+Gs/NUgFMx2ZaDQ314PKNP0pJTrpbhDqFkZADzpkqJWyQOfJ2Nd6Qk4TA==
dependencies:
"@rollup/pluginutils" "^3.1.0"
make-dir "^3.1.0"
mime "^2.4.6"

"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
Expand Down Expand Up @@ -10099,6 +10108,11 @@ mime@^2.4.4:
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.0.tgz#2b4af934401779806ee98026bb42e8c1ae1876b1"
integrity sha512-ft3WayFSFUVBuJj7BMLKAQcSlItKtfjsKDDsii3rqFDAZ7t11zRe8ASw/GlmivGwVUYtwkQrxiGGpL6gFvB0ag==

mime@^2.4.6:
version "2.5.2"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe"
integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==

mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
Expand Down

0 comments on commit ed2d693

Please sign in to comment.