This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork37
refactor(article): article-footer with copyright setting#1115
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
cae6046
feat(copyright): basic demo
mydearxymf8b5fb2
style(article-viewer): collect icon style & common footer
mydearxyme5cc748
refactor(article-footer): js -> ts, style adjust
mydearxymdf3d8dd
chore(spec): social type
mydearxym8595f92
refactor(copyright): basic UX done
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionspublic/icons/static/article/cc-by.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/cc-nc.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/cc-nd.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/cc-raw.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletionspublic/icons/static/article/cc.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/collect-bookmark.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/copyright-approve.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/copyright-forbid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/copyright-printer.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/copyright.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletionsrc/components/Buttons/IconButton.tsx
This file contains hidden or 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
8 changes: 4 additions & 4 deletionssrc/components/Buttons/styles/arrow_link.ts
This file contains hidden or 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
41 changes: 41 additions & 0 deletionssrc/components/Copyright/Label.tsx
This file contains hidden or 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,41 @@ | ||
import { FC, memo } from 'react' | ||
import { ICON } from '@/config' | ||
import { Wrapper, Icon, Text } from './styles/label' | ||
type TProps = { | ||
type?: 'cc' | 'approve' | 'forbid' | ||
} | ||
const Label: FC<TProps> = ({ type }) => { | ||
switch (type) { | ||
case 'approve': { | ||
return ( | ||
<Wrapper> | ||
<Icon src={`${ICON}/article/copyright-approve.svg`} /> | ||
<Text>转载需授权</Text> | ||
</Wrapper> | ||
) | ||
} | ||
case 'forbid': { | ||
return ( | ||
<Wrapper> | ||
<Icon src={`${ICON}/article/copyright-forbid.svg`} /> | ||
<Text>禁止转载</Text> | ||
</Wrapper> | ||
) | ||
} | ||
default: { | ||
return ( | ||
<Wrapper> | ||
<Icon src={`${ICON}/article/cc-raw.svg`} /> | ||
<Text>知识共享 4.0</Text> | ||
</Wrapper> | ||
) | ||
} | ||
} | ||
} | ||
export default memo(Label) |
88 changes: 88 additions & 0 deletionssrc/components/Copyright/ReadOnlyPanel.tsx
This file contains hidden or 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,88 @@ | ||
import { FC, memo } from 'react' | ||
import { ICON } from '@/config' | ||
import { ArrowLink } from '@/components/Buttons' | ||
import { | ||
Wrapper, | ||
Header, | ||
Icon, | ||
Title, | ||
Desc, | ||
Items, | ||
DescItem, | ||
Footer, | ||
} from './styles/readonly_panel' | ||
type TProps = { | ||
type?: 'cc' | 'approve' | 'forbid' | ||
} | ||
const ReadOnlyPanel: FC<TProps> = ({ type }) => { | ||
switch (type) { | ||
case 'approve': { | ||
return ( | ||
<Wrapper> | ||
<Header> | ||
<Icon src={`${ICON}/article/copyright-approve.svg`} /> | ||
<Title>转载需授权</Title> | ||
</Header> | ||
<Desc> | ||
根据作者设置,转载需获取本人授权。相关联系方式可参考作者主页。 | ||
</Desc> | ||
</Wrapper> | ||
) | ||
} | ||
case 'forbid': { | ||
return ( | ||
<Wrapper> | ||
<Header> | ||
<Icon src={`${ICON}/article/copyright-forbid.svg`} /> | ||
<Title>禁止转载</Title> | ||
</Header> | ||
<Desc> | ||
根据作者设置,本文严禁任何方式的转载,如有疑问,请尝试联系作者。 | ||
</Desc> | ||
</Wrapper> | ||
) | ||
} | ||
default: { | ||
return ( | ||
<Wrapper> | ||
<Header> | ||
<Icon src={`${ICON}/article/cc.svg`} /> | ||
<Title>知识共享 4.0</Title> | ||
</Header> | ||
<Desc> | ||
本作品采用知识共享「署名-非商业性使用-禁止演绎 4.0 | ||
国际」许可证授权。 | ||
<Items> | ||
<DescItem path="article/cc-by.svg" size="large" highlight> | ||
署名 | ||
</DescItem> | ||
<DescItem path="article/cc-nc.svg" size="large" highlight> | ||
非商业性使用 | ||
</DescItem> | ||
<DescItem path="article/cc-nd.svg" size="large" highlight> | ||
禁止演绎 | ||
</DescItem> | ||
</Items> | ||
</Desc> | ||
<Footer> | ||
<ArrowLink | ||
size="tiny" | ||
href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh" | ||
> | ||
查看完整版本 | ||
</ArrowLink> | ||
</Footer> | ||
</Wrapper> | ||
) | ||
} | ||
} | ||
} | ||
export default memo(ReadOnlyPanel) |
76 changes: 76 additions & 0 deletionssrc/components/Copyright/index.tsx
This file contains hidden or 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,76 @@ | ||
/* | ||
* | ||
* Copyright | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import type { TCopyright } from '@/spec' | ||
import Tooltip from '@/components/Tooltip' | ||
import { buildLog } from '@/utils' | ||
import Label from './Label' | ||
import SettingMenu from '@/components/SettingMenu' | ||
import ReadOnlyPanel from './ReadOnlyPanel' | ||
import { Wrapper } from './styles' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:Copyright:index') | ||
const options = [ | ||
{ | ||
title: '知识共享 4.0', | ||
desc: '署名-非商业性使用-禁止演绎', | ||
key: 'cc', | ||
}, | ||
{ | ||
title: '转载需授权', | ||
desc: '转载需得到我的明确授权。', | ||
key: 'approve', | ||
}, | ||
{ | ||
title: '禁止转载', | ||
desc: '禁止一切形式的转载,有疑问联系我。', | ||
key: 'forbid', | ||
}, | ||
] | ||
type TProps = { | ||
testid?: string | ||
type?: TCopyright | ||
mode?: 'readonly' | 'editable' | ||
onChange?: (type: string) => void | ||
} | ||
const Copyright: FC<TProps> = ({ | ||
testid = 'copyright', | ||
type = 'cc', | ||
mode = 'readonly', | ||
onChange = log, | ||
}) => { | ||
return ( | ||
<Wrapper testid={testid}> | ||
<Tooltip | ||
content={ | ||
mode === 'readonly' ? ( | ||
<ReadOnlyPanel type={type} /> | ||
) : ( | ||
<SettingMenu | ||
options={options} | ||
activeKey={type} | ||
onChange={onChange} | ||
/> | ||
) | ||
} | ||
placement="top" | ||
trigger="click" | ||
noPadding | ||
> | ||
<Label type={type} /> | ||
</Tooltip> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(Copyright) |
23 changes: 23 additions & 0 deletionssrc/components/Copyright/styles/index.ts
This file contains hidden or 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,23 @@ | ||
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, | ||
}))<TTestable>`` | ||
export const Label = styled.div` | ||
${css.flex('align-center')}; | ||
` | ||
export const Icon = styled(Img)` | ||
${css.size(14)}; | ||
fill: ${theme('thread.articleDigest')}; | ||
` | ||
export const Text = styled.div` | ||
font-size: 12px; | ||
color: ${theme('thread.articleDigest')}; | ||
margin-right: 5px; | ||
` |
29 changes: 29 additions & 0 deletionssrc/components/Copyright/styles/label.ts
This file contains hidden or 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,29 @@ | ||
import styled from 'styled-components' | ||
import Img from '@/Img' | ||
import { css, theme } from '@/utils' | ||
export const Wrapper = styled.div` | ||
${css.flex('align-center')}; | ||
cursor: pointer; | ||
` | ||
export const Icon = styled(Img)` | ||
fill: ${theme('thread.articleDigest')}; | ||
${css.size(13)}; | ||
${Wrapper}:hover & { | ||
fill: ${theme('thread.articleTitle')}; | ||
} | ||
transition: fill 0.2s; | ||
` | ||
export const Text = styled.div` | ||
font-size: 13px; | ||
color: ${theme('thread.articleDigest')}; | ||
margin-left: 6px; | ||
${Wrapper}:hover & { | ||
color: ${theme('thread.articleTitle')}; | ||
} | ||
transition: color 0.2s; | ||
` |
39 changes: 39 additions & 0 deletionssrc/components/Copyright/styles/readonly_panel.ts
This file contains hidden or 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,39 @@ | ||
import styled from 'styled-components' | ||
import IconText from '@/components/IconText' | ||
import Img from '@/Img' | ||
import { css, theme } from '@/utils' | ||
export const Wrapper = styled.div` | ||
${css.flexColumn()}; | ||
width: 240px; | ||
padding-left: 5px; | ||
` | ||
export const Header = styled.div` | ||
${css.flex('align-center')}; | ||
` | ||
export const Icon = styled(Img)` | ||
${css.size(18)}; | ||
fill: ${theme('thread.articleTitle')}; | ||
` | ||
export const Title = styled.div` | ||
font-size: 16px; | ||
color: ${theme('thread.articleTitle')}; | ||
margin-left: 8px; | ||
` | ||
export const Desc = styled.div` | ||
font-size: 13px; | ||
color: ${theme('thread.articleDigest')}; | ||
margin-top: 8px; | ||
margin-bottom: 8px; | ||
` | ||
export const Items = styled.div` | ||
margin-top: 10px; | ||
margin-bottom: 6px; | ||
` | ||
export const DescItem = styled(IconText)` | ||
margin-bottom: 3px; | ||
` | ||
export const Footer = styled.div` | ||
${css.flex('align-center')}; | ||
` |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.