Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: starter screen layout #4279

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions web/containers/CenterPanelContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@ import {
} from '@/helpers/atoms/App.atom'
import { reduceTransparentAtom } from '@/helpers/atoms/Setting.atom'

const CenterPanelContainer = ({ children }: PropsWithChildren) => {
type Props = {
isShowStarterScreen?: boolean
} & PropsWithChildren

const CenterPanelContainer = ({ children, isShowStarterScreen }: Props) => {
const reduceTransparent = useAtomValue(reduceTransparentAtom)
const matches = useMediaQuery('(max-width: 880px)')
const showLeftPanel = useAtomValue(showLeftPanelAtom)
const showRightPanel = useAtomValue(showRightPanelAtom)
const mainViewState = useAtomValue(mainViewStateAtom)

return (
<div
className={twMerge('flex h-full w-full')}
style={{
maxWidth: matches
? '100%'
: mainViewState === MainViewState.Thread
: mainViewState === MainViewState.Thread && !isShowStarterScreen
? `calc(100% - (${showRightPanel ? Number(localStorage.getItem(RIGHT_PANEL_WIDTH)) : 0}px + ${showLeftPanel ? Number(localStorage.getItem(LEFT_PANEL_WIDTH)) : 0}px))`
: '100%',
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
} from '@/helpers/atoms/Model.atom'
import { selectedSettingAtom } from '@/helpers/atoms/Setting.atom'

const OnDeviceStarterScreen = () => {
type Props = {
isShowStarterScreen?: boolean
}

const OnDeviceStarterScreen = ({ isShowStarterScreen }: Props) => {
const { extensionHasSettings } = useStarterScreen()
const [searchValue, setSearchValue] = useState('')
const [isOpen, setIsOpen] = useState(Boolean(searchValue.length))
Expand All @@ -60,7 +64,7 @@
)

if (manualRecommendModel.length === 2) {
return x.id === recommendModel[0] || x.id === recommendModel[1]

Check warning on line 67 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

67 line is not covered with tests
} else {
return (
x.metadata?.tags?.includes('Featured') && x.metadata?.size < 5000000000
Expand Down Expand Up @@ -88,13 +92,13 @@
const getRows = (array: string[], itemsPerRow: number) => {
const rows = []
for (let i = 0; i < array.length; i += itemsPerRow) {
rows.push(array.slice(i, i + itemsPerRow))

Check warning on line 95 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

95 line is not covered with tests
}
return rows
}

const rows = getRows(
groupByEngine.sort((a, b) => a.localeCompare(b)),

Check warning on line 101 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

101 line is not covered with tests
itemsPerRow
)

Expand All @@ -103,7 +107,7 @@
const [visibleRows, setVisibleRows] = useState(1)

return (
<CenterPanelContainer>
<CenterPanelContainer isShowStarterScreen={isShowStarterScreen}>
<ScrollArea className="flex h-full w-full items-center">
<div className="relative mt-4 flex h-full w-full flex-col items-center justify-center">
<div className="mx-auto flex h-full w-3/4 flex-col items-center justify-center py-16 text-center">
Expand All @@ -118,7 +122,7 @@
<div className="relative" ref={refDropdown}>
<Input
value={searchValue}
onFocus={() => setIsOpen(true)}

Check warning on line 125 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

125 line is not covered with tests
onChange={(e) => {
setSearchValue(e.target.value)
}}
Expand All @@ -139,10 +143,10 @@
</div>
) : (
filteredModels.map((model) => {
const isDownloading = downloadingModels.some(
(md) => md === model.id

Check warning on line 147 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

146-147 lines are not covered with tests
)
return (

Check warning on line 149 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

149 line is not covered with tests
<div
key={model.id}
className="flex items-center justify-between gap-4 px-3 py-2 hover:bg-[hsla(var(--dropdown-menu-hover-bg))]"
Expand All @@ -165,7 +169,7 @@
size={18}
className="cursor-pointer text-[hsla(var(--app-link))]"
onClick={() =>
downloadModel(

Check warning on line 172 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

172 line is not covered with tests
model.sources[0].url,
model.id,
model.name
Expand All @@ -174,9 +178,9 @@
/>
) : (
Object.values(downloadStates)
.filter((x) => x.modelId === model.id)

Check warning on line 181 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

181 line is not covered with tests
.map((item) => (
<ProgressCircle

Check warning on line 183 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

183 line is not covered with tests
key={item.modelId}
percentage={
formatDownloadPercentage(
Expand Down Expand Up @@ -204,7 +208,7 @@
<p
className="cursor-pointer text-sm text-[hsla(var(--text-secondary))]"
onClick={() => {
setMainViewState(MainViewState.Hub)

Check warning on line 211 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

211 line is not covered with tests
}}
>
See All
Expand Down
2 changes: 1 addition & 1 deletion web/screens/Thread/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Props = {

const ThreadPanels = memo(({ isShowStarterScreen }: Props) => {
return isShowStarterScreen ? (
<OnDeviceStarterScreen />
<OnDeviceStarterScreen isShowStarterScreen={isShowStarterScreen} />
) : (
<>
<ThreadLeftPanel />
Expand Down
Loading