Skip to content

Commit

Permalink
Merge pull request #47 from LHRUN/dev
Browse files Browse the repository at this point in the history
Feature/1.5.2
  • Loading branch information
LHRUN authored Nov 16, 2024
2 parents 2db3f25 + b0f7bd2 commit 7c6d954
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
dev-dist

# Editor directories and files
.vscode/*
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.5.2

### Feat

- add download image size config

# 1.5.1

### Feat
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "paint-board",
"private": true,
"version": "1.5.1",
"version": "1.5.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
46 changes: 41 additions & 5 deletions src/components/boardOperation/downloadImage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { canvasPreview } from './canvasPreview'
import Mask from '@/components/mask'
import ImageRotate from '@/components/icons/boardOperation/image-rotate.svg?react'
import ImageScale from '@/components/icons/boardOperation/image-scale.svg?react'
import ImageSize from '@/components/icons/boardOperation/image-size.svg?react'

import 'react-image-crop/dist/ReactCrop.css'

Expand All @@ -21,6 +22,7 @@ const DownloadImage: FC<IProps> = ({ url, showModal, setShowModal }) => {
const { t } = useTranslation()
const [saveImageRotate, updateSaveImageRotate] = useState(0)
const [saveImageScale, updateSaveImageScale] = useState(1)
const [saveImageSize, updateSaveImageSize] = useState(1)

const [completedCrop, setCompletedCrop] = useState<Crop | undefined>()
const [crop, setCrop] = useState<Crop | undefined>()
Expand Down Expand Up @@ -71,8 +73,8 @@ const DownloadImage: FC<IProps> = ({ url, showModal, setShowModal }) => {
const scaleY = image.naturalHeight / image.height

const offscreen = new OffscreenCanvas(
completedCrop.width * scaleX,
completedCrop.height * scaleY
completedCrop.width * scaleX * saveImageSize,
completedCrop.height * scaleY * saveImageSize
)
const ctx = offscreen.getContext('2d')
if (!ctx) {
Expand Down Expand Up @@ -140,7 +142,12 @@ const DownloadImage: FC<IProps> = ({ url, showModal, setShowModal }) => {
<div className="w-full flex justify-between">
<div className="w-[48%]">
<div className="flex items-center">
<ImageRotate className="mr-[6px] shrink-0" />
<div
className="mr-[6px] shrink-0 tooltip"
data-tip={t('downloadImage.rotate')}
>
<ImageRotate />
</div>
<input
className="range range-primary range-xs"
type="range"
Expand All @@ -155,7 +162,12 @@ const DownloadImage: FC<IProps> = ({ url, showModal, setShowModal }) => {
</div>

<div className="flex items-center mt-3">
<ImageScale className="mr-[12px] shrink-0" />
<div
className="mr-[12px] shrink-0 tooltip"
data-tip={t('downloadImage.scale')}
>
<ImageScale />
</div>
<input
className="range range-primary range-xs"
type="range"
Expand All @@ -168,9 +180,33 @@ const DownloadImage: FC<IProps> = ({ url, showModal, setShowModal }) => {
}}
/>
</div>

<div className="flex items-center flex-wrap mt-3 gap-y-2">
<div
className="mr-[12px] shrink-0 tooltip"
data-tip={t('downloadImage.size')}
>
<ImageSize />
</div>
<div className="tabs tabs-boxed bg-[#333C4D] shrink-0">
{[1, 2, 3].map((value) => (
<a
key={value}
className={`tab tab-sm flex-grow font-fredokaOne font-normal text-white ${
saveImageSize === value ? 'tab-active' : ''
}`}
onClick={() => {
updateSaveImageSize(value)
}}
>
{`${value}x`}
</a>
))}
</div>
</div>
</div>

<div className="w-[48%] flex flex-wrap gap-4">
<div className="w-[48%] flex flex-wrap gap-x-4 gap-y-2 h-fit">
<button
className="btn btn-ghost btn-outline btn-sm"
onClick={() => setShowModal(false)}
Expand Down
12 changes: 12 additions & 0 deletions src/components/icons/boardOperation/image-size.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,10 @@
"removeBackgroundProcessingSuccess": "Remove Background Processing Success",
"restore": "Restore",
"upload": "Upload"
},
"downloadImage": {
"rotate": "Rotate",
"scale": "Scale",
"size": "Size"
}
}
5 changes: 5 additions & 0 deletions src/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,10 @@
"removeBackgroundProcessingSuccess": "去除背景处理成功",
"restore": "还原",
"upload": "上传"
},
"downloadImage": {
"rotate": "旋转",
"scale": "缩放",
"size": "尺寸"
}
}
2 changes: 1 addition & 1 deletion src/store/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface FileAction {
}

const initId = uuidv4()
export const BOARD_VERSION = '1.5.1'
export const BOARD_VERSION = '1.5.2'

const useFileStore = create<FileState & FileAction>()(
persist(
Expand Down

0 comments on commit 7c6d954

Please sign in to comment.