Browse Source

Enforce configured font on popups/tooltips

- Move setting from misc -> config state
master
jeffvli 3 years ago
parent
commit
0044bf0b85
  1. 5
      src/App.tsx
  2. 2
      src/__tests__/App.test.tsx
  3. 7
      src/components/layout/Layout.tsx
  4. 6
      src/components/library/AlbumList.tsx
  5. 13
      src/components/library/AlbumView.tsx
  6. 18
      src/components/library/ArtistView.tsx
  7. 6
      src/components/player/NowPlayingMiniView.tsx
  8. 6
      src/components/player/NowPlayingView.tsx
  9. 15
      src/components/player/PlayerBar.tsx
  10. 13
      src/components/playlist/PlaylistList.tsx
  11. 17
      src/components/playlist/PlaylistView.tsx
  12. 6
      src/components/search/SearchBar.tsx
  13. 11
      src/components/settings/Config.tsx
  14. 6
      src/components/settings/ConfigPanels/CacheConfig.tsx
  15. 9
      src/components/settings/ConfigPanels/LookAndFeelConfig.tsx
  16. 6
      src/components/settings/ConfigPanels/PlayerConfig.tsx
  17. 6
      src/components/shared/ColumnSortPopover.tsx
  18. 8
      src/components/shared/CustomTooltip.tsx
  19. 13
      src/components/shared/Paginator.tsx
  20. 15
      src/components/shared/Popup.tsx
  21. 3
      src/components/shared/styled.ts
  22. 7
      src/redux/configSlice.ts
  23. 7
      src/redux/miscSlice.ts

5
src/App.tsx

