diff --git a/app.css b/app.css index 9c6fbc4..7dccf02 100644 --- a/app.css +++ b/app.css @@ -88,4 +88,26 @@ html .dark * ::-webkit-scrollbar-track { button { outline: none !important; +} + +.emoji-selector-button { + width: 24px; + height: 24px; + display: inline-block; + background-image: url("https://unpkg.com/emoji-datasource-twitter@5.0.1/img/twitter/sheets-256/64.png"); + background-size: 5700% 5700%; + background-position: 53.5714% 62.5%; + filter: grayscale(100%); +} + +.emoji-selector-button:hover { + filter: grayscale(0%); + transform: scale(1.1, 1.1); + opacity: 90%; + transition: ease-in 100ms; + cursor: pointer; +} + +.emoji-mart-category-list > *, .emoji-mart-emoji > span { + cursor: pointer; } \ No newline at end of file diff --git a/components/Form/TextArea.tsx b/components/Form/TextArea.tsx index c8b2622..8b092bf 100644 --- a/components/Form/TextArea.tsx +++ b/components/Form/TextArea.tsx @@ -1,12 +1,67 @@ +/* eslint-disable jsx-a11y/no-autofocus */ +import { useRef, useState } from 'react' import { Field } from 'formik' +import { Picker } from 'emoji-mart' -const TextArea = ({ name, placeholder }:TextAreaProps):JSX.Element => { - return +import useOutsideClick from '@utils/useOutsideClick' + +import 'emoji-mart/css/emoji-mart.css' + + + +const TextArea = ({ name, placeholder, theme='auto', setValue, value }:TextAreaProps):JSX.Element => { + const ref = useRef() + const [ emojiPickerHidden, setEmojiPickerHidden ] = useState(true) + useOutsideClick(ref, () => { + setEmojiPickerHidden(true) + }) + + return
+ +
+
+ { + !emojiPickerHidden && { + setEmojiPickerHidden(true) + setValue(value + ((e as { native: string }).native || e.colons)) + }} i18n={{ + search: '검색', + notfound: '검색 결과가 없습니다.', + categories: { + search: '검색 결과', + recent: '최근 사용', + people: '사람', + nature: '자연', + foods: '음식', + activity: '활동', + places: '장소', + objects: '사물', + symbols: '기호', + flags: '국기', + custom: '커스텀' + } + }} custom={[{ + name: '한국 디스코드봇 리스트', + short_names: ['koreanbots', 'kbots', 'dbkr'], + emoticons: [], + keywords: ['koreanbots', '한국 디스코드봇 리스트', '한디리', 'kbots'], + imageUrl: '/logo.png' + }]}/> + } +
+
+
+
+
} interface TextAreaProps { name: string placeholder?: string + theme?: 'auto' | 'dark' | 'light' + value: string + setValue(value: string): void } export default TextArea diff --git a/pages/addbot.tsx b/pages/addbot.tsx index cdad9fc..5098017 100644 --- a/pages/addbot.tsx +++ b/pages/addbot.tsx @@ -1,5 +1,5 @@ import { NextPage, NextPageContext } from 'next' -import { useState } from 'react' +import { useRef, useState } from 'react' import { useRouter } from 'next/router' import dynamic from 'next/dynamic' import Link from 'next/link' @@ -9,9 +9,10 @@ import { get } from '@utils/Query' import { cleanObject, parseCookie, redirectTo } from '@utils/Tools' import { AddBotSubmit, AddBotSubmitSchema } from '@utils/Yup' import { categories, library } from '@utils/Constants' -import { ResponseProps, SubmittedBot, User } from '@types' +import { ResponseProps, SubmittedBot, Theme, User } from '@types' import { getToken } from '@utils/Csrf' import Fetch from '@utils/Fetch' +import useOutsideClick from '@utils/useOutsideClick' const CheckBox = dynamic(() => import('@components/Form/CheckBox')) const Label = dynamic(() => import('@components/Form/Label')) @@ -27,7 +28,7 @@ const Container = dynamic(() => import('@components/Container')) const Message = dynamic(() => import('@components/Message')) const SEO = dynamic(() => import('@components/SEO')) -const AddBot:NextPage = ({ logged, user, csrfToken }) => { +const AddBot:NextPage = ({ logged, user, csrfToken, theme }) => { const [ data, setData ] = useState>(null) const router = useRouter() function toLogin() { @@ -149,7 +150,7 @@ const AddBot:NextPage = ({ logged, user, csrfToken }) => {