Skip to content

Commit

Permalink
rm sidebar compact
Browse files Browse the repository at this point in the history
  • Loading branch information
samlhuillier committed Nov 13, 2024
1 parent 298947b commit ee708cc
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 82 deletions.
7 changes: 0 additions & 7 deletions electron/main/electron-store/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ export const registerStoreHandlers = (store: Store<StoreSchema>, windowsManager:
return store.get(StoreKeys.LLMGenerationParameters)
})

ipcMain.handle('set-sb-compact', (event, isSBCompact) => {
store.set(StoreKeys.IsSBCompact, isSBCompact)
event.sender.send('sb-compact-changed', isSBCompact)
})

ipcMain.handle('get-sb-compact', () => store.get(StoreKeys.IsSBCompact))

ipcMain.handle('get-editor-flex-center', () => store.get(StoreKeys.EditorFlexCenter))

ipcMain.handle('set-editor-flex-center', (event, setEditorFlexCenter) => {
Expand Down
2 changes: 0 additions & 2 deletions electron/main/electron-store/storeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export interface StoreSchema {
agentConfigs: AgentConfig[]
analytics?: boolean
chunkSize: number
isSBCompact: boolean
spellCheck: string
EditorFlexCenter: boolean
showDocumentStats: boolean
Expand All @@ -79,7 +78,6 @@ export enum StoreKeys {
Chats = 'chats',
AgentConfigs = 'agentConfigs',
ChunkSize = 'chunkSize',
IsSBCompact = 'isSBCompact',
SpellCheck = 'spellCheck',
EditorFlexCenter = 'editorFlexCenter',
showDocumentStats = 'showDocumentStats',
Expand Down
2 changes: 0 additions & 2 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ const electronStore = {
saveChat: createIPCHandler<(chat: Chat) => Promise<void>>('save-chat'),
deleteChat: createIPCHandler<(chatID: string) => Promise<void>>('delete-chat'),
getChat: createIPCHandler<(chatID: string | undefined) => Promise<Chat | undefined>>('get-chat'),
getSBCompact: createIPCHandler<() => Promise<boolean>>('get-sb-compact'),
setSBCompact: createIPCHandler<(isSBCompact: boolean) => Promise<void>>('set-sb-compact'),
getEditorFlexCenter: createIPCHandler<() => Promise<boolean>>('get-editor-flex-center'),
setEditorFlexCenter: createIPCHandler<(editorFlexCenter: boolean) => Promise<void>>('set-editor-flex-center'),
getAgentConfigs: createIPCHandler<() => Promise<AgentConfig[]>>('get-agent-configs'),
Expand Down
51 changes: 2 additions & 49 deletions src/components/Settings/GeneralSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,6 @@
import React, { useEffect, useState } from 'react'
import Switch from '@mui/material/Switch'

export const AppearanceSection = () => {
const [isIconSBCompact, setIsIconSBCompact] = useState<boolean>(false)

useEffect(() => {
const fetchParams = async () => {
const storedIsIconSBCompact = await window.electronStore.getSBCompact()

if (storedIsIconSBCompact !== undefined) {
setIsIconSBCompact(storedIsIconSBCompact)
}
}

fetchParams()
}, [])

return (
<div className="flex w-full flex-col">
<h4 className="xs:text-sm mb-1 mt-10 flex w-full items-center justify-between gap-5 pb-2 text-lg text-white sm:text-base">
Appearance
</h4>
<div className="h-[2px] w-full bg-neutral-700" />
<div className="flex w-full flex-wrap items-center justify-between">
<div className="flex flex-col justify-center">
<p className="xs:text-xs flex flex-col text-base text-gray-100 opacity-80 sm:text-sm">
IconSidebar Compact
<span className="m-0 pt-1 text-xs text-gray-100">Decreases padding on IconSidebar</span>
</p>
</div>
<Switch
checked={isIconSBCompact}
onChange={() => {
setIsIconSBCompact(!isIconSBCompact)
if (isIconSBCompact !== undefined) {
window.electronStore.setSBCompact(!isIconSBCompact)
}
}}
/>
</div>
<div className="h-[2px] w-full bg-neutral-700" />
</div>
)
}

export const EditorSection = () => {
const [tempSpellCheckEnabled, setTempSpellCheckEnabled] = useState(false)
const [documentStatsEnabled, setDocumentStatsEnabled] = useState(false)
Expand Down Expand Up @@ -90,10 +47,7 @@ export const EditorSection = () => {
}, [])

return (
<div className="w-full flex-col">
<h4 className="xs:text-sm mb-1 mt-10 flex w-full items-center justify-between gap-5 pb-2 text-lg text-white sm:text-base">
Editor
</h4>
<div className="w-full flex-col pt-4">
<div className="h-[2px] w-full bg-neutral-700" />
<div className="flex w-full flex-wrap items-center justify-between">
<div className="flex w-[70%] flex-col justify-center">
Expand Down Expand Up @@ -157,8 +111,7 @@ export const EditorSection = () => {
const GeneralSettings = () => {
return (
<div className="w-full flex-col justify-between rounded bg-dark-gray-c-three">
<h2 className="mb-0 text-2xl font-semibold text-white">General</h2>
<AppearanceSection />
<h2 className="mb-0 text-2xl font-semibold text-white">Editor</h2>
<EditorSection />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SettingsModal: React.FC<SettingsModalProps> = ({
}`}
onClick={() => setActiveTab(SettingsTab.GeneralSettingsTab)}
>
General
Editor
</div>
<div
className={`flex cursor-pointer items-center rounded border-b border-gray-200 p-2 text-sm hover:bg-neutral-600 ${
Expand Down
23 changes: 2 additions & 21 deletions src/components/Sidebars/IconsSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import React from 'react'

import { FaSearch } from 'react-icons/fa'
import { GrNewWindow } from 'react-icons/gr'
Expand All @@ -18,31 +18,12 @@ export interface IconsSidebarProps {

const IconsSidebar: React.FC<IconsSidebarProps> = ({ getShortcutDescription }) => {
const { sidebarShowing, setSidebarShowing } = useChatContext()
const [sidebarWidth, setSidebarWidth] = useState<number>(40)

const { isSettingsModalOpen, setIsSettingsModalOpen, setIsNewDirectoryModalOpen } = useModalOpeners()
const { createUntitledNote } = useContentContext()

useEffect(() => {
const updateWidth = async () => {
const isCompact = await window.electronStore.getSBCompact()
setSidebarWidth(isCompact ? 40 : 60)
}

const handleSettingsChange = (isCompact: number) => {
setSidebarWidth(isCompact ? 40 : 60)
}

updateWidth()

window.ipcRenderer.receive('sb-compact-changed', handleSettingsChange)
}, [])

return (
<div
className="flex size-full flex-col items-center justify-between gap-1 bg-neutral-800"
style={{ width: `${sidebarWidth}px` }}
>
<div className="flex size-full w-[55px] flex-col items-center justify-between gap-1 bg-neutral-800 pt-2">
<div
className=" flex h-8 w-full cursor-pointer items-center justify-center"
onClick={() => setSidebarShowing('files')}
Expand Down

0 comments on commit ee708cc

Please sign in to comment.