generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Photogallerymodal tags #976
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8d80078
feat(#645): adding tags to the photos within the photogallerymodal
clintonlunn c338568
uncommenting tests
clintonlunn 8e12009
fix: mock child components
3242611
fix: make sure tests can run
8b0d0e8
add missing file
42ed589
feat(#645): add UsernameTag component, and add to TagList stacked
clintonlunn 8fad74c
adding basic UsernameTag test
clintonlunn 94f7731
refactor to BaseTag, LocationTag, UsernameTag, add tests
clintonlunn f29b626
fixing lint
clintonlunn da18a37
Merge remote-tracking branch 'origin/develop' into photogallerymodal-…
clintonlunn dea4173
refactoring photogallerymodal to look more like recentmediacard
clintonlunn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { useState } from 'react' | ||
import Image from 'next/image' | ||
import clx from 'classnames' | ||
import Card from '../ui/Card/Card' | ||
import TagList from '../media/TagList' | ||
import { MobileLoader } from '../../js/sirv/util' | ||
import { MediaWithTags } from '../../js/types' | ||
import { getUploadDateSummary } from '../../js/utils' | ||
import { PostHeader } from '../home/Post' | ||
|
||
const MOBILE_IMAGE_MAX_WIDITH = 600 | ||
|
||
interface GalleryImageCardProps { | ||
header?: JSX.Element | ||
mediaWithTags: MediaWithTags | ||
onImageClick?: (event: React.MouseEvent<HTMLImageElement>, mediaWithTags: MediaWithTags) => void | ||
} | ||
|
||
/** | ||
* Image card for the gallery page | ||
*/ | ||
export const GalleryImageCard = ({ | ||
mediaWithTags, | ||
onImageClick | ||
}: GalleryImageCardProps): JSX.Element => { | ||
const [loaded, setLoaded] = useState(false) | ||
const { mediaUrl, width, height, username } = mediaWithTags | ||
const imageRatio = width / height | ||
return ( | ||
<Card | ||
header={<PostHeader username={username} />} | ||
image={ | ||
<div className='relative block w-full h-full'> | ||
<Image | ||
src={MobileLoader({ | ||
src: mediaUrl, | ||
width: MOBILE_IMAGE_MAX_WIDITH | ||
})} | ||
width={MOBILE_IMAGE_MAX_WIDITH} | ||
height={MOBILE_IMAGE_MAX_WIDITH / imageRatio} | ||
sizes='100vw' | ||
objectFit='cover' | ||
onLoad={() => setLoaded(true)} | ||
className='rounded-md' | ||
onClick={(event) => { | ||
if (onImageClick != null) { | ||
console.log('onImageClick') | ||
event.stopPropagation() | ||
event.preventDefault() | ||
onImageClick(event, mediaWithTags) | ||
} | ||
}} | ||
/> | ||
<div | ||
className={clx( | ||
'absolute top-0 left-0 w-full h-full', | ||
loaded | ||
? 'bg-transparent' | ||
: 'bg-gray-50 bg-opacity-60 border animate-pulse' | ||
)} | ||
> | ||
{loaded} | ||
</div> | ||
</div> | ||
} | ||
body={ | ||
<> | ||
<section className='flex flex-col gap-y-4 justify-between px-2'> | ||
<TagList | ||
mediaWithTags={mediaWithTags} | ||
showActions={false} | ||
isAuthorized={false} | ||
isAuthenticated={false} | ||
/> | ||
<span className='uppercase text-xs text-base-200'> | ||
{getUploadDateSummary(mediaWithTags.uploadTime)} | ||
</span> | ||
</section> | ||
</> | ||
} | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visually these cards are very similar to RecentMedia cards. Let's merge after you rebase and refactor later.