-
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.
* refactor: placeholder style * feat: add accordion style * feat: accordion element * feat: accordion setting * cleanup * �feat: OG 이미지 설정 (#79) * feat: update thumbnail * feat: apply og image * feat: add layout thumbnail * feat: 템플릿의 썸네일이 초기 적용되도록 * feat: 로딩 (#80) * chore: InView with framer-motion * feat: add loading layout * feat: text-effect * feat: global loading * feat: delay create invitation * feat: 저장 중 로딩 * feat: 삭제 토스트 추가 * feat: 저장 버튼 평소 활성화 * �feat: OG 이미지 설정 (#79) * feat: update thumbnail * feat: apply og image * feat: add layout thumbnail * feat: 템플릿의 썸네일이 초기 적용되도록
- Loading branch information
Showing
8 changed files
with
226 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
|
||
import { AnimatePresence, motion } from "framer-motion"; | ||
import { ChevronDownIcon } from "lucide-react"; | ||
import { useState } from "react"; | ||
import ElementWrapper from "~/components/editor/elements/element-wrapper"; | ||
import Text from "~/components/editor/elements/text"; | ||
import { useEditor } from "~/components/editor/provider"; | ||
import type { InferEditorElement } from "~/components/editor/type"; | ||
|
||
export default function AccordionElement({ | ||
element, | ||
}: { | ||
element: InferEditorElement<"accordion">; | ||
}) { | ||
const { editor } = useEditor(); | ||
const [isOpen, setIsOpen] = useState( | ||
editor.state.isPreviewMode ? false : true, | ||
); | ||
|
||
return ( | ||
<ElementWrapper element={element}> | ||
<div | ||
className="overflow-hidden rounded-[20px] bg-muted pb-3" | ||
style={element.content.containerStyle} | ||
> | ||
<button | ||
data-state={isOpen ? "open" : "closed"} | ||
className="flex w-full select-none items-center justify-between p-6 pb-3 text-xl font-semibold [&[data-state=open]>svg]:rotate-180" | ||
style={element.content.triggerStyle} | ||
onClick={() => editor.state.isPreviewMode && setIsOpen(!isOpen)} | ||
> | ||
{element.content.triggerText ?? "제목"} | ||
<ChevronDownIcon className="h-6 w-6 shrink-0 transition-transform duration-200" /> | ||
</button> | ||
<AnimatePresence> | ||
{isOpen && ( | ||
<motion.div | ||
initial={{ height: 0 }} | ||
animate={{ height: "auto" }} | ||
transition={{ duration: 0.2, ease: "easeOut" }} | ||
exit={{ height: 0 }} | ||
style={element.content.contentStyle} | ||
className="overflow-hidden text-sm" | ||
> | ||
<div className="px-6 py-3"> | ||
<Text element={element.content.text} /> | ||
</div> | ||
</motion.div> | ||
)} | ||
</AnimatePresence> | ||
</div> | ||
</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
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
102 changes: 102 additions & 0 deletions
102
src/components/editor/sidebar/sidebar-element-settings-tab/accordion-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,102 @@ | ||
"use client"; | ||
|
||
import { useEditor } from "~/components/editor/provider"; | ||
import type { InferEditorElement } from "~/components/editor/type"; | ||
import { EditorInput } from "~/components/editor/ui/input"; | ||
|
||
export default function AccordionSetting() { | ||
const { editor, dispatch } = useEditor(); | ||
const element = editor.state | ||
.selectedElement as InferEditorElement<"accordion">; | ||
|
||
const update = ( | ||
content: Partial<InferEditorElement<"accordion">["content"]>, | ||
) => { | ||
dispatch({ | ||
type: "UPDATE_ELEMENT", | ||
payload: { | ||
elementDetails: { | ||
...element, | ||
content: { | ||
...element.content, | ||
...content, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="w-full grid-cols-9 gap-1 gap-y-2 border-t p-6"> | ||
<div> | ||
<EditorInput | ||
id="triggerText" | ||
defaultValue={element.content.triggerText} | ||
onDebounceChange={(e) => { | ||
if (!e.target.value) { | ||
return; | ||
} | ||
|
||
update({ | ||
triggerText: e.target.value, | ||
}); | ||
}} | ||
componentPrefix={<span className="text-xs">제목</span>} | ||
/> | ||
</div> | ||
<div className="col-span-9"> | ||
<EditorInput | ||
id="triggerColor" | ||
defaultValue={element.content.triggerStyle?.color ?? "inherit"} | ||
onDebounceChange={(e) => { | ||
update({ | ||
triggerStyle: { | ||
...element.content.triggerStyle, | ||
color: e.target.value, | ||
}, | ||
}); | ||
}} | ||
componentPrefix={ | ||
<div className="flex items-center gap-2"> | ||
<span className="text-xs">제목 색상</span> | ||
<div | ||
className="h-3.5 w-3.5 rounded ring-1 ring-border" | ||
style={{ | ||
backgroundColor: element.content.triggerStyle?.color, | ||
}} | ||
/> | ||
</div> | ||
} | ||
/> | ||
</div> | ||
<div className="col-span-9"> | ||
<EditorInput | ||
id="containerBackgroundColor" | ||
defaultValue={ | ||
element.content.containerStyle?.backgroundColor ?? "transparent" | ||
} | ||
onDebounceChange={(e) => { | ||
update({ | ||
containerStyle: { | ||
...element.content.containerStyle, | ||
backgroundColor: e.target.value, | ||
}, | ||
}); | ||
}} | ||
componentPrefix={ | ||
<div className="flex items-center gap-2"> | ||
<span className="text-xs">배경 색상</span> | ||
<div | ||
className="h-3.5 w-3.5 rounded ring-1 ring-border" | ||
style={{ | ||
backgroundColor: | ||
element.content.containerStyle?.backgroundColor, | ||
}} | ||
/> | ||
</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