Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
668bca4
chore(bg-editor): basic setup
mydearxym May 17, 2022
094f553
chore(bg-editor): rename to WallpaperEditor
mydearxym May 18, 2022
11d70b3
chore(bg-editor): rename to WallpaperEditor more
mydearxym May 18, 2022
5fc0154
refactor(wallpaper-editor): extract images to constant
mydearxym May 18, 2022
c708be8
refactor(wallpaper-editor): basic selector ux
mydearxym May 19, 2022
29da1a7
refactor(wallpaper-utils): extract helper & fmt
mydearxym May 20, 2022
f9757b8
refactor(wallpaper-utils): switch ux/logic
mydearxym May 20, 2022
26cd758
refactor(wallpaper-utils): renaming functions
mydearxym May 20, 2022
960ca8e
fix(wallpaper-utils): background-size not working
mydearxym May 20, 2022
0f2a162
refactor(wallpaper): re-org by move data source to store
mydearxym May 20, 2022
1e8f99c
refactor(wallpaper): wip
mydearxym May 20, 2022
9e77ded
feat(wallpaper): add toggle pattern effect
mydearxym May 20, 2022
98f82e2
feat(wallpaper): add toggle blur & condition checker
mydearxym May 20, 2022
c224835
refactor(wallpaper): adjust select effect & button slim
mydearxym May 20, 2022
1976a81
refactor(wallpaper): adjust block select effect
mydearxym May 20, 2022
5b128c1
refactor(wallpaper-editor): add some light animation
mydearxym May 21, 2022
e2b3484
refactor(wallpaper-editor): re-org modules into tab unit
mydearxym May 21, 2022
572a445
refactor(wallpaper-editor): add angle editor
mydearxym May 21, 2022
36d9688
refactor(wallpaper-editor): reset when drawer close
mydearxym May 22, 2022
3350700
refactor(wallpaper-editor): basic custom tab ui
mydearxym May 22, 2022
d8ef923
refactor(wallpaper-editor): add blank paper logic
mydearxym May 22, 2022
1783e09
chore: fix wired ci
mydearxym May 22, 2022
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
Binary file removed public/bg/Squares.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added public/wallpaper/patterns/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
48 changes: 48 additions & 0 deletions src/containers/editor/WallpaperEditor/BuildIn/AnglePanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { FC, memo } from 'react'

import {
Wrapper,
Top,
Bottom,
Left,
Right,
NeedleDot,
Needle,
} from '../styles/build_in/angle_panel'
import { changeDirection } from '../logic'

type TProps = {
direction: string
}

const AnglePanel: FC<TProps> = ({ direction }) => {
return (
<Wrapper>
<Top $active={direction === 'top'} onClick={() => changeDirection('top')}>
</Top>
<Bottom
$active={direction === 'bottom'}
onClick={() => changeDirection('bottom')}
>
</Bottom>
<Left
$active={direction === 'left'}
onClick={() => changeDirection('left')}
>
</Left>
<Right
$active={direction === 'right'}
onClick={() => changeDirection('right')}
>
</Right>
<NeedleDot />
<Needle direction={direction} />
</Wrapper>
)
}

export default memo(AnglePanel)
43 changes: 43 additions & 0 deletions src/containers/editor/WallpaperEditor/BuildIn/GradientGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { FC, memo } from 'react'
import { keys } from 'ramda'

import type { TWallpaperGradient } from '@/spec'
import { parseWallpaper } from '@/utils/wallpaper'

import {
Wrapper,
Block,
BallWrapper,
ColorBall,
} from '../styles/build_in/gradient_group'

import { changeWallpaper } from '../logic'

type TProps = {
wallpaper: string
gradientWallpapers: Record<string, TWallpaperGradient>
}

