UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

55 lines (50 loc) 2.07 kB
import * as React from "react"; import styled, { css } from "styled-components"; import defaultTheme from "../../defaultTheme"; import ButtonLink from "../../ButtonLink"; var StyledOnlyButton = styled.div.withConfig({ displayName: "FilterWrapper__StyledOnlyButton", componentId: "sc-1cpg3jn-0" })([""]); var hoverAndFocus = function hoverAndFocus() { return css(["background-color:", ";", "{visibility:visible;opacity:1;}"], function (_ref) { var theme = _ref.theme; return theme.orbit.paletteBlueLight; }, StyledOnlyButton); }; var StyledContentWrapper = styled.div.withConfig({ displayName: "FilterWrapper__StyledContentWrapper", componentId: "sc-1cpg3jn-1" })(["box-sizing:border-box;width:100%;padding-left:4px;border-radius:4px;display:flex;align-items:center;height:", ";", "{visibility:hidden;opacity:0;}", ";"], function (_ref2) { var theme = _ref2.theme; return theme.orbit.heightButtonSmall; }, StyledOnlyButton, function (_ref3) { var disabled = _ref3.disabled; return !disabled && css(["&:hover{", "}&:focus-within{", "}"], hoverAndFocus, hoverAndFocus); }); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledContentWrapper.defaultProps = { theme: defaultTheme }; var FilterWrapper = function FilterWrapper(_ref4) { var child = _ref4.child, children = _ref4.children, onOnlySelection = _ref4.onOnlySelection, onlySelectionText = _ref4.onlySelectionText; var _child$props = child.props, value = _child$props.value, label = _child$props.label, disabled = _child$props.disabled; return /*#__PURE__*/React.createElement(StyledContentWrapper, { disabled: disabled }, children, onOnlySelection && !disabled && /*#__PURE__*/React.createElement(StyledOnlyButton, null, /*#__PURE__*/React.createElement(ButtonLink, { type: "secondary", size: "small", onClick: function onClick(ev) { onOnlySelection(ev, { value: value, label: label }); } }, onlySelectionText))); }; export default FilterWrapper;