diff --git a/examples/vite/src/App.tsx b/examples/vite/src/App.tsx index a278ff314..215d7d0a1 100644 --- a/examples/vite/src/App.tsx +++ b/examples/vite/src/App.tsx @@ -200,7 +200,7 @@ const App = () => { { +export const AppSettings = ({ iconOnly = true }: { iconOnly?: boolean }) => { const [activeTab, setActiveTab] = useState('sidebar'); const [open, setOpen] = useState(false); return (
setOpen(true)} - showLabel={showLabels} text='Settings' /> setOpen(false)}> diff --git a/examples/vite/src/AppSettings/state.ts b/examples/vite/src/AppSettings/state.ts index cc03dfc41..f8b382e67 100644 --- a/examples/vite/src/AppSettings/state.ts +++ b/examples/vite/src/AppSettings/state.ts @@ -8,7 +8,7 @@ export type ReactionsSettingsState = { }; export type ChatViewSettingsState = { - showLabels: boolean; + iconOnly: boolean; }; export type AppSettingsState = { @@ -18,7 +18,7 @@ export type AppSettingsState = { const defaultAppSettingsState: AppSettingsState = { chatView: { - showLabels: false, + iconOnly: true, }, reactions: { flipHorizontalPosition: false, diff --git a/examples/vite/src/AppSettings/tabs/Sidebar/SidebarTab.tsx b/examples/vite/src/AppSettings/tabs/Sidebar/SidebarTab.tsx index fb60cf282..62b793a3c 100644 --- a/examples/vite/src/AppSettings/tabs/Sidebar/SidebarTab.tsx +++ b/examples/vite/src/AppSettings/tabs/Sidebar/SidebarTab.tsx @@ -4,7 +4,7 @@ import { appSettingsStore, useAppSettingsState } from '../../state'; export const SidebarTab = () => { const { chatView, - chatView: { showLabels }, + chatView: { iconOnly }, } = useAppSettingsState(); return ( @@ -13,22 +13,22 @@ export const SidebarTab = () => {
Label visibility
@@ -221,11 +221,11 @@ const unreadThreadCountSelector = ({ unreadThreadCount }: ThreadManagerState) => }); export type ChatViewSelectorItemProps = { - showLabels?: boolean; + iconOnly?: boolean; }; export const ChatViewChannelsSelectorButton = ({ - showLabels = false, + iconOnly = true, }: ChatViewSelectorItemProps) => { const { activeChatView, setActiveChatView } = useChatViewContext(); const { t } = useTranslationContext(); @@ -235,16 +235,16 @@ export const ChatViewChannelsSelectorButton = ({ ActiveIcon={IconBubble3Solid} aria-selected={activeChatView === 'channels'} Icon={IconBubble3ChatMessage} + iconOnly={iconOnly} isActive={activeChatView === 'channels'} onPointerDown={() => setActiveChatView('channels')} - showLabel={showLabels} text={t('Channels')} /> ); }; export const ChatViewThreadsSelectorButton = ({ - showLabels = false, + iconOnly = true, }: ChatViewSelectorItemProps) => { const { client } = useChatContext(); const { unreadThreadCount } = useStateStore( @@ -259,8 +259,8 @@ export const ChatViewThreadsSelectorButton = ({ return ( setActiveChatView('threads')} - showLabel={showLabels} text={t('Threads')} > @@ -278,8 +278,8 @@ export type ChatViewSelectorItem = { export type ChatViewSelectorEntry = ChatViewSelectorItem; export type ChatViewSelectorProps = { + iconOnly?: boolean; itemSet?: ChatViewSelectorEntry[]; - showLabels?: boolean; }; export const defaultChatViewSelectorItemSet: ChatViewSelectorEntry[] = [ @@ -294,12 +294,12 @@ export const defaultChatViewSelectorItemSet: ChatViewSelectorEntry[] = [ ]; const ChatViewSelector = ({ + iconOnly = true, itemSet = defaultChatViewSelectorItemSet, - showLabels = false, }: ChatViewSelectorProps) => (
{itemSet.map(({ Component, type }) => ( - + ))}
); diff --git a/src/components/ChatView/__tests__/ChatView.test.js b/src/components/ChatView/__tests__/ChatView.test.js index 5d424a39b..4399761cd 100644 --- a/src/components/ChatView/__tests__/ChatView.test.js +++ b/src/components/ChatView/__tests__/ChatView.test.js @@ -182,8 +182,8 @@ describe('ChatView.Selector', () => { ]); }); - it('renders labels inline when showLabels is enabled', async () => { - const { container } = await renderSelector({ showLabels: true }); + it('renders labels inline when iconOnly is disabled', async () => { + const { container } = await renderSelector({ iconOnly: false }); expect( container.querySelectorAll('.str-chat__chat-view__selector-button-tooltip'), diff --git a/src/components/Threads/styling/UnreadCountBadge.scss b/src/components/Threads/styling/UnreadCountBadge.scss new file mode 100644 index 000000000..42f264668 --- /dev/null +++ b/src/components/Threads/styling/UnreadCountBadge.scss @@ -0,0 +1,61 @@ +/* Only available in React SDK. */ +.str-chat { + --str-chat-unread-count-badge-color: var(--str-chat__on-unread-badge-color); + --str-chat-unread-count-badge-background-color: var(--str-chat__danger-color); +} + +.str-chat__unread-count-badge { + background-color: var(--str-chat-unread-count-badge-background-color); + color: var(--str-chat-unread-count-badge-color); + border-radius: 9999px; +} + +.str-chat { + --str-chat-unread-count-badge-absolute-offset-vertical: 50%; + --str-chat-unread-count-badge-absolute-offset-horizontal: 50%; +} + +.str-chat__unread-count-badge-container { + position: relative; + display: flex; + align-items: center; + justify-content: center; +} + +.str-chat__unread-count-badge { + font-size: 12px; + min-width: 18px; + min-height: 18px; + line-height: 8px; + font-weight: 700; + padding: 5px; + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; + font-variant-numeric: tabular-nums; + + &--top-right { + position: absolute; + translate: var(--str-chat-unread-count-badge-absolute-offset-horizontal) + calc(var(--str-chat-unread-count-badge-absolute-offset-vertical) * -1); + } + + &--bottom-left { + position: absolute; + translate: calc(var(--str-chat-unread-count-badge-absolute-offset-horizontal) * -1) + var(--str-chat-unread-count-badge-absolute-offset-vertical); + } + + &--bottom-right { + position: absolute; + translate: var(--str-chat-unread-count-badge-absolute-offset-horizontal) + var(--str-chat-unread-count-badge-absolute-offset-vertical); + } + + &--top-left { + position: absolute; + translate: calc(var(--str-chat-unread-count-badge-absolute-offset-horizontal) * -1) + calc(var(--str-chat-unread-count-badge-absolute-offset-vertical) * -1); + } +} diff --git a/src/components/Threads/styling/index.scss b/src/components/Threads/styling/index.scss new file mode 100644 index 000000000..2b0a70c3e --- /dev/null +++ b/src/components/Threads/styling/index.scss @@ -0,0 +1 @@ +@use 'UnreadCountBadge'; diff --git a/src/styling/index.scss b/src/styling/index.scss index 70aaa8a98..9c6233048 100644 --- a/src/styling/index.scss +++ b/src/styling/index.scss @@ -45,6 +45,7 @@ @use '../components/Reactions/styling' as Reactions; @use '../components/TextareaComposer/styling' as TextareaComposer; @use '../components/Thread/styling' as Thread; +@use '../components/Threads/styling' as Threads; @use '../components/Threads/ThreadList/styling' as ThreadList; @use '../components/VideoPlayer/styling' as VideoPlayer; @use '../components/SummarizedMessagePreview/styling' as SummarizedMessagePreview;