@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.
61 lines (60 loc) • 1.64 kB
JavaScript
"use client";
import * as React from "react";
import styled, { css } from "styled-components";
import defaultTheme from "../../defaultTheme";
import { SPACINGS } from "../../utils/layout/consts";
import Text from "../../Text";
const getSpacing = ({
theme
}) => ({
[SPACINGS.XXXSMALL]: theme.orbit.spaceXXXSmall,
[SPACINGS.XXSMALL]: theme.orbit.spaceXXSmall,
[SPACINGS.XSMALL]: theme.orbit.spaceXSmall,
[SPACINGS.SMALL]: theme.orbit.spaceSmall,
[SPACINGS.MEDIUM]: theme.orbit.spaceMedium,
[SPACINGS.LARGE]: theme.orbit.spaceLarge,
[SPACINGS.XLARGE]: theme.orbit.spaceXLarge,
[SPACINGS.XXLARGE]: theme.orbit.spaceXXLarge
});
const resolveSpacing = ({
spacing,
theme
}) => getSpacing({
theme
})[spacing];
const StyledWrapper = styled.div.withConfig({
displayName: "KeyValue__StyledWrapper",
componentId: "sc-vwphu0-0"
})(["", ";"], ({
$direction,
spacing,
theme
}) => css(["display:flex;flex-direction:", ";align-items:", ";gap:", ";"], $direction, $direction !== "column" ? "center" : "flex-start", resolveSpacing({
spacing,
theme
})));
StyledWrapper.defaultProps = {
theme: defaultTheme
};
const KeyValue = ({
dataTest,
label,
value,
direction,
size = "normal",
icon,
spacing
}) => {
return /*#__PURE__*/React.createElement(StyledWrapper, {
"data-test": dataTest,
$direction: direction,
spacing: spacing
}, label && /*#__PURE__*/React.createElement(Text, {
type: "secondary",
size: size === "normal" ? "small" : "normal"
}, label), icon, /*#__PURE__*/React.createElement(Text, {
size: size,
weight: "bold"
}, value));
};
export default KeyValue;