diff --git a/src/mainsite/components/Slider/SliderWithNowMarker.tsx b/src/mainsite/components/Slider/SliderWithNowMarker.tsx new file mode 100644 index 00000000..e5a27e2e --- /dev/null +++ b/src/mainsite/components/Slider/SliderWithNowMarker.tsx @@ -0,0 +1,70 @@ +import * as React from "react"; +import "./Slider.tsx"; +import { TimeFrameText } from "../../../components/Texts"; + +interface Props { + min: number; + max: number; + value?: number; + step?: number; + onChange: (e: React.ChangeEvent) => void; + onPointerDown?: () => void; + onPointerUp?: () => void; + thumbVisible?: boolean; + nowValue?: number; +} + +const THUMB_WIDTH = 14; + +/** + * The browser's native slider is difficult to style and leads + * to very small tap targets on mobile, so instead we render a + * transparent slider and use a custom UI in front of it. + */ +const Slider: React.FC = ({ + min, + max, + onChange, + onPointerDown, + onPointerUp, + step, + thumbVisible = true, + value, + nowValue, +}) => { + const nowValuePercent = + nowValue !== undefined ? ((nowValue - min) / max) * 100 : undefined; + return ( +
+ +
+
+ now +
+
+ ); +}; + +export default Slider; diff --git a/src/mainsite/components/TwoYearProjection/index.tsx b/src/mainsite/components/TwoYearProjection/index.tsx index bfbdcf08..68cb9cb5 100644 --- a/src/mainsite/components/TwoYearProjection/index.tsx +++ b/src/mainsite/components/TwoYearProjection/index.tsx @@ -5,7 +5,7 @@ import { estimatedDailyFeeBurn, estimatedDailyIssuance, } from "../../utils/metric-utils"; -import Slider from "../Slider/Slider"; +import SliderWithNowMarker from "../Slider/SliderWithNowMarker"; import { BaseText } from "../../../components/Texts"; import Twemoji from "../../../components/Twemoji"; import styles from "./TwoYearProjection.module.scss"; @@ -76,24 +76,10 @@ const TwoYearProjection: FC = () => { undefined, ); - const currentStakedEthPercent = - currentStakedEth !== undefined - ? ((currentStakedEth - MIN_PROJECTED_ETH_STAKING) / - MAX_PROJECTED_ETH_STAKING) * - 100 - : undefined; - const [currentBaseFee, setCurrentBaseFee] = useState( undefined, ); - const currentBaseFeePercent = - currentBaseFee !== undefined - ? ((currentBaseFee - MIN_PROJECTED_BASE_GAS_PRICE) / - MAX_PROJECTED_BASE_GAS_PRICE) * - 100 - : undefined; - useEffect(() => { if (effectiveBalanceSum === undefined || baseFeesOverTime === undefined) { return; @@ -164,8 +150,7 @@ const TwoYearProjection: FC = () => { } > -
- { onChange={handleProjectedStakingChange} onPointerDown={handleProjectedStakingPointerDown} onPointerUp={handleProjectedStakingPointerUp} + nowValue={currentStakedEth} /> -
-
- - now - -
-
{ } > -
- -
-
- - now - -
-