How to use the grommet/themes.grommet function in grommet

To help you get started, we’ve selected a few grommet 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 grommet / grommet / components / Grid / stories / Responsive.js View on Github external
var _themes = require("grommet/themes");

var _utils = require("grommet/utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

// Two responsive grids
//    - First one with a known number of elements
//    - Second one with an unknown number of elements
// set custom breakpoints so we can see the changes
var customBreakpoints = (0, _utils.deepMerge)(_themes.grommet, {
  global: {
    breakpoints: {
      small: {
        value: 600
      },
      medium: {
        value: 900
      },
      large: 3000
    }
  }
}); // columns, rows and areas are for Grid with a known number of contents / boxes.
// If the size is small, we only see 1 column
// If the size is medium, we only see 2 columns
// If the size is either large or xlarge, we see 3 columns
github grommet / grommet / components / RangeSelector / stories / CustomEdgeControl.js View on Github external
var _grommet = require("grommet");

var _themes = require("grommet/themes");

var _utils = require("grommet/utils");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var customEdge = (0, _utils.deepMerge)(_themes.grommet, {
  rangeSelector: {
    edge: {
      type: _react["default"].createElement(_grommetIcons.Gremlin, {
        size: "large",
        color: "neutral-2"
      }) // it is also possible to use an actual node
      // type:  <div style="{{">,

    }
  }
});

var CustomEdgeControl = function CustomEdgeControl(_ref) {
  var _ref$direction = _ref.direction,
      direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
      rest = _objectWithoutPropertiesLoose(_ref, ["direction"]);</div>
github grommet / grommet / components / Select / stories / Seasons.js View on Github external
width: '12px',
        height: '12px'
      }
    }))));
  };

  var renderOption = function renderOption(option, state) {
    return _react["default"].createElement(_grommet.Box, {
      pad: "small",
      background: state.active ? 'active' : undefined
    }, option);
  };

  return _react["default"].createElement(_grommet.Grommet, {
    full: true,
    theme: _themes.grommet
  }, _react["default"].createElement(_grommet.Box, {
    fill: true,
    align: "center",
    justify: "center"
  }, _react["default"].createElement(_grommet.Select, {
    closeOnChange: false,
    multiple: true,
    value: _react["default"].createElement(_grommet.Box, {
      wrap: true,
      direction: "row",
      width: "small"
    }, selected && selected.length ? selected.map(function (index) {
      return renderSeason(allSeasons[index]);
    }) : _react["default"].createElement(_grommet.Box, {
      pad: {
        vertical: 'xsmall',
github grommet / grommet / components / CheckBox / stories / CheckBoxInsideButton.js View on Github external
var CheckBoxInsideButton = function CheckBoxInsideButton() {
  var _useState = (0, _react.useState)(false),
      checked = _useState[0],
      setChecked = _useState[1];

  var onButtonClick = function onButtonClick() {
    return setChecked(!checked);
  };

  var onCheckboxChange = function onCheckboxChange() {};

  return _react["default"].createElement(_grommet.Grommet, {
    theme: _themes.grommet
  }, _react["default"].createElement(_grommet.Box, {
    align: "center",
    pad: "large"
  }, _react["default"].createElement(_grommet.Button, {
    hoverIndicator: "background",
    onClick: onButtonClick
  }, _react["default"].createElement(_grommet.CheckBox, {
    tabIndex: "-1",
    checked: checked,
    label: _react["default"].createElement(_grommet.Text, null, "Hi"),
    onChange: onCheckboxChange
  }))));
};
github grommet / grommet / components / Drop / stories / Overflow.js View on Github external
_proto.render = function render() {
    var _this2 = this;

    var _this$state = this.state,
        date = _this$state.date,
        showCalendar = _this$state.showCalendar;
    return _react["default"].createElement(_grommet.Grommet, {
      theme: _themes.grommet,
      full: true
    }, _react["default"].createElement(_grommet.Box, {
      fill: true,
      align: "center",
      justify: "center"
    }, _react["default"].createElement(_grommet.Box, {
      background: "dark-3",
      pad: "medium",
      align: "center",
      justify: "start",
      ref: this.targetRef
    }, "Target"), this.targetRef.current && _react["default"].createElement(_grommet.Drop, {
      overflow: "unset",
      align: {
        top: 'bottom',
        left: 'left'
github grommet / grommet / components / Select / stories / Basics.js View on Github external
var SimpleSelect = function SimpleSelect(_ref) {
  var theme = _ref.theme,
      rest = _objectWithoutPropertiesLoose(_ref, ["theme"]);

  var options = ['one', 'two'];

  var _useState = (0, _react.useState)(''),
      value = _useState[0],
      setValue = _useState[1];

  return _react["default"].createElement(_grommet.Grommet, {
    full: true,
    theme: theme || _themes.grommet
  }, _react["default"].createElement(_grommet.Box, {
    fill: true,
    align: "center",
    justify: "start",
    pad: "large"
  }, _react["default"].createElement(_grommet.Select, _extends({
    id: "select",
    name: "select",
    placeholder: "Select",
    value: value,
    options: options,
    onChange: function onChange(_ref2) {
      var option = _ref2.option;
      return setValue(option);
    }
  }, rest))));
github grommet / grommet / components / Chart / stories / Labelled.js View on Github external
var LabelledCharts = function LabelledCharts() {
  return _react["default"].createElement(_grommet.Grommet, {
    theme: _themes.grommet
  }, _react["default"].createElement(_grommet.Box, {
    pad: "large",
    direction: "row",
    gap: "medium"
  }, _react["default"].createElement(LabelledChart, {
    label: "Exported",
    value: 300
  }), _react["default"].createElement(LabelledChart, {
    label: "Usable",
    value: 200,
    color: "accent-2"
  }), _react["default"].createElement(LabelledChart, {
    label: "Used",
    value: 98.2,
    color: "accent-3"
  })));
github grommet / grommet / contexts / AnnounceContext / announce-context.stories.js View on Github external
var AnnounceContextComponent = function AnnounceContextComponent(props) {
  return _react["default"].createElement(_grommet.Grommet, {
    theme: _themes.grommet,
    full: true
  }, _react["default"].createElement(_grommet.Box, {
    justify: "center",
    align: "center",
    background: "brand",
    fill: true
  }, _react["default"].createElement(_grommet.Heading, null, "Welcome to announcement section"), _react["default"].createElement(_grommet.AnnounceContext.Consumer, null, function (announce) {
    return _react["default"].createElement(Announcer, _extends({
      announce: announce
    }, props));
  })));
};
github grommet / grommet / components / Calendar / stories / CustomHeader.js View on Github external
var CustomHeaderCalendar = function CustomHeaderCalendar() {
  var _useState = (0, _react.useState)(),
      date = _useState[0],
      setDate = _useState[1];

  var onSelect = function onSelect(nextDate) {
    setDate(nextDate !== date ? nextDate : undefined);
  };

  return _react["default"].createElement(_grommet.Grommet, {
    theme: _themes.grommet
  }, _react["default"].createElement(_grommet.Box, {
    align: "center",
    pad: "large"
  }, _react["default"].createElement(_grommet.Calendar, {
    date: date,
    onSelect: onSelect,
    size: "small",
    bounds: ['2018-09-08', '2018-12-13'],
    header: function header(_ref) {
      var currentDate = _ref.date,
          locale = _ref.locale,
          onPreviousMonth = _ref.onPreviousMonth,
          onNextMonth = _ref.onNextMonth,
          previousInBound = _ref.previousInBound,
          nextInBound = _ref.nextInBound;
      return _react["default"].createElement(_grommet.Box, {
github grommet / grommet / components / Chart / stories / Zoom.js View on Github external
_proto.render = function render() {
    var _this2 = this;

    var _this$state = this.state,
        axis = _this$state.axis,
        bounds = _this$state.bounds,
        interval = _this$state.interval,
        nextReference = _this$state.nextReference,
        previousReference = _this$state.previousReference,
        thickness = _this$state.thickness,
        values = _this$state.values;
    return _react["default"].createElement(_grommet.Grommet, {
      theme: _themes.grommet
    }, _react["default"].createElement(_grommet.Box, {
      pad: "large",
      direction: "row",
      gap: "medium"
    }, _react["default"].createElement(_grommet.Button, {
      hoverIndicator: true,
      icon: _react["default"].createElement(_grommetIcons.Previous, null),
      onClick: function onClick() {
        return _this2.setState({
          reference: previousReference
        });
      }
    }), _react["default"].createElement(_grommet.Box, {
      flex: true
    }, _react["default"].createElement(_grommet.Box, {
      direction: "row",