Skip to content

Commit

Permalink
add alignItems prop
Browse files Browse the repository at this point in the history
  • Loading branch information
serdec committed Sep 29, 2023
1 parent fc20bd0 commit 12fcd14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/Panel/Panel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Playground = {
height: "",
fillHeight: false,
width: "50%",
alignItems: "start",
children: (
<>
<Title type="h3">Example panel title</Title>
Expand Down
8 changes: 7 additions & 1 deletion src/components/Panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from "styled-components";

export type PanelPadding = "none" | "xs" | "sm" | "md" | "lg" | "xl";
export type PanelColor = "default" | "muted" | "transparent";
type AlignItemsOption = "start" | "center" | "end";

export interface PanelProps extends HTMLAttributes<HTMLDivElement> {
hasBorder?: boolean;
Expand All @@ -16,6 +17,7 @@ export interface PanelProps extends HTMLAttributes<HTMLDivElement> {
fillWidth?: boolean;
height?: string;
fillHeight?: boolean;
alignItems?: AlignItemsOption;
}

export const Panel = ({
Expand All @@ -29,6 +31,7 @@ export const Panel = ({
fillWidth,
height,
fillHeight,
alignItems = "center",
...props
}: PanelProps) => (
<Wrapper
Expand All @@ -41,6 +44,7 @@ export const Panel = ({
$fillWidth={fillWidth}
$height={height}
$fillHeight={fillHeight}
$alignItems={alignItems}
{...props}
>
{children}
Expand All @@ -57,11 +61,13 @@ const Wrapper = styled.div<{
$height?: string;
$fillHeight?: boolean;
$orientation?: Orientation;
$alignItems?: AlignItemsOption;
}>`
display: flex;
flex-flow: ${({ $orientation = "horizontal" }) =>
$orientation === "horizontal" ? "row wrap" : "column"};
align-items: flex-start;
align-items: ${({ $alignItems = "center" }) =>
$alignItems === "center" ? "center" : `flex-${$alignItems}`};
width: ${({ $width, $fillWidth }) => ($fillWidth ? "100%" : $width)};
height: ${({ $height, $fillHeight }) => ($fillHeight ? "100%" : $height)};
background-color: ${({ $color = "default", theme }) =>
Expand Down

0 comments on commit 12fcd14

Please sign in to comment.