Skip to content

Commit

Permalink
[UX] Accessibility option to always show titles in library without ha…
Browse files Browse the repository at this point in the history
…ving to hover (#3702)

* Add accessibility option to show titles in the library without having to hover.

* Fix typescript issue

* Update translations
  • Loading branch information
arielj authored Apr 25, 2024
1 parent e584791 commit 925a0bd
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"disable_dialog_backdrop_close": "Disable closing dialogs by clicking outside",
"fonts": "Fonts",
"title": "Accessibility",
"titles_always_visible": "Always show titles in library",
"zoom": "Zoom"
},
"add_game": "Add Game",
Expand Down
1 change: 1 addition & 0 deletions src/common/types/electron_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface StoreStructure {
contentFontFamily: string
actionsFontFamily: string
allTilesInColor: boolean
titlesAlwaysVisible: boolean
disableDialogBackdropClose: boolean
language: string
'general-logs': {
Expand Down
18 changes: 18 additions & 0 deletions src/frontend/screens/Accessibility/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default React.memo(function Accessibility() {
setZoomPercent,
allTilesInColor,
setAllTilesInColor,
titlesAlwaysVisible,
setTitlesAlwaysVisible,
setPrimaryFontFamily,
setSecondaryFontFamily,
disableDialogBackdropClose,
Expand Down Expand Up @@ -207,6 +209,22 @@ export default React.memo(function Accessibility() {
</label>
</span>

<span className="setting">
<label className={classNames('toggleWrapper', { isRTL: isRTL })}>
<ToggleSwitch
htmlId="setTitlesAlwaysVisible"
value={titlesAlwaysVisible}
handleChange={() => {
setTitlesAlwaysVisible(!titlesAlwaysVisible)
}}
title={t(
'accessibility.titles_always_visible',
'Always show titles in library'
)}
/>
</label>
</span>

<span className="setting">
<label className={classNames('toggleWrapper', { isRTL: isRTL })}>
<ToggleSwitch
Expand Down
7 changes: 4 additions & 3 deletions src/frontend/screens/Library/components/GameCard/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
transform: translateY(100%);
}

.gameCard:hover .gameTitle {
.gameCard:hover .gameTitle,
.titlesAlwaysVisible .gameTitle {
display: block;
transform: translateY(0);
}
Expand Down Expand Up @@ -301,8 +302,8 @@

.gameCard:hover .gameImg:not(.installed),
.gameCard:hover .gameLogo:not(.installed),
.gameImg.allTilesInColor,
.gameLogo.allTilesInColor {
.allTilesInColor .gameImg,
.allTilesInColor .gameLogo {
filter: grayscale(0);
}

Expand Down
9 changes: 2 additions & 7 deletions src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const GameCard = ({
const {
hiddenGames,
favouriteGames,
allTilesInColor,
showDialogModal,
setIsSettingsModalOpen,
activeController
Expand Down Expand Up @@ -367,12 +366,8 @@ const GameCard = ({
const notAvailableClass = notAvailable ? 'notAvailable' : ''
const gamepadClass = activeController ? 'gamepad' : ''
const justPlayedClass = justPlayed ? 'justPlayed' : ''
const imgClasses = `gameImg ${isInstalled ? 'installed' : ''} ${
allTilesInColor ? 'allTilesInColor' : ''
}`
const logoClasses = `gameLogo ${isInstalled ? 'installed' : ''} ${
allTilesInColor && 'allTilesInColor'
}`
const imgClasses = `gameImg ${isInstalled ? 'installed' : ''}`
const logoClasses = `gameLogo ${isInstalled ? 'installed' : ''}`

const wrapperClasses = `${
grid ? 'gameCard' : 'gameListItem'
Expand Down
7 changes: 5 additions & 2 deletions src/frontend/screens/Library/components/GamesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const GamesList = ({
isRecent = false,
isFavourite = false
}: Props): JSX.Element => {
const { gameUpdates } = useContext(ContextProvider)
const { gameUpdates, allTilesInColor, titlesAlwaysVisible } =
useContext(ContextProvider)
const { t } = useTranslation()
const listRef = useRef<HTMLDivElement | null>(null)
const { activeController } = useContext(ContextProvider)
Expand Down Expand Up @@ -118,7 +119,9 @@ const GamesList = ({
className={cx({
gameList: layout === 'grid',
gameListLayout: layout === 'list',
firstLane: isFirstLane
firstLane: isFirstLane,
allTilesInColor,
titlesAlwaysVisible
})}
ref={listRef}
>
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/state/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const initialContext: ContextType = {
setZoomPercent: () => null,
allTilesInColor: false,
setAllTilesInColor: () => null,
titlesAlwaysVisible: false,
setTitlesAlwaysVisible: () => null,
sidebarCollapsed: false,
setSideBarCollapsed: () => null,
activeController: '',
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface StateProps {
primaryFontFamily: string
secondaryFontFamily: string
allTilesInColor: boolean
titlesAlwaysVisible: boolean
sidebarCollapsed: boolean
activeController: string
connectivity: { status: ConnectivityStatus; retryIn: number }
Expand Down Expand Up @@ -190,6 +191,7 @@ class GlobalState extends PureComponent<Props> {
'--default-primary-font-family'
),
allTilesInColor: configStore.get('allTilesInColor', false),
titlesAlwaysVisible: configStore.get('titlesAlwaysVisible', false),
activeController: '',
connectivity: { status: 'offline', retryIn: 0 },
showInstallModal: {
Expand Down Expand Up @@ -267,6 +269,11 @@ class GlobalState extends PureComponent<Props> {
this.setState({ allTilesInColor: value })
}

setTitlesAlwaysVisible = (value: boolean) => {
configStore.set('titlesAlwaysVisible', value)
this.setState({ titlesAlwaysVisible: value })
}

setDisableDialogBackdropClose = (value: boolean) => {
configStore.set('disableDialogBackdropClose', value)
this.setState({ disableDialogBackdropClose: value })
Expand Down Expand Up @@ -1021,6 +1028,7 @@ class GlobalState extends PureComponent<Props> {
setTheme: this.setTheme,
setZoomPercent: this.setZoomPercent,
setAllTilesInColor: this.setAllTilesInColor,
setTitlesAlwaysVisible: this.setTitlesAlwaysVisible,
setSideBarCollapsed: this.setSideBarCollapsed,
setPrimaryFontFamily: this.setPrimaryFontFamily,
setSecondaryFontFamily: this.setSecondaryFontFamily,
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export interface ContextType {
installingEpicGame: boolean
allTilesInColor: boolean
setAllTilesInColor: (value: boolean) => void
titlesAlwaysVisible: boolean
setTitlesAlwaysVisible: (value: boolean) => void
setSideBarCollapsed: (value: boolean) => void
sidebarCollapsed: boolean
activeController: string
Expand Down

0 comments on commit 925a0bd

Please sign in to comment.