Skip to content

Commit

Permalink
feat(chat): update icon sizes (Issue #2098) (#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored Sep 20, 2024
1 parent a3e5bf3 commit 23e72d2
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 108 deletions.
1 change: 0 additions & 1 deletion apps/chat/src/components/Chat/ChangePathDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ export const ChangePathDialog = ({
isInitialRenameEnabled: true,
openedFoldersIds,
newAddedFolderId: newFolderId,
isSidePanelFolder: false,
loadingFolderIds,
additionalItemData: {
isChangePathFolder: true,
Expand Down
5 changes: 3 additions & 2 deletions apps/chat/src/components/Chat/Playback/PlaybackIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { IconNonModelWithTooltip } from '../IconNonModelWithTooltip';
interface Props {
isCustomTooltip?: boolean;
size?: number;
strokeWidth?: number;
}

export const PlaybackIcon = ({ isCustomTooltip, size }: Props) => {
export const PlaybackIcon = ({ isCustomTooltip, ...props }: Props) => {
const { t } = useTranslation(Translation.Chat);

return (
<IconNonModelWithTooltip
icon={<IconPlayerPlay size={size} />}
icon={<IconPlayerPlay {...props} />}
tooltipContent={t('Playback')}
isCustomTooltip={isCustomTooltip}
/>
Expand Down
11 changes: 8 additions & 3 deletions apps/chat/src/components/Chat/Publish/ApproveRequiredSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const PublicationItem = ({ publication, featureTypes }: PublicationProps) => {
);

const additionalItemData = useMemo(
() => ({ publicationUrl: publication.url }),
() => ({ publicationUrl: publication.url, isSidePanelItem: true }),
[publication.url],
);

Expand All @@ -96,7 +96,7 @@ const PublicationItem = ({ publication, featureTypes }: PublicationProps) => {
<div
onClick={handlePublicationSelect}
className={classNames(
'group relative flex h-[30px] items-center rounded border-l-2 hover:bg-accent-primary-alpha',
'group relative flex h-[34px] items-center rounded border-l-2 hover:bg-accent-primary-alpha',
selectedPublicationUrl === publication.url &&
!selectedConversationIds.length
? 'border-l-accent-primary bg-accent-primary-alpha'
Expand All @@ -107,7 +107,12 @@ const PublicationItem = ({ publication, featureTypes }: PublicationProps) => {
<div className="group/button flex size-full cursor-pointer items-center gap-1 py-2 pr-3">
<CaretIconComponent hidden={!showCaretIcon} isOpen={isOpen} />
<div className="relative">
<IconClipboard className="text-secondary" width={18} height={18} />
<IconClipboard
className="text-secondary"
strokeWidth={1.5}
width={24}
height={24}
/>
{(!itemsToReview
.filter((item) => !isFileId(item.reviewUrl))
.every((item) => item.reviewed) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export const PromptPublicationResources = ({
}
folderClassName={classNames(readonly && 'h-[38px]')}
showTooltip={showTooltip}
isSidePanelFolder={!readonly}
additionalItemData={additionalItemData}
/>
))}
Expand Down Expand Up @@ -366,7 +365,6 @@ export const ConversationPublicationResources = ({
folderClassName={classNames(readonly && 'h-[38px]')}
additionalItemData={additionalItemData}
showTooltip={showTooltip}
isSidePanelFolder={!readonly}
/>
))}
{itemsToDisplay.map((conversation) =>
Expand Down
5 changes: 3 additions & 2 deletions apps/chat/src/components/Chat/ReplayAsIsIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { IconNonModelWithTooltip } from './IconNonModelWithTooltip';
interface Props {
isCustomTooltip?: boolean;
size?: number;
strokeWidth?: number;
}

export const ReplayAsIsIcon = ({ isCustomTooltip, size }: Props) => {
export const ReplayAsIsIcon = ({ isCustomTooltip, ...props }: Props) => {
const { t } = useTranslation(Translation.Chat);

return (
<IconNonModelWithTooltip
icon={<IconRefreshDot size={size} />}
icon={<IconRefreshDot {...props} />}
tooltipContent={t('Replay as is')}
isCustomTooltip={isCustomTooltip}
/>
Expand Down
29 changes: 22 additions & 7 deletions apps/chat/src/components/Chatbar/ChatFolders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,22 @@ const ChatFolderTemplate = ({
const selectedConversations = useAppSelector(
ConversationsSelectors.selectSelectedItems,
);

const emptyFoldersIds = useAppSelector(
ConversationsSelectors.selectEmptyFolderIds,
);

const isFolderEmpty = useAppSelector((state) =>
ConversationsSelectors.selectIsFolderEmpty(state, folder.id),
);

const additionalFolderData = useMemo(
() => ({
selectedFolderIds: fullyChosenFolderIds,
partialSelectedFolderIds: partialChosenFolderIds,
isSidePanelItem: true,
}),
[fullyChosenFolderIds, partialChosenFolderIds],
);

const handleDrop = useCallback(
(e: DragEvent, folder: FolderInterface) => {
if (e.dataTransfer) {
Expand Down Expand Up @@ -289,10 +296,7 @@ const ChatFolderTemplate = ({
loadingFolderIds={loadingFolderIds}
onSelectFolder={handleFolderSelect}
canSelectFolders={isSelectMode}
additionalItemData={{
selectedFolderIds: fullyChosenFolderIds,
partialSelectedFolderIds: partialChosenFolderIds,
}}
additionalItemData={additionalFolderData}
/>
{isLast && (
<BetweenFoldersLine
Expand Down Expand Up @@ -342,6 +346,13 @@ export const ChatSection = ({

const { handleToggle, isExpanded } = useSectionToggle(name, FeatureType.Chat);

const additionalConvData = useMemo(
() => ({
isSidePanelItem: true,
}),
[],
);

const sortedRootConversations = useMemo(
() => sortByName(rootConversations),
[rootConversations],
Expand Down Expand Up @@ -407,7 +418,11 @@ export const ChatSection = ({
{displayRootFiles && (
<div className="flex flex-col gap-1">
{sortedRootConversations.map((item) => (
<ConversationComponent key={item.id} item={item} />
<ConversationComponent
additionalItemData={additionalConvData}
key={item.id}
item={item}
/>
))}
</div>
)}
Expand Down
6 changes: 3 additions & 3 deletions apps/chat/src/components/Chatbar/Chatbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ChatActionsBlock = () => {
return (
<div className="flex px-2 py-1">
<button
className="flex shrink-0 grow cursor-pointer select-none items-center gap-3 rounded px-3 py-2 transition-colors duration-200 hover:bg-accent-primary-alpha disabled:cursor-not-allowed hover:disabled:bg-transparent"
className="flex shrink-0 grow cursor-pointer select-none items-center gap-3 rounded px-3 py-[5px] transition-colors duration-200 hover:bg-accent-primary-alpha disabled:cursor-not-allowed hover:disabled:bg-transparent"
onClick={() => {
dispatch(
ConversationsActions.createNewConversations({
Expand All @@ -64,9 +64,9 @@ const ChatActionsBlock = () => {
data-qa="new-entity"
>
{isActiveNewConversationRequest ? (
<Spinner size={18} className="text-secondary" />
<Spinner size={24} className="text-secondary" />
) : (
<PlusIcon className="text-secondary" width={18} height={18} />
<PlusIcon className="text-secondary" width={24} height={24} />
)}
{t('New conversation')}
</button>
Expand Down
48 changes: 29 additions & 19 deletions apps/chat/src/components/Chatbar/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,26 @@ export function ConversationView({
!additionalItemData?.publicationUrl ||
selectedPublicationUrl === additionalItemData?.publicationUrl;

const iconSize = additionalItemData?.isSidePanelItem ? 24 : 18;
const strokeWidth = additionalItemData?.isSidePanelItem ? 1.5 : 2;

return (
<>
<div
className={classNames(
'relative size-[18px]',
isSelectMode &&
!isExternal &&
'shrink-0 group-hover/conversation-item:flex',
'relative',
additionalItemData?.isSidePanelItem
? 'size-[24px] items-center justify-center'
: 'size-[18px]',
isSelectMode && !isExternal && 'shrink-0 group-hover:flex',
isSelectMode && isChosen && !isExternal ? 'flex' : 'hidden',
)}
>
<input
className="checkbox peer size-[18px] bg-layer-3"
className={classNames(
'checkbox peer size-[18px] bg-layer-3',
additionalItemData?.isSidePanelItem && 'mr-0',
)}
type="checkbox"
checked={isChosen}
onChange={handleToggle}
Expand All @@ -163,14 +170,14 @@ export function ConversationView({
featureType={FeatureType.Chat}
isInvalid={isInvalid}
containerClassName={classNames(
isSelectMode && !isExternal && 'group-hover/conversation-item:hidden',
isSelectMode && !isExternal && 'group-hover:hidden',
isChosen && !isExternal && 'hidden',
)}
>
{resourceToReview && !resourceToReview.reviewed && (
<ReviewDot
className={classNames(
'group-hover/conversation-item:bg-accent-secondary-alpha',
'group-hover:bg-accent-secondary-alpha',
(selectedConversationIds.includes(conversation.id) ||
isContextMenu) &&
isPartOfSelectedPublication &&
Expand All @@ -180,19 +187,19 @@ export function ConversationView({
)}
{conversation.isReplay && (
<span className="flex shrink-0">
<ReplayAsIsIcon size={18} />
<ReplayAsIsIcon size={iconSize} />
</span>
)}

{conversation.isPlayback && (
<span className="flex shrink-0">
<PlaybackIcon size={18} />
<PlaybackIcon strokeWidth={strokeWidth} size={iconSize} />
</span>
)}

{!conversation.isReplay && !conversation.isPlayback && (
<ModelIcon
size={18}
size={iconSize}
entityId={conversation.model.id}
entity={modelsMap[conversation.model.id]}
isInvalid={isInvalid}
Expand Down Expand Up @@ -656,15 +663,19 @@ export const ConversationComponent = ({
}
}, [isSelectMode]);

const iconSize = additionalItemData?.isSidePanelItem ? 24 : 18;
const strokeWidth = additionalItemData?.isSidePanelItem ? 1.5 : 2;

return (
<div
className={classNames(
'group/conversation-item relative flex h-[30px] items-center rounded border-l-2 pr-3 hover:bg-accent-primary-alpha',
'group relative flex items-center rounded border-l-2 pr-3 hover:bg-accent-primary-alpha',
!isSelectMode && isHighlighted
? 'border-l-accent-primary'
: 'border-l-transparent',
(isHighlighted || isContextMenu) && 'bg-accent-primary-alpha',
isNameOrPathInvalid && !isRenaming && 'text-secondary',
additionalItemData?.isSidePanelItem ? 'h-[34px]' : 'h-[30px]',
)}
style={{
paddingLeft: (level && `${0.875 + level * 1.5}rem`) || '0.875rem',
Expand All @@ -684,19 +695,20 @@ export const ConversationComponent = ({
>
{conversation.isReplay && (
<span className="flex shrink-0">
<ReplayAsIsIcon size={18} />
<ReplayAsIsIcon strokeWidth={strokeWidth} size={iconSize} />
strokeWidth={strokeWidth}
</span>
)}

{conversation.isPlayback && (
<span className="flex shrink-0">
<PlaybackIcon size={18} />
<PlaybackIcon strokeWidth={strokeWidth} size={iconSize} />
</span>
)}

{!conversation.isReplay && !conversation.isPlayback && (
<ModelIcon
size={18}
size={iconSize}
entityId={conversation.model.id}
entity={modelsMap[conversation.model.id]}
/>
Expand All @@ -720,10 +732,8 @@ export const ConversationComponent = ({
) : (
<button
className={classNames(
'group/conversation-item flex size-full cursor-pointer items-center gap-2 disabled:cursor-not-allowed',
isSelectMode
? 'pr-0'
: '[&:not(:disabled)]:group-hover/conversation-item:pr-6',
'group flex size-full cursor-pointer items-center gap-2 disabled:cursor-not-allowed',
isSelectMode ? 'pr-0' : '[&:not(:disabled)]:group-hover:pr-6',
)}
onClick={() => {
setIsDeleting(false);
Expand Down Expand Up @@ -775,7 +785,7 @@ export const ConversationComponent = ({
ref={refs.setFloating}
{...getFloatingProps()}
className={classNames(
'absolute right-3 z-50 flex cursor-pointer justify-end group-hover/conversation-item:visible',
'absolute right-3 z-50 flex cursor-pointer justify-end group-hover:visible',
(conversation.status === UploadStatus.LOADED || !isContextMenu) &&
'invisible',
)}
Expand Down
10 changes: 9 additions & 1 deletion apps/chat/src/components/Chatbar/ConversationsRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';

import { useSectionToggle } from '@/src/hooks/useSectionToggle';

Expand Down Expand Up @@ -31,6 +31,13 @@ export const ConversationsRenderer = ({
FeatureType.Chat,
);

const additionalConvData = useMemo(
() => ({
isSidePanelItem: true,
}),
[],
);

useEffect(() => {
setIsSectionHighlighted(
conversations.some((conv) => selectedConversationsIds.includes(conv.id)),
Expand All @@ -52,6 +59,7 @@ export const ConversationsRenderer = ({
<ConversationComponent
key={conversation.id}
item={conversation}
additionalItemData={additionalConvData}
/>
))}
</div>
Expand Down
8 changes: 3 additions & 5 deletions apps/chat/src/components/Common/FolderContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface FolderContextMenuProps {
featureType: FeatureType;
isOpen?: boolean;
isEmpty?: boolean;
isSidePanelFolder?: boolean;
additionalItemData?: AdditionalItemData;
onDelete?: MouseEventHandler<unknown>;
onRename?: MouseEventHandler<unknown>;
Expand Down Expand Up @@ -69,7 +68,6 @@ export const FolderContextMenu = ({
onUpload,
isOpen,
isEmpty,
isSidePanelFolder,
additionalItemData,
onSelect,
}: FolderContextMenuProps) => {
Expand Down Expand Up @@ -163,7 +161,7 @@ export const FolderContextMenu = ({
isPublishingEnabled &&
isItemPublic(folder.id) &&
!!onUnpublish &&
isSidePanelFolder,
!!additionalItemData?.isSidePanelItem,
Icon: UnpublishIcon,
onClick: onUnpublish,
disabled: disableAll,
Expand Down Expand Up @@ -224,10 +222,10 @@ export const FolderContextMenu = ({
onPublish,
onPublishUpdate,
onUnpublish,
isSidePanelFolder,
additionalItemData?.isSidePanelItem,
additionalItemData?.isChangePathFolder,
onDelete,
onAddFolder,
additionalItemData?.isChangePathFolder,
],
);

Expand Down
1 change: 0 additions & 1 deletion apps/chat/src/components/Files/SelectFolderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export const SelectFolderModal = ({
onAddFolder: handleAddFolder,
newAddedFolderId: newFolderId,
loadingFolderIds: loadingFolderIds,
isSidePanelFolder: false,
}}
handleFolderSelect={handleFolderSelect}
isAllEntitiesOpened={isAllFilesOpened}
Expand Down
Loading

0 comments on commit 23e72d2

Please sign in to comment.