feat: add range input haptic feedback
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m33s
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m33s
This commit is contained in:
@@ -2,13 +2,14 @@ import { motion, type HTMLMotionProps } from "motion/react";
|
||||
import { useState } from "react";
|
||||
import clsx, { type ClassValue } from "clsx";
|
||||
|
||||
import tg from "@/tg";
|
||||
import classes from "./RangeInput.module.css";
|
||||
|
||||
type Props = Omit<HTMLMotionProps<"input">, "className"> & {
|
||||
className?: ClassValue;
|
||||
};
|
||||
|
||||
export default function RangeInput({ className, ...props }: Props) {
|
||||
export default function RangeInput({ className, onChange, ...props }: Props) {
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -16,6 +17,10 @@ export default function RangeInput({ className, ...props }: Props) {
|
||||
{...props}
|
||||
type="range"
|
||||
className={clsx(classes.rangeInput, isDragging && classes.dragging, className)}
|
||||
onChange={(e) => {
|
||||
tg.hapticFeedback.inputChange();
|
||||
onChange?.(e);
|
||||
}}
|
||||
onMouseDown={() => setIsDragging(true)}
|
||||
onMouseUp={() => setIsDragging(false)}
|
||||
onMouseLeave={() => setIsDragging(false)}
|
||||
|
||||
Reference in New Issue
Block a user