Skip to content

Commit

Permalink
feat: align checkbox to top of multiline text (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomictangerine authored Jan 17, 2023
1 parent 706931d commit 90f3d30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 7 additions & 6 deletions ui/checkbox/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import * as PrimitiveCheckbox from "@radix-ui/react-checkbox";

import { InputLabel } from "@washingtonpost/wpds-input-label";

import { RequiredIndicatorCSS } from "@washingtonpost/wpds-input-shared";

const StyledCheckbox = styled(PrimitiveCheckbox.Root, {
transition: `background ${theme.transitions.fast} ${theme.transitions.inOut}`,
appearance: "none",
Expand Down Expand Up @@ -260,15 +258,19 @@ const StyledInputLabel = styled(InputLabel, {
cursor: "default",
gap: "$025",
flexDirection: "row",
alignItems: "flex-end",
alignItems: "flex-start",
justifyContent: "center",
lineHeight: theme.lineHeights["050"],
});

const StyledLabel = styled("span", {
alignSelf: "flex-end",
});

export const Checkbox = React.forwardRef<HTMLButtonElement, CheckboxInterface>(
(props, ref) => {
return (
<StyledInputLabel htmlFor={props.id}>
<StyledInputLabel htmlFor={props.id} required={props.required}>
<StyledCheckbox ref={ref} {...props}>
<StyledIndicator
size={props.size}
Expand Down Expand Up @@ -300,8 +302,7 @@ export const Checkbox = React.forwardRef<HTMLButtonElement, CheckboxInterface>(
</StyledCheck>
</StyledIndicator>
</StyledCheckbox>
{props.label || props.children}
{props.required && <span className={RequiredIndicatorCSS()}>*</span>}
<StyledLabel>{props.label || props.children}</StyledLabel>
</StyledInputLabel>
);
}
Expand Down
8 changes: 6 additions & 2 deletions ui/checkbox/src/play.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ const ChromaticTemplate = () => {
checked
variant="primary"
data-testid="test-checkbox-primary"
label="this checkbox is required"
required={isRequired}
/>
>
this checkbox is required this checkbox is required this checkbox is
required this checkbox is required this checkbox is required this
checkbox is required this checkbox is required this checkbox is
required
</Component>
</HStack>
<HStack>
<Component
Expand Down

2 comments on commit 90f3d30

@vercel
Copy link

@vercel vercel bot commented on 90f3d30 Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit – ./build.washingtonpost.com

wpds-ui-kit-git-main.preview.now.washingtonpost.com
wpds-ui-kit.preview.now.washingtonpost.com
build.washingtonpost.com

@vercel
Copy link

@vercel vercel bot commented on 90f3d30 Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit-storybook – ./

wpds-ui-kit-storybook.preview.now.washingtonpost.com
wpds-ui-kit-storybook-git-main.preview.now.washingtonpost.com

Please sign in to comment.