const PicGroup: FC<TProps> = ({ wallpaper, gradientWallpapers }) => {
const gradientKeys = keys(gradientWallpapers)

return (
<Wrapper>
{gradientKeys.map((name) => (
<Block key={name}>
<BallWrapper
$active={name === wallpaper}
onClick={() => changeWallpaper(name)}
>
<ColorBall
$active={name === wallpaper}
background={parseWallpaper(gradientWallpapers, name).background}
/>
</BallWrapper>
</Block>
))}
</Wrapper>
)
}

export default memo(PicGroup)
43 changes: 43 additions & 0 deletions src/containers/editor/WallpaperEditor/BuildIn/PatternGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { FC, memo } from 'react'
import { keys } from 'ramda'

import type { TWallpaperPic } from '@/spec'

import {
Wrapper,
Block,
Image,
ActiveSign,
CheckIcon,
} from '../styles/build_in/pattern_group'

import { changeWallpaper } from '../logic'

type TProps = {
wallpaper: string
patternWallpapers: Record<string, TWallpaperPic>
}

const PatternGroup: FC<TProps> = ({ wallpaper, patternWallpapers }) => {
const patternKeys = keys(patternWallpapers)

return (
<Wrapper>
{patternKeys.map((name) => (
<Block key={name} $active={name === wallpaper}>
{name === wallpaper && (
<ActiveSign>
<CheckIcon />
</ActiveSign>
)}
<Image
src={patternWallpapers[name].bgImage}
onClick={() => changeWallpaper(name)}
/>
</Block>
))}
</Wrapper>
)
}

export default memo(PatternGroup)
91 changes: 91 additions & 0 deletions src/containers/editor/WallpaperEditor/BuildIn/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* *
* WallpaperEditor
*
*/

import { FC, Fragment } from 'react'

import { WALLPAPER_TYPE } from '@/constant'

import { Br } from '@/widgets/Common'
import Checker from '@/widgets/Checker'

import PatternGroup from './PatternGroup'
import GradientGroup from './GradientGroup'
import AnglePanel from './AnglePanel'

import type { TWallpaperData } from '../spec'
import {
Wrapper,
Title,
SettingWrapper,
GeneralSettings,
Divider,
AngleSettings,
} from '../styles/build_in'
import { togglePattern, toggleBlur } from '../logic'

type TProps = {
wallpaperData: TWallpaperData
}

const BuildIn: FC<TProps> = ({ wallpaperData }) => {
const {
wallpaper,
wallpaperType,
gradientWallpapers,
patternWallpapers,
hasPattern,
hasBlur,
direction,
} = wallpaperData

return (
<Wrapper>
<Title>图案:</Title>
<PatternGroup
wallpaper={wallpaper}
patternWallpapers={patternWallpapers}
/>
<Br top={20} />
<Title>纯色渐变:</Title>
<GradientGroup
wallpaper={wallpaper}
gradientWallpapers={gradientWallpapers}
/>
<Br top={25} />
<SettingWrapper show={wallpaperType !== WALLPAPER_TYPE.NONE}>
<GeneralSettings>
<Title>附加效果:</Title>
{wallpaperType === WALLPAPER_TYPE.GRADIENT && (
<Fragment>
<Br top={20} />
<Checker checked={hasPattern} onChange={togglePattern}>
叠加印纹
</Checker>
</Fragment>
)}

<Br top={10} />
<Checker checked={hasBlur} onChange={toggleBlur}>
模糊效果
</Checker>
</GeneralSettings>

{wallpaperType === WALLPAPER_TYPE.GRADIENT && (
<Fragment>
<Divider />

<AngleSettings>
<Title>渐变方向:</Title>
<AnglePanel direction={direction} />
</AngleSettings>
</Fragment>
)}
</SettingWrapper>
<Br top={50} />
</Wrapper>
)
}

export default BuildIn
36 changes: 36 additions & 0 deletions src/containers/editor/WallpaperEditor/Custom/UploadBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { FC, memo } from 'react'

import { SVG } from '@/constant'
import MenuButton from '@/widgets/Buttons/MenuButton'

import {
Wrapper,
Menu,
MoreIcon,
UploadIcon,
Title,
} from '../styles/custom/upload_box'

