Skip to content

Commit

Permalink
chore: clean up use os hook (janhq#1418)
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
namchuai and James authored Jan 7, 2024
1 parent fc151fb commit 9ca6487
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 106 deletions.
1 change: 1 addition & 0 deletions extensions/model-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export default class JanModelExtension implements ModelExtension {
const allDirectories: string[] = []
for (const file of files) {
if (file === '.DS_Store') continue
if (file === 'config') continue
allDirectories.push(file)
}

Expand Down
70 changes: 34 additions & 36 deletions web/containers/Layout/BottomBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ import { useGetDownloadedModels } from '@/hooks/useGetDownloadedModels'
import useGetSystemResources from '@/hooks/useGetSystemResources'
import { useMainViewState } from '@/hooks/useMainViewState'

const menuLinks = [
{
name: 'Discord',
icon: <FaDiscord size={20} className="flex-shrink-0" />,
link: 'https://discord.gg/FTk2MvZwJH',
},
{
name: 'Github',
icon: <FaGithub size={16} className="flex-shrink-0" />,
link: 'https://github.com/janhq/jan',
},
]

const BottomBar = () => {
const { activeModel, stateModel } = useActiveModel()
const { ram, cpu } = useGetSystemResources()
Expand All @@ -36,19 +49,6 @@ const BottomBar = () => {
const { setMainViewState } = useMainViewState()
const { downloadStates } = useDownloadState()

const linksMenu = [
{
name: 'Discord',
icon: <FaDiscord size={20} className="flex-shrink-0" />,
link: 'https://discord.gg/FTk2MvZwJH',
},
{
name: 'Github',
icon: <FaGithub size={16} className="flex-shrink-0" />,
link: 'https://github.com/janhq/jan',
},
]

return (
<div className="fixed bottom-0 left-16 z-20 flex h-12 w-[calc(100%-64px)] items-center justify-between border-t border-border bg-background/80 px-3">
<div className="flex flex-shrink-0 items-center gap-x-2">
Expand Down Expand Up @@ -99,30 +99,28 @@ const BottomBar = () => {
{/* VERSION is defined by webpack, please see next.config.js */}
<span className="text-xs">Jan v{VERSION ?? ''}</span>
<div className="mt-1 flex items-center gap-x-2">
{linksMenu
{menuLinks
.filter((link) => !!link)
.map((link, i) => {
return (
<div className="relative" key={i}>
<Tooltip>
<TooltipTrigger>
<a
href={link.link}
target="_blank"
rel="noopener noreferrer"
className="relative flex w-full flex-shrink-0 cursor-pointer items-center justify-center"
>
{link.icon}
</a>
</TooltipTrigger>
<TooltipContent side="top" sideOffset={10}>
<span>{link.name}</span>
<TooltipArrow />
</TooltipContent>
</Tooltip>
</div>
)
})}
.map((link, i) => (
<div className="relative" key={i}>
<Tooltip>
<TooltipTrigger>
<a
href={link.link}
target="_blank"
rel="noopener noreferrer"
className="relative flex w-full flex-shrink-0 cursor-pointer items-center justify-center"
>
{link.icon}
</a>
</TooltipTrigger>
<TooltipContent side="top" sideOffset={10}>
<span>{link.name}</span>
<TooltipArrow />
</TooltipContent>
</Tooltip>
</div>
))}
</div>
</div>
</div>
Expand Down
15 changes: 2 additions & 13 deletions web/containers/Shortcut/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import { useOs, type OS } from '@/hooks/useOs'

export default function ShortCut(props: { menu: string }) {
const os = useOs()
const { menu } = props
const getSymbol = (os: OS) => {
switch (os) {
case 'macos':
return '⌘'

default:
return 'Ctrl'
}
}
const symbol = isMac ? '⌘' : 'Ctrl'

return (
<div className="inline-flex items-center justify-center rounded-full bg-secondary px-1 py-0.5 text-xs font-bold text-muted-foreground">
<p>{getSymbol(os) + ' + ' + menu}</p>
<p>{symbol + ' + ' + menu}</p>
</div>
)
}
57 changes: 0 additions & 57 deletions web/hooks/useOs.ts

This file was deleted.

0 comments on commit 9ca6487

Please sign in to comment.