From 9f4103a270916ebe672605cc79e72bd208ec6e20 Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Wed, 15 Nov 2023 16:08:00 +0100 Subject: [PATCH] docs(datagrid): doc with menu & formatter --- .../usage-guidelines/usage-style.css | 6 + .../documentation/usage-guidelines/usage.mdx | 115 ++++++++++-------- packages/components/datagrid/src/index.html | 5 +- 3 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 packages/components/datagrid/documentation/usage-guidelines/usage-style.css diff --git a/packages/components/datagrid/documentation/usage-guidelines/usage-style.css b/packages/components/datagrid/documentation/usage-guidelines/usage-style.css new file mode 100644 index 0000000000..0c6e4196f2 --- /dev/null +++ b/packages/components/datagrid/documentation/usage-guidelines/usage-style.css @@ -0,0 +1,6 @@ +:root { + --ods-menu-position: absolute; + --ods-select-position: absolute; + --ods-popover-position: absolute; + --ods-tooltip-position: absolute; +} diff --git a/packages/components/datagrid/documentation/usage-guidelines/usage.mdx b/packages/components/datagrid/documentation/usage-guidelines/usage.mdx index 1604786e32..1065a99195 100644 --- a/packages/components/datagrid/documentation/usage-guidelines/usage.mdx +++ b/packages/components/datagrid/documentation/usage-guidelines/usage.mdx @@ -1,5 +1,5 @@ import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx'; - +import './usage-style.css'; ## Usage @@ -57,6 +57,7 @@ import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx'; height="150"> ``` + ### With sortable columns + +export const datagridFormatter = () => { + setTimeout(() => { + const datagrid = document.getElementById('datagridWithFormatter'); + if (!datagrid) { + return; + } + datagrid.columns = [ + { title: "Name", field: "name", isSortable: true }, + { title: "Firstname", field: "firstname" }, + { title: "Gender", field: "gender" }, + { title: "Date Of Birth", field: "dob", formatter: (value) => { + return ' ' + value + '' + } + }, + ]; + datagrid.rows = [ + { name: "Dupont", firstname: "Antoine", gender: "male", dob: "15/11/1996" }, + { name: "Garnbret", firstname: "Janja", gender: "female", dob: "12/03/1999" }, + ]; + datagrid.height = 150; + }, 0); +}; + + - +<>{ datagridFormatter() } ```html @@ -102,7 +123,7 @@ import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx'; { title: "Name", field: "name", isSortable: true }, { title: "Firstname", field: "firstname" }, { title: "Gender", field: "gender" }, - { title: "Date Of Birth", field: "dob", formatter: (value: string) => { + { title: "Date Of Birth", field: "dob", formatter: (value) => { return ' ' + value + '' } }, @@ -139,58 +160,52 @@ import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx'; ``` -### With Formatter - - - - - -```html - +### Use Select, Tooltip, Menu or Popover in row formatter - -``` + { name: "Garnbret", firstname: "Janja", gender: "female", dob: "12/03/1999" }, + ]; + datagrid.height = 150; + }, 0); +}; -### Empty rows - + -```html - +<>{ datagridWithMenu() } - -``` - -### Use Select, Tooltip, Menu or Popover in row formatter ```html diff --git a/packages/components/datagrid/src/index.html b/packages/components/datagrid/src/index.html index 938ee61fd5..844808cdfe 100644 --- a/packages/components/datagrid/src/index.html +++ b/packages/components/datagrid/src/index.html @@ -45,7 +45,10 @@

Empty state