const menuOptions = [
{
key: 'url',
icon: SVG.COPY,
title: '图片地址',
},
]

const UploadBox: FC = () => {
return (
<Wrapper>
<Menu>
<MenuButton placement="bottom-end" options={menuOptions}>
<MoreIcon />
</MenuButton>
</Menu>
<UploadIcon />
<Title>上传 / 引入图片</Title>
</Wrapper>
)
}

export default memo(UploadBox)
14 changes: 14 additions & 0 deletions src/containers/editor/WallpaperEditor/Custom/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FC, memo } from 'react'

import UploadBox from './UploadBox'
import { Wrapper } from '../styles/custom'

const Custom: FC = () => {
return (
<Wrapper>
<UploadBox />
</Wrapper>
)
}

export default memo(Custom)
31 changes: 31 additions & 0 deletions src/containers/editor/WallpaperEditor/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { FC, memo } from 'react'

import { TWallpaperType } from '@/spec'
import { WALLPAPER_TYPE } from '@/constant'

import Button from '@/widgets/Buttons/Button'
import { Wrapper, ForbidImgIcon, ConfirmBtn } from './styles/footer'
import { changeWallpaper } from './logic'

type TProps = {
wallpaperType: TWallpaperType
}
const Footer: FC<TProps> = ({ wallpaperType }) => {
return (
<Wrapper>
{wallpaperType !== WALLPAPER_TYPE.NONE ? (
<Button size="small" ghost noBorder onClick={() => changeWallpaper('')}>
<ForbidImgIcon /> 空白壁纸
</Button>
) : (
<div />
)}

<ConfirmBtn size="small" space={13}>
确定
</ConfirmBtn>
</Wrapper>
)
}

export default memo(Footer)
17 changes: 17 additions & 0 deletions src/containers/editor/WallpaperEditor/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { TTab } from './spec'

export const TAB = {
BUILDIN: 'buildin',
CUSTOM: 'custom',
} as Record<Uppercase<TTab>, TTab>

export const TAB_OPTIONS = [
{
title: '内置壁纸',
raw: TAB.BUILDIN,
},
{
title: '上传壁纸',
raw: TAB.CUSTOM,
},
]
66 changes: 66 additions & 0 deletions src/containers/editor/WallpaperEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* *
* WallpaperEditor
*
*/

import { FC } from 'react'

import { bond } from '@/utils/mobx'
import { VIEW, DRAWER_SCROLLER } from '@/constant'

import { Tabs } from '@/widgets/Switcher'
import CustomScroller from '@/widgets/CustomScroller'

import type { TStore } from './store'
import { TAB, TAB_OPTIONS } from './constant'

import BuildIn from './BuildIn'
import Custom from './Custom'
import Footer from './Footer'

import { Wrapper, Banner, Title, Content } from './styles'
import { useInit, changeTab } from './logic'

type TProps = {
wallpaperEditor?: TStore
testid?: string
}

const WallpaperEditorContainer: FC<TProps> = ({
wallpaperEditor: store,
testid = 'wallpaper-editor',
}) => {
useInit(store)
const { tab, wallpaperData } = store

return (
<Wrapper testid={testid}>
<Banner>
<Title>壁纸设置</Title>
<Tabs
items={TAB_OPTIONS}
activeKey={tab}
onChange={changeTab}
view={VIEW.DRAWER}
/>
</Banner>

<CustomScroller
instanceKey={DRAWER_SCROLLER}
direction="vertical"
height="calc(100vh - 226px)"
barSize="small"
showShadow={false}
autoHide={false}
>
<Content>
{tab === TAB.BUILDIN && <BuildIn wallpaperData={wallpaperData} />}
{tab === TAB.CUSTOM && <Custom />}
</Content>
</CustomScroller>
<Footer wallpaperType={wallpaperData.wallpaperType} />
</Wrapper>
)
}

export default bond(WallpaperEditorContainer, 'wallpaperEditor') as FC<TProps>
Loading