diff --git a/lib/src/flex/Flex.tsx b/lib/src/flex/Flex.tsx index 4695ebc67b..ecd2d7aef4 100644 --- a/lib/src/flex/Flex.tsx +++ b/lib/src/flex/Flex.tsx @@ -1,35 +1,52 @@ import React from "react"; import styled from "styled-components"; -import FlexPropsType from "./types"; +import FlexPropsType, { StyledProps } from "./types"; -const DxcFlex = ({ children, ...props }: FlexPropsType): JSX.Element => {children}; +const DxcFlex = ({ + direction = "row", + wrap = "nowrap", + gap = "0", + order = 0, + grow = 0, + shrink = 1, + basis = "auto", + children, + ...props +}: FlexPropsType): JSX.Element => ( + + {children} + +); -const Flex = styled.div` +const Flex = styled.div` display: flex; ${({ - direction = "row", - wrap = "nowrap", justifyContent = "flex-start", alignItems = "stretch", alignContent = "normal", alignSelf = "auto", - gap = "0", - order = 0, - grow = 0, - shrink = 1, - basis = "auto", + ...props }) => ` - flex-direction: ${direction}; - flex-wrap: ${wrap}; + flex-direction: ${props.$direction}; + flex-wrap: ${props.$wrap}; justify-content: ${justifyContent}; align-items: ${alignItems}; align-content: ${alignContent}; align-self: ${alignSelf}; - gap: ${typeof gap === "object" ? `${gap.rowGap} ${gap.columnGap}` : gap}; - order: ${order}; - flex-grow: ${grow}; - flex-shrink: ${shrink}; - flex-basis: ${basis}; + gap: ${typeof props.$gap === "object" ? `${props.$gap.rowGap} ${props.$gap.columnGap}` : props.$gap}; + order: ${props.$order}; + flex-grow: ${props.$grow}; + flex-shrink: ${props.$shrink}; + flex-basis: ${props.$basis}; `} `; diff --git a/lib/src/flex/types.ts b/lib/src/flex/types.ts index d330aa3f3b..43e79624d9 100644 --- a/lib/src/flex/types.ts +++ b/lib/src/flex/types.ts @@ -1,8 +1,6 @@ type Gap = { rowGap: string; columnGap: string }; -type Props = { - direction?: "row" | "row-reverse" | "column" | "column-reverse"; - wrap?: "nowrap" | "wrap" | "wrap-reverse"; +type CommonProps = { justifyContent?: | "flex-start" | "flex-end" @@ -36,6 +34,11 @@ type Props = { | "space-evenly" | "stretch"; alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "baseline" | "stretch"; +}; + +type Props = CommonProps & { + direction?: "row" | "row-reverse" | "column" | "column-reverse"; + wrap?: "nowrap" | "wrap" | "wrap-reverse"; gap?: string | Gap; order?: number; grow?: number; @@ -45,4 +48,14 @@ type Props = { children: React.ReactNode; }; +export type StyledProps = CommonProps & { + $direction?: "row" | "row-reverse" | "column" | "column-reverse"; + $wrap?: "nowrap" | "wrap" | "wrap-reverse"; + $gap?: string | Gap; + $order?: number; + $grow?: number; + $shrink?: number; + $basis?: string; +}; + export default Props; diff --git a/lib/src/text-input/TextInput.tsx b/lib/src/text-input/TextInput.tsx index 12ee254ab9..d386f2d6d9 100644 --- a/lib/src/text-input/TextInput.tsx +++ b/lib/src/text-input/TextInput.tsx @@ -642,12 +642,13 @@ const InputContainer = styled.div