diff --git a/public/icons/static/shape/warning.svg b/public/icons/static/shape/warning.svg new file mode 100644 index 000000000..f14e84d77 --- /dev/null +++ b/public/icons/static/shape/warning.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/NoticeBar/Icon.tsx b/src/components/NoticeBar/Icon.tsx new file mode 100644 index 000000000..fc0cfe5c9 --- /dev/null +++ b/src/components/NoticeBar/Icon.tsx @@ -0,0 +1,21 @@ +import React from 'react' + +import { ICON } from '@/config' +import { LockIcon, NoticeIcon } from './styles/icon' + +type TProps = { + type?: 'lock' | 'notice' | 'bot' +} + +const Icon: React.FC = ({ type = 'notice' }) => { + switch (type) { + case 'lock': { + return + } + default: { + return + } + } +} + +export default React.memo(Icon) diff --git a/src/components/NoticeBar/index.tsx b/src/components/NoticeBar/index.tsx new file mode 100755 index 000000000..b0a4c2428 --- /dev/null +++ b/src/components/NoticeBar/index.tsx @@ -0,0 +1,58 @@ +/* + * + * NoticeBar + * + */ + +import React from 'react' + +import TimeAgo from 'timeago-react' + +import { buildLog } from '@/utils' +import { ICON } from '@/config' + +import Icon from './Icon' + +import { Wrapper, Main, UserName, AuthorTag, Timestamp, Why } from './styles' + +/* eslint-disable-next-line */ +const log = buildLog('c:NoticeBar:index') + +type TProps = { + testid?: string + type?: 'lock' | 'notice' | 'bot' + user?: { + nickname: string + } | null + isArticleAuthor?: boolean + content: string + timestamp?: string | null +} + +const NoticeBar: React.FC = ({ + testid = 'notice-bar', + type = 'notice', + user = null, + isArticleAuthor = false, + content, + timestamp = null, +}) => { + return ( + + +
+ {user && {user.nickname}} + {isArticleAuthor && (作者)} + {content} +
+ {timestamp && ( + + + + )} + +
+ ) +} + +export default React.memo(NoticeBar) diff --git a/src/components/NoticeBar/styles/icon.ts b/src/components/NoticeBar/styles/icon.ts new file mode 100644 index 000000000..288bb7af9 --- /dev/null +++ b/src/components/NoticeBar/styles/icon.ts @@ -0,0 +1,17 @@ +import styled from 'styled-components' + +// import type { TTestable } from '@/spec' +import Img from '@/Img' +import { css, theme } from '@/utils' + +const Icon = styled(Img)` + fill: #a57a32; // ${theme('thread.articleTitle')}; + ${css.size(15)}; + margin-right: 12px; +` +export const LockIcon = styled(Icon)` + fill: #a57a32; // ${theme('thread.articleTitle')}; +` +export const NoticeIcon = styled(Icon)` + fill: #a57a32; // ${theme('thread.articleTitle')}; +` diff --git a/src/components/NoticeBar/styles/index.ts b/src/components/NoticeBar/styles/index.ts new file mode 100755 index 000000000..e246d2a44 --- /dev/null +++ b/src/components/NoticeBar/styles/index.ts @@ -0,0 +1,47 @@ +import styled from 'styled-components' + +import type { TTestable } from '@/spec' + +import Img from '@/Img' +import { css, theme } from '@/utils' + +export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({ + 'data-test-id': testid, +}))` + ${css.flex('align-center')}; + color: ${theme('thread.articleTitle')}; + padding-left: 12px; + padding-right: 15px; + width: 100%; + height: 40px; + background: #00333f; + border-radius: 8px; +` +export const Main = styled.div` + flex-grow: 1; + font-size: 14px; +` +export const UserName = styled.span` + color: ${theme('thread.articleTitle')}; + margin-right: 5px; +` +export const AuthorTag = styled.span` + color: ${theme('thread.articleDigest')}; + margin-left: 2px; + margin-right: 5px; +` +export const Timestamp = styled.div` + color: ${theme('thread.articleDigest')}; + font-size: 12px; +` +export const Why = styled(Img)` + ${css.size(15)}; + fill: ${theme('thread.articleDigest')}; + margin-left: 10px; + margin-top: -1px; + + &:hover { + fill: ${theme('thread.articleTitle')}; + cursor: pointer; + } +` diff --git a/src/components/NoticeBar/tests/index.test.ts b/src/components/NoticeBar/tests/index.test.ts new file mode 100755 index 000000000..9fba0c41a --- /dev/null +++ b/src/components/NoticeBar/tests/index.test.ts @@ -0,0 +1,10 @@ +// import React from 'react' +// import { shallow } from 'enzyme' + +// import NoticeBar from '../index' + +describe('TODO ', () => { + it('Expect to have unit tests specified', () => { + expect(true).toEqual(true) + }) +}) diff --git a/src/containers/unit/Comments/index.tsx b/src/containers/unit/Comments/index.tsx index aeb1be4a6..b948d6b40 100755 --- a/src/containers/unit/Comments/index.tsx +++ b/src/containers/unit/Comments/index.tsx @@ -7,7 +7,9 @@ import React from 'react' import { pluggedIn, buildLog } from '@/utils' + import Modal from '@/components/Modal' +import NoticeBar from '@/components/NoticeBar' import CommentEditor from './CommentEditor' import List from './List' @@ -75,6 +77,15 @@ const CommentsContainer: React.FC = ({ /> )} +
+ +