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

[Refactor] Sidebar cleanup (and a bit more that's related) #3544

Merged
merged 13 commits into from
Dec 14, 2024
Merged
5 changes: 4 additions & 1 deletion e2e/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ electronTest('Settings', async (app, page) => {
})

await test.step('shows the Advanced settings', async () => {
await page.getByTestId('settings').click()
await page
.locator('.Sidebar')
.locator('.Sidebar__item', { hasText: 'Settings' })
.click()
page.getByText('Global Settings')
await page.getByText('Advanced').click()
})
Expand Down
2 changes: 1 addition & 1 deletion src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ ipcMain.on('processShortcut', async (e, combination: string) => {
break
// hotkey to open the settings on frontend
case 'ctrl+k':
sendFrontendMessage('openScreen', '/settings/app/default/general')
sendFrontendMessage('openScreen', '/settings/general')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need these app/default routes anymore, the Settings component always renders Heroic's settings, game's settings are not handled by this url

break
// hotkey to open the downloads screen on frontend
case 'ctrl+j':
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const router = createHashRouter([
lazy: makeLazyFunc(import('./screens/WebView'))
},
{
path: 'settings/:runner/:appName/:type',
path: 'settings/:type',
lazy: makeLazyFunc(import('./screens/Settings'))
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.Sidebar {
.currentDownload {
font-size: var(--text-sm);
padding: var(--space-md) 0;
transition: 300ms;
margin-top: var(--space-sm);
align-self: end;

& > .gameTitle {
font-size: var(--text-md);
transition: 600ms;
font-weight: var(--bold);
}

&:hover > .gameTitle {
color: var(--accent-overlay);
transition: 600ms;
}

.downloadStatus {
color: var(--success);
font-family: var(--secondary-font-family);
font-style: italic;
font-weight: normal;
font-size: var(--text-sm);
line-height: var(--text-sm);
}

.MuiLinearProgress-bar1Determinate {
background-color: var(--success);
}

.statusIcon {
display: none;
margin-inline-end: 10px;
svg {
width: 27px;
height: auto;
color: var(--success);
}
}
}

&.collapsed {
.statusIcon {
display: block;
}
.full-size {
display: none;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Box from '@mui/material/Box'
import { getGameInfo } from 'frontend/helpers'
import { hasProgress } from 'frontend/hooks/hasProgress'
import { Runner } from 'common/types'
import './index.scss'
import './index.css'
import { useTranslation } from 'react-i18next'
import ContextProvider from 'frontend/state/ContextProvider'
import Badge from '@mui/material/Badge'
Expand Down Expand Up @@ -52,37 +52,35 @@ export default React.memo(function CurrentDownload({ appName, runner }: Props) {
}

return (
<>
<Link to={`/download-manager`} className="currentDownload">
<span className="statusIcon" title={`${getStatus()} - ${gameTitle}`}>
<Badge
badgeContent={`${Math.round(progress.percent ?? 0)}%`}
color="primary"
>
<FontAwesomeIcon icon={faDownload} />
</Badge>
</span>
<Link to={`/download-manager`} className="currentDownload">
<span className="statusIcon" title={`${getStatus()} - ${gameTitle}`}>
<Badge
badgeContent={`${Math.round(progress.percent ?? 0)}%`}
color="primary"
>
<FontAwesomeIcon icon={faDownload} />
</Badge>
</span>

<div className="full-size">
<span className="gameTitle">{gameTitle ?? 'GameName'}</span>
<br />
<span className="downloadStatus">{getStatus()}</span>
<br />
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Box sx={{ width: '100%', mr: 1 }}>
<LinearProgress
variant="determinate"
value={progress.percent || 0}
/>
</Box>
<Box sx={{ minWidth: 35 }}>
<Typography variant="body2">{`${Math.round(
progress.percent || 0
)}%`}</Typography>
</Box>
<div className="full-size">
<span className="gameTitle">{gameTitle ?? 'GameName'}</span>
<br />
<span className="downloadStatus">{getStatus()}</span>
<br />
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Box sx={{ width: '100%', mr: 1 }}>
<LinearProgress
variant="determinate"
value={progress.percent || 0}
/>
</Box>
</div>
</Link>
</>
<Box sx={{ minWidth: 35 }}>
<Typography variant="body2">{`${Math.round(
progress.percent || 0
)}%`}</Typography>
</Box>
</Box>
</div>
</Link>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me removing the extra <> fragment that was not needed, the diff is just the indentation

)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.Sidebar {
.heroicVersion {
display: flex;
gap: 5px;
font-size: var(--text-sm);
cursor: pointer;
transition: 300ms;
color: var(--brand-text-01);

&:hover {
color: var(--accent);
}
}

.heroicNewReleases {
display: flex;
flex-direction: column;
justify-content: space-around;
font-size: var(--text-sm);

& > a {
color: var(--accent);
transition: 300ms;
-webkit-app-region: no-drag;
cursor: pointer;

&:hover {
color: var(--accent-overlay);
}
}
}

&.collapsed {
.heroicVersion {
font-size: var(--text-xs);
text-align: center;
}

.heroicVersion__title {
display: none;
}

.heroicNewReleases {
display: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useContext, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import ContextProvider from 'frontend/state/ContextProvider'
import { ChangelogModal } from '../../../ChangelogModal'
import './index.css'

type Release = {
html_url: string
Expand Down
111 changes: 111 additions & 0 deletions src/frontend/components/UI/Sidebar/components/SidebarItem/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
.Sidebar {
.Sidebar__item {
--sidebar-item-inactive-text-color: var(
--navbar-inactive,
var(--navbar-accent)
);
--sidebar-hover-text-color: var(--text-hover);
--sidebar-item-active-text-color: var(
--navbar-active,
var(--accent-overlay, var(--accent))
);
--sidebar-active-item-background: var(--navbar-active-background);
Copy link
Collaborator Author

@arielj arielj Feb 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is mostly extraction of Sidebar__item styles that were in other places, but I also added these new custom properties to help themes


display: flex;
gap: 10px;
width: 100%;
padding: var(--space-xs) var(--sidebar-horizontal-padding);
border: none;
background: none;
cursor: pointer;
font-size: var(--text-md);
color: var(--sidebar-item-inactive-text-color);
transition: color 250ms;
text-align: start;
font-family: var(--primary-font-family);

.Sidebar__itemIcon {
width: 24px;
display: inline-flex;
justify-content: center;
}

&:focus-visible {
outline: 2px solid var(--sidebar-hover-text-color);
outline-offset: -2px;
}

&.active {
color: var(--sidebar-item-active-text-color);

.Sidebar__itemIcon {
color: currentColor;
}

&.SidebarLinks__subItem {
font-weight: var(--bold);
}
}
&.active:not(.SidebarLinks__subItem) {
background-color: var(--sidebar-active-item-background);
}

&.SidebarLinks__subItem {
&,
&:hover {
padding-block: var(--space-3xs);
padding-inline: var(--space-xl) var(--sidebar-horizontal-padding);
font-size: var(--text-sm);
line-height: 20px;
white-space: break-spaces;
}
&::before {
content: '• ';
}
& + .Sidebar__item:not(.SidebarLinks__subItem) {
margin-top: 4px;
}
}

&:hover {
background-color: var(--navbar-active-background);
transition: 0.1s;
padding-inline-start: 12px;
}

@media screen and (max-width: 730px) {
&,
&:hover {
padding: var(--space-3xs) var(--sidebar-horizontal-padding)
var(--space-3xs) var(--space-lg);
}
}
}

&.collapsed {
.Sidebar__item {
padding: var(--space-xs) 0;

& > span {
display: none;
}

&.SidebarLinks__subItem {
padding: var(--space-xs) var(--sidebar-horizontal-padding);
&::before {
display: none;
}
}

&.active svg,
& svg {
transform: scale(1.2);
padding: var(--space-2xs) 0;
}

.Sidebar__itemIcon {
margin: 0 auto;
}
}
}
}
Loading
Loading