From 00b2a31652f61c4a696c1f7748485568c6127670 Mon Sep 17 00:00:00 2001 From: Andrea Vanini Date: Thu, 13 Apr 2023 16:29:39 +0200 Subject: [PATCH] docs(changeset): List is now mobile friendly --- .changeset/gorgeous-tables-vanish.md | 9 +++ packages/data/data-manager/examples/Basic.tsx | 60 ++++++++-------- .../src/components/DataManagerView.tsx | 22 +++--- packages/data/list/package.json | 1 + packages/data/list/src/components/List.tsx | 59 ++++++++------- packages/data/table/package.json | 1 + packages/data/table/src/components/Table.tsx | 71 ++++++++----------- .../components/ScrollableContainer/styled.tsx | 1 + website/webpack.config.js | 2 + yarn.lock | 2 + 10 files changed, 120 insertions(+), 108 deletions(-) create mode 100644 .changeset/gorgeous-tables-vanish.md diff --git a/.changeset/gorgeous-tables-vanish.md b/.changeset/gorgeous-tables-vanish.md new file mode 100644 index 0000000000..4842f29f78 --- /dev/null +++ b/.changeset/gorgeous-tables-vanish.md @@ -0,0 +1,9 @@ +--- +'@uidu/table': minor +'@uidu/list': minor +'@uidu/data-manager': patch +'@uidu/shell': patch +'@uidu/guidu-website': patch +--- + +List is now mobile friendly diff --git a/packages/data/data-manager/examples/Basic.tsx b/packages/data/data-manager/examples/Basic.tsx index f8107fd03b..0a1a109e5b 100644 --- a/packages/data/data-manager/examples/Basic.tsx +++ b/packages/data/data-manager/examples/Basic.tsx @@ -252,7 +252,7 @@ export default function Basic({}) { <> - + @@ -368,40 +368,38 @@ export default function Basic({}) { updateView={onViewUpdate} > - - }> - }> + ( +
Ciao
+ ), + month: { event: (props) => ( -
Ciao
+
+ {props.title} +
), - month: { - event: (props) => ( -
- {props.title} -
- ), - }, }, }, - board: {}, - table: { - includeFooter: false, - headerHeight: 48, - rowHeight: 48, - }, - }} - /> -
-
+ }, + board: {}, + table: { + includeFooter: false, + headerHeight: 48, + rowHeight: 48, + }, + }} + /> +
diff --git a/packages/data/data-manager/src/components/DataManagerView.tsx b/packages/data/data-manager/src/components/DataManagerView.tsx index 216d621867..a901e3ad50 100644 --- a/packages/data/data-manager/src/components/DataManagerView.tsx +++ b/packages/data/data-manager/src/components/DataManagerView.tsx @@ -278,18 +278,16 @@ function DataManagerView({ }> }> {({ default: Table }: { default: FC> }) => ( -
- - +
)} diff --git a/packages/data/list/package.json b/packages/data/list/package.json index 0ece0c6fbd..b64eb4c8f1 100644 --- a/packages/data/list/package.json +++ b/packages/data/list/package.json @@ -13,6 +13,7 @@ "@tanstack/react-table": "^8.8.5", "@tanstack/react-virtual": "^3.0.0-beta.48", "@uidu/data-fields": "^2.1.42", + "@uidu/shell": "2.1.51", "react": "^18.2.0", "styled-components": "^5.3.9", "tslib": "^2.5.0" diff --git a/packages/data/list/src/components/List.tsx b/packages/data/list/src/components/List.tsx index f984c8904e..a29af987c3 100644 --- a/packages/data/list/src/components/List.tsx +++ b/packages/data/list/src/components/List.tsx @@ -1,5 +1,6 @@ import { Row } from '@tanstack/react-table'; import { useVirtualizer } from '@tanstack/react-virtual'; +import { ScrollableContainer } from '@uidu/shell'; import React, { useCallback, useEffect, useRef } from 'react'; import { StyledRow } from '../styled'; import { ListProps } from '../types'; @@ -29,7 +30,7 @@ export default function List({ const headerGroups = getHeaderGroups(); const { rows } = getRowModel(); - const rowVirtualizer = useVirtualizer({ + const rowVirtualizer = useVirtualizer({ count: hasNext ? rows.length + 1 : rows.length, getScrollElement: () => parentRef.current, getItemKey: (index) => rows[index]?.original?.id, @@ -95,29 +96,39 @@ export default function List({ }, [loadNext, hasNext, rows.length, virtualRows, isLoadingNext, isPending]); return ( -
-
-
-
- {isPending ? ( - - ) : ( - virtualRows.map(({ index, key, start, size }) => ( - - )) - )} -
+ +
+
+ {isPending ? ( + + ) : ( + virtualRows.map(({ index, key, start, size }) => ( + + )) + )}
-
+ ); } diff --git a/packages/data/table/package.json b/packages/data/table/package.json index 2b9d55e5e7..2980fbae64 100644 --- a/packages/data/table/package.json +++ b/packages/data/table/package.json @@ -21,6 +21,7 @@ "@uidu/menu": "^0.8.15", "@uidu/popup": "^0.7.16", "@uidu/portal": "1.0.9", + "@uidu/shell": "2.1.51", "numeral": "^2.0.6", "react": "^18.2.0", "react-cool-onclickoutside": "^1.7.0", diff --git a/packages/data/table/src/components/Table.tsx b/packages/data/table/src/components/Table.tsx index 74f6dfbbbb..da10db9d06 100644 --- a/packages/data/table/src/components/Table.tsx +++ b/packages/data/table/src/components/Table.tsx @@ -3,6 +3,7 @@ import { Row as RowType } from '@tanstack/react-table'; import { useVirtualizer } from '@tanstack/react-virtual'; +import { ScrollableContainer } from '@uidu/shell'; import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import * as defaultComponents from '../styled'; import { TableProps } from '../types'; @@ -129,55 +130,43 @@ function Table({ : 0; return ( -
-
- {/*
+ {/*
*/} - - {/* Here we should insert the pagination fragment, and manage data */} - - {/* {paddingTop > 0 &&
} */} - {isPending ? ( - - ) : ( - virtualRows.map(({ size, start, index, key }) => ( - - )) - )} - {/* {paddingBottom > 0 && ( + + {/* Here we should insert the pagination fragment, and manage data */} + + {/* {paddingTop > 0 &&
} */} + {isPending ? ( + + ) : ( + virtualRows.map(({ size, start, index, key }) => ( + + )) + )} + {/* {paddingBottom > 0 && (
)} */} - - {includeFooter ? ( -
- ) : null} -
- {/*
*/} -
+ + {includeFooter ? ( +
+ ) : null} + ); } diff --git a/packages/navigation/shell/src/components/ScrollableContainer/styled.tsx b/packages/navigation/shell/src/components/ScrollableContainer/styled.tsx index e800783c73..5d7f6d1daf 100644 --- a/packages/navigation/shell/src/components/ScrollableContainer/styled.tsx +++ b/packages/navigation/shell/src/components/ScrollableContainer/styled.tsx @@ -3,6 +3,7 @@ import styled from 'styled-components'; export const StyledScrollableContainer = styled.div` flex: 1 1 auto; scroll-behavior: smooth; + overscroll-behavior: contain contain; overflow-x: hidden; overflow-y: auto; // to fix chrome flex diff --git a/website/webpack.config.js b/website/webpack.config.js index dafee0be17..dbd64d8481 100644 --- a/website/webpack.config.js +++ b/website/webpack.config.js @@ -24,6 +24,8 @@ runDevServer({ // and bind address to 0.0.0.0 using ifconfig 192.168.xxx.xxx:9000 // https: false, https, + // host: 'local-ip', + // disableHostCheck: true, }, } : {}), diff --git a/yarn.lock b/yarn.lock index 9e15eb1231..32b573953d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9123,6 +9123,7 @@ __metadata: "@tanstack/react-virtual": ^3.0.0-beta.48 "@uidu/data-fields": ^2.1.42 "@uidu/docs": ^0.5.28 + "@uidu/shell": 2.1.51 react: ^18.2.0 styled-components: ^5.3.9 tslib: ^2.5.0 @@ -10045,6 +10046,7 @@ __metadata: "@uidu/menu": ^0.8.15 "@uidu/popup": ^0.7.16 "@uidu/portal": 1.0.9 + "@uidu/shell": 2.1.51 numeral: ^2.0.6 react: ^18.2.0 react-cool-onclickoutside: ^1.7.0