Skip to content

Commit

Permalink
refactor: add asset accept constants
Browse files Browse the repository at this point in the history
  • Loading branch information
powaaaaa committed May 7, 2024
1 parent 8afed66 commit b6d7332
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/constants/supportExtension/asset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ASSET_EXTENSION = [
export const ASSET_EXTENSIONS = [
{
category: '画像',
exts: ['png', 'jpg', 'jpeg', 'bmp', 'gif'],
Expand All @@ -20,3 +20,6 @@ export const ASSET_EXTENSION = [
exts: ['zip'],
},
];

export const ASSET_ACCEPT_EXTENSIONS =
'image/png, image/jpeg, image/jpg, image/bmp, image/gif, video/mp4, video/mov, audio/mp3, audio/wav, audio/m4a, model/gltf, model/fbx, application/zip';
2 changes: 1 addition & 1 deletion src/constants/supportExtension/thumbnail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const THUMBNAIL_EXTENSION = [
export const THUMBNAIL_EXTENSIONS = [
{
category: '画像',
exts: ['png', 'jpg', 'jpeg', 'bmp', 'gif'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { DropImage } from '@/components/functional/DropImage';
import { Center } from '@/components/ui/Center';
import { Input } from '@/components/ui/Input';
import { Typography } from '@/components/ui/Typography';
import { ASSET_EXTENSION } from '@/constants/supportExtension';
import {
ASSET_ACCEPT_EXTENSIONS,
ASSET_EXTENSIONS,
} from '@/constants/supportExtension';
import { cn } from '@/libs/utils';

type Props = {
Expand All @@ -25,7 +28,7 @@ export const AssetUpload: FC<Props> = ({ handleUploadAssets, assets }) => (
<Typography className="text-red-500" variant="body2">
必須
</Typography>
<SupportExtPopOver supportedExts={ASSET_EXTENSION} />
<SupportExtPopOver supportedExts={ASSET_EXTENSIONS} />
</Vertical>
<Vertical className="gap-2 w-full overflow-scroll">
{assets.map((asset) => AssetRender(asset, 'w-24 p-0'))}
Expand Down Expand Up @@ -60,7 +63,7 @@ export const AssetUpload: FC<Props> = ({ handleUploadAssets, assets }) => (
void handleUploadAssets(e.target.files);
}}
multiple
accept="image/png, image/jpeg, image/jpg, image/bmp, image/gif, video/mp4, video/mov, audio/mp3, audio/wav, audio/m4a, model/gltf, model/fbx, application/zip"
accept={ASSET_ACCEPT_EXTENSIONS}
type="file"
/>
</DropImage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DropImage } from '@/components/functional/DropImage';
import { Center } from '@/components/ui/Center';
import { Input } from '@/components/ui/Input';
import { Typography } from '@/components/ui/Typography';
import { THUMBNAIL_EXTENSION } from '@/constants/supportExtension';
import { THUMBNAIL_EXTENSIONS } from '@/constants/supportExtension';
import { cn } from '@/libs/utils';

type Props = {
Expand All @@ -26,7 +26,7 @@ export const ThumbnailUpload: FC<Props> = ({
<Typography variant="body2" className="text-red-500">
必須
</Typography>
<SupportExtPopOver supportedExts={THUMBNAIL_EXTENSION} />
<SupportExtPopOver supportedExts={THUMBNAIL_EXTENSIONS} />
</Vertical>
<DropImage
onDrop={(e) => {
Expand Down

0 comments on commit b6d7332

Please sign in to comment.