on c19b2a8 help sign in
bridge/src/views/Login/Hardware.js
52 lines 1.1 kB history raw
1import React, { useMemo, useState } from 'react';
3import useBreakpoints from 'lib/useBreakpoints';
5import Accordion from 'components/Accordion';
7import Ledger from './Ledger';
8import Trezor from './Trezor';
10const NAMES = {
11 LEDGER: 'LEDGER',
12 TREZOR: 'TREZOR',
13};
15const VIEWS = {
16 [NAMES.LEDGER]: Ledger,
17 [NAMES.TREZOR]: Trezor,
18};
20const OPTIONS = [
21 { text: 'Ledger', value: NAMES.LEDGER },
22 { text: 'Trezor', value: NAMES.TREZOR },
23];
25export default function Hardware({ className, ...rest }) {
26 const [currentTab, setCurrentTab] = useState(undefined);
28 // using breakpoint to decide if we're on mobile or not
29 // see ActivateCode for more details on this approach
30 const hardwareAllowed = useBreakpoints([false, true, true]);
32 const options = useMemo(
33 () =>
34 OPTIONS.map(option => ({
35 ...option,
36 disabled: !hardwareAllowed && ' not availble on mobile',
37 })),
38 [hardwareAllowed]
39 );
41 return (
42 <Accordion
43 className={className}
44 views={VIEWS}
45 options={options}
46 currentTab={currentTab}
47 onTabChange={setCurrentTab}
48 //
49 {...rest}
50 />
51 );