-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add experimental ServerPhotoAlbum component
- Loading branch information
1 parent
81b9b02
commit a668225
Showing
18 changed files
with
352 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { resolveCommonProps, resolveResponsiveParameter } from "../../core/utils"; | ||
import { ColumnsPhotoAlbumProps, Photo } from "../../types"; | ||
|
||
export default function resolveColumnsProps<TPhoto extends Photo>( | ||
containerWidth: number | undefined, | ||
{ columns, ...rest }: ColumnsPhotoAlbumProps<TPhoto>, | ||
) { | ||
return { | ||
...rest, | ||
...resolveCommonProps(containerWidth, rest), | ||
columns: resolveResponsiveParameter(columns, containerWidth, [5, 4, 3, 2], 1), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { resolveCommonProps, resolveResponsiveParameter } from "../../core/utils"; | ||
import { MasonryPhotoAlbumProps, Photo } from "../../types"; | ||
|
||
export default function resolveMasonryProps<TPhoto extends Photo>( | ||
containerWidth: number | undefined, | ||
{ columns, ...rest }: MasonryPhotoAlbumProps<TPhoto>, | ||
) { | ||
return { | ||
...rest, | ||
...resolveCommonProps(containerWidth, rest), | ||
columns: resolveResponsiveParameter(columns, containerWidth, [5, 4, 3, 2], 1), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { resolveCommonProps, resolveResponsiveParameter, unwrapParameter } from "../../core/utils"; | ||
import { Photo, RowsPhotoAlbumProps } from "../../types"; | ||
|
||
export default function resolveRowsProps<TPhoto extends Photo>( | ||
containerWidth: number | undefined, | ||
{ photos, targetRowHeight, rowConstraints, ...rest }: RowsPhotoAlbumProps<TPhoto>, | ||
) { | ||
const { spacing, padding, componentsProps, render } = resolveCommonProps(containerWidth, rest); | ||
const { singleRowMaxHeight, minPhotos, maxPhotos } = unwrapParameter(rowConstraints, containerWidth) || {}; | ||
|
||
if (singleRowMaxHeight !== undefined && spacing !== undefined && padding !== undefined) { | ||
const maxWidth = Math.floor( | ||
photos.reduce( | ||
(acc, { width, height }) => acc + (width / height) * singleRowMaxHeight - 2 * padding, | ||
padding * photos.length * 2 + spacing * (photos.length - 1), | ||
), | ||
); | ||
|
||
if (maxWidth > 0) { | ||
componentsProps.container = { ...componentsProps.container }; | ||
componentsProps.container.style = { maxWidth, ...componentsProps.container.style }; | ||
} | ||
} | ||
|
||
return { | ||
...rest, | ||
targetRowHeight: resolveResponsiveParameter(targetRowHeight, containerWidth, [ | ||
(w) => w / 5, | ||
(w) => w / 4, | ||
(w) => w / 3, | ||
(w) => w / 2, | ||
]), | ||
render, | ||
spacing, | ||
padding, | ||
minPhotos, | ||
maxPhotos, | ||
componentsProps, | ||
}; | ||
} |
Oops, something went wrong.