Skip to content

Commit 14aef37

Browse files
committed
add noWrap property to display CardActions without wrapping its children to multiple lines
1 parent eba8881 commit 14aef37

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2323
- `<NodeContent />`
2424
- `resizeDirections` to specifiy the axis that can be used to resize the node
2525
- `resizeMaxDimensions` to add maximum values for resizing height/width
26+
- `<CardActions />`
27+
- `noWrap` property to display them without wrapping its children on multiple lines
28+
- `<SimpleDialog />`
29+
- `actionsProps` property to forward `CardActions` properties, e.g. `noWrap`
2630

2731
## [24.0.1] - 2025-02-06
2832

src/components/Card/CardActions.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export interface CardActionsProps extends React.HTMLAttributes<HTMLDivElement> {
88
* Mainly used for cards used as modals (dialogs).
99
*/
1010
inverseDirection?: boolean;
11+
/**
12+
* Set footer to display its children on only one line.
13+
*/
14+
noWrap?: boolean;
1115
}
1216

1317
/**
@@ -18,6 +22,7 @@ export const CardActions = ({
1822
children,
1923
className = "",
2024
inverseDirection = false,
25+
noWrap = false,
2126
...otherProps
2227
}: CardActionsProps) => {
2328
return (
@@ -26,6 +31,7 @@ export const CardActions = ({
2631
className={
2732
`${eccgui}-card__actions` +
2833
(inverseDirection ? ` ${eccgui}-card__actions--inversedirection` : "") +
34+
(noWrap ? ` ${eccgui}-card__actions--nowrap` : "") +
2935
(className ? " " + className : "")
3036
}
3137
>

src/components/Card/card.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ $eccgui-size-card-spacing: $eccgui-size-typo-base !default;
236236
flex-direction: row-reverse;
237237
}
238238

239+
.#{$eccgui}-card__actions--nowrap {
240+
flex-wrap: nowrap;
241+
}
242+
239243
.#{$eccgui}-card__actions__aux {
240244
display: flex;
241245
flex-flow: row wrap;
@@ -272,4 +276,15 @@ $eccgui-size-card-spacing: $eccgui-size-typo-base !default;
272276
.#{$eccgui}-card__actions--inversedirection > & {
273277
justify-content: flex-start;
274278
}
279+
280+
.#{$eccgui}-card__actions--nowrap > & {
281+
flex-shrink: 5;
282+
flex-wrap: nowrap;
283+
min-width: 0;
284+
285+
& > * {
286+
flex-shrink: 10;
287+
min-width: 0;
288+
}
289+
}
275290
}

src/components/Dialog/SimpleDialog.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
55
import IconButton from "../Icon/IconButton";
66
import { TestableComponent } from "../interfaces";
77

8-
import { Card, CardActions, CardContent, CardHeader, CardOptions, CardTitle } from "./../Card";
8+
import { Card, CardActions, CardActionsProps, CardContent, CardHeader, CardOptions, CardTitle } from "./../Card";
99
import Divider from "./../Separation/Divider";
1010
import Modal, { ModalProps } from "./Modal";
1111

@@ -45,6 +45,8 @@ export interface SimpleDialogProps extends ModalProps, TestableComponent {
4545
showFullScreenToggler?: boolean;
4646
/** Starts the modal in full screen mode. The show full screen toggler will be automatically enabled. */
4747
startInFullScreenMode?: boolean;
48+
/** Forward properties to the actions footer component. */
49+
actionsProps?: Omit<CardActionsProps, "inverseDirection">;
4850
}
4951

5052
/**
@@ -66,6 +68,7 @@ export const SimpleDialog = ({
6668
showFullScreenToggler = false,
6769
startInFullScreenMode = false,
6870
size,
71+
actionsProps,
6972
...otherProps
7073
}: SimpleDialogProps) => {
7174
const [displayFullscreen, setDisplayFullscreen] = React.useState<boolean>(startInFullScreenMode);
@@ -112,7 +115,11 @@ export const SimpleDialog = ({
112115
<CardContent className={`${eccgui}-dialog__notifications`}>{notifications}</CardContent>
113116
)}
114117
{actions && (
115-
<CardActions inverseDirection className={intentClassName}>
118+
<CardActions
119+
{...actionsProps}
120+
inverseDirection
121+
className={`${actionsProps?.className ?? ""} ${intentClassName}`}
122+
>
116123
{actions}
117124
</CardActions>
118125
)}

0 commit comments

Comments
 (0)