-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
303 additions
and
3 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
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,106 @@ | ||
"use client"; | ||
|
||
import { PopoverArrow, PopoverClose } from "@radix-ui/react-popover"; | ||
import { LinkIcon } from "lucide-react"; | ||
import { toast } from "sonner"; | ||
import ElementWrapper from "~/components/editor/elements/element-wrapper"; | ||
import { useEditor } from "~/components/editor/provider"; | ||
import type { InferEditorElement } from "~/components/editor/type"; | ||
import { KakaoIcon, ShareIcon } from "~/components/ui/icons"; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "~/components/ui/popover"; | ||
|
||
type Props = { | ||
element: InferEditorElement<"share">; | ||
}; | ||
|
||
export default function ShareElement({ element }: Props) { | ||
const { editor } = useEditor(); | ||
|
||
const handleCopyLink = async () => { | ||
const link = `https://${editor.config.invitationSubdomain}.invi.my`; | ||
|
||
try { | ||
await navigator.clipboard.writeText(link); | ||
toast("๋งํฌ๊ฐ ๋ณต์ฌ๋์์ต๋๋ค.", { | ||
description: link, | ||
position: "top-center", | ||
duration: 2000, | ||
style: { | ||
backgroundColor: "black", | ||
opacity: 0.9, | ||
height: "56px", | ||
color: "white", | ||
border: 0, | ||
}, | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
toast.error("๋งํฌ ๋ณต์ฌ์ ์คํจํ์ต๋๋ค."); | ||
} | ||
}; | ||
|
||
const handleKakaoShare = () => { | ||
// ์นด์นด์ค ์ ์ฑ ์ ์๋ธ๋๋ฉ์ธ์ ์ฌ์ฉํ ์ ์์ | ||
const link = `https://invi.my/i/${editor.config.invitationSubdomain}`; | ||
|
||
window.Kakao.Share.sendDefault({ | ||
objectType: "feed", | ||
content: { | ||
imageUrl: editor.config.invitationThumbnail, | ||
imageWidth: 600, | ||
imageHeight: 450, | ||
title: editor.config.invitationTitle, | ||
description: editor.config.invitationDesc, | ||
link: { | ||
mobileWebUrl: link, | ||
webUrl: link, | ||
}, | ||
}, | ||
buttons: [ | ||
{ | ||
title: "์ด๋์ฅ ์ด๊ธฐ", | ||
link: { | ||
mobileWebUrl: link, | ||
webUrl: link, | ||
}, | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
return ( | ||
<ElementWrapper | ||
element={element} | ||
className="flex items-center justify-center" | ||
> | ||
<Popover> | ||
<PopoverTrigger className=""> | ||
<ShareIcon className="size-6" /> | ||
</PopoverTrigger> | ||
<PopoverContent sideOffset={5} className="w-auto border-none p-2"> | ||
<PopoverClose | ||
className="flex w-full items-center gap-2 rounded-lg p-2 text-xs transition-colors focus:outline-none active:bg-gray-100" | ||
onClick={handleCopyLink} | ||
> | ||
<div className="flex h-4 w-4 items-center justify-center"> | ||
<LinkIcon /> | ||
</div> | ||
๋งํฌ ๋ณต์ฌํ๊ธฐ | ||
</PopoverClose> | ||
<PopoverClose | ||
onClick={handleKakaoShare} | ||
className="flex w-full items-center gap-2 rounded-lg p-2 text-xs transition-colors focus:outline-none active:bg-gray-100" | ||
> | ||
<KakaoIcon className="h-4 w-4" /> | ||
<span>๊ณต์ ํ๊ธฐ</span> | ||
</PopoverClose> | ||
<PopoverArrow className="fill-white" /> | ||
</PopoverContent> | ||
</Popover> | ||
</ElementWrapper> | ||
); | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/components/editor/sidebar/sidebar-element-settings-tab/share-setting.tsx
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,52 @@ | ||
"use client"; | ||
|
||
import { HeightIcon } from "@radix-ui/react-icons"; | ||
import { useEditor } from "~/components/editor/provider"; | ||
import { EditorInput } from "~/components/editor/ui/input"; | ||
|
||
export default function ShareSetting() { | ||
const { editor, dispatch } = useEditor(); | ||
const element = editor.state.selectedElement; | ||
|
||
return ( | ||
<div className="space-y-1 border-t p-6 pt-4"> | ||
<div className="flex h-10 items-center"> | ||
<h4 className="text-sm font-medium">๋ ์ด์์ ์ค์ </h4> | ||
</div> | ||
|
||
<div className="grid w-full grid-cols-9 gap-1"> | ||
<div className="col-span-4"> | ||
<EditorInput | ||
id="height_input" | ||
defaultValue={element.styles.height} | ||
onDebounceChange={(e) => | ||
dispatch({ | ||
type: "UPDATE_ELEMENT_STYLE", | ||
payload: { height: e.target.value }, | ||
}) | ||
} | ||
componentPrefix={<HeightIcon />} | ||
/> | ||
</div> | ||
<div className="col-span-4"> | ||
<EditorInput | ||
id="color" | ||
defaultValue={element.styles.color ?? "transparent"} | ||
onDebounceChange={(e) => { | ||
dispatch({ | ||
type: "UPDATE_ELEMENT_STYLE", | ||
payload: { color: e.target.value }, | ||
}); | ||
}} | ||
componentPrefix={ | ||
<div | ||
className="h-3.5 w-3.5 rounded ring-1 ring-border" | ||
style={{ backgroundColor: element.styles.color }} | ||
/> | ||
} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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,27 @@ | ||
"use client"; | ||
|
||
import Script from "next/script"; | ||
import { env } from "~/lib/env"; | ||
|
||
export default function KakaoShareScript() { | ||
const kakaoInit = () => { | ||
try { | ||
if (!window.Kakao.isInitialized()) { | ||
window.Kakao.init(env.NEXT_PUBLIC_KAKAO_JS_KEY); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Script | ||
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.2/kakao.min.js" | ||
integrity="sha384-TiCUE00h649CAMonG018J2ujOgDKW/kVWlChEuu4jK2vxfAAD0eZxzCKakxg55G4" | ||
crossOrigin="anonymous" | ||
onLoad={kakaoInit} | ||
/> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.