forked from vkruglikov/react-telegram-web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHapticFeedbackDemo.tsx
65 lines (63 loc) · 2.14 KB
/
HapticFeedbackDemo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Button, Form, Typography, Select } from 'antd';
import { FC, useState } from 'react';
import {
ImpactOccurredFunction,
NotificationOccurredFunction,
useHapticFeedback,
} from '@vkruglikov/react-telegram-web-app';
const HapticFeedbackDemo: FC = () => {
const [impactOccurred, notificationOccurred, selectionChanged] =
useHapticFeedback();
const [style, setStyle] =
useState<Parameters<ImpactOccurredFunction>[0]>('light');
const [type, setType] =
useState<Parameters<NotificationOccurredFunction>[0]>('error');
return (
<>
<Typography.Title level={3}>useHapticFeedback</Typography.Title>
<Form
labelCol={{ span: 6 }}
name="HapticFeedbackDemo"
layout="horizontal"
autoComplete="off"
>
<Form.Item label="style">
<Select value={style} onChange={value => setStyle(value)}>
<Select.Option value="light">light</Select.Option>
<Select.Option value="medium">medium</Select.Option>
<Select.Option value="heavy">heavy</Select.Option>
<Select.Option value="rigid">rigid</Select.Option>
<Select.Option value="soft">soft</Select.Option>
</Select>
</Form.Item>
<Form.Item>
<Button block type="primary" onClick={() => impactOccurred(style)}>
impactOccurred
</Button>
</Form.Item>
<Form.Item label="type">
<Select value={type} onChange={value => setType(value)}>
<Select.Option value="error">error</Select.Option>
<Select.Option value="success">success</Select.Option>
<Select.Option value="warning">warning</Select.Option>
</Select>
</Form.Item>
<Form.Item>
<Button
block
type="primary"
onClick={() => notificationOccurred(type)}
>
notificationOccurred
</Button>
</Form.Item>
<Form.Item>
<Button block type="primary" onClick={() => selectionChanged()}>
selectionChanged
</Button>
</Form.Item>
</Form>
</>
);
};
export default HapticFeedbackDemo;