UNPKG

vcc-ui

Version:

VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.

70 lines (62 loc) 2.47 kB
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import React from "react"; import PropTypes from "prop-types"; import { Block, withTheme } from "../block"; import { ConfigContext } from "../../config-context"; import { getImagesSrc } from "./helpers"; var images = { square: "vcc-ui/images/volvo-logo.png", square2x: "vcc-ui/images/volvo-logo-2x.png", wordmark: "vcc-ui/images/volvo-wordmark-white.png", wordmark2x: "vcc-ui/images/volvo-wordmark-white-2x.png" }; var LOGO_TYPES = { SQUARE: "square", WORDMARK: "wordmark" }; var LogoComponent = function LogoComponent(_ref) { var type = _ref.type, height = _ref.height, theme = _ref.theme, altText = _ref.altText; return React.createElement(ConfigContext.Consumer, null, function (_ref2) { var pathPrefix = _ref2.pathPrefix; var _getImagesSrc = getImagesSrc({ type: type, theme: theme, pathPrefix: pathPrefix, defaultImages: images }), src = _getImagesSrc.src, srcSet = _getImagesSrc.srcSet; return React.createElement(Block, { as: "img", src: src, srcSet: srcSet, alt: altText, extend: _objectSpread({ verticalAlign: "middle", maxHeight: "100%" }, theme.logo), height: height }); }); }; var propTypes = { /** Logo type square or wordmark */ type: PropTypes.oneOf([LOGO_TYPES.SQUARE, LOGO_TYPES.WORDMARK]), /** Apply custom height to logo image */ height: PropTypes.string, /** Alternative text for the logo image */ altText: PropTypes.string }; var defaultProps = { type: LOGO_TYPES.SQUARE, altText: "Volvo logo" }; LogoComponent.propTypes = propTypes; LogoComponent.defaultProps = defaultProps; LogoComponent.displayName = "Logo"; var Logo = withTheme(LogoComponent); export { Logo, LOGO_TYPES };