Sha256: 9ac7b2568051539f39a7fb4d28e6ae78c580e24031ee1776f761ab88744efae3

Contents?: true

Size: 1.76 KB

Versions: 85

Compression:

Stored size: 1.76 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { Switch, Level, LevelItem } from '@patternfly/react-core';
import {
  OverlayTrigger,
  Tooltip,
  Icon,
  Grid,
  ControlLabel,
  noop,
} from 'patternfly-react';

const Switcher = ({
  id,
  label,
  tooltip,
  isChecked,
  onChange,
  labelCol = 5,
  SwitchCol = 2,
}) => (
  <React.Fragment>
    <Grid.Col sm={labelCol}>
      <ControlLabel className="control-label" style={{ paddingTop: '0' }}>
        <Level>
          <LevelItem>
            <span className={`rh-cloud-switcher-${id}-label`}>{label}</span>
          </LevelItem>
          <LevelItem>
            <OverlayTrigger
              overlay={
                <Tooltip
                  id={`rh-cloud-switcher-${id}-tooltip`}
                  style={{ zIndex: 10000 }}
                >
                  {tooltip}
                </Tooltip>
              }
              placement="bottom"
              trigger={['hover', 'focus']}
              rootClose={false}
            >
              <Icon type="pf" name="info" />
            </OverlayTrigger>
          </LevelItem>
        </Level>
      </ControlLabel>
    </Grid.Col>
    <Grid.Col sm={SwitchCol} style={{ marginBottom: '5px' }}>
      <Switch
        id={`rh-cloud-switcher-${id}`}
        isChecked={isChecked}
        onChange={onChange}
        label=" "
      />
    </Grid.Col>
  </React.Fragment>
);

Switcher.propTypes = {
  id: PropTypes.string.isRequired,
  label: PropTypes.string,
  tooltip: PropTypes.string,
  isChecked: PropTypes.bool,
  onChange: PropTypes.func,
  labelCol: PropTypes.number,
  SwitchCol: PropTypes.number,
};

Switcher.defaultProps = {
  label: null,
  tooltip: null,
  isChecked: true,
  onChange: noop,
  labelCol: 5,
  SwitchCol: 2,
};

export default Switcher;

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.0.3 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.59 webpack/common/Switcher/index.js
foreman_rh_cloud-11.0.2 webpack/common/Switcher/index.js
foreman_rh_cloud-11.0.1 webpack/common/Switcher/index.js
foreman_rh_cloud-11.0.0 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.58 webpack/common/Switcher/index.js
foreman_rh_cloud-10.0.2 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.57 webpack/common/Switcher/index.js
foreman_rh_cloud-10.0.1 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.56 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.55 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.54 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.53 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.52 webpack/common/Switcher/index.js
foreman_rh_cloud-8.0.52 webpack/common/Switcher/index.js
foreman_rh_cloud-9.0.51 webpack/common/Switcher/index.js
foreman_rh_cloud-8.0.51 webpack/common/Switcher/index.js
foreman_rh_cloud-7.0.48 webpack/common/Switcher/index.js
foreman_rh_cloud-7.0.47 webpack/common/Switcher/index.js
foreman_rh_cloud-8.0.50 webpack/common/Switcher/index.js