-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb86a18
commit 8f23730
Showing
9 changed files
with
159 additions
and
1 deletion.
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> | ||
} | ||
|
||
return <div>Thread content</div> | ||
} | ||
|
||
const displaySidebar = () => { | ||
if (isLoading || !thread) { | ||
return null | ||
} | ||
|
||
return ( | ||
<SidePanel neighbor={sideNeighborRef}> | ||
<ActivitiesBlock activities={[]} label="Suggested Threads" /> | ||
</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