Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

feat(abuse report): redesign #1069

Merged
merged 21 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ cypress//integration/examples
cypress/videos/
.vscode/
.DS_Store
report.*
.eslintcache
1 change: 1 addition & 0 deletions public/icons/static/article/report-solid.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 deletions public/icons/static/article/report.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 1 addition & 13 deletions src/components/ArticleActionsPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import React from 'react'
import T from 'prop-types'
import { values } from 'ramda'

import { ICON_CMD } from '@/config'
import { THREAD } from '@/constant'
import { buildLog } from '@/utils'

import Informer from '@/containers/tool/Informer'
import PinOption from './PinOption'
import RefineOption from './RefineOption'
import EditOption from './EditOption'
import CommunitySetterOption from './CommunitySetterOption'
import DeleteOption from './DeleteOption'

import { Wrapper, Option, OptionIcon, OptionTitle } from './styles'
import { Wrapper } from './styles'

/* eslint-disable-next-line */
const log = buildLog('c:ArticleActionsPanel:index')
Expand All @@ -33,7 +31,6 @@ const ArticleActionsPanel = ({
onSetRefined,
onUnsetRefined,
onEdit,
onInform,
onDelete,
onCommunitySet,
}) => {
Expand Down Expand Up @@ -66,13 +63,6 @@ const ArticleActionsPanel = ({
onCommunitySet={onCommunitySet}
/>

<Informer>
<Option onClick={onInform}>
<OptionIcon src={`${ICON_CMD}/flag.svg`} />
<OptionTitle>举报该内容</OptionTitle>
</Option>
</Informer>

<DeleteOption
passport="owner"
ownerId={data.author?.id}
Expand Down Expand Up @@ -100,7 +90,6 @@ ArticleActionsPanel.propTypes = {
}).isRequired,
communityRaw: T.string.isRequired,
thread: T.oneOf(values(THREAD)),
onInform: T.func,
onDelete: T.func,
onEdit: T.func,
onPin: T.func,
Expand All @@ -112,7 +101,6 @@ ArticleActionsPanel.propTypes = {

ArticleActionsPanel.defaultProps = {
thread: THREAD.POST,
onInform: log,
onDelete: log,
onEdit: log,
onPin: log,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Buttons/ArrowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type TProps = {
direction?: 'left' | 'right'
dimWhenIdle?: boolean
disabled?: boolean
arrowStyle?: string
arrowStyle?: 'default' | 'simple'
}

const ArrowButton: React.FC<TProps> = ({
Expand Down
34 changes: 34 additions & 0 deletions src/components/Buttons/YesOrNoButtons.tsx
Original file line number Diff line number Diff line change
@@ -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<TProps> = ({
align = 'center',
cancelText = '取消',
confirmText = '确定',
onCancel = console.log,
onConfirm = console.log,
}) => {
return (
<Wrapper align={align}>
<CancelBtn onClick={() => onCancel?.()}>{cancelText}</CancelBtn>
<Space left={5} right={10} />
<Button size="small" type="primary" onClick={() => onConfirm?.()}>
{confirmText}
</Button>
</Wrapper>
)
}

export default YesOrNoButton
1 change: 1 addition & 0 deletions src/components/Buttons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
15 changes: 15 additions & 0 deletions src/components/Buttons/styles/yes_or_no_buttons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from 'styled-components'

import { css, theme } from '@/utils'

type TWrapper = { align: 'center' | 'right' }
export const Wrapper = styled.div<TWrapper>`
${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;
`
8 changes: 4 additions & 4 deletions src/components/Checker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ 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<TProps> = ({
checked = false,
onChange = log,
hiddenMode = false,
size = SIZE.MEDIUM,
children,
children = null,
}) => {
const show = checked || !hiddenMode

Expand Down
5 changes: 2 additions & 3 deletions src/components/Checker/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export const Wrapper = styled.div<TActive>`
`
export const IconWrapper = styled.div<TItem>`
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;
Expand Down
1 change: 1 addition & 0 deletions src/components/FormItem/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const TextAreaInput = styled(Input)<{ error: string }>`
error === 'true' ? theme('baseColor.red') : ''};
border-right-color: ${({ error }) =>
error === 'true' ? theme('baseColor.red') : ''};
border: 1px solid tomato;
`

export const FormItemWrapper = styled.div<TSpace>`
Expand Down
51 changes: 0 additions & 51 deletions src/components/Input/Textarea.js

This file was deleted.

43 changes: 43 additions & 0 deletions src/components/Input/Textarea.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* Input
*
*/

import React, { useCallback } from 'react'
import { pickBy } from 'ramda'

import { buildLog } from '@/utils'

import { Wrapper } from './styles/textarea'

/* eslint-disable-next-line */
const log = buildLog('c:Input:index')

type TProps = {
testid?: string
placeholder?: string
value?: string | null
onChange?: (e) => void | null
}

const Textarea: React.FC<TProps> = ({
onChange = null,
testid = 'textarea',
...restProps
}) => {
const handleOnChange = useCallback((e) => onChange?.(e), [onChange])
const validProps = pickBy((v) => v !== null, restProps)

return (
<Wrapper
testid={testid}
onChange={handleOnChange}
minRows={1}
spellcheck="false"
{...validProps}
/>
)
}

export default React.memo(Textarea)
62 changes: 24 additions & 38 deletions src/components/Input/index.js → src/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React, { useCallback } from 'react'
import T from 'prop-types'
import { pickBy } from 'ramda'

import { buildLog, nilOrEmpty } from '@/utils'
Expand All @@ -22,14 +21,29 @@ import {
/* eslint-disable-next-line */
const log = buildLog('c:Input:index')

const Input = ({
behavior,
onChange,
prefixIcon,
prefixActive,
suffixIcon,
suffixActive,
testid,
type TProps = {
testid?: string
behavior?: 'default' | 'textarea'
placeholder?: string
value?: string | null
prefixIcon?: string | null
prefixActive?: boolean
suffixIcon?: string | null
suffixActive?: boolean
disabled?: boolean
autoFocus?: boolean

onChange?: (e) => void | null
}

const Input: React.FC<TProps> = ({
behavior = 'default',
onChange = null,
prefixIcon = null,
prefixActive = false,
suffixIcon = null,
suffixActive = false,
testid = 'input',
...restProps
}) => {
const handleOnChange = useCallback((e) => onChange && onChange(e), [onChange])
Expand All @@ -53,36 +67,8 @@ const Input = ({
</SuffixWrapper>
</Wrapper>
) : (
<Textarea testid={testid} onChange={onChange} minRows={1} {...restProps} />
<Textarea testid={testid} onChange={onChange} {...restProps} />
)
}

Input.propTypes = {
behavior: T.oneOf(['default', 'textarea']),
placeholder: T.string,
value: T.oneOfType([T.string, T.instanceOf(null)]),
onChange: T.oneOfType([T.func, T.instanceOf(null)]),
prefixIcon: T.oneOfType([T.string, T.instanceOf(null)]),
prefixActive: T.bool,
suffixIcon: T.oneOfType([T.string, T.instanceOf(null)]),
suffixActive: T.bool,
disabled: T.bool,
autoFocus: T.bool,
testid: T.string,
}

Input.defaultProps = {
behavior: 'default',
placeholder: '',
value: null,
onChange: null,
prefixIcon: null,
prefixActive: false,
suffixIcon: null,
suffixActive: false,
disabled: false,
autoFocus: false,
testid: 'input',
}

export default React.memo(Input)
1 change: 1 addition & 0 deletions src/components/Input/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { css, theme } from '@/utils'
type IInput = {
hasPrefix: boolean
hasSuffix: boolean
spellcheck: string
}

export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
Expand Down
9 changes: 7 additions & 2 deletions src/components/Input/styles/textarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import { theme } from '@/utils'

import { baseInput } from './index'

type TWrapper = TTestable | { spellcheck: string }

export const Wrapper = styled(TextareaAutosize).attrs(
({ testid }: TTestable) => ({
'data-test-id': testid,
}),
)<TTestable>`
)<TWrapper>`
${baseInput};
background-color: #0b2631;
color: ${theme('form.text')};
min-height: 56px;
padding: 6px 10px;
background-color: #06303b;
border: 1px solid;
border-color: ${theme('editor.border')};
resize: none;
Expand Down
Loading