diff --git a/src/components/Buttons/ArrowButton.tsx b/src/components/Buttons/ArrowButton.tsx index e7034793b..606417562 100755 --- a/src/components/Buttons/ArrowButton.tsx +++ b/src/components/Buttons/ArrowButton.tsx @@ -4,7 +4,7 @@ * */ -import { FC, ReactNode, useRef, useState, useEffect, memo } from 'react' +import { FC, ReactNode, memo } from 'react' import type { TSIZE } from '@/spec' import { ICON } from '@/config' @@ -40,32 +40,12 @@ const ArrowButton: FC = ({ ? `${ICON}/shape/arrow.svg` : `${ICON}/shape/arrow-simple.svg` - const leftTextRef = useRef(null) - const rightTextRef = useRef(null) - - const [leftChildWidth, setLeftTextWidth] = useState(50) - const [rightChildWidth, setRightTextWidth] = useState(50) - - useEffect(() => { - if (leftTextRef) { - setLeftTextWidth(leftTextRef.current?.clientWidth) - } - }, [leftTextRef]) - - useEffect(() => { - if (rightTextRef) { - setRightTextWidth(rightTextRef.current?.clientWidth) - } - }, [rightTextRef]) - - const textWidth = direction === 'left' ? leftChildWidth : rightChildWidth - return ( !disabled && onClick()} dimWhenIdle={dimWhenIdle} + direction={direction} size={size} - width={textWidth} disabled={disabled} > {direction === 'left' ? ( @@ -76,15 +56,11 @@ const ArrowButton: FC = ({ src={iconSrc} disabled={disabled} /> - - {children} - + {children} ) : ( <> - - {children} - + {children} void + onClick?: (key?: string) => void } const MenuButton: FC = ({ diff --git a/src/components/Buttons/styles/arrow_button.ts b/src/components/Buttons/styles/arrow_button.ts index 063ffd070..1d0d98e6c 100755 --- a/src/components/Buttons/styles/arrow_button.ts +++ b/src/components/Buttons/styles/arrow_button.ts @@ -4,30 +4,36 @@ import Img from '@/Img' import { css } from '@/utils' import { - getWidth, getIconSize, getFontSize, getMargin, getSimpleMargin, + // + getArrowTopOffset, + getArrowMaxWidth, + getArrowInitWidth, } from './metircs/arrow_button' type TWrapper = { disabled: boolean dimWhenIdle: boolean + direction: 'left' | 'right' size: string - width: number } export const Wrapper = styled.div` + position: relative; ${css.flex('align-center')}; opacity: ${({ dimWhenIdle, disabled }) => dimWhenIdle || disabled ? '0.65' : 1}; - min-width: ${({ size, width }) => getWidth(size, width)}; + justify-content: ${({ direction }) => + direction === 'left' ? 'flex-end' : 'flex-start'}; + margin-left: ${({ size }) => getArrowMaxWidth(size)}; &:hover { cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')}; opacity: ${({ disabled }) => (disabled ? 0.65 : 1)}; } - transition: all 0.25s; + transition: all 0.2s; ` export const Text = styled.div<{ size: string }>` font-size: ${({ size }) => getFontSize(size)}; @@ -42,33 +48,37 @@ export const Icon = styled(Img)<{ size: string }>` ` type TIcon = { size: string; arrowStyle: string; disabled: boolean } export const LeftIcon = styled(Icon)` + position: absolute; + top: ${({ size }) => getArrowTopOffset(size)}; + left: ${({ size }) => `-${getArrowInitWidth(size)}`}; + + opacity: 0.6; margin-right: ${({ size, arrowStyle }) => arrowStyle === 'default' ? getMargin(size) : getSimpleMargin(size)}; ${Wrapper}:hover & { - margin-left: ${({ arrowStyle, disabled }) => { + opacity: 1; + left: ${({ size, disabled }) => { if (disabled) return 0 - return arrowStyle === 'default' ? '-4px' : '-2px' + return `-${getArrowMaxWidth(size)}` }}; - /* margin-left: ${({ size, arrowStyle, disabled }) => { - return arrowStyle === 'default' - ? `-${getMargin(size, !disabled)}` - : `-${getSimpleMargin(size, !disabled)}` - }}; */ - fill: #327ca1; } ` export const RightIcon = styled(Icon)` + position: absolute; + top: ${({ size }) => getArrowTopOffset(size)}; + right: ${({ size }) => `-${getArrowInitWidth(size)}`}; + + opacity: 0.6; margin-left: ${({ size, arrowStyle }) => arrowStyle === 'default' ? getMargin(size) : getSimpleMargin(size)}; ${Wrapper}:hover & { - margin-left: ${({ size, arrowStyle, disabled }) => { - return arrowStyle === 'default' - ? getMargin(size, !disabled) - : getSimpleMargin(size, !disabled) + opacity: 1; + right: ${({ size, disabled }) => { + if (disabled) return 0 + return `-${getArrowMaxWidth(size)}` }}; - fill: #327ca1; } transform: rotate(180deg); diff --git a/src/components/Buttons/styles/button.ts b/src/components/Buttons/styles/button.ts index 6916a42ba..a512b6b5d 100644 --- a/src/components/Buttons/styles/button.ts +++ b/src/components/Buttons/styles/button.ts @@ -26,11 +26,12 @@ export const Wrapper = styled.button` border: 1px solid transparent; white-space: nowrap; padding: ${({ size }) => getPadding(size)}; - font-size: 14px; + font-size: ${({ size }) => getFontSize(size)}; + /* font-size: 14px; */ border-radius: 4px; height: ${({ size }) => getHeight(size)}; user-select: none; - transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); + transition: all 0.1s cubic-bezier(0.645, 0.045, 0.355, 1); position: relative; color: ${({ ghost, disabled }) => getColor(ghost, disabled)}; @@ -39,7 +40,7 @@ export const Wrapper = styled.button` border-color: ${({ noBorder, disabled }) => getBorderColor(noBorder, disabled)}; - opacity: ${({ noBorder }) => (noBorder ? '0.7' : 1)}; + opacity: ${({ noBorder }) => (noBorder ? '0.8' : 1)}; &:hover { color: ${({ ghost, disabled }) => getColor(ghost, disabled)}; @@ -89,34 +90,27 @@ export const LoadingMask = styled.div<{ width: string }>` left: 0; background: ${({ width }) => (width === '100%' ? 'transparent' : '#2c6b94')}; z-index: 1; - transition: width 0.3s; + transition: width 0.1s; ` export const RedWrapper = styled(Wrapper)` color: ${({ ghost }) => (ghost ? theme('baseColor.red') : 'white')}; background-color: ${({ ghost }) => !ghost ? theme('baseColor.red') : 'transparent'}; - border-color: ${theme('baseColor.red')}; + + border-color: ${({ noBorder }) => + noBorder ? 'transparent' : theme('baseColor.red')}; &:hover { - border: 2px solid; background-color: ${({ ghost }) => !ghost ? lighten(0.1, 'tomato') : 'transparent'}; - border-color: ${lighten(0.1, 'tomato')}; - font-weight: ${({ ghost }) => (ghost ? 'bold' : 'normal')}; } &:focus { - border: 2px solid; background-color: ${({ ghost }) => !ghost ? lighten(0.1, 'tomato') : 'transparent'}; - border-color: ${lighten(0.1, 'tomato')}; - font-weight: ${({ ghost }) => (ghost ? 'bold' : 'normal')}; } &:active { - border: 2px solid; background-color: ${({ ghost }) => !ghost ? lighten(0.1, 'tomato') : 'transparent'}; - border-color: ${lighten(0.1, 'tomato')}; - font-weight: ${({ ghost }) => (ghost ? 'bold' : 'normal')}; } - transition: all 0.25s; + transition: all 0.1s; ` diff --git a/src/components/Buttons/styles/metircs/arrow_button.ts b/src/components/Buttons/styles/metircs/arrow_button.ts index 1134a6196..6e8a7ad4d 100644 --- a/src/components/Buttons/styles/metircs/arrow_button.ts +++ b/src/components/Buttons/styles/metircs/arrow_button.ts @@ -17,25 +17,6 @@ const MEDIUM_MARGIN_HOVER = 10 const LARGE_MARGIN = 6 const LARGE_MARGIN_HOVER = 10 -// arrow button should have width -// otherwise the arrow will jump -export const getWidth = (size: string, width = 30): string => { - switch (size) { - case SIZE.TINY: { - return `${width + TINY_SIZE + TINY_MARGIN_HOVER}px` - } - case SIZE.SMALL: { - return `${width + SMALL_SIZE + SMALL_MARGIN_HOVER}px` - } - case SIZE.MEDIUM: { - return `${width + MEDIUM_SIZE + MEDIUM_MARGIN_HOVER}px` - } - default: { - return `${width + LARGE_SIZE + LARGE_MARGIN_HOVER}px` - } - } -} - export const getIconSize = (size: string): string => { switch (size) { case SIZE.TINY: { @@ -103,3 +84,55 @@ export const getSimpleMargin = (size: string, hover = false): string => { } } } + +// +export const getArrowTopOffset = (size: string): string => { + switch (size) { + case SIZE.TINY: { + return '3px;' + } + case SIZE.SMALL: { + return '4px;' + } + case SIZE.MEDIUM: { + return '5px;' + } + default: { + return '6px;' + } + } +} + +export const getArrowMaxWidth = (size: string): string => { + switch (size) { + case SIZE.TINY: { + return '18px;' + } + case SIZE.SMALL: { + return '20px;' + } + case SIZE.MEDIUM: { + return '25px;' + } + default: { + return '28px;' + } + } +} + +export const getArrowInitWidth = (size: string): string => { + switch (size) { + case SIZE.TINY: { + return '15px;' + } + case SIZE.SMALL: { + return '17px;' + } + case SIZE.MEDIUM: { + return '20px;' + } + default: { + return '23px;' + } + } +} diff --git a/src/components/Buttons/styles/metircs/button.ts b/src/components/Buttons/styles/metircs/button.ts index d90f0cb70..ec89af09c 100644 --- a/src/components/Buttons/styles/metircs/button.ts +++ b/src/components/Buttons/styles/metircs/button.ts @@ -63,7 +63,7 @@ export const getHeight = (size: string): string => { export const getPadding = (size: string): string => { switch (size) { case SIZE.TINY: { - return '1px 5px' + return '0 4px' } case SIZE.SMALL: { diff --git a/src/components/Checker/styles/index.ts b/src/components/Checker/styles/index.ts index 46b3719f5..bee319b66 100755 --- a/src/components/Checker/styles/index.ts +++ b/src/components/Checker/styles/index.ts @@ -35,8 +35,8 @@ export const Icon = styled(Img)` cursor: pointer; ` export const ChildWrapper = styled.div` - color: ${theme('thread.articleDigest')}; - opacity: ${({ checked }) => (checked ? 1 : 0.9)}; + color: ${({ checked }) => + checked ? theme('thread.articleTitle') : theme('thread.articleDigest')}; font-size: ${({ size }) => getFontSize(size)}; margin-left: 6px; cursor: pointer; diff --git a/src/components/Folder/Content.js b/src/components/Folder/Content.js deleted file mode 100644 index 3e748842b..000000000 --- a/src/components/Folder/Content.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react' - -import { Wrapper, TextWrapper, Cover } from './styles/content' - -const Content = ({ contentType, cover, desc }) => { - switch (contentType) { - case 'text': { - return ( - - {desc}, djifek d djifek idfk d fjdekj idfkjei dfkejife dfjei - - ) - } - - default: - return ( - - - - ) - } -} - -export default React.memo(Content) diff --git a/src/components/Folder/Content.tsx b/src/components/Folder/Content.tsx new file mode 100644 index 000000000..a8fbb0b95 --- /dev/null +++ b/src/components/Folder/Content.tsx @@ -0,0 +1,31 @@ +import { FC, memo } from 'react' +import TimeAgo from 'timeago-react' + +import { ICON } from '@/config' + +import { Wrapper, Info, Total, Unit, Text, LockIcon } from './styles/content' + +type TProps = { + total?: number + updatedAt?: string + lock?: boolean + inactive: boolean +} + +const Content: FC = ({ total, updatedAt, lock, inactive }) => { + return ( + + {lock && } + + + {total} + + + + + + + ) +} + +export default memo(Content) diff --git a/src/components/Folder/DetailInfo.tsx b/src/components/Folder/DetailInfo.tsx new file mode 100644 index 000000000..8016db1a0 --- /dev/null +++ b/src/components/Folder/DetailInfo.tsx @@ -0,0 +1,22 @@ +import { FC, memo } from 'react' +import { Wrapper, Title, Desc } from './styles/detail_info' + +const DetailInfo: FC = () => { + return ( + + 名称 + 新收藏夹 + + 内容数 + 12 项 + + 最后更新时间 + 3 天前 + + 是否公开 + 公开 + + ) +} + +export default memo(DetailInfo) diff --git a/src/components/Folder/Footer.js b/src/components/Folder/Footer.js deleted file mode 100644 index 5f33483a2..000000000 --- a/src/components/Folder/Footer.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react' -import TimeAgo from 'timeago-react' - -import { ICON_CMD } from '@/config' - -import { Wrapper, Title, Intro, Total, Update, LockIcon } from './styles/footer' - -const Footer = ({ title, total, updatedAt, lock, onClick }) => { - return ( - - - {title} - {lock && <LockIcon src={`${ICON_CMD}/lock.svg`} />} - - - 共 {total} 项 - - - - - - ) -} - -export default React.memo(Footer) diff --git a/src/components/Folder/Footer.tsx b/src/components/Folder/Footer.tsx new file mode 100644 index 000000000..55c368af0 --- /dev/null +++ b/src/components/Folder/Footer.tsx @@ -0,0 +1,76 @@ +import { FC, memo } from 'react' + +import { ICON } from '@/config' +import { IconButton, MenuButton } from '@/components/Buttons' +import Tooltip from '@/components/Tooltip' + +import DetailInfo from './DetailInfo' +// import { LavaLampLoading } from '@/components/Loading' +import { + Wrapper, + Title, + Name, + FolderInfoPopWrapper, + MenuWrapper, + HintWrapper, + AddHint, +} from './styles/footer' + +const menuOptions = [ + { + key: 'edit', + icon: `${ICON}/edit/publish-pen.svg`, + title: '编辑', + }, + { + key: 'lock', + icon: `${ICON}/shape/lock.svg`, + title: '加锁', + }, +] + +type TProps = { + title: string + inactive: boolean + onClick: () => void + onMenuClick?: (key: string) => void +} + +const Footer: FC = ({ title, onClick, onMenuClick, inactive }) => { + return ( + + + {!inactive ? ( + <Tooltip + delay={600} + content={ + <FolderInfoPopWrapper> + <DetailInfo /> + </FolderInfoPopWrapper> + } + noPadding + > + <Name>{title}</Name> + </Tooltip> + ) : ( + <Name>{title}</Name> + )} + + {!inactive && ( + <MenuButton options={menuOptions} onClick={onMenuClick}> + <MenuWrapper> + <IconButton path="shape/more-l.svg" mRight={0} /> + </MenuWrapper> + </MenuButton> + )} + + + {/* */} + {/* 已收入 */} + {/* 已收入 */} + + + ) +} + +export default memo(Footer) diff --git a/src/components/Folder/index.js b/src/components/Folder/index.js deleted file mode 100755 index ec5a7fda1..000000000 --- a/src/components/Folder/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Folder - * see orignal example at: https://codepen.io/mydearxym2/pen/YzyLYqL - * - */ - -import React from 'react' -import T from 'prop-types' - -import { ICON_CMD } from '@/config' -import { SIZE } from '@/constant' -import { buildLog } from '@/utils' - -import Content from './Content' -import Footer from './Footer' - -import { Wrapper, TabShape, EditIconWrapper, EditIcon } from './styles' - -/* eslint-disable-next-line */ -const log = buildLog('c:Folder:index') - -const Folder = ({ - size, - title, - desc, - cover, - total, - updatedAt, - lock, - editable, - contentType, - onEdit, - onSelect, -}) => { - return ( - - {editable && ( - - - - )} - - -