diff --git a/apps/website/screens/components/container/code/ContainerCodePage.tsx b/apps/website/screens/components/container/code/ContainerCodePage.tsx index e3ec95970..c48b2e152 100644 --- a/apps/website/screens/components/container/code/ContainerCodePage.tsx +++ b/apps/website/screens/components/container/code/ContainerCodePage.tsx @@ -361,6 +361,14 @@ const sections = [ 'static' + + ref + + {"React.Ref"} + + Reference to the component. + - + width diff --git a/apps/website/screens/components/flex/code/FlexCodePage.tsx b/apps/website/screens/components/flex/code/FlexCodePage.tsx index 9fb0ce5ff..175a58535 100644 --- a/apps/website/screens/components/flex/code/FlexCodePage.tsx +++ b/apps/website/screens/components/flex/code/FlexCodePage.tsx @@ -135,6 +135,16 @@ const sections = [ 'row' + + fullHeight + + boolean + + If true, the component will take the full height of its parent container. + + false + + gap diff --git a/packages/lib/src/container/Container.tsx b/packages/lib/src/container/Container.tsx index 37ac9672b..6297fd8b0 100644 --- a/packages/lib/src/container/Container.tsx +++ b/packages/lib/src/container/Container.tsx @@ -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 ?? ""} ${ @@ -82,6 +83,10 @@ const Container = styled.div` padding-left: ${({ padding }) => (typeof padding === "object" && padding.left ? padding.left : "")}; `; -export default function DxcContainer({ display, width, height, overflow, ...props }: ContainerPropsType) { - return ; -} +const DxcContainer = forwardRef( + ({ display, width, height, overflow, ...props }, ref) => { + return ; + } +); + +export default DxcContainer; diff --git a/packages/lib/src/flex/Flex.stories.tsx b/packages/lib/src/flex/Flex.stories.tsx index fd088a1cb..3368f4615 100644 --- a/packages/lib/src/flex/Flex.stories.tsx +++ b/packages/lib/src/flex/Flex.stories.tsx @@ -113,6 +113,12 @@ const Flex = () => ( + + <div style={{ height: "300px", backgroundColor: "#f2eafa", margin: "2.5rem" }}> + <DxcFlex fullHeight justifyContent="center" alignItems="center"> + <Placeholder /> + </DxcFlex> + </div> </> ); diff --git a/packages/lib/src/flex/Flex.tsx b/packages/lib/src/flex/Flex.tsx index 1a198e554..ca57aa486 100644 --- a/packages/lib/src/flex/Flex.tsx +++ b/packages/lib/src/flex/Flex.tsx @@ -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};` : ""} @@ -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} @@ -28,6 +29,7 @@ const DxcFlex = ({ basis, direction, gap, grow, order, shrink, wrap, ...props }: $order={order} $shrink={shrink} $wrap={wrap} + $fullHeight={fullHeight} {...props} /> ); diff --git a/packages/lib/src/flex/types.ts b/packages/lib/src/flex/types.ts index e7c28dfcb..b61097530 100644 --- a/packages/lib/src/flex/types.ts +++ b/packages/lib/src/flex/types.ts @@ -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. * @@ -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;