-
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.
Merge branch 'main' of github.com:Joystream/pioneer into main
- Loading branch information
Showing
51 changed files
with
873 additions
and
143 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
17 changes: 17 additions & 0 deletions
17
packages/ui/dev/scripts/generators/forum/generateCategories.ts
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,17 @@ | ||
import faker from 'faker' | ||
|
||
import { RawForumCategoryMock } from '@/mocks/data/seedForum' | ||
|
||
import { randomFromRange } from '../utils' | ||
|
||
export const generateCategories = (): RawForumCategoryMock[] => { | ||
let nextId = 0 | ||
|
||
return [...new Array(5)].map(() => { | ||
return { | ||
id: String(nextId++), | ||
title: faker.lorem.words(randomFromRange(3, 5)), | ||
description: faker.lorem.paragraph(randomFromRange(2, 3)), | ||
} | ||
}) | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/ui/dev/scripts/generators/forum/generateForumMocks.ts
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,19 @@ | ||
import { saveFile } from '../../helpers/saveFile' | ||
|
||
import { generateCategories } from './generateCategories' | ||
import { generateForumThreads } from './generateForumThreads' | ||
|
||
export const generateForum = () => { | ||
const forumCategories = generateCategories() | ||
const forumThreads = generateForumThreads(forumCategories) | ||
|
||
const forumMocks = { forumCategories, forumThreads } | ||
|
||
Object.entries(forumMocks).forEach(([fileName, contents]) => saveFile(fileName, contents)) | ||
} | ||
|
||
export const forumModule = { | ||
command: 'forum', | ||
describe: 'Generate forum from other mocks', | ||
handler: generateForum, | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/ui/dev/scripts/generators/forum/generateForumThreads.ts
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,22 @@ | ||
import faker from 'faker' | ||
|
||
import { RawForumCategoryMock, RawForumThreadMock } from '@/mocks/data/seedForum' | ||
|
||
import { randomFromRange } from '../utils' | ||
|
||
export const generateForumThreads = (forumCategories: Pick<RawForumCategoryMock, 'id'>[]): RawForumThreadMock[] => { | ||
let nextId = 0 | ||
|
||
return forumCategories | ||
.map(({ id }) => { | ||
return [...new Array(randomFromRange(3, 10))].map(() => { | ||
return { | ||
id: String(nextId++), | ||
categoryId: id, | ||
isSticky: !(nextId % 5), | ||
title: faker.lorem.words(randomFromRange(4, 8)), | ||
} | ||
}) | ||
}) | ||
.flatMap((a) => a) | ||
} |
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,14 @@ | ||
import React, { ReactNode } from 'react' | ||
|
||
import { Loading } from '@/common/components/Loading' | ||
import { useApi } from '@/common/hooks/useApi' | ||
|
||
export const WaitForAPI = ({ children }: { children: ReactNode }) => { | ||
const { connectionState } = useApi() | ||
|
||
if (connectionState === 'connecting') { | ||
return <Loading text="Waiting for API initialization" /> | ||
} | ||
|
||
return <>{children}</> | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './App' | ||
export { WaitForAPI } from '@/app/components/WaitForAPI' |
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 { Route, Switch } from 'react-router-dom' | ||
|
||
import { ForumCategories } from '@/app/pages/Forum/ForumCategories' | ||
import { ForumCategory } from '@/app/pages/Forum/ForumCategory' | ||
|
||
export const Forum = () => { | ||
return ( | ||
<Switch> | ||
<Route path="/forum" exact component={ForumCategories} /> | ||
<Route path="/forum/category/:id" exact component={ForumCategory} /> | ||
</Switch> | ||
) | ||
} |
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,30 @@ | ||
import React from 'react' | ||
|
||
import { PageLayout } from '@/app/components/PageLayout' | ||
import { Loading } from '@/common/components/Loading' | ||
import { RouterLink } from '@/common/components/RouterLink' | ||
import { useForumCategories } from '@/forum/hooks/useForumCategories' | ||
|
||
export const ForumCategories = () => { | ||
const { isLoading, forumCategories } = useForumCategories() | ||
|
||
return ( | ||
<PageLayout | ||
header={<h2>Categories</h2>} | ||
main={ | ||
<div> | ||
{isLoading && <Loading />} | ||
{!isLoading && | ||
forumCategories.length && | ||
forumCategories.map((category) => { | ||
return ( | ||
<div key={category.id}> | ||
{category.id} | <RouterLink to={`/forum/category/${category.id}`}> {category.title}</RouterLink> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
} | ||
/> | ||
) | ||
} |
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,32 @@ | ||
import React from 'react' | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { PageLayout } from '@/app/components/PageLayout' | ||
import { Loading } from '@/common/components/Loading' | ||
import { useForumCategoryThreads } from '@/forum/hooks/useForumCategoryThreads' | ||
|
||
export const ForumCategory = () => { | ||
const { id } = useParams<{ id: string }>() | ||
|
||
const { isLoading, threads } = useForumCategoryThreads(id) | ||
|
||
return ( | ||
<PageLayout | ||
header={<h2>Category</h2>} | ||
main={ | ||
<div> | ||
{isLoading && <Loading />} | ||
{!isLoading && | ||
threads.length && | ||
threads.map((thread) => { | ||
return ( | ||
<div key={thread.id}> | ||
{thread.id} | {thread.isSticky ? '📌' : ''} {thread.title} | ||
</div> | ||
) | ||
})} | ||
</div> | ||
} | ||
/> | ||
) | ||
} |
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 @@ | ||
export * from './Forum' |
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.