Skip to content
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

feat(website): implement group topic page #113

Merged
merged 88 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
0e3a8b5
feat: new folder
cokemine Aug 3, 2022
9da3b46
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Aug 22, 2022
909002e
wip
cokemine Aug 22, 2022
5c444b1
fix: fix style import
cokemine Aug 22, 2022
f22e6d4
update api
cokemine Aug 31, 2022
657a9cb
refactor: replyinfo
cokemine Aug 31, 2022
540fa34
wip: add comments
cokemine Aug 31, 2022
75c95c9
add comment reply
cokemine Aug 31, 2022
45ce877
revert ci changes
cokemine Aug 31, 2022
15ce6ca
fix some styles
cokemine Aug 31, 2022
1d1d401
fix reply floor
cokemine Aug 31, 2022
cd06def
add reply collapse
cokemine Sep 1, 2022
de31299
update styles
cokemine Sep 1, 2022
1028ff9
add button group
cokemine Sep 3, 2022
ec9b9f6
fix
cokemine Sep 3, 2022
3a0ea4f
add reply editor
cokemine Sep 4, 2022
783b35f
fix bbcode editor style
cokemine Sep 4, 2022
e3c1b62
add reply editor
cokemine Sep 4, 2022
5d44f1f
add deleted state
cokemine Sep 4, 2022
9bf3939
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Sep 4, 2022
822b8b1
add special comment state
cokemine Sep 4, 2022
c17ce25
refactor
cokemine Sep 4, 2022
7155beb
wip: right col
cokemine Sep 5, 2022
bb7d72b
group info
cokemine Sep 5, 2022
592a50f
wip
cokemine Sep 5, 2022
1e5b3b4
wip
cokemine Sep 5, 2022
bf2c9d3
add reopen state
cokemine Sep 5, 2022
974e4de
fix button style
cokemine Sep 5, 2022
ade0492
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Sep 20, 2022
84a1833
wip
cokemine Sep 22, 2022
88c1ac1
wip
cokemine Sep 22, 2022
9c27ff4
fix build
cokemine Sep 22, 2022
a403251
fix: reply should not show sign
cokemine Sep 22, 2022
77d7599
fix
cokemine Sep 22, 2022
a7af1e1
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Sep 27, 2022
05cd4ef
fix: remove layout
cokemine Sep 27, 2022
9d79ed6
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 17, 2022
56de47b
update
cokemine Nov 17, 2022
d721963
refactor
cokemine Nov 17, 2022
163254c
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 17, 2022
25bd8dc
Update packages/website/src/pages/index/group/topic/[id]/index.tsx
cokemine Nov 17, 2022
61c02a8
Merge branch 'master' into feat/group-topic
cokemine Nov 18, 2022
37def0c
Merge remote-tracking branch 'upstream/master' into feat/group-topic
trim21 Nov 18, 2022
8967f0f
prettier
trim21 Nov 18, 2022
888ac07
prettier
trim21 Nov 18, 2022
693b933
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 20, 2022
4f05ce7
Merge branch 'master' into feat/group-topic
cokemine Nov 20, 2022
5bb75f1
Merge branch 'master' into feat/group-topic
cokemine Nov 20, 2022
ef67c33
wip
cokemine Nov 20, 2022
5c90032
fix build
cokemine Nov 20, 2022
ba9b244
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 20, 2022
c90decc
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 21, 2022
f5f79cf
wip
cokemine Nov 21, 2022
3c1f845
update styles
cokemine Nov 21, 2022
85d8b8d
update story
cokemine Nov 21, 2022
50d963b
refactor: move pages utils to @bangumi/utils
cokemine Nov 21, 2022
b30f76c
update story
cokemine Nov 21, 2022
03d6efa
update
cokemine Nov 21, 2022
06b9981
update
cokemine Nov 21, 2022
233653e
fix and add tests
cokemine Nov 21, 2022
a58c1a4
wip: add tests
cokemine Nov 21, 2022
8affaf1
update tests
cokemine Nov 21, 2022
9916249
add tests
cokemine Nov 21, 2022
1c0cdd1
update
cokemine Nov 21, 2022
fbd95a8
update
cokemine Nov 21, 2022
c227a64
links
cokemine Nov 21, 2022
697a2a9
update snapshots
cokemine Nov 21, 2022
c7a2c39
update
cokemine Nov 21, 2022
d3d522a
add layout component
cokemine Nov 21, 2022
59ce2ce
add error boundary
cokemine Nov 21, 2022
02be365
add layout story
cokemine Nov 21, 2022
b9ee86b
fix styles
cokemine Nov 21, 2022
d77f0a2
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 21, 2022
9b1cbff
fix
cokemine Nov 21, 2022
a9b770e
fix: add missing id
cokemine Nov 21, 2022
123d1e6
update
cokemine Nov 21, 2022
b44cc7c
update snapshot
cokemine Nov 21, 2022
4521a25
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 22, 2022
e862555
update
cokemine Nov 22, 2022
c2261be
fix test
cokemine Nov 22, 2022
7864ef8
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 27, 2022
d9b7d9b
Merge branch 'master' into feat/group-topic
trim21 Nov 28, 2022
ab670f1
update
cokemine Nov 28, 2022
2f3c8b9
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Nov 30, 2022
053ab01
update
cokemine Nov 30, 2022
7d4f7e1
update enum
cokemine Dec 1, 2022
b38c505
Merge branch 'master' of https://github.com/bangumi/frontend into fea…
cokemine Dec 1, 2022
4b156b8
update story
cokemine Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ module.exports = {
},
},
{
files: ['*.spec.tsx'],
files: ['*.spec.tsx', '*.test.tsx', '*.stories.tsx'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
Expand Down
9 changes: 3 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,9 @@ module.exports = {
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],

transformIgnorePatterns: ['<rootDir>/node_modules/.pnpm/(?!(openapi-typescript-fetch)@)'],
transformIgnorePatterns: [
'<rootDir>/node_modules/.pnpm/(?!(lodash-es|openapi-typescript-fetch)@)',
],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
1 change: 1 addition & 0 deletions packages/client/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { components } from './types';

export type User = components['schemas']['User'];
export type Avatar = components['schemas']['Avatar'];
export type Topic = components['schemas']['Topic'];
export type Pagination = Omit<components['schemas']['Paged'], 'data'>;
Expand Down
1 change: 1 addition & 0 deletions packages/client/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './common';
export type Group = components['schemas']['Group'];
export type GroupProfile = components['schemas']['GroupProfile'];
export type GroupMember = components['schemas']['GroupMember'];
export type GroupTopics = components['schemas']['PrivateTopicDetail'];
16 changes: 16 additions & 0 deletions packages/client/topic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { components } from './types';

export * from './common';

export type Comment = components['schemas']['Comment'];
export type Reply = components['schemas']['Comment']['replies'][0];

// https://github.com/drwpow/openapi-typescript/issues/941
export enum State {
Normal = 0,
Closed = 1,
Reopen = 2,
Silent = 5,
DeletedByUser = 6,
DeletedByAdmin = 7,
}
5 changes: 1 addition & 4 deletions packages/client/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { components } from './types';

export * from './common';

export type User = components['schemas']['User'];

// https://github.com/drwpow/openapi-typescript/issues/941
export enum UserGroup {
Admin = 1,
BangumiAdmin = 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/design/components/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const componentMeta: ComponentMeta<typeof Avatar> = {
title: 'modern/Avatar',
component: Avatar,
args: {
src: 'https://lain.bgm.tv/pic/user/l/000/00/00/1.jpg',
src: 'https://lain.bgm.tv/pic/user/l/icon.jpg',
size: 'small',
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/design/components/Avatar/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
}

&--medium img {
height: 48px;
width: 48px;
height: 60px;
width: 60px;
}

&--large img {
Expand Down
12 changes: 7 additions & 5 deletions packages/design/components/EditorForm/style/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../../../theme/base';

@toolbox-with: 215px;
@toolbox-width: 215px;
@text-width: 682px;

.bgm-editor {
&__container {
Expand All @@ -10,14 +11,15 @@
border: 2px solid @gray-10;
border-radius: 12px;
padding: 8px 0 0 10px;
z-index: 9999;
}

&__toolbox {
display: flex;
justify-content: space-between;
align-items: center;
height: 26px;
width: @toolbox-with;
width: @toolbox-width;
padding: 0 4px;
margin-bottom: 10px;

Expand All @@ -29,13 +31,12 @@
&__text {
flex: 1 0 auto;
padding: 0;
min-width: @toolbox-with;
width: 682px;
min-width: @toolbox-width;
width: @text-width;
border: none;
outline: none;
color: @gray-100;
line-height: 26px;
resize: vertical;

&::placeholder {
color: @gray-60;
Expand All @@ -47,6 +48,7 @@
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: @text-width;
}

&__submit {
Expand Down
24 changes: 24 additions & 0 deletions packages/design/components/Layout/Layout.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react';

import Layout from '.';

const componentMeta: ComponentMeta<typeof Layout> = {
title: 'Grid/Layout',
component: Layout,
};

export default componentMeta;

const Template: ComponentStory<typeof Layout> = (args) => <Layout {...args} />;

const leftChildren = <div style={{ width: '100%', height: '100vh', background: '#B5E6B5' }} />;
const rightChildren = <div style={{ width: '100%', height: '100vh', background: '#FFF2E2' }} />;

export const Usage = Template.bind({});

Usage.args = {
type: 'alpha',
leftChildren,
rightChildren,
};
22 changes: 22 additions & 0 deletions packages/design/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import classnames from 'classnames';
import type { FC } from 'react';
import React from 'react';

export interface LayoutProps {
type: 'alpha' | 'beta';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beta 好像没有用到?话说 alpha 是什么意思?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看了看小组页面、小组主题帖、和搜索页面的布局是一样的。 条目具体信息会用另一套布局。应该不会有太多布局就放着复用了(

className?: string;
leftChildren?: React.ReactNode;
rightChildren?: React.ReactNode;
}

const Index: FC<LayoutProps> = ({ leftChildren, rightChildren, type, className }) => {
const containerClassNames = classnames('bgm-layout', `bgm-layout--${type}`, className);
return (
<div className={containerClassNames}>
<div className='bgm-layout__left'>{leftChildren}</div>
<div className='bgm-layout__right'>{rightChildren}</div>
</div>
);
};

export default Index;
15 changes: 15 additions & 0 deletions packages/design/components/Layout/style/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.bgm-layout {
display: flex;

&--alpha {
.bgm-layout__left {
width: 913px;
flex: 1;
margin-right: 40px;
}

.bgm-layout__right {
width: 427px;
}
}
}
1 change: 1 addition & 0 deletions packages/design/components/Layout/style/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './index.less';
6 changes: 5 additions & 1 deletion packages/design/components/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export interface PaginationProps {
total?: number;
/* 页码改变的回调 */
onChange?: (offset: number) => void;

/* 自定义 classname */
wrapperClass?: string;
}

function calculatePage(pageSize: number, total: number): number {
Expand All @@ -25,6 +28,7 @@ const Pagination: FC<PaginationProps> = ({
currentPage = 1,
pageSize = 30,
total = 0,
wrapperClass,
...restProps
}) => {
const [current, setCurrent] = useState(() => currentPage);
Expand Down Expand Up @@ -108,7 +112,7 @@ const Pagination: FC<PaginationProps> = ({
}
}
return (
<ul className='bgm-pagination' data-testid='pagination-wrapper'>
<ul className={cn('bgm-pagination', wrapperClass)} data-testid='pagination-wrapper'>
{prevButton}
{pagerList}
{nextButton}
Expand Down
6 changes: 3 additions & 3 deletions packages/design/components/RichContent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import classNames from 'classnames';
import React from 'react';

export interface RichTextProps {
export interface RichContentProps {
html: string;
classname?: string;
}

const RichContent: React.FC<RichTextProps> = ({ html, classname }) => {
const RichContent: React.FC<RichContentProps> = ({ html, classname }) => {
return (
<article
<div
className={classNames('bgm-rich-content', classname)}
dangerouslySetInnerHTML={{ __html: html }}
/>
Expand Down
4 changes: 4 additions & 0 deletions packages/design/components/RichContent/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
color: @blue-100;
text-decoration: none;
}

img {
max-width: 99%;
}
}
11 changes: 9 additions & 2 deletions packages/design/components/Section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import classnames from 'classnames';
import type { PropsWithChildren } from 'react';
import React from 'react';

export interface SectionProps {
title: string;
renderFooter?: () => React.ReactNode;
wrapperClass?: string;
}
const Section = ({ title, children, renderFooter }: PropsWithChildren<SectionProps>) => {
const Section = ({
title,
wrapperClass,
children,
renderFooter,
}: PropsWithChildren<SectionProps>) => {
return (
<div className='bgm-section'>
<div className={classnames('bgm-section', wrapperClass)}>
<h3 className='bgm-section__title'>{title}</h3>
{children}
{renderFooter && <div className='bgm-section__footer'>{renderFooter()}</div>}
Expand Down
76 changes: 76 additions & 0 deletions packages/design/components/Topic/Comment.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import type { ComponentStory } from '@storybook/react';
import React from 'react';

import { State } from '@bangumi/client/topic';

import repliesComment from './__test__/fixtures/repliesComment.json';
import singleComment from './__test__/fixtures/singleComment.json';
import specialComment from './__test__/fixtures/specialComment.json';
import mockedCurrentUser from './__test__/fixtures/user.json';
import type { CommentProps } from './Comment';
import Comment from './Comment';

export default {
title: 'Topic/Comment',
component: Comment,
};

const Template: ComponentStory<typeof Comment> = (args: CommentProps & { states?: State[] }) => {
// 0 正常评论 6 被用户删除 7 违反社区指导原则,已被删除
cokemine marked this conversation as resolved.
Show resolved Hide resolved
// 1 关闭 2 重开 5 下沉
return (
<div style={{ width: 913 }}>
{(args.states ?? [0]).map((state, idx) => (
<div key={idx} style={{ marginBottom: 20 }}>
<h1>State: {state}</h1>
<Comment {...args} state={state} />
</div>
))}
</div>
);
};

export const SingleComment = Template.bind({});

SingleComment.args = {
...singleComment,
isReply: false,
is_friend: true,
originalPosterId: 1,
created_at: String(new Date()),
floor: 2,
states: [State.Normal, State.DeletedByUser, State.DeletedByAdmin],
} as any;

export const CommentWithReplies = Template.bind({});
CommentWithReplies.args = {
...repliesComment,
isReply: false,
is_friend: false,
created_at: String(new Date()),
floor: 2,
} as any;

export const SelfComment = Template.bind({});

const selfUser = { ...mockedCurrentUser, id: 1 };

SelfComment.args = {
...singleComment,
isReply: false,
is_friend: false,
created_at: String(new Date()),
user: selfUser,
floor: 2,
} as any;

export const SpecialComment = Template.bind({});

SpecialComment.args = {
...specialComment,
isReply: false,
is_friend: false,
created_at: String(new Date()),
floor: 2,
states: [State.Closed, State.Reopen, State.Silent],
} as any;
Loading