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
51 changes: 34 additions & 17 deletions lib/src/flex/Flex.tsx
Original file line number Diff line number Diff line change
@@ -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 => <Flex {...props}>{children}</Flex>;
const DxcFlex = ({
direction = "row",
wrap = "nowrap",
gap = "0",
order = 0,
grow = 0,
shrink = 1,
basis = "auto",
children,
...props
}: FlexPropsType): JSX.Element => (
<Flex
$direction={direction}
$wrap={wrap}
$order={order}
$grow={grow}
$shrink={shrink}
$basis={basis}
$gap={gap}
{...props}
>
{children}
</Flex>
);

const Flex = styled.div<FlexPropsType>`
const Flex = styled.div<StyledProps>`
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};
`}
`;

Expand Down
19 changes: 16 additions & 3 deletions lib/src/flex/types.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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;
13 changes: 7 additions & 6 deletions lib/src/text-input/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,13 @@ const InputContainer = styled.div<CommonDisabledBackgroundTypeProps & { error: b
: props.theme.hoverBorderColor
};
${
props.error &&
`box-shadow: 0 0 0 2px ${
props.backgroundType === "dark"
? props.theme.hoverErrorBorderColorOnDark
: props.theme.hoverErrorBorderColor
};`
props.error
? `box-shadow: 0 0 0 2px ${
props.backgroundType === "dark"
? props.theme.hoverErrorBorderColorOnDark
: props.theme.hoverErrorBorderColor
};`
: ""
}
}
&:focus-within {
Expand Down