1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import {
type ForwardRefRenderFunction,
type HTMLAttributes,
forwardRef,
type ReactNode,
} from 'react';
import styles from './card.module.scss';
export type CardActionsProps = Omit<
HTMLAttributes<HTMLDivElement>,
'children'
> & {
/**
* The actions alignment.
*
* @default 'end'
*/
alignment?: 'center' | 'end' | 'start';
/**
* The card actions (ie. buttons, links...).
*/
children: ReactNode;
};
const CardActionsWithRef: ForwardRefRenderFunction<
HTMLDivElement,
CardActionsProps
> = ({ alignment = 'end', children, className = '', style, ...props }, ref) => {
const actionsClass = `${styles.actions} ${className}`;
const actionsStyles = {
...style,
'--alignment': alignment === 'center' ? alignment : `flex-${alignment}`,
};
return (
<div {...props} className={actionsClass} ref={ref} style={actionsStyles}>
{children}
</div>
);
};
export const CardActions = forwardRef(CardActionsWithRef);
|