From a1f0f43992616dafcb2305be5f265bafcf7c2a2a Mon Sep 17 00:00:00 2001 From: Kunal Vishwakarma <116634168+kunalv17@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:54:26 +0530 Subject: [PATCH] feat: icon picker (#689) * feat: icon picker * style: icon picker modal --------- Co-authored-by: Dakshesh Jain --- .../components/emoji-icon-picker/icons.json | 607 ++++++++++++++++++ .../components/emoji-icon-picker/index.tsx | 128 +++- .../components/emoji-icon-picker/types.d.ts | 2 + apps/app/styles/globals.css | 5 + 4 files changed, 720 insertions(+), 22 deletions(-) create mode 100644 apps/app/components/emoji-icon-picker/icons.json diff --git a/apps/app/components/emoji-icon-picker/icons.json b/apps/app/components/emoji-icon-picker/icons.json new file mode 100644 index 000000000..f844f22d4 --- /dev/null +++ b/apps/app/components/emoji-icon-picker/icons.json @@ -0,0 +1,607 @@ +{ + "material_rounded": [ + { + "name": "search" + }, + { + "name": "home" + }, + { + "name": "menu" + }, + { + "name": "close" + }, + { + "name": "settings" + }, + { + "name": "done" + }, + { + "name": "check_circle" + }, + { + "name": "favorite" + }, + { + "name": "add" + }, + { + "name": "delete" + }, + { + "name": "arrow_back" + }, + { + "name": "star" + }, + { + "name": "logout" + }, + { + "name": "add_circle" + }, + { + "name": "cancel" + }, + { + "name": "arrow_drop_down" + }, + { + "name": "more_vert" + }, + { + "name": "check" + }, + { + "name": "check_box" + }, + { + "name": "toggle_on" + }, + { + "name": "open_in_new" + }, + { + "name": "refresh" + }, + { + "name": "login" + }, + { + "name": "radio_button_unchecked" + }, + { + "name": "more_horiz" + }, + { + "name": "apps" + }, + { + "name": "radio_button_checked" + }, + { + "name": "download" + }, + { + "name": "remove" + }, + { + "name": "toggle_off" + }, + { + "name": "bolt" + }, + { + "name": "arrow_upward" + }, + { + "name": "filter_list" + }, + { + "name": "delete_forever" + }, + { + "name": "autorenew" + }, + { + "name": "key" + }, + { + "name": "sort" + }, + { + "name": "sync" + }, + { + "name": "add_box" + }, + { + "name": "block" + }, + { + "name": "restart_alt" + }, + { + "name": "menu_open" + }, + { + "name": "shopping_cart_checkout" + }, + { + "name": "expand_circle_down" + }, + { + "name": "backspace" + }, + { + "name": "undo" + }, + { + "name": "done_all" + }, + { + "name": "do_not_disturb_on" + }, + { + "name": "open_in_full" + }, + { + "name": "double_arrow" + }, + { + "name": "sync_alt" + }, + { + "name": "zoom_in" + }, + { + "name": "done_outline" + }, + { + "name": "drag_indicator" + }, + { + "name": "fullscreen" + }, + { + "name": "star_half" + }, + { + "name": "settings_accessibility" + }, + { + "name": "reply" + }, + { + "name": "exit_to_app" + }, + { + "name": "unfold_more" + }, + { + "name": "library_add" + }, + { + "name": "cached" + }, + { + "name": "select_check_box" + }, + { + "name": "terminal" + }, + { + "name": "change_circle" + }, + { + "name": "disabled_by_default" + }, + { + "name": "swap_horiz" + }, + { + "name": "swap_vert" + }, + { + "name": "app_registration" + }, + { + "name": "download_for_offline" + }, + { + "name": "close_fullscreen" + }, + { + "name": "file_open" + }, + { + "name": "minimize" + }, + { + "name": "open_with" + }, + { + "name": "dataset" + }, + { + "name": "add_task" + }, + { + "name": "start" + }, + { + "name": "keyboard_voice" + }, + { + "name": "create_new_folder" + }, + { + "name": "forward" + }, + { + "name": "download" + }, + { + "name": "settings_applications" + }, + { + "name": "compare_arrows" + }, + { + "name": "redo" + }, + { + "name": "zoom_out" + }, + { + "name": "publish" + }, + { + "name": "html" + }, + { + "name": "token" + }, + { + "name": "switch_access_shortcut" + }, + { + "name": "fullscreen_exit" + }, + { + "name": "sort_by_alpha" + }, + { + "name": "delete_sweep" + }, + { + "name": "indeterminate_check_box" + }, + { + "name": "view_timeline" + }, + { + "name": "settings_backup_restore" + }, + { + "name": "arrow_drop_down_circle" + }, + { + "name": "assistant_navigation" + }, + { + "name": "sync_problem" + }, + { + "name": "clear_all" + }, + { + "name": "density_medium" + }, + { + "name": "heart_plus" + }, + { + "name": "filter_alt_off" + }, + { + "name": "expand" + }, + { + "name": "subdirectory_arrow_right" + }, + { + "name": "download_done" + }, + { + "name": "arrow_outward" + }, + { + "name": "123" + }, + { + "name": "swipe_left" + }, + { + "name": "auto_mode" + }, + { + "name": "saved_search" + }, + { + "name": "place_item" + }, + { + "name": "system_update_alt" + }, + { + "name": "javascript" + }, + { + "name": "search_off" + }, + { + "name": "output" + }, + { + "name": "select_all" + }, + { + "name": "fit_screen" + }, + { + "name": "swipe_up" + }, + { + "name": "dynamic_form" + }, + { + "name": "hide_source" + }, + { + "name": "swipe_right" + }, + { + "name": "switch_access_shortcut_add" + }, + { + "name": "browse_gallery" + }, + { + "name": "css" + }, + { + "name": "density_small" + }, + { + "name": "assistant_direction" + }, + { + "name": "check_small" + }, + { + "name": "youtube_searched_for" + }, + { + "name": "move_up" + }, + { + "name": "swap_horizontal_circle" + }, + { + "name": "data_thresholding" + }, + { + "name": "install_mobile" + }, + { + "name": "move_down" + }, + { + "name": "dataset_linked" + }, + { + "name": "keyboard_command_key" + }, + { + "name": "view_kanban" + }, + { + "name": "swipe_down" + }, + { + "name": "key_off" + }, + { + "name": "transcribe" + }, + { + "name": "send_time_extension" + }, + { + "name": "swipe_down_alt" + }, + { + "name": "swipe_left_alt" + }, + { + "name": "swipe_right_alt" + }, + { + "name": "swipe_up_alt" + }, + { + "name": "keyboard_option_key" + }, + { + "name": "cycle" + }, + { + "name": "rebase" + }, + { + "name": "rebase_edit" + }, + { + "name": "empty_dashboard" + }, + { + "name": "magic_exchange" + }, + { + "name": "acute" + }, + { + "name": "point_scan" + }, + { + "name": "step_into" + }, + { + "name": "cheer" + }, + { + "name": "emoticon" + }, + { + "name": "explosion" + }, + { + "name": "water_bottle" + }, + { + "name": "weather_hail" + }, + { + "name": "syringe" + }, + { + "name": "pill" + }, + { + "name": "genetics" + }, + { + "name": "allergy" + }, + { + "name": "medical_mask" + }, + { + "name": "body_fat" + }, + { + "name": "barefoot" + }, + { + "name": "infrared" + }, + { + "name": "wrist" + }, + { + "name": "metabolism" + }, + { + "name": "conditions" + }, + { + "name": "taunt" + }, + { + "name": "altitude" + }, + { + "name": "tibia" + }, + { + "name": "footprint" + }, + { + "name": "eyeglasses" + }, + { + "name": "man_3" + }, + { + "name": "woman_2" + }, + { + "name": "rheumatology" + }, + { + "name": "tornado" + }, + { + "name": "landslide" + }, + { + "name": "foggy" + }, + { + "name": "severe_cold" + }, + { + "name": "tsunami" + }, + { + "name": "vape_free" + }, + { + "name": "sign_language" + }, + { + "name": "emoji_symbols" + }, + { + "name": "clear_night" + }, + { + "name": "emoji_food_beverage" + }, + { + "name": "hive" + }, + { + "name": "thunderstorm" + }, + { + "name": "communication" + }, + { + "name": "rocket" + }, + { + "name": "pets" + }, + { + "name": "public" + }, + { + "name": "quiz" + }, + { + "name": "mood" + }, + { + "name": "gavel" + }, + { + "name": "eco" + }, + { + "name": "diamond" + }, + { + "name": "forest" + }, + { + "name": "rainy" + }, + { + "name": "skull" + } + ] +} diff --git a/apps/app/components/emoji-icon-picker/index.tsx b/apps/app/components/emoji-icon-picker/index.tsx index 69a2c45e7..e78af4c10 100644 --- a/apps/app/components/emoji-icon-picker/index.tsx +++ b/apps/app/components/emoji-icon-picker/index.tsx @@ -1,10 +1,13 @@ import React, { useEffect, useState, useRef } from "react"; // headless ui import { Tab, Transition, Popover } from "@headlessui/react"; +// react colors +import { TwitterPicker } from "react-color"; // types import { Props } from "./types"; // emojis import emojis from "./emojis.json"; +import icons from "./icons.json"; // helpers import { getRecentEmojis, saveRecentEmoji } from "./helpers"; import { getRandomEmoji } from "helpers/common.helper"; @@ -22,10 +25,18 @@ const tabOptions = [ }, ]; -const EmojiIconPicker: React.FC = ({ label, value, onChange }) => { +const EmojiIconPicker: React.FC = ({ + label, + value, + onChange, + onIconColorChange, + onIconsClick, +}) => { const ref = useRef(null); const [isOpen, setIsOpen] = useState(false); + const [openColorPicker, setOpenColorPicker] = useState(false); + const [activeColor, setActiveColor] = useState("#020617"); const [recentEmojis, setRecentEmojis] = useState([]); @@ -58,20 +69,25 @@ const EmojiIconPicker: React.FC = ({ label, value, onChange }) => { leaveFrom="transform opacity-100 scale-100" leaveTo="transform opacity-0 scale-95" > - -
+ +
- + {tabOptions.map((tab) => ( - - `-my-1 w-1/2 border-b py-2 text-center text-sm font-medium outline-none transition-colors ${ - selected ? "border-theme" : "border-transparent" - }` - } - > - {tab.title} + + {({ selected }) => ( + + )} ))} @@ -79,12 +95,12 @@ const EmojiIconPicker: React.FC = ({ label, value, onChange }) => { {recentEmojis.length > 0 && (
-

Recent Emojis

-
+ {/*

Recent Emojis

*/} +
{recentEmojis.map((emoji) => (
)} +
-

All Emojis

-
+ {/*

All Emojis

*/} +
{emojis.map((emoji) => (
- -

Coming Soon...

-
+
+
+
+ {[ + "#D687FF", + "#F7AE59", + "#FF6B00", + "#8CC1FF", + "#FCBE1D", + "#18904F", + "#ADF672", + "#05C3FF", + "#000000", + ].map((curCol) => ( + setActiveColor(curCol)} + /> + ))} + +
+
+ { + setActiveColor(color.hex); + if (onIconColorChange) onIconColorChange(color.hex); + }} + triangle="hide" + width="205px" + /> +
+
+
+ +
+ {icons.material_rounded.map((icon) => ( + + ))} +
+
+
diff --git a/apps/app/components/emoji-icon-picker/types.d.ts b/apps/app/components/emoji-icon-picker/types.d.ts index 2d3e26353..0162640f5 100644 --- a/apps/app/components/emoji-icon-picker/types.d.ts +++ b/apps/app/components/emoji-icon-picker/types.d.ts @@ -2,4 +2,6 @@ export type Props = { label: string | React.ReactNode; value: any; onChange: (data: any) => void; + onIconsClick?: (data: any) => void; + onIconColorChange?: (data: any) => void; }; diff --git a/apps/app/styles/globals.css b/apps/app/styles/globals.css index f4dd63e48..eeed87dd4 100644 --- a/apps/app/styles/globals.css +++ b/apps/app/styles/globals.css @@ -128,4 +128,9 @@ .react-datepicker-popper { z-index: 30 !important; } + +.conical-gradient{ + background: conic-gradient(from 180deg at 50% 50%, #FF6B00 0deg, #F7AE59 70.5deg, #3F76FF 151.12deg, #05C3FF 213deg, #18914F 289.87deg, #F6F172 329.25deg, #FF6B00 360deg); +} + /* end react datepicker styling */