Skip to content

Commit

Permalink
Fix Alignment issue in form elements
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok committed Sep 28, 2023
1 parent 7b19eff commit 7e2c57b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/Input/InputWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const InputWrapper = ({
<FormRoot
$orientation={orientation}
$dir={dir}
$addLabelPadding
>
<FormElementContainer>
<Wrapper $error={!!error}>{children}</Wrapper>
Expand Down
1 change: 1 addition & 0 deletions src/components/Select/common/InternalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export const InternalSelect = ({
<FormRoot
$orientation={orientation}
$dir={dir}
$addLabelPadding
{...props}
>
<FormElementContainer>
Expand Down
15 changes: 10 additions & 5 deletions src/components/commonElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { IconSize } from "./Icon/types";
export const FormRoot = styled.div<{
$orientation?: "horizontal" | "vertical";
$dir?: "start" | "end";
$addLabelPadding?: boolean;
}>`
display: flex;
width: 100%;
gap: ${({ theme }) => theme.click.field.space.gap};
${({ theme, $orientation = "vertical", $dir = "start" }) => `
${({ theme, $orientation = "vertical", $dir = "start", $addLabelPadding = false }) => `
flex-direction: ${
$orientation === "horizontal"
? $dir === "start"
Expand All @@ -19,11 +20,15 @@ export const FormRoot = styled.div<{
: "column"
};
align-items: flex-start;
${
$addLabelPadding && $orientation === "horizontal"
? `
label {
padding-top: ${
$orientation === "horizontal" ? `calc(${theme.click.field.space.y} + 1px)` : 0
};
${$orientation === "horizontal" ? "line-height: 1lh;" : ""}
padding-top: calc(${theme.click.field.space.y} + 1px);
line-height: 1lh;
}
`
: ""
}
`}
* {
Expand Down

0 comments on commit 7e2c57b

Please sign in to comment.