import React from 'react'; import * as storage from '../../util/storage' import ListReport from '../reports/list' import * as api from '../../api' import * as url from '../../util/url' function Browsers({query, site}) { function fetchData() { return api.get(url.apiPath(site, '/browsers'), query) } return ( ) } function BrowserVersions({query, site}) { function fetchData() { return api.get(url.apiPath(site, '/browser-versions'), query) } return ( ) } function OperatingSystems({query, site}) { function fetchData() { return api.get(url.apiPath(site, '/operating-systems'), query) } return ( ) } function OperatingSystemVersions({query, site}) { function fetchData() { return api.get(url.apiPath(site, '/operating-system-versions'), query) } return ( ) } function ScreenSizes({query, site}) { function fetchData() { return api.get(url.apiPath(site, '/screen-sizes'), query) } function renderIcon(screenSize) { return iconFor(screenSize.name) } function renderTooltipText(screenSize) { return EXPLANATION[screenSize.name] } return ( ) } const EXPLANATION = { 'Mobile': 'up to 576px', 'Tablet': '576px to 992px', 'Laptop': '992px to 1440px', 'Desktop': 'above 1440px', } function iconFor(screenSize) { if (screenSize === 'Mobile') { return ( ) } else if (screenSize === 'Tablet') { return ( ) } else if (screenSize === 'Laptop') { return ( ) } else if (screenSize === 'Desktop') { return ( ) } } export default class Devices extends React.Component { constructor(props) { super(props) this.tabKey = `deviceTab__${ props.site.domain}` const storedTab = storage.getItem(this.tabKey) this.state = { mode: storedTab || 'size' } } setMode(mode) { return () => { storage.setItem(this.tabKey, mode) this.setState({mode}) } } renderContent() { switch (this.state.mode) { case 'browser': if (this.props.query.filters.browser) { return } return case 'os': if (this.props.query.filters.os) { return } return case 'size': default: return ( ) } } renderPill(name, mode) { const isActive = this.state.mode === mode if (isActive) { return (
  • {name}
  • ) } return (
  • {name}
  • ) } render() { return (

    Devices

      { this.renderPill('Size', 'size') } { this.renderPill('Browser', 'browser') } { this.renderPill('OS', 'os') }
    { this.renderContent() }
    ) } }