Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Component implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
francocorreasosa committed Jan 28, 2020
1 parent 7e90a1d commit 8ecc782
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/components/molecules/form/field/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface IFieldProps {
actions?: Array<JSX.Element | ActionWithIcon>;
/** checkbox alignment */
checkbox?: boolean;
/** Shows the user this field is required */
required?: boolean;
hasError?: boolean;
htmlFor?: string;
children?: React.ReactNode;
Expand Down Expand Up @@ -123,6 +125,7 @@ const Field = (props: IFieldProps) => {
<Field.Element layout={context.layout} fullWidth={context.fullWidth} {...Automation("form.field")}>
<Field.LabelLayout checkbox={useCheckboxStyle} layout={context.layout}>
<Label htmlFor={id}>{props.label}</Label>
{props.required && <Field.RequiredIndicator />}
</Field.LabelLayout>
<Field.ContentLayout layout={context.layout} {...Automation("form.field.content")}>
{props.fieldComponent ? (
Expand Down Expand Up @@ -177,6 +180,11 @@ Field.Element = styled.div`
}
`;

Field.RequiredIndicator = styled.span.attrs({ children: "*" })`
color: red;
margin-left: ${spacing.unit / 2}px;
`;

Field.FieldSetElement = styled.fieldset`
&:not(:last-child):not(:only-child) {
margin-bottom: ${spacing.medium};
Expand Down

0 comments on commit 8ecc782

Please sign in to comment.