-
Notifications
You must be signed in to change notification settings - Fork 298
feat: add icons to ComponentContext #3246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { IconMicrophoneSolid, IconVideoFill } from '../Icons'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useComponentContextIcons } from '../../context'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, { type ComponentType } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { LocalAttachment } from 'stream-chat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import clsx from 'clsx'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -10,13 +10,15 @@ export type MediaBadgeProps = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: 'video' | 'voice-recording' | string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const MediaBadgeVariantToIcon: Record<MediaBadgeVariant, ComponentType> = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| video: IconVideoFill, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voiceRecording: IconMicrophoneSolid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const MediaBadge = ({ attachment, variant }: MediaBadgeProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Icon = MediaBadgeVariantToIcon[variant]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { IconMicrophoneSolid, IconVideoFill } = useComponentContextIcons(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const mediaBadgeVariantToIcon: Record<MediaBadgeVariant, ComponentType> = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| video: IconVideoFill, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voiceRecording: IconMicrophoneSolid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Icon = mediaBadgeVariantToIcon[variant]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
13
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win Fix variant mapping key to match the exact string type. The 🐛 Proposed fix for the dictionary key const mediaBadgeVariantToIcon: Record<MediaBadgeVariant, ComponentType> = {
video: IconVideoFill,
- voiceRecording: IconMicrophoneSolid,
+ 'voice-recording': IconMicrophoneSolid,
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MartinCupela - would you know whether this is a type issue or is the mapping is wrong? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={clsx('str-chat__media-badge', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add coverage for the contextual icon override.
Extend
src/components/Badge/__tests__/Badge.test.tsxto verify both the default icon and anicons.IconExclamationMarkFilloverride.As per coding guidelines, “Add and extend tests in the matching module's
__tests__/folder.”🤖 Prompt for AI Agents
Source: Coding guidelines