add default downloads tab based on user OS

This commit is contained in:
Paul Wackerow 2022-12-14 22:07:14 -08:00
parent 63bbde1747
commit 832f1002bc
No known key found for this signature in database
GPG Key ID: BB63E296FE9CAB8D
1 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { Stack, Tabs, TabList, Tab, Text, TabPanel, TabPanels } from '@chakra-ui/react';
import { FC } from 'react';
import { FC, useMemo } from 'react';
import { DataTable } from '../../UI';
@ -37,6 +37,15 @@ export const DownloadsTable: FC<Props> = ({
const LAST_2_LINUX_RELEASES = amountOfReleasesToShow + 12;
const getDefaultIndex = useMemo<number>(() => {
const OS: string = typeof window !== 'undefined' ? window.navigator.platform : '';
if (OS.includes('Mac')) return 1;
if (OS.includes('Win')) return 2;
if (OS.includes('iPhone')) return 3;
if (OS.includes('Android')) return 4;
return 0;
}, [])
return (
<Stack
sx={{ mt: '0 !important' }}
@ -46,7 +55,7 @@ export const DownloadsTable: FC<Props> = ({
: 'none'
}
>
<Tabs variant='unstyled' onChange={idx => setTotalReleases(totalReleases[idx])}>
<Tabs variant='unstyled' onChange={idx => setTotalReleases(totalReleases[idx])} defaultIndex={getDefaultIndex}>
<TabList color='primary' bg='button-bg'>
{DOWNLOADS_TABLE_TABS.map((tab, idx) => {
return (