diff --git a/.changeset/tall-pandas-care.md b/.changeset/tall-pandas-care.md new file mode 100644 index 0000000..fdfde2b --- /dev/null +++ b/.changeset/tall-pandas-care.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": minor +--- + +add auto right alignment for the actions column in DataGrid diff --git a/packages/react/src/components/DataGrid/index.mdx b/packages/react/src/components/DataGrid/index.mdx index 247c441..931e7e2 100644 --- a/packages/react/src/components/DataGrid/index.mdx +++ b/packages/react/src/components/DataGrid/index.mdx @@ -163,6 +163,12 @@ The component automatically displays an empty state when there is no data to dis +## 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 diff --git a/packages/react/src/components/DataGrid/index.scss b/packages/react/src/components/DataGrid/index.scss index 0f0e384..3996e79 100644 --- a/packages/react/src/components/DataGrid/index.scss +++ b/packages/react/src/components/DataGrid/index.scss @@ -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; + } } } diff --git a/packages/react/src/components/DataGrid/index.stories.tsx b/packages/react/src/components/DataGrid/index.stories.tsx index 18e8c09..c51f86e 100644 --- a/packages/react/src/components/DataGrid/index.stories.tsx +++ b/packages/react/src/components/DataGrid/index.stories.tsx @@ -272,8 +272,8 @@ export const DataListOnly = () => { { field: "title" }, { field: "date" }, { - headerName: "action", - id: "action", + headerName: "actions", + id: "actions", renderCell: () => { return (