mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-15 12:36:48 +00:00
Merge pull request #167 from ethereum/default-downloads-os
Add default tab on downloads page based on user OS
This commit is contained in:
commit
022a7be96e
1 changed files with 12 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { Stack, Tabs, TabList, Tab, Text, TabPanel, TabPanels } from '@chakra-ui/react';
|
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';
|
import { DataTable } from '../../UI';
|
||||||
|
|
||||||
|
|
@ -37,6 +37,16 @@ export const DownloadsTable: FC<Props> = ({
|
||||||
|
|
||||||
const LAST_2_LINUX_RELEASES = amountOfReleasesToShow + 12;
|
const LAST_2_LINUX_RELEASES = amountOfReleasesToShow + 12;
|
||||||
|
|
||||||
|
const getDefaultIndex = useMemo<number>(() => {
|
||||||
|
const OS: string = typeof window !== 'undefined' ? window.navigator.platform : '';
|
||||||
|
const userAgent = typeof window !== 'undefined' ? window.navigator.userAgent : '';
|
||||||
|
if (/Mac/i.test(OS)) return 1;
|
||||||
|
if (/Win/i.test(OS)) return 2;
|
||||||
|
if (/iPhone/i.test(OS)) return 3;
|
||||||
|
if (/Android/i.test(userAgent)) return 4;
|
||||||
|
return 0;
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
sx={{ mt: '0 !important' }}
|
sx={{ mt: '0 !important' }}
|
||||||
|
|
@ -46,7 +56,7 @@ export const DownloadsTable: FC<Props> = ({
|
||||||
: 'none'
|
: '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'>
|
<TabList color='primary' bg='button-bg'>
|
||||||
{DOWNLOADS_TABLE_TABS.map((tab, idx) => {
|
{DOWNLOADS_TABLE_TABS.map((tab, idx) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue