Skip to content

Commit a590f96

Browse files
committed
chore: release v2.0.7
1 parent d321a4a commit a590f96

File tree

11 files changed

+322
-126
lines changed

11 files changed

+322
-126
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [2.0.7](https://github.com/geekdada/yasd/compare/v2.0.6...v2.0.7) (2024-09-21)
2+
3+
4+
15
## [2.0.6](https://github.com/geekdada/yasd/compare/v2.0.5...v2.0.6) (2024-09-08)
26

37

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yasd",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"private": true,
55
"type": "module",
66
"license": "MIT",
@@ -151,7 +151,9 @@
151151
"twin.macro": "^3.4.0",
152152
"typescript": "^5.1.6",
153153
"use-is-in-viewport": "^1.0.9",
154+
"usehooks-ts": "^3.1.0",
154155
"uuid": "^9.0.0",
156+
"vaul": "^0.9.4",
155157
"zod": "^3.21.4",
156158
"zx": "~7.2.3"
157159
},

src/components/ActionsModal.tsx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import { useTranslation } from 'react-i18next'
3+
import { useMediaQuery } from 'usehooks-ts'
34

45
import { Button } from '@/components/ui/button'
56
import {
@@ -8,6 +9,15 @@ import {
89
DialogHeader,
910
DialogTitle,
1011
} from '@/components/ui/dialog'
12+
import {
13+
Drawer,
14+
DrawerClose,
15+
DrawerContent,
16+
DrawerFooter,
17+
DrawerHeader,
18+
DrawerTitle,
19+
} from '@/components/ui/drawer'
20+
import { BottomSafeArea } from '@/components/VerticalSafeArea'
1121

1222
export type Action = {
1323
id: number | string
@@ -26,23 +36,49 @@ const ActionsModal = ({
2636
...props
2737
}: ActionsModalProps): JSX.Element => {
2838
const { t } = useTranslation()
39+
const isDesktop = useMediaQuery('(min-width: 768px)')
2940

30-
return (
31-
<Dialog {...props}>
32-
<DialogContent>
33-
<DialogHeader>
34-
<DialogTitle>{title}</DialogTitle>
35-
</DialogHeader>
41+
if (isDesktop) {
42+
return (
43+
<Dialog {...props}>
44+
<DialogContent>
45+
<DialogHeader>
46+
<DialogTitle>{title}</DialogTitle>
47+
</DialogHeader>
48+
49+
<div className="space-y-5">
50+
{actions.map((action) => (
51+
<Button stretch key={action.id} onClick={action.onClick}>
52+
{t(action.title)}
53+
</Button>
54+
))}
55+
</div>
56+
</DialogContent>
57+
</Dialog>
58+
)
59+
}
3660

37-
<div className="space-y-5">
61+
return (
62+
<Drawer {...props}>
63+
<DrawerContent className="select-none">
64+
<DrawerHeader>
65+
<DrawerTitle>{title}</DrawerTitle>
66+
</DrawerHeader>
67+
<DrawerFooter>
3868
{actions.map((action) => (
3969
<Button stretch key={action.id} onClick={action.onClick}>
4070
{t(action.title)}
4171
</Button>
4272
))}
43-
</div>
44-
</DialogContent>
45-
</Dialog>
73+
<DrawerClose>
74+
<Button className="w-full" variant="outline">
75+
{t('common.close')}
76+
</Button>
77+
</DrawerClose>
78+
</DrawerFooter>
79+
<BottomSafeArea />
80+
</DrawerContent>
81+
</Drawer>
4682
)
4783
}
4884

src/components/BackButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BackButton = ({ title }: { title?: string }) => {
88
const navigate = useNavigate()
99

1010
return (
11-
<div className="space-x-4">
11+
<div className="space-x-4 select-none">
1212
<Button
1313
variant="outline"
1414
onClick={() => navigate(-1)}

src/components/VerticalSafeArea.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const BottomSafeArea = () => {
66
<div
77
className="flex flex-1 sm:hidden"
88
css={css`
9-
height: env(safe-area-inset-bottom, 0px);
9+
height: 0;
10+
padding-bottom: env(safe-area-inset-bottom, 0px);
1011
`}
1112
></div>
1213
)

src/components/ui/drawer.tsx

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import * as React from 'react'
2+
import { Drawer as DrawerPrimitive } from 'vaul'
3+
4+
import { cn } from '@/utils/shadcn'
5+
6+
const Drawer = ({
7+
shouldScaleBackground = true,
8+
...props
9+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
10+
<DrawerPrimitive.Root
11+
shouldScaleBackground={shouldScaleBackground}
12+
{...props}
13+
/>
14+
)
15+
Drawer.displayName = 'Drawer'
16+
17+
const DrawerTrigger = DrawerPrimitive.Trigger
18+
19+
const DrawerPortal = DrawerPrimitive.Portal
20+
21+
const DrawerClose = DrawerPrimitive.Close
22+
23+
const DrawerOverlay = React.forwardRef<
24+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
25+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
26+
>(({ className, ...props }, ref) => (
27+
<DrawerPrimitive.Overlay
28+
ref={ref}
29+
className={cn('fixed inset-0 z-50 bg-black/80', className)}
30+
{...props}
31+
/>
32+
))
33+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName
34+
35+
const DrawerContent = React.forwardRef<
36+
React.ElementRef<typeof DrawerPrimitive.Content>,
37+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
38+
>(({ className, children, ...props }, ref) => (
39+
<DrawerPortal>
40+
<DrawerOverlay />
41+
<DrawerPrimitive.Content
42+
ref={ref}
43+
className={cn(
44+
'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background',
45+
className,
46+
)}
47+
{...props}
48+
>
49+
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
50+
{children}
51+
</DrawerPrimitive.Content>
52+
</DrawerPortal>
53+
))
54+
DrawerContent.displayName = 'DrawerContent'
55+
56+
const DrawerHeader = ({
57+
className,
58+
...props
59+
}: React.HTMLAttributes<HTMLDivElement>) => (
60+
<div
61+
className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)}
62+
{...props}
63+
/>
64+
)
65+
DrawerHeader.displayName = 'DrawerHeader'
66+
67+
const DrawerFooter = ({
68+
className,
69+
...props
70+
}: React.HTMLAttributes<HTMLDivElement>) => (
71+
<div
72+
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
73+
{...props}
74+
/>
75+
)
76+
DrawerFooter.displayName = 'DrawerFooter'
77+
78+
const DrawerTitle = React.forwardRef<
79+
React.ElementRef<typeof DrawerPrimitive.Title>,
80+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
81+
>(({ className, ...props }, ref) => (
82+
<DrawerPrimitive.Title
83+
ref={ref}
84+
className={cn(
85+
'text-lg font-semibold leading-none tracking-tight',
86+
className,
87+
)}
88+
{...props}
89+
/>
90+
))
91+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName
92+
93+
const DrawerDescription = React.forwardRef<
94+
React.ElementRef<typeof DrawerPrimitive.Description>,
95+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
96+
>(({ className, ...props }, ref) => (
97+
<DrawerPrimitive.Description
98+
ref={ref}
99+
className={cn('text-sm text-muted-foreground', className)}
100+
{...props}
101+
/>
102+
))
103+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName
104+
105+
export {
106+
Drawer,
107+
DrawerPortal,
108+
DrawerOverlay,
109+
DrawerTrigger,
110+
DrawerClose,
111+
DrawerContent,
112+
DrawerHeader,
113+
DrawerFooter,
114+
DrawerTitle,
115+
DrawerDescription,
116+
}

src/i18n/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"sw_updated": "Surge Web Dashboard has been updated, refresh page to use the new version.",
2121
"refresh": "Refresh",
2222
"confirm": "Confirm",
23-
"cancel": "Cancel"
23+
"cancel": "Cancel",
24+
"close": "Close"
2425
},
2526
"tls_instruction": {
2627
"title": "Needed a certificate?",

src/i18n/zh/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"sw_updated": "Surge Web Dashboard 已更新,刷新页面以使用新版本。",
2121
"refresh": "刷新",
2222
"confirm": "确认",
23-
"cancel": "取消"
23+
"cancel": "取消",
24+
"close": "关闭"
2425
},
2526
"tls_instruction": {
2627
"title": "需要证书吗?",

0 commit comments

Comments
 (0)