From 160d1e994b8996f3a30e93f704e572f5cf9d726a Mon Sep 17 00:00:00 2001 From: mydearxym Date: Sun, 25 Apr 2021 10:37:17 +0800 Subject: [PATCH 01/21] chore(abuse-report): basic setup && fix generator typo --- src/containers/tool/AbuseReport/index.tsx | 40 +++++++++++++++++++ src/containers/tool/AbuseReport/logic.ts | 28 +++++++++++++ src/containers/tool/AbuseReport/schema.ts | 23 +++++++++++ src/containers/tool/AbuseReport/store.ts | 30 ++++++++++++++ .../tool/AbuseReport/styles/index.ts | 11 +++++ .../tool/AbuseReport/tests/index.test.js | 10 +++++ .../tool/AbuseReport/tests/store.test.js | 10 +++++ src/stores/RootStore/index.ts | 2 + src/stores/index.ts | 1 + .../generators/container/hooks.tsx.hbs | 4 +- 10 files changed, 157 insertions(+), 2 deletions(-) create mode 100755 src/containers/tool/AbuseReport/index.tsx create mode 100755 src/containers/tool/AbuseReport/logic.ts create mode 100755 src/containers/tool/AbuseReport/schema.ts create mode 100755 src/containers/tool/AbuseReport/store.ts create mode 100755 src/containers/tool/AbuseReport/styles/index.ts create mode 100755 src/containers/tool/AbuseReport/tests/index.test.js create mode 100755 src/containers/tool/AbuseReport/tests/store.test.js diff --git a/src/containers/tool/AbuseReport/index.tsx b/src/containers/tool/AbuseReport/index.tsx new file mode 100755 index 000000000..41508474c --- /dev/null +++ b/src/containers/tool/AbuseReport/index.tsx @@ -0,0 +1,40 @@ +// + +/* + * + * AbuseReport + * + */ + +import React from 'react' + +import { pluggedIn, buildLog } from '@/utils' + +import type { TStore } from './store' + +import { Wrapper } from './styles' +import { useInit } from './logic' + +/* eslint-disable-next-line */ +const log = buildLog('C:AbuseReport') + +type TProps = { + abuseReport?: TStore + testid: string +} + +const AbuseReportContainer: React.FC = ({ + abuseReport: store, + testid, +}) => { + useInit(store) + + return ( + +

AbuseReport hooks container!

