Skip to content

Commit

Permalink
fix: assistant and topic list style
Browse files Browse the repository at this point in the history
  • Loading branch information
kangfenmao committed Sep 4, 2024
1 parent 87216b5 commit 521670f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 55 deletions.
31 changes: 19 additions & 12 deletions src/renderer/src/pages/home/Assistants.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CopyOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons'
import { CopyOutlined, DeleteOutlined, EditOutlined, MinusCircleOutlined } from '@ant-design/icons'
import DragableList from '@renderer/components/DragableList'
import AssistantSettingPopup from '@renderer/components/Popups/AssistantSettingPopup'
import { useAssistant, useAssistants } from '@renderer/hooks/useAssistant'
Expand All @@ -24,7 +24,7 @@ interface Props {
const Assistants: FC<Props> = ({ activeAssistant, setActiveAssistant, onCreateAssistant }) => {
const { assistants, removeAssistant, addAssistant, updateAssistants } = useAssistants()
const generating = useAppSelector((state) => state.runtime.generating)
const { updateAssistant } = useAssistant(activeAssistant.id)
const { updateAssistant, removeAllTopics } = useAssistant(activeAssistant.id)
const { toggleShowTopics } = useShowTopics()
const { t } = useTranslation()

Expand Down Expand Up @@ -65,6 +65,19 @@ const Assistants: FC<Props> = ({ activeAssistant, setActiveAssistant, onCreateAs
setActiveAssistant(_assistant)
}
},
{
label: t('chat.topics.delete.all.title'),
key: 'delete-all',
icon: <MinusCircleOutlined />,
onClick: () => {
window.modal.confirm({
title: t('chat.topics.delete.all.title'),
content: t('chat.topics.delete.all.content'),
okButtonProps: { danger: true },
onOk: removeAllTopics
})
}
},
{ type: 'divider' },
{
label: t('common.delete'),
Expand All @@ -74,7 +87,7 @@ const Assistants: FC<Props> = ({ activeAssistant, setActiveAssistant, onCreateAs
onClick: () => onDelete(assistant)
}
] as ItemType[],
[addAssistant, onDelete, onEditAssistant, setActiveAssistant, t]
[addAssistant, onDelete, onEditAssistant, removeAllTopics, setActiveAssistant, t]
)

const onSwitchAssistant = useCallback(
Expand Down Expand Up @@ -146,17 +159,11 @@ const AssistantItem = styled.div`
opacity: 0;
color: var(--color-text-3);
}
/* &:hover {
background-color: var(--color-background-soft);
.topics-count {
display: none;
}
.iconfont {
opacity: 1;
}
} */
&.active {
background-color: var(--color-background-mute);
.name {
font-weight: 500;
}
.topics-count {
display: none;
}
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/src/pages/home/Inputbar/Inputbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { CSSProperties, FC, useCallback, useEffect, useMemo, useRef, useState }
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import SelectModelButton from '../components/SelectModelButton'
import SettingsTab from '../Settings'
import SendMessageButton from './SendMessageButton'

Expand Down Expand Up @@ -256,7 +255,6 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
)}
</ToolbarMenu>
<ToolbarMenu>
<SelectModelButton assistant={assistant} />
{generating && (
<Tooltip placement="top" title={t('chat.input.pause')} arrow>
<ToolbarButton type="text" onClick={onPause} style={{ marginRight: -2, marginTop: 1 }}>
Expand Down
20 changes: 5 additions & 15 deletions src/renderer/src/pages/home/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { FC, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import SelectModelButton from './components/SelectModelButton'

interface Props {
activeAssistant: Assistant
activeTopic: Topic
Expand Down Expand Up @@ -84,10 +86,8 @@ const HeaderNavbar: FC<Props> = ({ activeAssistant, setActiveAssistant, setActiv
<i className="iconfont icon-sidebar-left" />
</NewButton>
)}
<TitleText>
{assistant.name}
{/* {!showTopics && <HashTag onClick={() => toggleShowTopics()}>#{activeTopic.name}#</HashTag>} */}
</TitleText>
<TitleText style={{ marginRight: 10 }}>{assistant.name}</TitleText>
<SelectModelButton assistant={assistant} />
</HStack>
<HStack alignItems="center">
<ThemeSwitch
Expand Down Expand Up @@ -134,6 +134,7 @@ const TitleText = styled.span`
margin-left: 5px;
font-family: Ubuntu;
font-size: 13px;
font-weight: 500;
`

const ThemeSwitch = styled(Switch)`
Expand All @@ -144,15 +145,4 @@ const ThemeSwitch = styled(Switch)`
}
`

// const HashTag = styled.span`
// -webkit-app-region: no-drag;
// color: var(--color-primary);
// margin-left: 5px;
// user-select: none;
// cursor: pointer;
// &:hover {
// text-decoration: underline;
// }
// `

export default HeaderNavbar
27 changes: 3 additions & 24 deletions src/renderer/src/pages/home/Topics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fetchMessagesSummary } from '@renderer/services/api'
import LocalStorage from '@renderer/services/storage'
import { useAppSelector } from '@renderer/store'
import { Assistant, Topic } from '@renderer/types'
import { Button, Dropdown, MenuProps } from 'antd'
import { Dropdown, MenuProps } from 'antd'
import { FC, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
Expand All @@ -18,7 +18,7 @@ interface Props {
}

const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic }) => {
const { assistant, removeTopic, updateTopic, updateTopics, removeAllTopics } = useAssistant(_assistant.id)
const { assistant, removeTopic, updateTopic, updateTopics } = useAssistant(_assistant.id)
const { t } = useTranslation()
const generating = useAppSelector((state) => state.runtime.generating)

Expand Down Expand Up @@ -87,15 +87,6 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
[generating, setActiveTopic, t]
)

const onDeleteAll = () => {
window.modal.confirm({
title: t('chat.topics.delete.all.title'),
content: t('chat.topics.delete.all.content'),
okButtonProps: { danger: true },
onOk: removeAllTopics
})
}

return (
<Container>
<DragableList list={assistant.topics} onUpdate={updateTopics}>
Expand All @@ -109,13 +100,6 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
</Dropdown>
)}
</DragableList>
{assistant.topics.length > 10 && (
<Footer>
<Button style={{ width: '100%' }} onClick={onDeleteAll}>
{t('chat.topics.delete.all.title')}
</Button>
</Footer>
)}
</Container>
)
}
Expand Down Expand Up @@ -148,13 +132,8 @@ const TopicListItem = styled.div`
&.active {
background-color: var(--color-primary);
color: white;
font-weight: 500;
}
`

const Footer = styled.div`
padding: 0 10px;
padding-bottom: 10px;
width: 100%;
`

export default Topics
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SelectModelButton: FC<Props> = ({ assistant }) => {
}

return (
<SelectModelDropdown model={model} onSelect={setModel} placement="topLeft">
<SelectModelDropdown model={model} onSelect={setModel} placement="top">
<DropdownButton size="small" type="default">
<ModelAvatar model={model} size={20} />
<ModelName>{model ? upperFirst(model.name) : t('button.select_model')}</ModelName>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/store/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const migrateConfig = {
settings: {
...state.settings,
showTopics: true,
windowStyle: 'opaque'
windowStyle: 'transparent'
}
}
}
Expand Down

0 comments on commit 521670f

Please sign in to comment.