-
Notifications
You must be signed in to change notification settings - Fork 71
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
👽 Introduce Forum Thread View #1133
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,71 @@ | ||
import React, { useRef } from 'react' | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { PageLayout } from '@/app/components/PageLayout' | ||
import { ActivitiesBlock } from '@/common/components/Activities/ActivitiesBlock' | ||
import { ButtonGhost, ButtonsGroup } from '@/common/components/buttons' | ||
import { LinkIcon, WatchIcon } from '@/common/components/icons' | ||
import { Loading } from '@/common/components/Loading' | ||
import { PageHeader } from '@/common/components/page/PageHeader' | ||
import { PageTitle } from '@/common/components/page/PageTitle' | ||
import { PreviousPage } from '@/common/components/page/PreviousPage' | ||
import { SidePanel } from '@/common/components/page/SidePanel' | ||
import { useCopyToClipboard } from '@/common/hooks/useCopyToClipboard' | ||
import { useForumThread } from '@/forum/hooks/useForumThread' | ||
|
||
export const ForumThread = () => { | ||
const { id } = useParams<{ id: string }>() | ||
const { isLoading, thread } = useForumThread(id) | ||
|
||
const { copyValue } = useCopyToClipboard() | ||
const sideNeighborRef = useRef<HTMLDivElement>(null) | ||
|
||
const displayHeader = () => { | ||
if (isLoading || !thread) { | ||
return null | ||
} | ||
|
||
return ( | ||
<PageHeader> | ||
<PreviousPage> | ||
<PageTitle>{thread.title}</PageTitle> | ||
</PreviousPage> | ||
<ButtonsGroup> | ||
<ButtonGhost size="medium" onClick={() => copyValue(window.location.href)}> | ||
<LinkIcon /> | ||
Copy link | ||
</ButtonGhost> | ||
<ButtonGhost size="medium"> | ||
<WatchIcon /> | ||
Watch thread | ||
</ButtonGhost> | ||
</ButtonsGroup> | ||
</PageHeader> | ||
) | ||
} | ||
|
||
const displayMain = () => { | ||
if (isLoading) { | ||
return <Loading /> | ||
} | ||
if (!thread) { | ||
return <h1>404 Not Found</h1> | ||
} | ||
nick-olizarenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return <div>Thread content</div> | ||
} | ||
|
||
const displaySidebar = () => { | ||
if (isLoading || !thread) { | ||
return null | ||
} | ||
|
||
return ( | ||
<SidePanel neighbor={sideNeighborRef}> | ||
<ActivitiesBlock activities={[]} label="Suggested Threads" /> | ||
nick-olizarenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</SidePanel> | ||
) | ||
} | ||
|
||
return <PageLayout header={displayHeader()} main={displayMain()} sidebar={displaySidebar()} /> | ||
} |
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,14 @@ | ||
import React from 'react' | ||
|
||
import { Icon } from './Icon' | ||
|
||
export const WatchIcon = React.memo(() => ( | ||
<Icon size="16" viewBox="0 0 16 16" fill="none" color="currentColor"> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M8.18185 4.94346C6.62683 4.94346 5.36187 6.20841 5.36187 7.76343C5.36187 9.31844 6.62683 10.5834 8.18185 10.5834C9.73686 10.5834 11.0018 9.31844 11.0018 7.76343C11.0018 6.20841 9.73686 4.94346 8.18185 4.94346ZM14.9399 7.44899C14.503 6.74506 12.0895 3.21657 7.99681 3.33494C4.21092 3.42357 2.0091 6.50641 1.42423 7.44899C1.30301 7.64396 1.30301 7.88388 1.42423 8.07885C1.855 8.77328 4.18352 12.1948 8.19885 12.1948C8.25501 12.1948 8.31116 12.1942 8.36732 12.1929C12.1525 12.1036 14.355 9.02143 14.9399 8.07885C15.0604 7.88388 15.0604 7.64396 14.9399 7.44899Z" | ||
fill="currentColor" | ||
/> | ||
</Icon> | ||
)) |
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,11 @@ | ||
import { useGetForumThreadQuery } from '@/forum/queries/__generated__/forum.generated' | ||
import { asForumThread } from '@/forum/types' | ||
|
||
export const useForumThread = (threadId: string) => { | ||
const { loading, data } = useGetForumThreadQuery({ variables: { where: { id: threadId } } }) | ||
|
||
return { | ||
isLoading: loading, | ||
thread: data && data.thread ? asForumThread(data.thread) : null, | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
packages/ui/src/forum/queries/__generated__/forum.generated.tsx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
A simple test for the "loaded" state might be beneficial as well.