style(app): adjust styles for better layout and user experience

- Adjusted navbar and sidebar padding, height, and width
- Modified background color and scrollbar appearance for consistency
- Added input bar component for typing messages in chat
- Enhanced alignment and display of navbar elements

BREAKING CHANGE: Changes may affect layout and require UI adjustments.
This commit is contained in:
kangfenmao 2024-06-18 16:22:37 +08:00
parent f866387862
commit 22eef75bf2
9 changed files with 88 additions and 36 deletions

View File

@ -22,7 +22,7 @@ function createWindow(): void {
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
titleBarStyle: 'hiddenInset', titleBarStyle: 'hiddenInset',
trafficLightPosition: { x: 10, y: 16 }, trafficLightPosition: { x: 8, y: 8 },
...(process.platform === 'linux' ? { icon } : {}), ...(process.platform === 'linux' ? { icon } : {}),
webPreferences: { webPreferences: {
preload: join(__dirname, '../preload/index.js'), preload: join(__dirname, '../preload/index.js'),

View File

@ -1,4 +1,4 @@
@import 'https://at.alicdn.com/t/c/font_4563475_65n90fm9f93.css'; @import 'https://at.alicdn.com/t/c/font_4563475_yuh5d3ftmm.css';
:root { :root {
--ev-c-white: #ffffff; --ev-c-white: #ffffff;
@ -24,15 +24,13 @@
--ev-button-alt-hover-text: var(--ev-c-text-1); --ev-button-alt-hover-text: var(--ev-c-text-1);
--ev-button-alt-hover-bg: var(--ev-c-gray-2); --ev-button-alt-hover-bg: var(--ev-c-gray-2);
--navbar-height: 48px; --navbar-height: 40px;
--sidebar-width: 64px; --sidebar-width: 70px;
--conversations-width: 240px; --conversations-width: 240px;
--settings-width: 320px; --settings-width: 280px;
--status-bar-height: 48px; --status-bar-height: 40px;
}
:root { --color-background: #181818;
--color-background: #1b1b1f;
--color-background-soft: #222222; --color-background-soft: #222222;
--color-background-mute: var(--ev-c-black-mute); --color-background-mute: var(--ev-c-black-mute);
@ -55,10 +53,14 @@ ul {
} }
body { body {
display: flex;
min-height: 100vh; min-height: 100vh;
color: var(--color-text); color: var(--color-text);
background: var(--color-background); background: var(--color-background);
line-height: 1.6; line-height: 1.6;
overflow: hidden;
background-size: cover;
user-select: none;
font-family: font-family:
Inter, Inter,
-apple-system, -apple-system,
@ -77,14 +79,6 @@ body {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
body {
display: flex;
overflow: hidden;
background-size: cover;
user-select: none;
background-color: #0b0a09;
}
code { code {
font-weight: 600; font-weight: 600;
padding: 3px 5px; padding: 3px 5px;
@ -116,6 +110,7 @@ body,
flex: 1; flex: 1;
} }
/*
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 5px; width: 5px;
height: 5px; height: 5px;
@ -131,4 +126,4 @@ body,
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background-color: #444c51; background-color: #444c51;
} } */

View File

@ -4,7 +4,6 @@ import { Provider } from 'react-redux'
import { BrowserRouter, Route, Routes } from 'react-router-dom' import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { PersistGate } from 'redux-persist/integration/react' import { PersistGate } from 'redux-persist/integration/react'
import Sidebar from './components/app/Sidebar' import Sidebar from './components/app/Sidebar'
import Statusbar from './components/app/Statusbar'
import AppsPage from './pages/apps/AppsPage' import AppsPage from './pages/apps/AppsPage'
import HomePage from './pages/home/HomePage' import HomePage from './pages/home/HomePage'
import SettingsPage from './pages/settings/SettingsPage' import SettingsPage from './pages/settings/SettingsPage'
@ -16,11 +15,10 @@ function App(): JSX.Element {
<BrowserRouter> <BrowserRouter>
<Sidebar /> <Sidebar />
<Routes> <Routes>
<Route path="/" element={<HomePage />} /> <Route path="" element={<HomePage />} />
<Route path="/apps" element={<AppsPage />} /> <Route path="/apps" element={<AppsPage />} />
<Route path="/settings/*" element={<SettingsPage />} /> <Route path="/settings/*" element={<SettingsPage />} />
</Routes> </Routes>
<Statusbar />
</BrowserRouter> </BrowserRouter>
</PersistGate> </PersistGate>
</Provider> </Provider>

View File

@ -52,4 +52,7 @@ const NavbarCenterContainer = styled.div`
const NavbarRightContainer = styled.div` const NavbarRightContainer = styled.div`
min-width: var(--settings-width); min-width: var(--settings-width);
display: flex;
align-items: center;
padding: 0 16px;
` `

View File

@ -47,8 +47,9 @@ const Container = styled.div`
min-height: 100%; min-height: 100%;
border-top: 1px solid #ffffff20; border-top: 1px solid #ffffff20;
border-right: 1px solid #ffffff20; border-right: 1px solid #ffffff20;
margin-top: 47px; padding-top: 40px;
padding-bottom: 52px; padding-bottom: 10px;
-webkit-app-region: drag !important;
` `
const Avatar = styled.div`` const Avatar = styled.div``
@ -80,6 +81,7 @@ const Icon = styled.div`
border-radius: 6px; border-radius: 6px;
margin-bottom: 5px; margin-bottom: 5px;
transition: background-color 0.2s ease; transition: background-color 0.2s ease;
-webkit-app-region: none;
.iconfont { .iconfont {
color: var(--color-icon); color: var(--color-icon);
font-size: 22px; font-size: 22px;

View File

@ -16,10 +16,8 @@ const HomePage: FC = () => {
const onCreateConversation = () => { const onCreateConversation = () => {
const _thread = { const _thread = {
// ID auto increment
id: Math.random().toString(), id: Math.random().toString(),
name: 'New conversation', name: 'New conversation',
// placeholder url
avatar: 'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y', avatar: 'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y',
lastMessage: 'message', lastMessage: 'message',
lastMessageAt: 'now' lastMessageAt: 'now'
@ -36,13 +34,16 @@ const HomePage: FC = () => {
<i className="iconfont icon-a-addchat"></i> <i className="iconfont icon-a-addchat"></i>
</NewButton> </NewButton>
</NavbarLeft> </NavbarLeft>
<NavbarCenter>Cherry AI</NavbarCenter> <NavbarCenter style={{ border: 'none' }}>{activeThread.name}</NavbarCenter>
<NavbarRight /> <NavbarRight style={{ justifyContent: 'flex-end', padding: 5 }}>
<NewButton>
<i className="iconfont icon-showsidebarhoriz"></i>
</NewButton>
</NavbarRight>
</Navbar> </Navbar>
<ContentContainer> <ContentContainer>
<Threads threads={threads} activeThread={activeThread} onSelectThread={setActiveThread} /> <Threads threads={threads} activeThread={activeThread} onSelectThread={setActiveThread} />
<Chat activeThread={activeThread} /> <Chat activeThread={activeThread} />
<Settings />
</ContentContainer> </ContentContainer>
</Container> </Container>
) )
@ -76,6 +77,9 @@ const NewButton = styled.div`
.iconfont { .iconfont {
font-size: 22px; font-size: 22px;
} }
.icon-showsidebarhoriz {
font-size: 18px;
}
&:hover { &:hover {
background-color: var(--color-background-soft); background-color: var(--color-background-soft);
cursor: pointer; cursor: pointer;
@ -83,10 +87,4 @@ const NewButton = styled.div`
} }
` `
const Settings = styled.div`
display: flex;
height: 100%;
min-width: var(--settings-width);
`
export default HomePage export default HomePage

View File

@ -1,21 +1,38 @@
import { Thread } from '@renderer/types' import { Thread } from '@renderer/types'
import { FC } from 'react' import { FC } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import Inputbar from './Inputbar'
interface Props { interface Props {
activeThread?: Thread activeThread?: Thread
} }
const Chat: FC<Props> = ({ activeThread }) => { const Chat: FC<Props> = ({ activeThread }) => {
return <Container>{activeThread?.lastMessage}</Container> return (
<Container>
<Conversations>{activeThread?.lastMessage}</Conversations>
<Inputbar />
</Container>
)
} }
const Container = styled.div` const Container = styled.div`
display: flex; display: flex;
flex-direction: column;
height: 100%; height: 100%;
flex: 1; flex: 1;
border-right: 1px solid #ffffff20; border-right: 1px solid #ffffff20;
`
const Conversations = styled.div`
display: flex;
flex-direction: column;
flex: 1;
padding: 15px; padding: 15px;
overflow-y: scroll;
&::-webkit-scrollbar {
display: none;
}
` `
export default Chat export default Chat

View File

@ -0,0 +1,39 @@
import { FC, useState } from 'react'
import styled from 'styled-components'
const Inputbar: FC = () => {
const [text, setText] = useState('')
const handleKeyDown = (event) => {
if (event.key === 'Enter') {
// 当用户按下Enter键时执行的操作
console.log('Enter key was pressed')
setText('')
}
}
return (
<Textarea
value={text}
onChange={(e) => setText(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Type a message..."
autoFocus
/>
)
}
const Textarea = styled.textarea`
padding: 15px;
width: 100%;
height: 100px;
border: none;
outline: none;
resize: none;
font-size: 14px;
color: var(--color-text);
background-color: transparent;
border-top: 1px solid #ffffff20;
`
export default Inputbar

View File

@ -30,7 +30,7 @@ const Container = styled.div`
flex-direction: column; flex-direction: column;
min-width: var(--conversations-width); min-width: var(--conversations-width);
border-right: 1px solid #ffffff20; border-right: 1px solid #ffffff20;
height: calc(100vh - var(--navbar-height) - var(--status-bar-height)); height: calc(100vh - var(--navbar-height));
padding: 10px; padding: 10px;
overflow-y: scroll; overflow-y: scroll;
&::-webkit-scrollbar { &::-webkit-scrollbar {