Skip to content

Commit 90d3f0b

Browse files
[Vertical Galleries] Update styles to allow tile vertical resizing (#2785)
* Added overflowGalleryLayout prop to VideoGallery to control component for overflow participants * Refactor FloatingLocalVideo props * renamed VideoGalleryResponsiveHorizontalGallery -> OverflowGallery * Change files * Duplicate change files for beta release * remove ScrollableHorizontalGallery from DefaultLayout * lint fix * overflowGalleryLayout = 'HorizontalBottom' as default for VIdeoGallery * update CSS for proper button placement. * update css for larger page counts * fix up styles bottom out control bar * Change files * Duplicate change files for beta release * memoize styles in verticalGallery * update style name * fix lint * update per comments * update styles to allow tile vertical resizing * Change files * Duplicate change files for beta release * fix pagination label bug * fix pagination label issues --------- Signed-off-by: Donald McEachern <94866715+dmceachernmsft@users.noreply.github.com> Co-authored-by: mgamis-msft <79475487+mgamis-msft@users.noreply.github.com>
1 parent 3b29a61 commit 90d3f0b

5 files changed

Lines changed: 34 additions & 11 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "update styles to allow tile vertical resizing",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "update styles to allow tile vertical resizing",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/src/components/VerticalGallery.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ interface VerticalGalleryControlBarProps {
7474
export const VerticalGallery = (props: VerticalGalleryProps): JSX.Element => {
7575
const { children, styles, childrenPerPage } = props;
7676

77-
const [page, setPage] = useState(0);
77+
const [page, setPage] = useState(1);
7878
const [buttonState, setButtonState] = useState<{ previous: boolean; next: boolean }>({ previous: true, next: true });
7979

8080
const numberOfChildren = React.Children.count(children);
81-
const lastPage = Math.ceil(numberOfChildren / childrenPerPage) - 1;
81+
const lastPage = Math.ceil(numberOfChildren / childrenPerPage);
8282

8383
const paginatedChildren: React.ReactNode[][] = useMemo(() => {
8484
return bucketize(React.Children.toArray(children), childrenPerPage);
8585
}, [children, childrenPerPage]);
8686

87-
const firstIndexOfCurrentPage = page * childrenPerPage;
87+
const firstIndexOfCurrentPage = (page - 1) * childrenPerPage;
8888
const clippedPage = firstIndexOfCurrentPage < numberOfChildren - 1 ? page : lastPage;
89-
const childrenOnCurrentPage = paginatedChildren[clippedPage];
89+
const childrenOnCurrentPage = paginatedChildren[clippedPage - 1];
9090

9191
const showButtons = numberOfChildren > childrenPerPage;
9292

@@ -97,11 +97,15 @@ export const VerticalGallery = (props: VerticalGalleryProps): JSX.Element => {
9797
setPage(page + 1);
9898
};
9999

100+
if (page > lastPage && lastPage > 0) {
101+
setPage(lastPage);
102+
}
103+
100104
useEffect(() => {
101-
if (page > 0 && page < lastPage && showButtons) {
105+
if (page > 1 && page < lastPage && showButtons) {
102106
// we are somewhere in between first and last pages.
103107
setButtonState({ previous: false, next: false });
104-
} else if (page === 0 && showButtons) {
108+
} else if (page === 1 && showButtons) {
105109
// we are on the first page.
106110
setButtonState({ previous: true, next: false });
107111
} else if (page === lastPage && showButtons) {
@@ -111,7 +115,7 @@ export const VerticalGallery = (props: VerticalGalleryProps): JSX.Element => {
111115
}, [page, numberOfChildren, lastPage, showButtons]);
112116

113117
const childContainerStyle = useMemo(() => {
114-
return { root: childrenContainerStyle };
118+
return { root: childrenContainerStyle(2) };
115119
}, []);
116120

117121
const childrenStyles = useMemo(() => {

packages/react-components/src/components/VideoGallery/styles/VideoGalleryResponsiveVerticalGallery.styles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export const VERTICAL_GALLERY_TILE_STYLE = {
3939
minHeight: `${VERTICAL_GALLERY_TILE_SIZE_REM.minHeight}rem`,
4040
minWidth: `${VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`,
4141
maxHeight: `${VERTICAL_GALLERY_TILE_SIZE_REM.maxHeight}rem`,
42-
maxWidth: `${VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`
42+
maxWidth: `${VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`,
43+
width: '100%',
44+
height: '100%'
4345
};
4446
/**
4547
* @private

packages/react-components/src/components/styles/VerticalGallery.styles.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ export const VERTICAL_GALLERY_GAP = 0.5;
1313
/**
1414
* @private
1515
*/
16-
export const childrenContainerStyle: IStyle = {
17-
width: '100%',
18-
gap: `${VERTICAL_GALLERY_GAP}rem`
16+
export const childrenContainerStyle = (pageControlBarHeight: number): IStyle => {
17+
return {
18+
width: '100%',
19+
height: `calc(100% - ${pageControlBarHeight + VERTICAL_GALLERY_GAP}rem)`,
20+
gap: `${VERTICAL_GALLERY_GAP}rem`
21+
};
1922
};
2023

2124
/**

0 commit comments

Comments
 (0)