-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add share dialog * refactor: Fix folder structures * fix: Fix tag error * fix: Fix console error * feat: Add copy url and toast * feat: Add checking postposition
- Loading branch information
1 parent
7c06735
commit fe504b3
Showing
29 changed files
with
180 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import Image from 'next/image'; | ||
import { useCallback } from 'react'; | ||
import { toast } from 'sonner'; | ||
import logo from '@public/assets/logo.svg'; | ||
import snow from '@public/assets/snow.png'; | ||
import share1 from '@public/shares/share_01.png'; | ||
import share2 from '@public/shares/share_02.png'; | ||
import share3 from '@public/shares/share_03.png'; | ||
import share4 from '@public/shares/share_04.png'; | ||
import { CloseIcon } from '@/shared/icons'; | ||
import { cn, getPostposition } from '@/shared/lib'; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogDescription, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from '@/shared/ui/dialog'; | ||
|
||
interface ShareDialogProps { | ||
trigger: React.ReactNode; | ||
name?: string; | ||
} | ||
|
||
const ShareDialog = ({ trigger, name }: ShareDialogProps) => { | ||
const handleCopyUrl = useCallback(() => { | ||
const currentUrl = window.location.href; | ||
navigator.clipboard | ||
.writeText(currentUrl) | ||
.then(() => { | ||
toast('클립보드에 복사되었습니다'); | ||
}) | ||
.catch((error) => { | ||
console.error('클립보드 복사 실패!', error); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger>{trigger}</DialogTrigger> | ||
|
||
<DialogContent | ||
className={cn( | ||
'w-[321px] gap-0 overflow-hidden rounded-[7px] bg-white px-[30px] pb-[30px] pt-[27px]' | ||
)} | ||
> | ||
<DialogTitle className={cn('hidden')} /> | ||
<DialogDescription className={cn('hidden')} /> | ||
<Image | ||
src={snow} | ||
alt="snow" | ||
className={cn('absolute right-[-41px] top-0 h-[196px] w-[191px]')} | ||
/> | ||
<DialogClose> | ||
<CloseIcon className={cn('absolute right-6 top-6 size-6 cursor-pointer text-gray-50')} /> | ||
</DialogClose> | ||
<Image src={logo} alt="logo" /> | ||
<div className={cn('h3-semibold mb-[31px] mt-[38px] flex h-16 flex-col justify-evenly')}> | ||
<p>{getPostposition(name || '')}</p> | ||
<p>공유해보세요!</p> | ||
</div> | ||
<div className={cn('body3-medium z-10 flex justify-between gap-3 text-gray-70')}> | ||
<div className={cn('flex flex-col items-center gap-[6px]')}> | ||
<button> | ||
<Image src={share1} alt="kakao-talk" width={46} height={46} /> | ||
</button> | ||
<p>카카오톡</p> | ||
</div> | ||
<div className={cn('flex flex-col items-center gap-[6px]')}> | ||
<button> | ||
<Image src={share2} alt="instagram" width={46} height={46} /> | ||
</button> | ||
<p>인스타그램</p> | ||
</div> | ||
<div className={cn('flex flex-col items-center gap-[6px]')}> | ||
<button> | ||
<Image src={share3} alt="thread" width={46} height={46} /> | ||
</button> | ||
<p>스레드</p> | ||
</div> | ||
<div className={cn('flex flex-col items-center gap-[6px]')}> | ||
<button onClick={handleCopyUrl}> | ||
<Image src={share4} alt="link" width={46} height={46} /> | ||
</button> | ||
<p>링크 공유</p> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default ShareDialog; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const getPostposition = (name: string) => { | ||
const charCode = name.charCodeAt(name.length - 1); | ||
|
||
const consonantCode = (charCode - 44032) % 28; | ||
|
||
if (consonantCode === 0) { | ||
return `${name}를`; | ||
} | ||
return `${name}을`; | ||
}; | ||
|
||
export default getPostposition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as cn } from '@/shared/lib/cn'; | ||
export { default as getBoundedPositions } from '@/shared/lib/getBoundedPositions'; | ||
export { default as getPostposition } from '@/shared/lib/getPostposition'; | ||
export type { ExcludeArray } from '@/shared/lib/util.d.ts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client'; | ||
|
||
import { useTheme } from 'next-themes'; | ||
import { Toaster as Sonner } from 'sonner'; | ||
|
||
type ToasterProps = React.ComponentProps<typeof Sonner>; | ||
|
||
const Toaster = ({ ...props }: ToasterProps) => { | ||
const { theme = 'system' } = useTheme(); | ||
|
||
return ( | ||
<Sonner | ||
theme={theme as ToasterProps['theme']} | ||
className="toaster group" | ||
toastOptions={{ | ||
classNames: { | ||
toast: | ||
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg', | ||
description: 'group-[.toast]:text-muted-foreground', | ||
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground', | ||
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground', | ||
}, | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export { Toaster }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2337,6 +2337,11 @@ natural-compare@^1.4.0: | |
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" | ||
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== | ||
|
||
next-themes@^0.3.0: | ||
version "0.3.0" | ||
resolved "https://registry.yarnpkg.com/next-themes/-/next-themes-0.3.0.tgz#b4d2a866137a67d42564b07f3a3e720e2ff3871a" | ||
integrity sha512-/QHIrsYpd6Kfk7xakK4svpDI5mmXP0gfvCoJdGpZQ2TOrQZmsW0QxjaiLn8wbIKjtm4BTSqLoix4lxYYOnLJ/w== | ||
|
||
[email protected]: | ||
version "14.2.5" | ||
resolved "https://registry.yarnpkg.com/next/-/next-14.2.5.tgz#afe4022bb0b752962e2205836587a289270efbea" | ||
|
@@ -2878,6 +2883,11 @@ slash@^3.0.0: | |
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" | ||
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== | ||
|
||
sonner@^1.5.0: | ||
version "1.5.0" | ||
resolved "https://registry.yarnpkg.com/sonner/-/sonner-1.5.0.tgz#af359f817063318415326b33aab54c5d17c747b7" | ||
integrity sha512-FBjhG/gnnbN6FY0jaNnqZOMmB73R+5IiyYAw8yBj7L54ER7HB3fOSE5OFiQiE2iXWxeXKvg6fIP4LtVppHEdJA== | ||
|
||
source-map-js@^1.0.2, source-map-js@^1.2.0: | ||
version "1.2.0" | ||
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" | ||
|