UNPKG

jobiqo-cl

Version:

[![CircleCI](https://circleci.com/gh/jobiqo/jobiqo-cl.svg?style=svg&circle-token=5a24efa5b8bbc4879276123e77d0d3f35ca7144c)](https://circleci.com/gh/jobiqo/jobiqo-cl)

66 lines (62 loc) 2.67 kB
import { __rest } from '../../../../../node_modules/tslib/tslib.es6.js'; import React__default from 'react'; import styled from 'styled-components'; import { Grid } from '../../../02-atoms/06-layout/04-grid/index.js'; import { Cell } from '../../../02-atoms/06-layout/04-grid/Cell.js'; /** * @file index.tsx * * @fileoverview Creates a group of several form items and displays them * together under a single label and description. */ const StyledFormGroup = styled.div ` margin: ${props => props.theme.formGroup.margin}; padding: ${props => props.theme.formGroup.padding}; border-top-width: ${props => props.theme.formGroup.borderWidth}; border-top-style: ${props => props.theme.formGroup.borderStyle}; border-top-color: ${props => props.theme.formGroup.borderColor}; &:first-child { border-top-width: 0px; padding-top: 0; margin-top: 0; } `; const StyledLabel = styled.div ` display: flex; color: ${props => props.valid ? props.theme.colors.success : props.theme.formGroup.label.color}; text-transform: ${props => props.theme.formGroup.label.textTransform}; letter-spacing: ${props => props.theme.formGroup.label.letterSpacing}; font-weight: ${props => props.theme.formGroup.label.fontWeight}; font-size: ${props => props.theme.formGroup.label.fontSize}; svg { margin-right: 0.5rem; width: 20px; height: 20px; } `; const StyledDescription = styled.div ` margin-top: ${props => props.theme.formGroup.description.marginTop}; font-size: ${props => props.theme.formGroup.description.fontSize}; color: ${props => props.valid ? props.theme.colors.success : props.theme.formGroup.description.color}; `; /** * The form group component groups several form items together in a group. * For longer forms it is recommended to group items together in logical * groups so that the user can scan the form more easily. */ const FormGroup = (_a) => { var { children, label, description, icon, valid } = _a, props = __rest(_a, ["children", "label", "description", "icon", "valid"]); return (React__default.createElement(StyledFormGroup, null, React__default.createElement(Grid, { gap: "2rem", columns: "repeat(auto-fit,minmax(250px,1fr))" }, (label || description) && (React__default.createElement(Cell, { width: 1 }, React__default.createElement(StyledLabel, { valid: valid }, icon, label), React__default.createElement(StyledDescription, { valid: valid }, description))), React__default.createElement(Cell, { width: 2 }, children)))); }; export { FormGroup };