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 { useState } from "react";
|
||||||
import clsx, { type ClassValue } from "clsx";
|
import clsx, { type ClassValue } from "clsx";
|
||||||
|
|
||||||
|
import tg from "@/tg";
|
||||||
import classes from "./RangeInput.module.css";
|
import classes from "./RangeInput.module.css";
|
||||||
|
|
||||||
type Props = Omit<HTMLMotionProps<"input">, "className"> & {
|
type Props = Omit<HTMLMotionProps<"input">, "className"> & {
|
||||||
className?: ClassValue;
|
className?: ClassValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RangeInput({ className, ...props }: Props) {
|
export default function RangeInput({ className, onChange, ...props }: Props) {
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -16,6 +17,10 @@ export default function RangeInput({ className, ...props }: Props) {
|
|||||||
{...props}
|
{...props}
|
||||||
type="range"
|
type="range"
|
||||||
className={clsx(classes.rangeInput, isDragging && classes.dragging, className)}
|
className={clsx(classes.rangeInput, isDragging && classes.dragging, className)}
|
||||||
|
onChange={(e) => {
|
||||||
|
tg.hapticFeedback.inputChange();
|
||||||
|
onChange?.(e);
|
||||||
|
}}
|
||||||
onMouseDown={() => setIsDragging(true)}
|
onMouseDown={() => setIsDragging(true)}
|
||||||
onMouseUp={() => setIsDragging(false)}
|
onMouseUp={() => setIsDragging(false)}
|
||||||
onMouseLeave={() => setIsDragging(false)}
|
onMouseLeave={() => setIsDragging(false)}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export default {
|
|||||||
console.log(
|
console.log(
|
||||||
isRealTelegram() ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized",
|
isRealTelegram() ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized",
|
||||||
);
|
);
|
||||||
|
console.log(tg.retrieveLaunchParams());
|
||||||
},
|
},
|
||||||
openLink(url: string | URL, options?: tg.OpenLinkOptions) {
|
openLink(url: string | URL, options?: tg.OpenLinkOptions) {
|
||||||
tg.openLink.ifAvailable(url, options);
|
tg.openLink.ifAvailable(url, options);
|
||||||
@@ -95,6 +96,9 @@ export default {
|
|||||||
click() {
|
click() {
|
||||||
tg.hapticFeedback.impactOccurred.ifAvailable("light");
|
tg.hapticFeedback.impactOccurred.ifAvailable("light");
|
||||||
},
|
},
|
||||||
|
inputChange() {
|
||||||
|
tg.hapticFeedback.selectionChanged.ifAvailable();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
initData: tg.initData,
|
initData: tg.initData,
|
||||||
storage: {
|
storage: {
|
||||||
|
|||||||
Reference in New Issue
Block a user