@ -35,6 +35,7 @@ const App = () => {
const [theme, setTheme] = useState<any>(defaultDark); const [theme, setTheme] = useState<any>(defaultDark);
const [font, setFont] = useState('Poppins'); const [font, setFont] = useState('Poppins');
const misc = useAppSelector((state) => state.misc); const misc = useAppSelector((state) => state.misc);
const config = useAppSelector((state) => state.config);
useEffect(() => { useEffect(() => {
const themes: any = const themes: any =
@ -45,8 +46,8 @@ const App = () => {
}, [misc.theme]); }, [misc.theme]);
useEffect(() => { useEffect(() => {
setFont(misc.font); setFont(config.lookAndFeel.font);
}, [misc.font]); }, [config.lookAndFeel.font]);
if (!localStorage.getItem('server') || !localStorage.getItem('serverBase64')) { if (!localStorage.getItem('server') || !localStorage.getItem('serverBase64')) {
return ( return (

2
src/__tests__/App.test.tsx

@ -72,7 +72,6 @@ const playerState: Player = {
const miscState: General = { const miscState: General = {
theme: 'defaultDark', theme: 'defaultDark',
font: 'Poppins',
contextMenu: { contextMenu: {
show: false, show: false,
}, },
@ -136,6 +135,7 @@ const configState: ConfigPage = {
sort: {}, sort: {},
serverType: Server.Subsonic, serverType: Server.Subsonic,
lookAndFeel: { lookAndFeel: {
font: 'Poppins',
listView: { listView: {
music: { music: {
columns: [ columns: [

7
src/components/layout/Layout.tsx

@ -10,7 +10,7 @@ import { RootContainer, RootFooter, MainContainer } from './styled';
import { setContextMenu } from '../../redux/miscSlice'; import { setContextMenu } from '../../redux/miscSlice';
import { useAppDispatch, useAppSelector } from '../../redux/hooks'; import { useAppDispatch, useAppSelector } from '../../redux/hooks';
import { clearSelected } from '../../redux/multiSelectSlice'; import { clearSelected } from '../../redux/multiSelectSlice';
import { StyledButton, StyledNavItem, StyledPopover } from '../shared/styled'; import { StyledButton, StyledNavItem } from '../shared/styled';
import { import {
GridViewConfigPanel, GridViewConfigPanel,
ListViewConfigPanel, ListViewConfigPanel,
@ -25,6 +25,7 @@ import WindowConfig from '../settings/ConfigPanels/WindowConfig';
import AdvancedConfig from '../settings/ConfigPanels/AdvancedConfig'; import AdvancedConfig from '../settings/ConfigPanels/AdvancedConfig';
import { setSidebar } from '../../redux/configSlice'; import { setSidebar } from '../../redux/configSlice';
import SearchBar from '../search/SearchBar'; import SearchBar from '../search/SearchBar';
import Popup from '../shared/Popup';
const Layout = ({ footer, children, disableSidebar, font }: any) => { const Layout = ({ footer, children, disableSidebar, font }: any) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -157,7 +158,7 @@ const Layout = ({ footer, children, disableSidebar, font }: any) => {
<SearchBar /> <SearchBar />
<Whisper <Whisper
speaker={ speaker={
<StyledPopover <Popup
style={{ style={{
width: '620px', width: '620px',
maxHeight: '80vh', maxHeight: '80vh',
@ -193,7 +194,7 @@ const Layout = ({ footer, children, disableSidebar, font }: any) => {
<AdvancedConfig /> <AdvancedConfig />
</> </>
)} )}
</StyledPopover> </Popup>
} }
trigger="click" trigger="click"
placement="bottomEnd" placement="bottomEnd"

6
src/components/library/AlbumList.tsx

@ -16,7 +16,6 @@ import {
StyledInputPicker, StyledInputPicker,
StyledInputPickerContainer, StyledInputPickerContainer,
StyledNavItem, StyledNavItem,
StyledPopover,
StyledTag, StyledTag,
} from '../shared/styled'; } from '../shared/styled';
import { FilterButton, RefreshButton } from '../shared/ToolbarButtons'; import { FilterButton, RefreshButton } from '../shared/ToolbarButtons';
@ -31,6 +30,7 @@ import { setFilter, setPagination, setAdvancedFilters, setColumnSort } from '../
import useGridScroll from '../../hooks/useGridScroll'; import useGridScroll from '../../hooks/useGridScroll';
import useListScroll from '../../hooks/useListScroll'; import useListScroll from '../../hooks/useListScroll';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
export const ALBUM_SORT_TYPES = [ export const ALBUM_SORT_TYPES = [
{ label: i18n.t('A-Z (Name)'), value: 'alphabeticalByName', role: i18n.t('Default') }, { label: i18n.t('A-Z (Name)'), value: 'alphabeticalByName', role: i18n.t('Default') },
@ -315,7 +315,7 @@ const AlbumList = () => {
placement="bottomEnd" placement="bottomEnd"
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover width="275px" opacity={0.97}> <Popup width="275px">
<Nav <Nav
activeKey={view.album.advancedFilters.nav} activeKey={view.album.advancedFilters.nav}
onSelect={(e) => onSelect={(e) =>
@ -383,7 +383,7 @@ const AlbumList = () => {
} }
/> />
)} )}
</StyledPopover> </Popup>
} }
> >
<FilterButton <FilterButton

13
src/components/library/AlbumView.tsx

@ -39,13 +39,7 @@ import {
getPlayedSongsNotification, getPlayedSongsNotification,
isCached, isCached,
} from '../../shared/utils'; } from '../../shared/utils';
import { import { LinkWrapper, StyledButton, StyledLink, StyledTagLink } from '../shared/styled';
LinkWrapper,
StyledButton,
StyledLink,
StyledPopover,
StyledTagLink,
} from '../shared/styled';
import { import {
BlurredBackground, BlurredBackground,
BlurredBackgroundWrapper, BlurredBackgroundWrapper,
@ -58,6 +52,7 @@ import Card from '../card/Card';
import { setFilter, setPagination } from '../../redux/viewSlice'; import { setFilter, setPagination } from '../../redux/viewSlice';
import CenterLoader from '../loader/CenterLoader'; import CenterLoader from '../loader/CenterLoader';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
interface AlbumParams { interface AlbumParams {
id: string; id: string;
@ -501,7 +496,7 @@ const AlbumView = ({ ...rest }: any) => {
enterable enterable
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover> <Popup>
<ButtonToolbar> <ButtonToolbar>
<StyledButton onClick={() => handleDownload('download')}> <StyledButton onClick={() => handleDownload('download')}>
{t('Download')} {t('Download')}
@ -510,7 +505,7 @@ const AlbumView = ({ ...rest }: any) => {
{t('Copy to clipboard')} {t('Copy to clipboard')}
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<DownloadButton <DownloadButton

18
src/components/library/ArtistView.tsx

@ -37,14 +37,7 @@ import {
getPlayedSongsNotification, getPlayedSongsNotification,
isCached, isCached,
} from '../../shared/utils'; } from '../../shared/utils';
import { import { LinkWrapper, SectionTitle, StyledButton, StyledLink, StyledPanel } from '../shared/styled';
LinkWrapper,
SectionTitle,
StyledButton,
StyledLink,
StyledPanel,
StyledPopover,
} from '../shared/styled';
import { setStatus } from '../../redux/playerSlice'; import { setStatus } from '../../redux/playerSlice';
import { GradientBackground, PageHeaderSubtitleDataLine } from '../layout/styled'; import { GradientBackground, PageHeaderSubtitleDataLine } from '../layout/styled';
import { apiController } from '../../api/controller'; import { apiController } from '../../api/controller';
@ -58,6 +51,7 @@ import CustomTooltip from '../shared/CustomTooltip';
import { setFilter, setPagination } from '../../redux/viewSlice'; import { setFilter, setPagination } from '../../redux/viewSlice';
import CenterLoader from '../loader/CenterLoader'; import CenterLoader from '../loader/CenterLoader';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
const fac = new FastAverageColor(); const fac = new FastAverageColor();
@ -712,7 +706,7 @@ const ArtistView = ({ ...rest }: any) => {
enterable enterable
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover> <Popup>
<ButtonToolbar> <ButtonToolbar>
<StyledButton onClick={() => handleDownload('download')}> <StyledButton onClick={() => handleDownload('download')}>
{t('Download')} {t('Download')}
@ -721,7 +715,7 @@ const ArtistView = ({ ...rest }: any) => {
{t('Copy to clipboard')} {t('Copy to clipboard')}
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<DownloadButton size="lg" appearance="subtle" /> <DownloadButton size="lg" appearance="subtle" />
@ -733,14 +727,14 @@ const ArtistView = ({ ...rest }: any) => {
enterable enterable
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover> <Popup>
{data.info.externalUrl && {data.info.externalUrl &&
data.info.externalUrl.map((ext: GenericItem) => ( data.info.externalUrl.map((ext: GenericItem) => (
<StyledButton key={ext.id} onClick={() => shell.openExternal(ext.id)}> <StyledButton key={ext.id} onClick={() => shell.openExternal(ext.id)}>
{ext.title} {ext.title}
</StyledButton> </StyledButton>
))} ))}
</StyledPopover> </Popup>
} }
> >
<CustomTooltip text={t('Info')}> <CustomTooltip text={t('Info')}>

6
src/components/player/NowPlayingMiniView.tsx

@ -29,7 +29,6 @@ import {
StyledInputNumber, StyledInputNumber,
StyledInputPicker, StyledInputPicker,
StyledInputPickerContainer, StyledInputPickerContainer,
StyledPopover,
StyledTag, StyledTag,
} from '../shared/styled'; } from '../shared/styled';
import { MiniViewContainer } from './styled'; import { MiniViewContainer } from './styled';
@ -52,6 +51,7 @@ import { notifyToast } from '../shared/toast';
import { apiController } from '../../api/controller'; import { apiController } from '../../api/controller';
import { Server, Song } from '../../types'; import { Server, Song } from '../../types';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
const NowPlayingMiniView = () => { const NowPlayingMiniView = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -274,7 +274,7 @@ const NowPlayingMiniView = () => {
trigger="click" trigger="click"
enterable enterable
speaker={ speaker={
<StyledPopover> <Popup>
<ControlLabel>{`${t('How many tracks?')} ${ <ControlLabel>{`${t('How many tracks?')} ${
config.serverType === Server.Subsonic ? '(1 - 500)*' : '(1 - ∞)' config.serverType === Server.Subsonic ? '(1 - 500)*' : '(1 - ∞)'
}`}</ControlLabel> }`}</ControlLabel>
@ -387,7 +387,7 @@ const NowPlayingMiniView = () => {
{t('Play')} {t('Play')}
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<AutoPlaylistButton size="xs" noText /> <AutoPlaylistButton size="xs" noText />

6
src/components/player/NowPlayingView.tsx

@ -40,7 +40,6 @@ import {
StyledInputNumber, StyledInputNumber,
StyledInputPicker, StyledInputPicker,
StyledInputPickerContainer, StyledInputPickerContainer,
StyledPopover,
StyledTag, StyledTag,
} from '../shared/styled'; } from '../shared/styled';
import { import {
@ -57,6 +56,7 @@ import { setPlaylistRate } from '../../redux/playlistSlice';
import NowPlayingInfoView from './NowPlayingInfoView'; import NowPlayingInfoView from './NowPlayingInfoView';
import CenterLoader from '../loader/CenterLoader'; import CenterLoader from '../loader/CenterLoader';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
const NowPlayingView = () => { const NowPlayingView = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -303,7 +303,7 @@ const NowPlayingView = () => {
trigger="click" trigger="click"
enterable enterable
speaker={ speaker={
<StyledPopover> <Popup>
<ControlLabel>{`${t('How many tracks?')} ${ <ControlLabel>{`${t('How many tracks?')} ${
config.serverType === Server.Subsonic ? '(1 - 500)*' : '(1 - ∞)' config.serverType === Server.Subsonic ? '(1 - 500)*' : '(1 - ∞)'
}`}</ControlLabel> }`}</ControlLabel>
@ -417,7 +417,7 @@ const NowPlayingView = () => {
{t('Play')} {t('Play')}
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<AutoPlaylistButton size="sm" /> <AutoPlaylistButton size="sm" />

15
src/components/player/PlayerBar.tsx

@ -25,13 +25,7 @@ import CustomTooltip from '../shared/CustomTooltip';
import placeholderImg from '../../img/placeholder.png'; import placeholderImg from '../../img/placeholder.png';
import DebugWindow from '../debug/DebugWindow'; import DebugWindow from '../debug/DebugWindow';
import { getCurrentEntryList, writeOBSFiles } from '../../shared/utils'; import { getCurrentEntryList, writeOBSFiles } from '../../shared/utils';
import { import { LinkWrapper, SecondaryTextWrapper, StyledButton, StyledRate } from '../shared/styled';
LinkWrapper,
SecondaryTextWrapper,
StyledButton,
StyledPopover,
StyledRate,
} from '../shared/styled';
import { apiController } from '../../api/controller'; import { apiController } from '../../api/controller';
import { Artist, Server } from '../../types'; import { Artist, Server } from '../../types';
import { notifyToast } from '../shared/toast'; import { notifyToast } from '../shared/toast';
@ -40,6 +34,7 @@ import { setPlaylistRate } from '../../redux/playlistSlice';
import useGetLyrics from '../../hooks/useGetLyrics'; import useGetLyrics from '../../hooks/useGetLyrics';
import usePlayerControls from '../../hooks/usePlayerControls'; import usePlayerControls from '../../hooks/usePlayerControls';
import { setSidebar } from '../../redux/configSlice'; import { setSidebar } from '../../redux/configSlice';
import Popup from '../shared/Popup';
const DiscordRPC = require('discord-rpc'); const DiscordRPC = require('discord-rpc');
@ -815,11 +810,7 @@ const PlayerBar = () => {
placement="top" placement="top"
delay={200} delay={200}
preventOverflow preventOverflow
speaker={ speaker={<Popup>{muted ? t('Muted') : Math.floor(localVolume * 100)}</Popup>}
<StyledPopover>
{muted ? t('Muted') : Math.floor(localVolume * 100)}
</StyledPopover>
}
> >
<CustomSlider <CustomSlider
tabIndex={0} tabIndex={0}

13
src/components/playlist/PlaylistList.tsx

@ -9,13 +9,7 @@ import ListViewType from '../viewtypes/ListViewType';
import GenericPage from '../layout/GenericPage'; import GenericPage from '../layout/GenericPage';
import GenericPageHeader from '../layout/GenericPageHeader'; import GenericPageHeader from '../layout/GenericPageHeader';
import GridViewType from '../viewtypes/GridViewType'; import GridViewType from '../viewtypes/GridViewType';
import { import { StyledButton, StyledInput, StyledInputGroup, StyledTag } from '../shared/styled';
StyledButton,
StyledInput,
StyledInputGroup,
StyledPopover,
StyledTag,
} from '../shared/styled';
import { errorMessages, isFailedResponse } from '../../shared/utils'; import { errorMessages, isFailedResponse } from '../../shared/utils';
import { notifyToast } from '../shared/toast'; import { notifyToast } from '../shared/toast';
import { AddPlaylistButton, FilterButton } from '../shared/ToolbarButtons'; import { AddPlaylistButton, FilterButton } from '../shared/ToolbarButtons';
@ -26,6 +20,7 @@ import { Item, Server } from '../../types';
import { setSort } from '../../redux/playlistSlice'; import { setSort } from '../../redux/playlistSlice';
import ColumnSortPopover from '../shared/ColumnSortPopover'; import ColumnSortPopover from '../shared/ColumnSortPopover';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
const PlaylistList = () => { const PlaylistList = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -147,7 +142,7 @@ const PlaylistList = () => {
placement="auto" placement="auto"
trigger="click" trigger="click"
speaker={ speaker={
<StyledPopover> <Popup>
<Form> <Form>
<StyledInputGroup> <StyledInputGroup>
<StyledInput <StyledInput
@ -171,7 +166,7 @@ const PlaylistList = () => {
{t('Create')} {t('Create')}
</StyledButton> </StyledButton>
</Form> </Form>
</StyledPopover> </Popup>
} }
> >
<AddPlaylistButton <AddPlaylistButton

17
src/components/playlist/PlaylistView.tsx

@ -49,13 +49,7 @@ import GenericPageHeader from '../layout/GenericPageHeader';
import { setStatus } from '../../redux/playerSlice'; import { setStatus } from '../../redux/playerSlice';
import { notifyToast } from '../shared/toast'; import { notifyToast } from '../shared/toast';
import { addProcessingPlaylist, removeProcessingPlaylist } from '../../redux/miscSlice'; import { addProcessingPlaylist, removeProcessingPlaylist } from '../../redux/miscSlice';
import { import { StyledButton, StyledCheckbox, StyledInput, StyledLink } from '../shared/styled';
StyledButton,
StyledCheckbox,
StyledInput,
StyledLink,
StyledPopover,
} from '../shared/styled';
import { import {
removeFromPlaylist, removeFromPlaylist,
setPlaylistData, setPlaylistData,
@ -69,6 +63,7 @@ import { Server } from '../../types';
import Card from '../card/Card'; import Card from '../card/Card';
import CenterLoader from '../loader/CenterLoader'; import CenterLoader from '../loader/CenterLoader';
import useListClickHandler from '../../hooks/useListClickHandler'; import useListClickHandler from '../../hooks/useListClickHandler';
import Popup from '../shared/Popup';
interface PlaylistParams { interface PlaylistParams {
id: string; id: string;
@ -582,7 +577,7 @@ const PlaylistView = ({ ...rest }) => {
placement="auto" placement="auto"
trigger="click" trigger="click"
speaker={ speaker={
<StyledPopover> <Popup>
<Form> <Form>
<ControlLabel>{t('Name')}</ControlLabel> <ControlLabel>{t('Name')}</ControlLabel>
<StyledInput <StyledInput
@ -616,7 +611,7 @@ const PlaylistView = ({ ...rest }) => {
{t('Save')} {t('Save')}
</StyledButton> </StyledButton>
</Form> </Form>
</StyledPopover> </Popup>
} }
> >
<EditButton <EditButton
@ -631,12 +626,12 @@ const PlaylistView = ({ ...rest }) => {
placement="auto" placement="auto"
trigger="click" trigger="click"
speaker={ speaker={
<StyledPopover> <Popup>
<p>{t('Are you sure you want to delete this playlist?')}</p> <p>{t('Are you sure you want to delete this playlist?')}</p>
<StyledButton onClick={handleDelete} appearance="link"> <StyledButton onClick={handleDelete} appearance="link">
{t('Yes')} {t('Yes')}
</StyledButton> </StyledButton>
</StyledPopover> </Popup>
} }
> >
<DeleteButton <DeleteButton

6
src/components/search/SearchBar.tsx

@ -17,9 +17,9 @@ import {
StyledInput, StyledInput,
StyledInputGroup, StyledInputGroup,
StyledInputGroupButton, StyledInputGroupButton,
StyledPopover,
} from '../shared/styled'; } from '../shared/styled';
import { Item, Song } from '../../types'; import { Item, Song } from '../../types';
import Popup from '../shared/Popup';
const SearchContainer = styled.div` const SearchContainer = styled.div`
height: 100%; height: 100%;
@ -313,7 +313,7 @@ const SearchBar = () => {
preventOverflow preventOverflow
enterable enterable
speaker={ speaker={
<StyledPopover <Popup
style={{ style={{
width: '620px', width: '620px',
maxHeight: '80vh', maxHeight: '80vh',
@ -583,7 +583,7 @@ const SearchBar = () => {
<></> <></>
)} )}
</SearchContainer> </SearchContainer>
</StyledPopover> </Popup>
} }
> >
<span style={{ display: 'inline-block' }}> <span style={{ display: 'inline-block' }}>

11
src/components/settings/Config.tsx

@ -7,7 +7,7 @@ import GenericPage from '../layout/GenericPage';
import DisconnectButton from './DisconnectButton'; import DisconnectButton from './DisconnectButton';
import GenericPageHeader from '../layout/GenericPageHeader'; import GenericPageHeader from '../layout/GenericPageHeader';
import setDefaultSettings from '../shared/setDefaultSettings'; import setDefaultSettings from '../shared/setDefaultSettings';
import { StyledButton, StyledNavItem, StyledPopover } from '../shared/styled'; import { StyledButton, StyledNavItem } from '../shared/styled';
import PlaybackConfig from './ConfigPanels/PlaybackConfig'; import PlaybackConfig from './ConfigPanels/PlaybackConfig';
import LookAndFeelConfig from './ConfigPanels/LookAndFeelConfig'; import LookAndFeelConfig from './ConfigPanels/LookAndFeelConfig';
import PlayerConfig from './ConfigPanels/PlayerConfig'; import PlayerConfig from './ConfigPanels/PlayerConfig';
@ -20,6 +20,7 @@ import { useAppDispatch, useAppSelector } from '../../redux/hooks';
import { setActive } from '../../redux/configSlice'; import { setActive } from '../../redux/configSlice';
import { apiController } from '../../api/controller'; import { apiController } from '../../api/controller';
import ExternalConfig from './ConfigPanels/ExternalConfig'; import ExternalConfig from './ConfigPanels/ExternalConfig';
import Popup from '../shared/Popup';
const GITHUB_RELEASE_URL = 'https://api.github.com/repos/jeffvli/sonixd/releases?per_page=3'; const GITHUB_RELEASE_URL = 'https://api.github.com/repos/jeffvli/sonixd/releases?per_page=3';
@ -148,7 +149,7 @@ const Config = () => {
trigger="click" trigger="click"
placement="auto" placement="auto"
speaker={ speaker={
<StyledPopover title={t('Confirm')}> <Popup title={t('Confirm')}>
<div>{t('Are you sure you want to reset your settings to default?')}</div> <div>{t('Are you sure you want to reset your settings to default?')}</div>
<strong>{t('WARNING: This will reload the application')}</strong> <strong>{t('WARNING: This will reload the application')}</strong>
<div> <div>
@ -164,7 +165,7 @@ const Config = () => {
{t('Yes')} {t('Yes')}
</StyledButton> </StyledButton>
</div> </div>
</StyledPopover> </Popup>
} }
> >
<StyledButton size="sm">{t('Reset defaults')}</StyledButton> <StyledButton size="sm">{t('Reset defaults')}</StyledButton>
@ -175,7 +176,7 @@ const Config = () => {
enterable enterable
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover> <Popup>
<> <>
{t('Current version:')} {packageJson.version} {t('Current version:')} {packageJson.version}
<br /> <br />
@ -207,7 +208,7 @@ const Config = () => {
{t('View CHANGELOG')} {t('View CHANGELOG')}
</StyledButton> </StyledButton>
</> </>
</StyledPopover> </Popup>
} }
> >
<StyledButton <StyledButton

6
src/components/settings/ConfigPanels/CacheConfig.tsx

@ -11,7 +11,6 @@ import {
StyledCheckbox, StyledCheckbox,
StyledInputGroup, StyledInputGroup,
StyledLink, StyledLink,
StyledPopover,
StyledTag, StyledTag,
StyledButton, StyledButton,
StyledInputGroupButton, StyledInputGroupButton,
@ -20,6 +19,7 @@ import { getSongCachePath, getImageCachePath, getRootCachePath } from '../../../
import { notifyToast } from '../../shared/toast'; import { notifyToast } from '../../shared/toast';
import { setMiscSetting } from '../../../redux/miscSlice'; import { setMiscSetting } from '../../../redux/miscSlice';
import { useAppDispatch } from '../../../redux/hooks'; import { useAppDispatch } from '../../../redux/hooks';
import Popup from '../../shared/Popup';
const fsUtils = require('nodejs-fs-utils'); const fsUtils = require('nodejs-fs-utils');
@ -218,7 +218,7 @@ const CacheConfig = ({ bordered }: any) => {
trigger="click" trigger="click"
placement="autoVertical" placement="autoVertical"
speaker={ speaker={
<StyledPopover> <Popup>
{t('Which cache would you like to clear?')} {t('Which cache would you like to clear?')}
<ButtonToolbar> <ButtonToolbar>
<StyledButton size="sm" onClick={handleClearSongCache}> <StyledButton size="sm" onClick={handleClearSongCache}>
@ -237,7 +237,7 @@ const CacheConfig = ({ bordered }: any) => {
{t('Folder images')} {t('Folder images')}
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<StyledButton>{t('Clear cache')}</StyledButton> <StyledButton>{t('Clear cache')}</StyledButton>

9
src/components/settings/ConfigPanels/LookAndFeelConfig.tsx

@ -17,7 +17,6 @@ import {
StyledIconButton, StyledIconButton,
StyledToggle, StyledToggle,
StyledButton, StyledButton,
StyledPopover,
StyledCheckbox, StyledCheckbox,
StyledCheckPicker, StyledCheckPicker,
} from '../../shared/styled'; } from '../../shared/styled';
@ -25,7 +24,7 @@ import ListViewConfig from './ListViewConfig';
import { Fonts } from '../Fonts'; import { Fonts } from '../Fonts';
import { ALBUM_SORT_TYPES } from '../../library/AlbumList'; import { ALBUM_SORT_TYPES } from '../../library/AlbumList';
import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
import { setTheme, setFont, setDynamicBackground, setMiscSetting } from '../../../redux/miscSlice'; import { setTheme, setDynamicBackground, setMiscSetting } from '../../../redux/miscSlice';
import { import {
songColumnPicker, songColumnPicker,
songColumnListAuto, songColumnListAuto,
@ -40,6 +39,7 @@ import {
} from '../ListViewColumns'; } from '../ListViewColumns';
import { import {
setActive, setActive,
setFont,
setGridAlignment, setGridAlignment,
setGridCardSize, setGridCardSize,
setGridGapSize, setGridGapSize,
@ -51,6 +51,7 @@ import i18n, { Languages } from '../../../i18n/i18n';
import { notifyToast } from '../../shared/toast'; import { notifyToast } from '../../shared/toast';
import { setPagination } from '../../../redux/viewSlice'; import { setPagination } from '../../../redux/viewSlice';
import { MUSIC_SORT_TYPES } from '../../library/MusicList'; import { MUSIC_SORT_TYPES } from '../../library/MusicList';
import Popup from '../../shared/Popup';
export const ListViewConfigPanel = ({ bordered }: any) => { export const ListViewConfigPanel = ({ bordered }: any) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -412,7 +413,7 @@ export const ThemeConfigPanel = ({ bordered }: any) => {
trigger="none" trigger="none"
placement="auto" placement="auto"
speaker={ speaker={
<StyledPopover title={t('Restart?')}> <Popup title={t('Restart?')}>
<div>{t('Do you want to restart the application now?')}</div> <div>{t('Do you want to restart the application now?')}</div>
<strong>{t('This is highly recommended!')}</strong> <strong>{t('This is highly recommended!')}</strong>
<div> <div>
@ -427,7 +428,7 @@ export const ThemeConfigPanel = ({ bordered }: any) => {
{t('Yes')} {t('Yes')}
</StyledButton> </StyledButton>
</div> </div>
</StyledPopover> </Popup>
} }
> >
<StyledInputPicker <StyledInputPicker

6
src/components/settings/ConfigPanels/PlayerConfig.tsx

@ -14,7 +14,6 @@ import {
StyledInputPickerContainer, StyledInputPickerContainer,
StyledLink, StyledLink,
StyledPanel, StyledPanel,
StyledPopover,
StyledToggle, StyledToggle,
} from '../../shared/styled'; } from '../../shared/styled';
import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
@ -26,6 +25,7 @@ import { notifyToast } from '../../shared/toast';
import ConfigOption from '../ConfigOption'; import ConfigOption from '../ConfigOption';
import { Server } from '../../../types'; import { Server } from '../../../types';
import { isWindows, isWindows10 } from '../../../shared/utils'; import { isWindows, isWindows10 } from '../../../shared/utils';
import Popup from '../../shared/Popup';
const getAudioDevice = async () => { const getAudioDevice = async () => {
const devices = await navigator.mediaDevices.enumerateDevices(); const devices = await navigator.mediaDevices.enumerateDevices();
@ -176,7 +176,7 @@ const PlayerConfig = ({ bordered }: any) => {
trigger="none" trigger="none"
placement="auto" placement="auto"
speaker={ speaker={
<StyledPopover title={t('Restart?')}> <Popup title={t('Restart?')}>
<div>{t('Do you want to restart the application now?')}</div> <div>{t('Do you want to restart the application now?')}</div>
<strong>{t('This is highly recommended!')}</strong> <strong>{t('This is highly recommended!')}</strong>
<div> <div>
@ -191,7 +191,7 @@ const PlayerConfig = ({ bordered }: any) => {
{t('Yes')} {t('Yes')}
</StyledButton> </StyledButton>
</div> </div>
</StyledPopover> </Popup>
} }
> >
<StyledToggle <StyledToggle

6
src/components/shared/ColumnSortPopover.tsx

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Whisper } from 'rsuite'; import { Whisper } from 'rsuite';
import { StyledPopover } from './styled';
import ColumnSort from './ColumnSort'; import ColumnSort from './ColumnSort';
import Popup from './Popup';
const ColumnSortPopover = ({ children, ...rest }: any) => { const ColumnSortPopover = ({ children, ...rest }: any) => {
return ( return (
@ -11,9 +11,9 @@ const ColumnSortPopover = ({ children, ...rest }: any) => {
placement="bottomEnd" placement="bottomEnd"
preventOverflow preventOverflow
speaker={ speaker={
<StyledPopover width="275px" placement="bottomEnd"> <Popup width="275px" placement="bottomEnd">
<ColumnSort {...rest} /> <ColumnSort {...rest} />
</StyledPopover> </Popup>
} }
> >
{children} {children}

8
src/components/shared/CustomTooltip.tsx

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Tooltip, Whisper } from 'rsuite'; import { Tooltip, Whisper } from 'rsuite';
import styled from 'styled-components'; import styled from 'styled-components';
import { useAppSelector } from '../../redux/hooks';
const StyledTooltip = styled(Tooltip)` const StyledTooltip = styled(Tooltip)`
.rs-tooltip-inner { .rs-tooltip-inner {
@ -11,14 +12,15 @@ const StyledTooltip = styled(Tooltip)`
} }
`; `;
export const tooltip = (text: string) => <StyledTooltip>{text}</StyledTooltip>;
const CustomTooltip = ({ children, text, delay, placement, disabled, ...rest }: any) => { const CustomTooltip = ({ children, text, delay, placement, disabled, ...rest }: any) => {
const config = useAppSelector((state) => state.config);
return ( return (
<Whisper <Whisper
trigger={disabled ? 'none' : 'hover'} trigger={disabled ? 'none' : 'hover'}
delay={delay || 500} delay={delay || 500}
speaker={tooltip(text)} speaker={
<StyledTooltip style={{ fontFamily: config.lookAndFeel.font }}>{text}</StyledTooltip>
}
placement={placement || 'top'} placement={placement || 'top'}
{...rest} {...rest}
> >

13
src/components/shared/Paginator.tsx

@ -1,12 +1,7 @@
import React from 'react'; import React from 'react';
import { ButtonGroup, ButtonToolbar, FlexboxGrid, Icon, Whisper } from 'rsuite'; import { ButtonGroup, ButtonToolbar, FlexboxGrid, Icon, Whisper } from 'rsuite';
import { import Popup from './Popup';
SecondaryTextWrapper, import { SecondaryTextWrapper, StyledButton, StyledIconButton, StyledPagination } from './styled';
StyledButton,
StyledIconButton,
StyledPagination,
StyledPopover,
} from './styled';
const Paginator = ({ startIndex, endIndex, handleGoToButton, children, ...rest }: any) => { const Paginator = ({ startIndex, endIndex, handleGoToButton, children, ...rest }: any) => {
return ( return (
@ -37,7 +32,7 @@ const Paginator = ({ startIndex, endIndex, handleGoToButton, children, ...rest }
placement="autoVerticalEnd" placement="autoVerticalEnd"
trigger="click" trigger="click"
speaker={ speaker={
<StyledPopover> <Popup>
<ButtonGroup> <ButtonGroup>
<StyledButton <StyledButton
appearance="subtle" appearance="subtle"
@ -96,7 +91,7 @@ const Paginator = ({ startIndex, endIndex, handleGoToButton, children, ...rest }
-50 -50
</StyledButton> </StyledButton>
</ButtonToolbar> </ButtonToolbar>
</StyledPopover> </Popup>
} }
> >
<StyledIconButton size="sm" appearance="subtle" icon={<Icon icon="caret-right" />} /> <StyledIconButton size="sm" appearance="subtle" icon={<Icon icon="caret-right" />} />

15
src/components/shared/Popup.tsx

@ -0,0 +1,15 @@
import React from 'react';
import { useAppSelector } from '../../redux/hooks';
import { StyledPopover } from './styled';
const Popup = ({ children, ...rest }: any) => {
const config = useAppSelector((state) => state.config);
return (
<StyledPopover font={config.lookAndFeel.font} {...rest}>
{children}
</StyledPopover>
);
};
export default Popup;

3
src/components/shared/styled.ts

@ -472,13 +472,14 @@ export const ContextMenuPopover = styled(Popover)`
z-index: 2000; z-index: 2000;
`; `;
export const StyledPopover = styled(Popover)<{ width?: string }>` export const StyledPopover = styled(Popover)<{ width?: string; font?: string }>`
color: ${(props) => props.theme.colors.popover.color}; color: ${(props) => props.theme.colors.popover.color};
background: ${(props) => props.theme.colors.popover.background}; background: ${(props) => props.theme.colors.popover.background};
border: 1px #3c4043 solid; border: 1px #3c4043 solid;
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;
width: ${(props) => props.width}; width: ${(props) => props.width};
font-family: ${(props) => props.font};
`; `;
export const SectionTitleWrapper = styled.div<{ maxWidth?: string }>` export const SectionTitleWrapper = styled.div<{ maxWidth?: string }>`

7
src/redux/configSlice.ts

@ -29,6 +29,7 @@ export interface ConfigPage {
playlistListPage?: SortColumn; playlistListPage?: SortColumn;
}; };
lookAndFeel: { lookAndFeel: {
font: string;
listView: { listView: {
music: { columns: any; rowHeight: number; fontSize: number }; music: { columns: any; rowHeight: number; fontSize: number };
album: { columns: any; rowHeight: number; fontSize: number }; album: { columns: any; rowHeight: number; fontSize: number };
@ -114,6 +115,7 @@ const initialState: ConfigPage = {
playlistListPage: undefined, playlistListPage: undefined,
}, },
lookAndFeel: { lookAndFeel: {
font: String(parsedSettings.font),
listView: { listView: {
music: { music: {
columns: parsedSettings.musicListColumns!.map((col: any) => { columns: parsedSettings.musicListColumns!.map((col: any) => {
@ -250,6 +252,10 @@ const configSlice = createSlice({
state.playback.filters[selectedFilterIndex] = action.payload.newFilter; state.playback.filters[selectedFilterIndex] = action.payload.newFilter;
}, },
setFont: (state, action: PayloadAction<string>) => {
state.lookAndFeel.font = action.payload;
},
setAudioDeviceId: (state, action: PayloadAction<string>) => { setAudioDeviceId: (state, action: PayloadAction<string>) => {
state.playback.audioDeviceId = action.payload; state.playback.audioDeviceId = action.payload;
}, },
@ -326,6 +332,7 @@ export const {
setAudioDeviceId, setAudioDeviceId,
setColumnList, setColumnList,
setRowHeight, setRowHeight,
setFont,
setFontSize, setFontSize,
setGridCardSize, setGridCardSize,
setGridGapSize, setGridGapSize,

7
src/redux/miscSlice.ts

@ -47,7 +47,6 @@ export interface ContextMenu {
export interface General { export interface General {
theme: string; theme: string;
font: string;
modal: Modal; modal: Modal;
modalPages: ModalPage[]; modalPages: ModalPage[];
imgModal: ImgModal; imgModal: ImgModal;
@ -63,7 +62,6 @@ export interface General {
const initialState: General = { const initialState: General = {
theme: String(parsedSettings.theme), theme: String(parsedSettings.theme),
font: String(parsedSettings.font),
modal: { modal: {
show: false, show: false,
currentPageIndex: undefined, currentPageIndex: undefined,
@ -139,10 +137,6 @@ const miscSlice = createSlice({
state.theme = action.payload; state.theme = action.payload;
}, },
setFont: (state, action: PayloadAction<string>) => {
state.font = action.payload;
},
setImgModal: (state, action: PayloadAction<ImgModal>) => { setImgModal: (state, action: PayloadAction<ImgModal>) => {
state.imgModal = action.payload; state.imgModal = action.payload;
}, },
@ -194,7 +188,6 @@ const miscSlice = createSlice({
export const { export const {
setTheme, setTheme,
setFont,
setSearchQuery, setSearchQuery,
hideModal, hideModal,
addModalPage, addModalPage,

Loading…
Cancel
Save