From 9c2acfb6fc79e5b39d36c16a866f1fe486797fb7 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Thu, 2 Jun 2022 14:03:05 +0800 Subject: [PATCH] client: improve emoji-picker layout --- .../components/emoji-picker/index.module.scss | 2 + .../src/components/emoji-picker/index.tsx | 55 +++++++++++-------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/packages/client/src/components/emoji-picker/index.module.scss b/packages/client/src/components/emoji-picker/index.module.scss index 94a6dacd..c5b683f1 100644 --- a/packages/client/src/components/emoji-picker/index.module.scss +++ b/packages/client/src/components/emoji-picker/index.module.scss @@ -5,8 +5,10 @@ .listWrap { display: flex; + height: 250px; padding: 0; margin: 0; + overflow: auto; list-style: none; flex-wrap: wrap; diff --git a/packages/client/src/components/emoji-picker/index.tsx b/packages/client/src/components/emoji-picker/index.tsx index 4cad7e32..a62eeda9 100644 --- a/packages/client/src/components/emoji-picker/index.tsx +++ b/packages/client/src/components/emoji-picker/index.tsx @@ -1,4 +1,4 @@ -import { Button, Popover, SideSheet, Typography } from '@douyinfe/semi-ui'; +import { Button, Popover, SideSheet, TabPane, Tabs } from '@douyinfe/semi-ui'; import { createKeysLocalStorageLRUCache } from 'helpers/lru-cache'; import { IsOnMobile } from 'hooks/use-on-mobile'; import { useToggle } from 'hooks/use-toggle'; @@ -7,8 +7,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { ACTIVITIES, EXPRESSIONES, GESTURES, OBJECTS, SKY_WEATHER, SYMBOLS } from './constants'; import styles from './index.module.scss'; -const { Title } = Typography; - const emojiLocalStorageLRUCache = createKeysLocalStorageLRUCache('EMOJI_PICKER', 20); const LIST = [ @@ -39,10 +37,11 @@ const LIST = [ ]; interface IProps { + showClear?: boolean; onSelectEmoji: (arg: string) => void; } -export const EmojiPicker: React.FC = ({ onSelectEmoji, children }) => { +export const EmojiPicker: React.FC = ({ showClear = false, onSelectEmoji, children }) => { const { isMobile } = IsOnMobile.useHook(); const [recentUsed, setRecentUsed] = useState([]); const [visible, toggleVisible] = useToggle(false); @@ -67,26 +66,36 @@ export const EmojiPicker: React.FC = ({ onSelectEmoji, children }) => { const content = useMemo( () => (
- - {renderedList.map((item, index) => { - return ( -
- - {item.title} - -
    - {(item.data || []).map((ex) => ( -
  • selectEmoji(ex)}> - {ex} -
  • - ))} -
-
- ); - })} + + 清除 + + ) : null + } + collapsible + > + {renderedList.map((list) => { + return ( + +
    + {(list.data || []).map((ex) => ( +
  • selectEmoji(ex)}> + {ex} +
  • + ))} +
+
+ ); + })} +
), - [isMobile, renderedList, selectEmoji, clear] + [isMobile, showClear, renderedList, selectEmoji, clear] ); useEffect(() => { @@ -120,7 +129,7 @@ export const EmojiPicker: React.FC = ({ onSelectEmoji, children }) => { position="bottomLeft" visible={visible} onVisibleChange={toggleVisible} - content={
{content}
} + content={
{content}
} > {children}