From e3db31fcaacea72b8c143032e9e2ac3b0f68f29f Mon Sep 17 00:00:00 2001 From: ajaypratap003 Date: Thu, 11 Apr 2024 19:48:52 +0530 Subject: [PATCH] DataList width modifiers demo --- .../examples/DataListWidthModifiers.tsx | 261 ++++++++++++++++++ packages/react-core/src/demos/DataListDemo.md | 9 + 2 files changed, 270 insertions(+) create mode 100644 packages/react-core/src/demos/DataList/examples/DataListWidthModifiers.tsx diff --git a/packages/react-core/src/demos/DataList/examples/DataListWidthModifiers.tsx b/packages/react-core/src/demos/DataList/examples/DataListWidthModifiers.tsx new file mode 100644 index 00000000000..c1686fa08a0 --- /dev/null +++ b/packages/react-core/src/demos/DataList/examples/DataListWidthModifiers.tsx @@ -0,0 +1,261 @@ +import React from 'react'; +import { + DataList, + DataListItem, + DataListCell, + DataListCheck, + DataListAction, + DataListToggle, + DataListContent, + DataListItemCells, + DataListItemRow, + Text, + TextVariants, + TextContent, + Dropdown, + DropdownList, + DropdownItem, + MenuToggle, + MenuToggleElement, + PageSectionVariants, + PageSection +} from '@patternfly/react-core'; +import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; +/* eslint-disable camelcase */ +import global_Color_100 from '@patternfly/react-tokens/dist/esm/global_Color_100'; +import global_BackgroundColor_200 from '@patternfly/react-tokens/dist/esm/global_BackgroundColor_200'; +import global_BorderColor_100 from '@patternfly/react-tokens/dist/esm/global_BorderColor_100'; +import global_BorderWidth_sm from '@patternfly/react-tokens/dist/esm/global_BorderWidth_sm'; +import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper'; + +export const DataListWidthModifiers: React.FunctionComponent = () => { + const [show, setShow] = React.useState(true); + const [isOpen1, setIsOpen1] = React.useState(false); + const [isOpen2, setIsOpen2] = React.useState(false); + + const onToggle1 = () => { + setIsOpen1(!isOpen1); + }; + + const onSelect1 = () => { + setIsOpen1(!isOpen1); + }; + + const onToggle2 = () => { + setIsOpen2(!isOpen2); + }; + + const onSelect2 = () => { + setIsOpen2(!isOpen2); + }; + + const previewPlaceholder = { + display: 'block', + width: '100%', + padding: '.25rem .5rem', + color: global_Color_100.var, + backgroundColor: global_BackgroundColor_200.var, + border: `${global_BorderWidth_sm.var} ${global_BorderColor_100.var} solid` + }; + + return ( + + + + Projects + This is a demo that showcases PatternFly Data List + + +
+ + Default fitting - example 1 + + + + + + +
+ default +

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+
+ , + +
+ default +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut + labore et dolore magna aliqua. +

+
+
+ ]} + /> +
+
+
+
+
+ + Flex modifiers - example 2 + + + + + + +
+ width 2 +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.

+
+ , + +
+ width 4 +

Lorem ipsum dolor sit amet.

+
+
+ ]} + /> + + ) => ( + + + )} + isOpen={isOpen1} + onOpenChange={(isOpen: boolean) => setIsOpen1(isOpen)} + > + + Action + {/* Prevent default onClick functionality for example + purposes */} + event.preventDefault()}> + Link + + + Disabled Action + + event.preventDefault()} + > + Disabled Link + + + + +
+
+
+
+
+ + Flex modifiers - example 3 + + + + + setShow(!show)} + /> + + +
+ width 5 +

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+
+ , + +
+ width 2 +

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

+
+
, + +
default
+
+ ]} + /> + + ) => ( + + + )} + isOpen={isOpen2} + onOpenChange={(isOpen: boolean) => setIsOpen2(isOpen)} + > + + Action + {/* Prevent default onClick functionality for example + purposes */} + event.preventDefault()}> + Link + + + Disabled Action + + event.preventDefault()} + > + Disabled Link + + + + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. +

+
+
+
+
+
+ ); +}; diff --git a/packages/react-core/src/demos/DataListDemo.md b/packages/react-core/src/demos/DataListDemo.md index b156dc8c192..ee144a918ed 100644 --- a/packages/react-core/src/demos/DataListDemo.md +++ b/packages/react-core/src/demos/DataListDemo.md @@ -15,6 +15,10 @@ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/excl import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper'; +import global_Color_100 from '@patternfly/react-tokens/dist/esm/global_Color_100'; +import global_BackgroundColor_200 from '@patternfly/react-tokens/dist/esm/global_BackgroundColor_200'; +import global_BorderColor_100 from '@patternfly/react-tokens/dist/esm/global_BorderColor_100'; +import global_BorderWidth_sm from '@patternfly/react-tokens/dist/esm/global_BorderWidth_sm'; ## Demos @@ -28,3 +32,8 @@ import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/Dashboard ```js file="./DataList/examples/DataListExpandableControlInToolbar.tsx" isFullscreen ``` + +### Width modifiers + +```js file="./DataList/examples/DataListWidthModifiers.tsx" isFullscreen +``` \ No newline at end of file