-
Notifications
You must be signed in to change notification settings - Fork 2
Add dashboard thumbnails #17
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cdc3474
Add component for dashboard project thumbnails
Melissa0x1f992 bb2b7b7
Add project thumbnails
Melissa0x1f992 9f05532
Rearrange join/leave button UI
Melissa0x1f992 9478076
Make thumbnail component more responsive
Melissa0x1f992 e524242
Make project layout much more responsive
Melissa0x1f992 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 hidden or 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 hidden or 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,14 @@ | ||
| import styled from "styled-components"; | ||
|
|
||
| const ThumbnailImage = styled.img` | ||
| display: block; | ||
| margin-bottom: 10px; | ||
|
|
||
| width: 100%; | ||
| height: 300px; | ||
| object-fit: contain; | ||
|
|
||
| image-rendering: pixelated; | ||
| `; | ||
|
|
||
| export default ThumbnailImage; |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,37 +3,49 @@ import Router from "next/router"; | |
| import styled from "styled-components"; | ||
| import { useEffect, useState } from "react"; | ||
| import { PageTitle } from "../lib/common-style"; | ||
| import { makeApiRequest } from "../lib/api"; | ||
| import { makeApiRequest, API_BASE } from "../lib/api"; | ||
| import SubmitButton from "../components/submit-button"; | ||
| import ThumbnailImage from "../components/thumbnail-image"; | ||
|
|
||
| const ProjectsContainer = styled.div` | ||
| display: grid; | ||
| grid-template-columns: repeat(3, 1fr); | ||
| grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | ||
| gap: 10px; | ||
| `; | ||
|
|
||
| const ProjectCard = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-between; | ||
| padding: 12px; | ||
| font-size: 1.1em; | ||
|
|
||
| background: ${(props) => props.theme.colors.backgroundMuted}; | ||
| border-radius: 8px; | ||
| `; | ||
|
|
||
| const ProjectDetails = styled.div` | ||
| width: 50%; | ||
| float: left; | ||
| margin-top: auto; | ||
| `; | ||
|
|
||
| class MembershipStatus { | ||
| static Joining = new MembershipStatus("Joining..."); | ||
| static Joined = new MembershipStatus("Joined"); | ||
| static Leaving = new MembershipStatus("Leaving..."); | ||
| static NotJoined = new MembershipStatus("Not Joined"); | ||
| static Unknown = new MembershipStatus("Unknown"); | ||
| static Joining = new MembershipStatus("Joining...", "🔃"); | ||
| static Joined = new MembershipStatus("Joined", "✅"); | ||
| static Leaving = new MembershipStatus("Leaving...", "🔃"); | ||
| static NotJoined = new MembershipStatus("Not Joined", "❌"); | ||
| static Unknown = new MembershipStatus("Unknown", "❔"); | ||
|
|
||
| constructor(text) { | ||
| constructor(text, emoji) { | ||
| this.text = text; | ||
| this.emoji = emoji; | ||
| } | ||
| } | ||
|
|
||
| const ProjectPreview = ({ project }) => { | ||
|
|
||
|
|
||
| const initialMembershipStatus = () => { | ||
| if (typeof project.joined === "boolean") { | ||
| return project.joined ? MembershipStatus.Joined : MembershipStatus.NotJoined; | ||
|
|
@@ -80,27 +92,41 @@ const ProjectPreview = ({ project }) => { | |
| } | ||
| } | ||
|
|
||
| const [removeImage, setRemoveImage] = useState(false); | ||
|
|
||
| return ( | ||
| <ProjectCard> | ||
| <h3>{project.name || "Unnamed Project"}</h3> | ||
| {typeof membershipStatus === "object" && ( | ||
| <p>Membership Status: {`${membershipStatus.text}`}</p> | ||
| )} | ||
| {typeof project.members === "number" && ( | ||
| <p>{project.members} members</p> | ||
| )} | ||
| {typeof membershipStatus !== MembershipStatus.Unknown && ( | ||
| <form onSubmit={membershipStatus === MembershipStatus.Joined ? leaveProject : joinProject}> | ||
| <SubmitButton | ||
| type="submit" | ||
| value={ | ||
| membershipStatus === MembershipStatus.Joined ? "Leave" : | ||
| membershipStatus === MembershipStatus.NotJoined ? "Join" : | ||
| "Error" | ||
| } | ||
| /> | ||
| </form> | ||
| {!removeImage && ( | ||
| <ThumbnailImage | ||
| src={`${API_BASE}/y22/projects/${project.uuid}/bitmap`} | ||
| onError={() => setRemoveImage(true)} | ||
| /> | ||
| )} | ||
| <div> | ||
| <ProjectDetails> | ||
| {typeof membershipStatus !== MembershipStatus.Unknown && ( | ||
| <p>Joined: {`${membershipStatus.emoji}`}</p> | ||
| )} | ||
| {typeof project.members === "number" && ( | ||
| <p>{project.members} members</p> | ||
| )} | ||
| </ProjectDetails> | ||
| {typeof membershipStatus !== MembershipStatus.Unknown && ( | ||
| <form onSubmit={membershipStatus === MembershipStatus.Joined ? leaveProject : joinProject}> | ||
| <SubmitButton | ||
| type="submit" | ||
| value={ | ||
| membershipStatus === MembershipStatus.Joined ? "➖ Leave" : | ||
| membershipStatus === MembershipStatus.Joining ? "➕ Joining..." : | ||
| membershipStatus === MembershipStatus.NotJoined ? "➕ Join" : | ||
| membershipStatus === MembershipStatus.Leaving ? "➖ Leaving..." : | ||
| "Error" | ||
|
Comment on lines
+120
to
+124
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These values could be stored in the |
||
| } | ||
| /> | ||
| </form> | ||
| )} | ||
| </div> | ||
| </ProjectCard> | ||
| ); | ||
| }; | ||
|
|
||
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.
Could Font Awesome icons be used instead of emojis here?