+
impress me!
+
+ ) +} + +export default pluggedIn(AbuseReportContainer) diff --git a/src/containers/tool/AbuseReport/logic.ts b/src/containers/tool/AbuseReport/logic.ts new file mode 100755 index 000000000..05377d497 --- /dev/null +++ b/src/containers/tool/AbuseReport/logic.ts @@ -0,0 +1,28 @@ +import { useEffect } from 'react' +// import { } from 'ramda' + +import { buildLog } from '@/utils' + +// import S from './service' +import type { TStore } from './store' + +let store: TStore | undefined + +/* eslint-disable-next-line */ +const log = buildLog('L:AbuseReport') + +export const someMethod = (): void => { + // +} + +// ############################### +// init & uninit handlers +// ############################### + +export const useInit = (_store: TStore): void => { + useEffect(() => { + store = _store + log('useInit: ', store) + // return () => store.reset() + }, [_store]) +} diff --git a/src/containers/tool/AbuseReport/schema.ts b/src/containers/tool/AbuseReport/schema.ts new file mode 100755 index 000000000..0035db982 --- /dev/null +++ b/src/containers/tool/AbuseReport/schema.ts @@ -0,0 +1,23 @@ +import gql from 'graphql-tag' + +const simpleMutation = gql` + mutation($id: ID!) { + post(id: $id) { + id + } + } +` +const simpleQuery = gql` + query($filter: filter!) { + post(id: $id) { + id + } + } +` + +const schema = { + simpleMutation, + simpleQuery, +} + +export default schema diff --git a/src/containers/tool/AbuseReport/store.ts b/src/containers/tool/AbuseReport/store.ts new file mode 100755 index 000000000..81fef82fc --- /dev/null +++ b/src/containers/tool/AbuseReport/store.ts @@ -0,0 +1,30 @@ +/* + * AbuseReport store + */ + +import { types as T, getParent, Instance } from 'mobx-state-tree' +// import {} from 'ramda' + +import type { TCommunity, TRootStore } from '@/spec' +import { markStates, buildLog, stripMobx } from '@/utils' + +/* eslint-disable-next-line */ +const log = buildLog('S:AbuseReport') + +const AbuseReport = T.model('AbuseReport', {}) + .views((self) => ({ + get curCommunity(): TCommunity { + const root = getParent(self) as TRootStore + + return stripMobx(root.viewing.community) + }, + })) + .actions((self) => ({ + mark(sobj: Record): void { + markStates(sobj, self) + }, + })) + +export type TStore = Instance + +export default AbuseReport diff --git a/src/containers/tool/AbuseReport/styles/index.ts b/src/containers/tool/AbuseReport/styles/index.ts new file mode 100755 index 000000000..1c0b72a65 --- /dev/null +++ b/src/containers/tool/AbuseReport/styles/index.ts @@ -0,0 +1,11 @@ +import styled from 'styled-components' + +import type { TTestable } from '@/spec' +// import { theme } from '@/utils' + +export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ + 'data-test-id': testid, +}))` + // +` +export const Title = styled.div`` diff --git a/src/containers/tool/AbuseReport/tests/index.test.js b/src/containers/tool/AbuseReport/tests/index.test.js new file mode 100755 index 000000000..fe0894312 --- /dev/null +++ b/src/containers/tool/AbuseReport/tests/index.test.js @@ -0,0 +1,10 @@ +// import React from 'react' +// import { shallow } from 'enzyme' + +// import AbuseReport from '../index' + +describe('TODO ', () => { + it('Expect to have unit tests specified', () => { + expect(true).toEqual(true) + }) +}) diff --git a/src/containers/tool/AbuseReport/tests/store.test.js b/src/containers/tool/AbuseReport/tests/store.test.js new file mode 100755 index 000000000..f2764f3e3 --- /dev/null +++ b/src/containers/tool/AbuseReport/tests/store.test.js @@ -0,0 +1,10 @@ +/* + * AbuseReport store test + * + */ + +// import AbuseReport from '../index' + +it('TODO: store test AbuseReport', () => { + expect(1 + 1).toBe(2) +}) diff --git a/src/stores/RootStore/index.ts b/src/stores/RootStore/index.ts index 2c00e0c4c..696f76c69 100755 --- a/src/stores/RootStore/index.ts +++ b/src/stores/RootStore/index.ts @@ -99,6 +99,7 @@ import { CoolGuideContentStore, // GEN: IMPORT SUBSTORE + AbuseReportStore, HelpCenterContentStore, CommunityJoinBadgeStore, ArticleEditorStore, @@ -219,6 +220,7 @@ const rootStore = T.model({ coolGuideContent: T.optional(CoolGuideContentStore, {}), // GEN: PLUG SUBSTORE TO ROOTSTORE + abuseReport: T.optional(AbuseReportStore, {}), helpCenterContent: T.optional(HelpCenterContentStore, {}), communityJoinBadge: T.optional(CommunityJoinBadgeStore, {}), articleEditor: T.optional(ArticleEditorStore, {}), diff --git a/src/stores/index.ts b/src/stores/index.ts index 6dc12199f..a894505ed 100755 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -106,6 +106,7 @@ export { default as CommunityEditorStore } from '@/containers/editor/CommunityEd export { default as WorksEditorStore } from '@/containers/editor/WorksEditor/store' // GEN: EXPORT CONTAINERS STORE HERE +export { default as AbuseReportStore } from '@/containers/tool/AbuseReport/store' export { default as HelpCenterContentStore } from '@/containers/content/HelpCenterContent/store' export { default as CommunityJoinBadgeStore } from '@/containers/tool/CommunityJoinBadge/store' export { default as ArticleEditorStore } from '@/containers/editor/ArticleEditor/store' diff --git a/utils/scripts/generators/container/hooks.tsx.hbs b/utils/scripts/generators/container/hooks.tsx.hbs index 844ab9d61..1382788d6 100755 --- a/utils/scripts/generators/container/hooks.tsx.hbs +++ b/utils/scripts/generators/container/hooks.tsx.hbs @@ -13,7 +13,7 @@ import { pluggedIn, buildLog } from '@/utils' import { useTrans } from '@/hooks' {{/if}} -import type { IStore } from './store' +import type { TStore } from './store' import { Wrapper } from './styles' import { useInit } from './logic' @@ -22,7 +22,7 @@ import { useInit } from './logic' const log = buildLog('C:{{ properCase name }}') type TProps = { - {{ camelCase name }}?: IStore + {{ camelCase name }}?: TStore testid: string } From bc7db91d45d3bc190f8a96296a43021a2e145ea1 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Sun, 25 Apr 2021 11:18:49 +0800 Subject: [PATCH 02/21] chore(abuse-report): wip --- src/containers/layout/GlobalLayout/index.tsx | 3 ++ .../GlobalLayout/{logic.js => logic.ts} | 20 ++++++++----- .../tool/AbuseReport/ArticleReport/index.tsx | 14 ++++++++++ src/containers/tool/AbuseReport/Header.tsx | 16 +++++++++++ src/containers/tool/AbuseReport/index.tsx | 14 ++++++---- .../styles/article_report/index.tsx | 8 ++++++ .../tool/AbuseReport/styles/header.ts | 28 +++++++++++++++++++ .../tool/AbuseReport/styles/index.ts | 5 ++-- 8 files changed, 94 insertions(+), 14 deletions(-) rename src/containers/layout/GlobalLayout/{logic.js => logic.ts} (84%) create mode 100644 src/containers/tool/AbuseReport/ArticleReport/index.tsx create mode 100644 src/containers/tool/AbuseReport/Header.tsx create mode 100644 src/containers/tool/AbuseReport/styles/article_report/index.tsx create mode 100644 src/containers/tool/AbuseReport/styles/header.ts diff --git a/src/containers/layout/GlobalLayout/index.tsx b/src/containers/layout/GlobalLayout/index.tsx index ce6f638ae..d17c492b2 100755 --- a/src/containers/layout/GlobalLayout/index.tsx +++ b/src/containers/layout/GlobalLayout/index.tsx @@ -17,6 +17,8 @@ import Header from '@/containers/unit/Header' import Sidebar from '@/containers/unit/Sidebar' import ModeLine from '@/containers/unit/ModeLine' import Drawer from '@/containers/tool/Drawer' +import AbuseReport from '@/containers/tool/AbuseReport' + import CustomScroller from '@/components/CustomScroller' import type { TStore } from './store' @@ -91,6 +93,7 @@ const GlobalLayoutContainer: React.FC = ({ sidebarPin={sidebarPin} // noSidebar={noSidebar} > + {!noSidebar && } diff --git a/src/containers/layout/GlobalLayout/logic.js b/src/containers/layout/GlobalLayout/logic.ts similarity index 84% rename from src/containers/layout/GlobalLayout/logic.js rename to src/containers/layout/GlobalLayout/logic.ts index f1d0c65b5..08369f7e2 100755 --- a/src/containers/layout/GlobalLayout/logic.js +++ b/src/containers/layout/GlobalLayout/logic.ts @@ -1,22 +1,25 @@ import React, { useEffect } from 'react' +import type { TScrollDirection } from '@/spec' import { buildLog } from '@/utils' +import type { TStore } from './store' /* eslint-disable-next-line */ const log = buildLog('L:GlobalLayout') -let store = null +let store: TStore | undefined -export const openDoraemon = () => store.openDoraemon() +export const openDoraemon = (): void => store.openDoraemon() // custromScroll's scroll direction change -export const bodyScrollDirectionOnChange = (bodyScrollDirection) => - store.mark({ bodyScrollDirection }) +export const bodyScrollDirectionOnChange = ( + bodyScrollDirection: TScrollDirection, +): void => store.mark({ bodyScrollDirection }) /** * log ascii Buddha just for fun * 控制台打印佛祖保佑 */ -export const logBuddha = () => { +export const logBuddha = (): void => { if (process.env.NODE_ENV === 'production') { /* eslint-disable */ console.log( @@ -50,7 +53,10 @@ export const logBuddha = () => { // cloning children with new props // see detail: https://stackoverflow.com/questions/32370994/how-to-pass-props-to-this-props-children -export const childrenWithProps = (children, props) => { +export const childrenWithProps = ( + children: React.ReactNode, + props: Record, +): React.ReactNode => { return React.Children.map(children, (child) => { // checking isValidElement is the safe way and avoids a typescript error too if (React.isValidElement(child)) { @@ -63,7 +69,7 @@ export const childrenWithProps = (children, props) => { // ############################### // init & uninit // ############################### -export const useInit = (_store, extra) => { +export const useInit = (_store: TStore, extra): void => { useEffect(() => { store = _store diff --git a/src/containers/tool/AbuseReport/ArticleReport/index.tsx b/src/containers/tool/AbuseReport/ArticleReport/index.tsx new file mode 100644 index 000000000..c4bc3b49c --- /dev/null +++ b/src/containers/tool/AbuseReport/ArticleReport/index.tsx @@ -0,0 +1,14 @@ +import React from 'react' + +import { Wrapper } from '../styles/article_report' + +const ArticleReport: React.FC = () => { + return ( + +
header
+
content
+
+ ) +} + +export default ArticleReport diff --git a/src/containers/tool/AbuseReport/Header.tsx b/src/containers/tool/AbuseReport/Header.tsx new file mode 100644 index 000000000..74cf708b1 --- /dev/null +++ b/src/containers/tool/AbuseReport/Header.tsx @@ -0,0 +1,16 @@ +import React from 'react' + +import { ICON } from '@/config' +import { Wrapper, ReportIcon, Text, ContentTitle } from './styles/header' + +const Header = () => { + return ( + + + 举报内容 + 这是一首简单的小情歌 + + ) +} + +export default Header diff --git a/src/containers/tool/AbuseReport/index.tsx b/src/containers/tool/AbuseReport/index.tsx index 41508474c..3679b8e33 100755 --- a/src/containers/tool/AbuseReport/index.tsx +++ b/src/containers/tool/AbuseReport/index.tsx @@ -10,8 +10,11 @@ import React from 'react' import { pluggedIn, buildLog } from '@/utils' -import type { TStore } from './store' +import Modal from '@/components/Modal' + +import Header from './Header' +import type { TStore } from './store' import { Wrapper } from './styles' import { useInit } from './logic' @@ -30,10 +33,11 @@ const AbuseReportContainer: React.FC = ({ useInit(store) return ( - -

AbuseReport hooks container!

-
impress me!
-
+ console.log('close')}> + +
+ + ) } diff --git a/src/containers/tool/AbuseReport/styles/article_report/index.tsx b/src/containers/tool/AbuseReport/styles/article_report/index.tsx new file mode 100644 index 000000000..a7518f034 --- /dev/null +++ b/src/containers/tool/AbuseReport/styles/article_report/index.tsx @@ -0,0 +1,8 @@ +import styled from 'styled-components' + +import { css, theme } from '@/utils' + +export const Wrapper = styled.div` + ${css.flexColumn()}; +` +export const Title = styled.div`` diff --git a/src/containers/tool/AbuseReport/styles/header.ts b/src/containers/tool/AbuseReport/styles/header.ts new file mode 100644 index 000000000..9b9db7d9e --- /dev/null +++ b/src/containers/tool/AbuseReport/styles/header.ts @@ -0,0 +1,28 @@ +import styled from 'styled-components' + +import Img from '@/Img' +import { theme, css } from '@/utils' + +export const Wrapper = styled.div` + ${css.flex('align-center')}; + color: ${theme('thread.articleDigest')}; +` +export const ReportIcon = styled(Img)` + ${css.size(16)}; + fill: ${theme('baseColor.red')}; +` +export const Text = styled.div` + color: ${theme('thread.articleTitle')}; + margin-left: 5px; +` +export const ContentTitle = styled.div` + color: ${theme('thread.articleDigest')}; + margin-left: 3px; + margin-right: 3px; + &:before { + content: '('; + } + &:after { + content: ')'; + } +` diff --git a/src/containers/tool/AbuseReport/styles/index.ts b/src/containers/tool/AbuseReport/styles/index.ts index 1c0b72a65..758f118c3 100755 --- a/src/containers/tool/AbuseReport/styles/index.ts +++ b/src/containers/tool/AbuseReport/styles/index.ts @@ -1,11 +1,12 @@ import styled from 'styled-components' import type { TTestable } from '@/spec' -// import { theme } from '@/utils' +import { theme } from '@/utils' export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ 'data-test-id': testid, }))` - // + padding: 15px 30px; + color: ${theme('thread.articleDigest')}; ` export const Title = styled.div`` From ba1b4ea1c5b64ae8370c53a94ef20ba1f29ea8f1 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Sun, 25 Apr 2021 12:37:45 +0800 Subject: [PATCH 03/21] chore(abuse-report): wip --- public/icons/static/article/report-solid.svg | 1 + src/components/Checker/index.tsx | 8 ++-- src/components/Checker/styles/index.ts | 5 +- .../tool/AbuseReport/ArticleReport/index.tsx | 47 +++++++++++++++++-- src/containers/tool/AbuseReport/Header.tsx | 2 +- src/containers/tool/AbuseReport/index.tsx | 2 + .../styles/article_report/index.tsx | 34 +++++++++++++- .../tool/AbuseReport/styles/header.ts | 5 +- .../tool/AbuseReport/styles/index.ts | 2 +- 9 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 public/icons/static/article/report-solid.svg diff --git a/public/icons/static/article/report-solid.svg b/public/icons/static/article/report-solid.svg new file mode 100644 index 000000000..d4b35a49a --- /dev/null +++ b/public/icons/static/article/report-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/Checker/index.tsx b/src/components/Checker/index.tsx index 1554b79c6..b3c5350a6 100755 --- a/src/components/Checker/index.tsx +++ b/src/components/Checker/index.tsx @@ -17,11 +17,11 @@ import { Wrapper, IconWrapper, Icon, ChildWrapper } from './styles' const log = buildLog('c:Checker:index') type TProps = { - children: React.ReactNode + children?: React.ReactNode | null checked?: boolean - hiddenMode: boolean + hiddenMode?: boolean size?: TSIZE_SM - onChange: (checked: boolean) => void + onChange?: (checked: boolean) => void } const Checker: React.FC = ({ @@ -29,7 +29,7 @@ const Checker: React.FC = ({ onChange = log, hiddenMode = false, size = SIZE.MEDIUM, - children, + children = null, }) => { const show = checked || !hiddenMode diff --git a/src/components/Checker/styles/index.ts b/src/components/Checker/styles/index.ts index 95d1f21be..46b3719f5 100755 --- a/src/components/Checker/styles/index.ts +++ b/src/components/Checker/styles/index.ts @@ -14,13 +14,12 @@ export const Wrapper = styled.div` ` export const IconWrapper = styled.div` position: relative; - background: ${({ checked }) => (checked ? '#114759' : '#00262F')}; + background: ${({ checked }) => (checked ? '#0d3d4e' : '#012f3a')}; width: ${({ size }) => getIconSize(size)}; height: ${({ size }) => getIconSize(size)}; ${css.flex('align-both')}; border: 1px solid; - border-color: ${({ checked }) => (checked ? 'transparent' : '#114759')}; - + border-color: ${({ checked }) => (checked ? '#246b8c' : '#1c5975')}; border-radius: ${({ size }) => getBorderRadius(size)}; transition: all 0.2s; diff --git a/src/containers/tool/AbuseReport/ArticleReport/index.tsx b/src/containers/tool/AbuseReport/ArticleReport/index.tsx index c4bc3b49c..ca8f44cfd 100644 --- a/src/containers/tool/AbuseReport/ArticleReport/index.tsx +++ b/src/containers/tool/AbuseReport/ArticleReport/index.tsx @@ -1,12 +1,53 @@ import React from 'react' -import { Wrapper } from '../styles/article_report' +import { ICON } from '@/config' +import Checker from '@/components/Checker' + +import { + Wrapper, + Option, + Title, + QuestionIcon, + Note, +} from '../styles/article_report' const ArticleReport: React.FC = () => { return ( -
header
-
content
+ + + + + + + + + 举报成功后社区志愿者会在第一时间处理,处理结果会公示在这里。如果你对社区治理有更好的想法或建议,请联系我们。 +
) } diff --git a/src/containers/tool/AbuseReport/Header.tsx b/src/containers/tool/AbuseReport/Header.tsx index 74cf708b1..9aaf01717 100644 --- a/src/containers/tool/AbuseReport/Header.tsx +++ b/src/containers/tool/AbuseReport/Header.tsx @@ -6,7 +6,7 @@ import { Wrapper, ReportIcon, Text, ContentTitle } from './styles/header' const Header = () => { return ( - + 举报内容 这是一首简单的小情歌 diff --git a/src/containers/tool/AbuseReport/index.tsx b/src/containers/tool/AbuseReport/index.tsx index 3679b8e33..056e43778 100755 --- a/src/containers/tool/AbuseReport/index.tsx +++ b/src/containers/tool/AbuseReport/index.tsx @@ -13,6 +13,7 @@ import { pluggedIn, buildLog } from '@/utils' import Modal from '@/components/Modal' import Header from './Header' +import ArticleReport from './ArticleReport' import type { TStore } from './store' import { Wrapper } from './styles' @@ -36,6 +37,7 @@ const AbuseReportContainer: React.FC = ({ console.log('close')}>
+ ) diff --git a/src/containers/tool/AbuseReport/styles/article_report/index.tsx b/src/containers/tool/AbuseReport/styles/article_report/index.tsx index a7518f034..48d0b035c 100644 --- a/src/containers/tool/AbuseReport/styles/article_report/index.tsx +++ b/src/containers/tool/AbuseReport/styles/article_report/index.tsx @@ -1,8 +1,40 @@ import styled from 'styled-components' +import Img from '@/Img' import { css, theme } from '@/utils' export const Wrapper = styled.div` ${css.flexColumn()}; ` -export const Title = styled.div`` +export const Option = styled.div` + ${css.flex('align-center')}; + font-size: 16px; + padding: 12px 0; + border-bottom: 1px solid; + border-bottom-color: #125065; + + &:hover { + cursor: pointer; + } +` +export const Title = styled.div` + color: ${theme('thread.articleTitle')}; + margin-left: 5px; + flex-grow: 1; +` +export const QuestionIcon = styled(Img)` + fill: ${theme('thread.articleTitle')}; + ${css.size(16)}; + margin-right: 10px; + opacity: 0; + + ${Option}:hover & { + opacity: 1; + } + transition: all 0.25s; +` +export const Note = styled.div` + color: ${theme('thread.articleDigest')}; + margin-top: 22px; + font-size: 14px; +` diff --git a/src/containers/tool/AbuseReport/styles/header.ts b/src/containers/tool/AbuseReport/styles/header.ts index 9b9db7d9e..cc0d48bc4 100644 --- a/src/containers/tool/AbuseReport/styles/header.ts +++ b/src/containers/tool/AbuseReport/styles/header.ts @@ -6,6 +6,7 @@ import { theme, css } from '@/utils' export const Wrapper = styled.div` ${css.flex('align-center')}; color: ${theme('thread.articleDigest')}; + margin-bottom: 20px; ` export const ReportIcon = styled(Img)` ${css.size(16)}; @@ -13,10 +14,12 @@ export const ReportIcon = styled(Img)` ` export const Text = styled.div` color: ${theme('thread.articleTitle')}; - margin-left: 5px; + margin-left: 8px; + margin-right: 6px; ` export const ContentTitle = styled.div` color: ${theme('thread.articleDigest')}; + font-size: 15px; margin-left: 3px; margin-right: 3px; &:before { diff --git a/src/containers/tool/AbuseReport/styles/index.ts b/src/containers/tool/AbuseReport/styles/index.ts index 758f118c3..2840f2116 100755 --- a/src/containers/tool/AbuseReport/styles/index.ts +++ b/src/containers/tool/AbuseReport/styles/index.ts @@ -6,7 +6,7 @@ import { theme } from '@/utils' export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ 'data-test-id': testid, }))` - padding: 15px 30px; + padding: 25px 40px; color: ${theme('thread.articleDigest')}; ` export const Title = styled.div`` From f378e63b099e0dbf1ff514db293a918917e55a12 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Sun, 25 Apr 2021 13:38:48 +0800 Subject: [PATCH 04/21] chore(abuse-report): wip --- src/components/Buttons/YesOrNoButtons.tsx | 34 +++++++++++++++++++ src/components/Buttons/index.tsx | 1 + .../Buttons/styles/yes_or_no_buttons.ts | 15 ++++++++ src/containers/layout/GlobalLayout/index.tsx | 2 ++ .../tool/AbuseReport/ArticleReport/index.tsx | 7 +++- src/containers/tool/AbuseReport/Footer.tsx | 15 ++++++++ src/containers/tool/AbuseReport/Header.tsx | 2 +- src/containers/tool/AbuseReport/index.tsx | 2 ++ .../tool/AbuseReport/styles/footer.ts | 9 +++++ 9 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/components/Buttons/YesOrNoButtons.tsx create mode 100644 src/components/Buttons/styles/yes_or_no_buttons.ts create mode 100644 src/containers/tool/AbuseReport/Footer.tsx create mode 100644 src/containers/tool/AbuseReport/styles/footer.ts diff --git a/src/components/Buttons/YesOrNoButtons.tsx b/src/components/Buttons/YesOrNoButtons.tsx new file mode 100644 index 000000000..20239f1bc --- /dev/null +++ b/src/components/Buttons/YesOrNoButtons.tsx @@ -0,0 +1,34 @@ +import React from 'react' + +import { Space } from '@/components/Common' +import Button from './Button' + +import { Wrapper, CancelBtn } from './styles/yes_or_no_buttons' + +type TProps = { + align?: 'center' | 'right' + cancelText?: string + confirmText?: string + onCancel?: () => void + onConfirm?: () => void +} + +const YesOrNoButton: React.FC = ({ + align = 'center', + cancelText = '取消', + confirmText = '确定', + onCancel = console.log, + onConfirm = console.log, +}) => { + return ( + + onCancel?.()}>{cancelText} + + + + ) +} + +export default YesOrNoButton diff --git a/src/components/Buttons/index.tsx b/src/components/Buttons/index.tsx index a9e14362a..911f53b88 100755 --- a/src/components/Buttons/index.tsx +++ b/src/components/Buttons/index.tsx @@ -6,3 +6,4 @@ export { default as OrButton } from './OrButton' export { default as DropdownButton } from './DropdownButton' export { default as NotifyButton } from './NotifyButton' export { default as FollowButton } from './FollowButton' +export { default as YesOrNoButtons } from './YesOrNoButtons' diff --git a/src/components/Buttons/styles/yes_or_no_buttons.ts b/src/components/Buttons/styles/yes_or_no_buttons.ts new file mode 100644 index 000000000..0a30e4e54 --- /dev/null +++ b/src/components/Buttons/styles/yes_or_no_buttons.ts @@ -0,0 +1,15 @@ +import styled from 'styled-components' + +import { css, theme } from '@/utils' + +type TWrapper = { align: 'center' | 'right' } +export const Wrapper = styled.div` + ${css.flex('align-center')}; + width: 100%; + justify-content: ${({ align }) => + align === 'center' ? 'center' : 'flex-end'}; +` +export const CancelBtn = styled.div` + color: ${theme('button.primary')}; + font-size: 14px; +` diff --git a/src/containers/layout/GlobalLayout/index.tsx b/src/containers/layout/GlobalLayout/index.tsx index d17c492b2..97bc0dc6b 100755 --- a/src/containers/layout/GlobalLayout/index.tsx +++ b/src/containers/layout/GlobalLayout/index.tsx @@ -93,7 +93,9 @@ const GlobalLayoutContainer: React.FC = ({ sidebarPin={sidebarPin} // noSidebar={noSidebar} > +
reload
+ {!noSidebar && } diff --git a/src/containers/tool/AbuseReport/ArticleReport/index.tsx b/src/containers/tool/AbuseReport/ArticleReport/index.tsx index ca8f44cfd..3dca080fc 100644 --- a/src/containers/tool/AbuseReport/ArticleReport/index.tsx +++ b/src/containers/tool/AbuseReport/ArticleReport/index.tsx @@ -29,6 +29,11 @@ const ArticleReport: React.FC = () => { 硬广,软广 +