How to use the current-device.type function in current-device

To help you get started, we’ve selected a few current-device examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metasfresh / metasfresh-webui-frontend / src / utils / documentListHelper.js View on Github external
? getSelection({
        state,
        windowType: props.parentWindowType,
        viewId: props.parentDefaultViewId,
      })
    : NO_SELECTION,
  modal: state.windowHandler.modal,
});

const NO_SELECTION = [];
const NO_VIEW = {};
const PANEL_WIDTHS = ['1', '.2', '4'];
const GEO_PANEL_STATES = ['grid', 'all', 'map'];

// for mobile devices we only want to show either map or grid
if (currentDevice.type === 'mobile' || currentDevice.type === 'tablet') {
  GEO_PANEL_STATES.splice(1, 1);
}

const filtersToMap = function(filtersArray) {
  let filtersMap = Map();

  if (filtersArray && filtersArray.length) {
    filtersArray.forEach(filter => {
      filtersMap = filtersMap.set(filter.filterId, filter);
    });
  }
  return filtersMap;
};

const doesSelectionExist = function({
  data,
github metasfresh / metasfresh-webui-frontend / src / components / app / DocumentList.js View on Github external
constructor(props) {
    super(props);

    const { defaultViewId, defaultPage, defaultSort } = props;

    this.pageLength =
      currentDevice.type === 'mobile' || currentDevice.type === 'tablet'
        ? 9999
        : 100;
    this.supportAttribute = false;

    this.state = {
      data: null, // view result (result, firstRow, pageLength etc)
      layout: null,
      pageColumnInfosByFieldName: null,
      toggleWidth: 0,
      viewId: defaultViewId,
      page: defaultPage || 1,
      sort: defaultSort,
      filtersActive: Map(),
      initialValuesNulled: Map(),
      clickOutsideLock: true,
      isShowIncluded: false,
github metasfresh / metasfresh-webui-frontend / src / components / app / QRCode.js View on Github external
constructor(props) {
    super(props);

    let val = 400;

    if (currentDevice.type === 'mobile') {
      val = 300;
    }

    this.width = val;
    this.height = val;
  }
  componentDidMount() {
github metasfresh / metasfresh-webui-frontend / src / components / widget / BarcodeScanner / BarcodeScannerWidget.js View on Github external
onClose={val => {
                const value = typeof val !== 'undefined' ? val : false;
                this.scanBarcode(value);

                if (currentDevice.type === 'mobile') {
                  closeOverlay();
                }
              }}
            />
github metasfresh / metasfresh-webui-frontend / src / actions / WindowActions.js View on Github external
modalType,
  tabId,
  rowId,
  isAdvanced,
  viewId,
  viewDocumentIds,
  dataId,
  triggerField,
  parentViewId,
  parentViewSelectedIds,
  childViewId,
  childViewSelectedIds,
  staticModalType
) {
  const isMobile =
    currentDevice.type === 'mobile' || currentDevice.type === 'tablet';

  if (isMobile) {
    toggleFullScreen();
  }

  return {
    type: OPEN_MODAL,
    windowType: windowId,
    tabId: tabId,
    rowId: rowId,
    viewId: viewId,
    dataId: dataId,
    title: title,
    isAdvanced: isAdvanced,
    viewDocumentIds: viewDocumentIds,
    triggerField: triggerField,
github metasfresh / metasfresh-webui-frontend / src / components / filters / FiltersFrequent.js View on Github external
constructor(props) {
    super(props);

    this.deviceType = currentDevice.type;
  }
github metasfresh / metasfresh-webui-frontend / src / utils / tableHelpers.js View on Github external
export function shouldRenderColumn(column) {
  if (
    !column.restrictToMediaTypes ||
    column.restrictToMediaTypes.length === 0
  ) {
    return true;
  }

  const deviceType = currentDevice.type;
  let mediaType = 'tablet';

  if (deviceType === 'mobile') {
    mediaType = 'phone';
  } else if (deviceType === 'desktop') {
    mediaType = 'screen';
  }

  return column.restrictToMediaTypes.indexOf(mediaType) !== -1;
}

current-device

The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo, AppleTV, etc), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis

Similar packages