Skip to content

Commit

Permalink
Add 'errored' props in Container and ExpandableContainers
Browse files Browse the repository at this point in the history
  • Loading branch information
subinasr committed Mar 26, 2024
1 parent 4734b06 commit 17f7f7e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/Container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface Props {
ellipsizeHeading?: boolean;
withoutExternalPadding?: boolean;
visibleOverflow?: boolean;
errored?: boolean;
}

function Container(props: Props) {
Expand Down Expand Up @@ -103,6 +104,7 @@ function Container(props: Props) {
withoutExternalPadding,
visibleOverflow,
headingDescriptionClassName,
errored,
} = props;

const internalRef = React.useRef<HTMLDivElement>(null);
Expand All @@ -126,6 +128,7 @@ function Container(props: Props) {
spacingToStyleMap[spacing],
withoutExternalPadding && styles.withoutExternalPadding,
visibleOverflow && styles.visibleOverflow,
errored && styles.errored,
className,
)}
ref={elementRef}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Container/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
overflow: visible;
}
}
&.errored {
border: var(--dui-width-separator-thin) solid var(--dui-color-danger);
}
}

@keyframes get-focus {
Expand Down
9 changes: 8 additions & 1 deletion src/components/ControlledExpandableContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function ControlledExpandableContainer<T>(props: Props<T>) {
spacing = 'comfortable',
withoutExternalPadding,
withoutBorder,
errored,
...otherProps
} = props;

Expand All @@ -78,6 +79,7 @@ function ControlledExpandableContainer<T>(props: Props<T>) {
withoutExternalPadding && styles.withoutExternalPadding,
!withoutBorder && styles.withBorder,
expanded && styles.expanded,
errored && styles.errored,
className,
)}
headerElementProps={
Expand All @@ -89,9 +91,14 @@ function ControlledExpandableContainer<T>(props: Props<T>) {
styles.header,
headerClassName,
expansionTriggerArea === 'header' && !disabled && styles.clickableHeader,
errored && styles.errored,
)}
headingContainerClassName={_cs(styles.headingContainer, headingContainerClassName)}
headingClassName={_cs(styles.heading, headingClassName)}
headingClassName={_cs(
styles.heading,
headingClassName,
errored && styles.errored,
)}
heading={heading}
headingSize={headingSize ?? 'small'}
spacing={spacing}
Expand Down
11 changes: 11 additions & 0 deletions src/components/ControlledExpandableContainer/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
.heading-container {
.heading {
color: var(--dui-color-accent);

&.errored {
color: var(--dui-color-danger);
}
}
}

Expand All @@ -21,6 +25,10 @@
&.clickable-header {
cursor: pointer;
}

&.errored {
background-color: var(--dui-color-surface-negative);
}
}

&.expanded {
Expand Down Expand Up @@ -60,5 +68,8 @@
&.loose-spacing {
--spacing: var(--dui-spacing-large);
}
&.errored {
border: var(--dui-width-separator-thin) solid var(--dui-color-danger);
}
}

6 changes: 6 additions & 0 deletions storybook/stories/ControlledExpandableContainer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ export const Default = Template.bind({});
Default.args = {
children: 'A lof of ui elements',
};

export const Errored = Template.bind({});
Errored.args = {
children: 'A lof of ui elements',
errored: true,
};
7 changes: 7 additions & 0 deletions storybook/stories/ExpandableContainer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ DisabledExpandableContainer.args = {
children: 'I should expand on arrow click and not the whole header.',
disabled: true,
};

export const ErroredExpandableContainer = Template.bind({});
ErroredExpandableContainer.args = {
heading: 'Extended Matrixes',
children: 'I should expand on arrow click and not the whole header.',
errored: true,
};

0 comments on commit 17f7f7e

Please sign in to comment.