feat: add range input haptic feedback
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m33s

This commit is contained in:
Hewston Fox
2026-03-18 02:12:05 +02:00
parent 81c99c6c5f
commit f93bc7d3e0
2 changed files with 10 additions and 1 deletions

View File

@@ -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)}

View File

@@ -87,6 +87,7 @@ export default {
console.log(
isRealTelegram() ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized",
);
console.log(tg.retrieveLaunchParams());
},
openLink(url: string | URL, options?: tg.OpenLinkOptions) {
tg.openLink.ifAvailable(url, options);
@@ -95,6 +96,9 @@ export default {
click() {
tg.hapticFeedback.impactOccurred.ifAvailable("light");
},
inputChange() {
tg.hapticFeedback.selectionChanged.ifAvailable();
},
},
initData: tg.initData,
storage: {