1.1.0 • Published 2 years ago

device-picker v1.1.0

Weekly downloads
307
License
-
Repository
-
Last release
2 years ago

Device Picker

npm version

Installation

npm install device-picker

Usage

import React from 'react';
import { View, DevicePicker } from 'device-picker';
import memoize from 'lodash/memoize';
function MyDevicePicker() {
   return (
         <DevicePicker
            allowOrphan={true}
            initialDevice={'iPhone'}
            initialView={View.Grid}
            fetchHierarchy={() =>
               fetch(
                  'https://www.cominor.com/api/2.0/wikis/CATEGORY?display=hierarchy',
               ).then(response => response.json())
            }
            fetchChildren={
                memoize(title =>
                    fetch(
                        `https://www.cominor.com/api/2.0/wikis/CATEGORY/${title}/children`,
                    ).then(response => response.json()),
                )
            }
            onSubmit={title => alert(`Selected "${title}"`)}
            onCancel={() => alert(`Cancelled`)}
            objectName="device"
         />
   );
}

export default MyDevicePicker;

Props

PropTypeDefaultRequiredDescription
allowOrphanbooleanfalseNo
initialDevicestring''NoDefault device to load picker with.
initialViewViewView.GridNoDefault layout for displaying devices. Available options View.Grid, View.Column. For IE defaults to View.Column
fetchHierarchyfunctionundefinedYesFunction to get devices categories
fetchChildrenfunctionundefinedYesFunction to get category items
onSubmitfunctionundefinedYesFunction that receives the device title.
onCancelfunctionundefinedYesFunction when picker is cancelled.
objectNamestringdeviceNoSingular object name for objects, usually "Device" or "Category".

Sample Integration

Contributing

Local development setup

Clone repo

git clone https://github.com/iFixit/device-picker.git

Change directory

cd device-picker

Install dependencies

npm install

Start dev server

npm run dev
1.1.0

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.20-rc4

5 years ago

0.1.20-rc3

5 years ago

0.1.20-rc2

5 years ago

0.1.20-rc1

5 years ago

0.1.19

5 years ago

0.1.19-rc1

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.7

6 years ago