@navinc/base-react-components
Version:
Nav's Pattern Library
65 lines (62 loc) • 2.56 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LabelOverValueContainer = exports.LabelOverValue = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = __importDefault(require("styled-components"));
const copy_1 = __importDefault(require("./copy"));
const header_js_1 = __importDefault(require("./header.js"));
const Label = (0, styled_components_1.default)(copy_1.default).attrs(() => ({ size: 'xs' })) ``;
const LabelAlignmentWrapper = styled_components_1.default.div `
display: flex;
height: 30px;
align-items: flex-end;
`;
const Value = (0, styled_components_1.default)(header_js_1.default).attrs(() => ({ size: 'md', as: copy_1.default })) `
min-height: 30px;
word-break: break-word;
`;
const Wrapper = styled_components_1.default.div `
width: 122px;
max-width: 270px;
display: flex;
flex-flow: column nowrap;
border-bottom: solid 1px ${({ theme }) => theme.neutral300};
border-top: solid 1px ${({ theme }) => theme.white};
padding-bottom: 16px;
padding-top: 16px;
flex-grow: 1;
`;
const Container = styled_components_1.default.div `
display: flex;
flex-flow: row wrap;
align-items: stretch;
${({ borderColor }) => (borderColor ? `border: 1px solid ${borderColor}` : '')};
border-radius: 4px;
padding: 16px;
flex-grow: ${({ length = 1 }) => length};
flex-shrink: ${({ length = 1 }) => length};
margin-top: -16px; /* these margin-tops are to give space between rows when they wrap */
margin-right: -16px;
& > * {
margin-right: 16px;
margin-top: 16px;
}
& > & {
margin-top: 16px;
margin-right: 16px;
& > ${Wrapper} {
margin-top: 0;
border: none;
padding-bottom: 0;
padding-top: 0;
}
}
`;
const LabelOverValue = ({ value = '', label = '' }) => ((0, jsx_runtime_1.jsxs)(Wrapper, { children: [(0, jsx_runtime_1.jsx)(LabelAlignmentWrapper, { children: (0, jsx_runtime_1.jsx)(Label, { children: label }, void 0) }, void 0), (0, jsx_runtime_1.jsx)(Value, { children: value }, void 0)] }, void 0));
exports.LabelOverValue = LabelOverValue;
const LabelOverValueContainer = ({ children = [], borderColor }) => ((0, jsx_runtime_1.jsx)(Container, Object.assign({ length: children.length, borderColor: borderColor }, { children: children }), void 0));
exports.LabelOverValueContainer = LabelOverValueContainer;
//# sourceMappingURL=label-over-value.js.map