💄(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:
5
.changeset/tall-pandas-care.md
Normal file
5
.changeset/tall-pandas-care.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@openfun/cunningham-react": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
add auto right alignment for the actions column in DataGrid
|
||||||
@@ -163,6 +163,12 @@ The component automatically displays an empty state when there is no data to dis
|
|||||||
<Story id="components-datagrid--empty"/>
|
<Story id="components-datagrid--empty"/>
|
||||||
</Canvas>
|
</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
|
## Do's and don'ts
|
||||||
|
|
||||||
### Button
|
### Button
|
||||||
|
|||||||
@@ -105,6 +105,11 @@
|
|||||||
color: var(--c--theme--colors--greyscale-800);
|
color: var(--c--theme--colors--greyscale-800);
|
||||||
font-weight: var(--c--theme--font--weights--medium);
|
font-weight: var(--c--theme--font--weights--medium);
|
||||||
}
|
}
|
||||||
|
&--actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -272,8 +272,8 @@ export const DataListOnly = () => {
|
|||||||
{ field: "title" },
|
{ field: "title" },
|
||||||
{ field: "date" },
|
{ field: "date" },
|
||||||
{
|
{
|
||||||
headerName: "action",
|
headerName: "actions",
|
||||||
id: "action",
|
id: "actions",
|
||||||
renderCell: () => {
|
renderCell: () => {
|
||||||
return (
|
return (
|
||||||
<Button size="small" color="secondary">
|
<Button size="small" color="secondary">
|
||||||
|
|||||||
@@ -225,6 +225,8 @@ export const DataGrid = <T extends Row>({
|
|||||||
key={cell.id}
|
key={cell.id}
|
||||||
className={classNames({
|
className={classNames({
|
||||||
"c__datagrid__row__cell--highlight": highlight,
|
"c__datagrid__row__cell--highlight": highlight,
|
||||||
|
"c__datagrid__row__cell--actions":
|
||||||
|
cell.column.id === "actions",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{flexRender(
|
{flexRender(
|
||||||
|
|||||||
Reference in New Issue
Block a user