💄(react) align actions column items on the right

The design-system guidelines tell that actions button must be aligned
on the right. To make this behavior effortless this feature adds a
special class to actions column to apply the correct css style in order
to achieve that.
This commit is contained in:
Nathan Vasse
2023-09-01 11:33:56 +02:00
committed by NathanVss
parent 4d2a5d1873
commit cf299d9e2b
5 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": minor
---
add auto right alignment for the actions column in DataGrid

View File

@@ -163,6 +163,12 @@ The component automatically displays an empty state when there is no data to dis
<Story id="components-datagrid--empty"/>
</Canvas>
## Actions alignment
As you can see from examples above there's often a dedicated column for actions ( the right-most one ). Our recommendation
is to align on the right the actions buttons, in order to make this easy and convenient we automatically align the right
the cell contents of this column when you give it the `id` `actions`.
## Do's and don'ts
### Button

View File

@@ -105,6 +105,11 @@
color: var(--c--theme--colors--greyscale-800);
font-weight: var(--c--theme--font--weights--medium);
}
&--actions {
display: flex;
align-items: center;
justify-content: flex-end;
}
}
}

View File

@@ -272,8 +272,8 @@ export const DataListOnly = () => {
{ field: "title" },
{ field: "date" },
{
headerName: "action",
id: "action",
headerName: "actions",
id: "actions",
renderCell: () => {
return (
<Button size="small" color="secondary">

View File

@@ -225,6 +225,8 @@ export const DataGrid = <T extends Row>({
key={cell.id}
className={classNames({
"c__datagrid__row__cell--highlight": highlight,
"c__datagrid__row__cell--actions":
cell.column.id === "actions",
})}
>
{flexRender(