Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ const sections = [
<TableCode>'static'</TableCode>
</td>
</tr>
<tr>
<td>ref</td>
<td>
<TableCode>{"React.Ref<HTMLDivElement>"}</TableCode>
</td>
<td>Reference to the component.</td>
<td>-</td>
</tr>
<tr>
<td>width</td>
<td>
Expand Down
10 changes: 10 additions & 0 deletions apps/website/screens/components/flex/code/FlexCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ const sections = [
<TableCode>'row'</TableCode>
</td>
</tr>
<tr>
<td>fullHeight</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>If true, the component will take the full height of its parent container.</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>gap</td>
<td>
Expand Down
11 changes: 8 additions & 3 deletions packages/lib/src/container/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from "@emotion/styled";
import ContainerPropsType, { BorderProperties, StyledProps } from "./types";
import { forwardRef } from "react";

const getBorderStyles = (direction: "top" | "bottom" | "left" | "right", borderProperties: BorderProperties) =>
`border-${direction}: ${borderProperties.width ?? ""} ${borderProperties.style ?? ""} ${
Expand Down Expand Up @@ -82,6 +83,10 @@ const Container = styled.div<StyledProps>`
padding-left: ${({ padding }) => (typeof padding === "object" && padding.left ? padding.left : "")};
`;

export default function DxcContainer({ display, width, height, overflow, ...props }: ContainerPropsType) {
return <Container $display={display} $width={width} $height={height} $overflow={overflow} {...props} />;
}
const DxcContainer = forwardRef<HTMLDivElement, ContainerPropsType>(
({ display, width, height, overflow, ...props }, ref) => {
return <Container ref={ref} $display={display} $width={width} $height={height} $overflow={overflow} {...props} />;
}
);

export default DxcContainer;
6 changes: 6 additions & 0 deletions packages/lib/src/flex/Flex.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ const Flex = () => (
</DxcFlex>
</DxcFlex>
</Container>
<Title title="Full Height" level={4} />
<div style={{ height: "300px", backgroundColor: "#f2eafa", margin: "2.5rem" }}>
<DxcFlex fullHeight justifyContent="center" alignItems="center">
<Placeholder />
</DxcFlex>
</div>
</>
);

Expand Down
4 changes: 3 additions & 1 deletion packages/lib/src/flex/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Flex = styled.div<StyledProps>`
${typeof props.alignSelf === "string" ? `align-self: ${props.alignSelf};` : ""}
${typeof props.$basis === "string" ? `flex-basis: ${props.$basis};` : ""}
${typeof props.$direction === "string" ? `flex-direction: ${props.$direction};` : ""}
${props.$fullHeight ? "height: 100%;" : ""}
${typeof props.$gap === "string" ? `gap: ${props.$gap};` : ""}
${typeof props.$gap === "object" ? `column-gap: ${props.$gap.columnGap}; row-gap: ${props.$gap.rowGap};` : ""}
${typeof props.$grow === "number" ? `flex-grow: ${props.$grow};` : ""}
Expand All @@ -19,7 +20,7 @@ const Flex = styled.div<StyledProps>`
`}
`;

const DxcFlex = ({ basis, direction, gap, grow, order, shrink, wrap, ...props }: FlexPropsType) => (
const DxcFlex = ({ basis, direction, fullHeight = false, gap, grow, order, shrink, wrap, ...props }: FlexPropsType) => (
<Flex
$basis={basis}
$direction={direction}
Expand All @@ -28,6 +29,7 @@ const DxcFlex = ({ basis, direction, gap, grow, order, shrink, wrap, ...props }:
$order={order}
$shrink={shrink}
$wrap={wrap}
$fullHeight={fullHeight}
{...props}
/>
);
Expand Down
5 changes: 5 additions & 0 deletions packages/lib/src/flex/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type Props = CommonProps & {
* See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/order
*/
order?: number;
/**
* If true, the flex container will take the full height of its parent.
*/
fullHeight?: boolean;
/**
* Sets the flex-grow CSS property.
*
Expand Down Expand Up @@ -117,6 +121,7 @@ export type StyledProps = CommonProps & {
$direction?: "row" | "row-reverse" | "column" | "column-reverse";
$wrap?: "nowrap" | "wrap" | "wrap-reverse";
$gap?: Gap;
$fullHeight?: boolean;
$order?: number;
$grow?: number;
$shrink?: number;
Expand Down