-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
作品作成画面の対応拡張子のポップアップ #235
base: develop
Are you sure you want to change the base?
作品作成画面の対応拡張子のポップアップ #235
Changes from 8 commits
f5c7684
85b447e
6e29f35
032d64d
611ecf8
8afed66
b6d7332
679563a
4ae3a45
a810fbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export const ASSET_EXTENSIONS = [ | ||
{ | ||
category: '画像', | ||
exts: ['png', 'jpg', 'jpeg', 'bmp', 'gif'], | ||
}, | ||
{ | ||
category: '動画', | ||
exts: ['mp4', 'mov'], | ||
}, | ||
{ | ||
category: '音源', | ||
exts: ['mp3', 'wav', 'm4a'], | ||
}, | ||
{ | ||
category: 'モデル', | ||
exts: ['gltf', 'fbx'], | ||
}, | ||
{ | ||
category: 'zip', | ||
exts: ['zip'], | ||
}, | ||
]; | ||
|
||
const categoryToPrefixMap: { [key: string]: string } = { | ||
画像: 'image', | ||
動画: 'video', | ||
音源: 'audio', | ||
モデル: 'model', | ||
zip: 'application', | ||
}; | ||
|
||
export const ASSET_ACCEPT_EXTENSIONS = ASSET_EXTENSIONS.flatMap((category) => | ||
category.exts.map((ext) => { | ||
const prefix = categoryToPrefixMap[category.category]; | ||
return `${prefix}/${ext}`; | ||
}) | ||
).join(', '); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './asset'; | ||
|
||
export * from './thumbnail'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const THUMBNAIL_EXTENSIONS = [ | ||
{ | ||
category: '画像', | ||
exts: ['png', 'jpg', 'jpeg', 'bmp', 'gif'], | ||
}, | ||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as const |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,84 +2,73 @@ import type { FC } from 'react'; | |
|
||
import { AssetRender } from '../../../AssetList/assetRender'; | ||
|
||
import { SupportExtPopOver } from './SupportExtPopOver'; | ||
|
||
import type { Asset } from '@/domains/Work/types'; | ||
|
||
import { Horizontal } from '@/components/Layout/Horizontal'; | ||
import { Vertical } from '@/components/Layout/Vertical'; | ||
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_ACCEPT_EXTENSIONS, | ||
ASSET_EXTENSIONS, | ||
} from '@/constants/supportExtension'; | ||
import { cn } from '@/libs/utils'; | ||
|
||
type Props = { | ||
handleUploadAssets: (files: FileList) => Promise<void>; | ||
assets: Asset[]; | ||
}; | ||
export const AssetUpload: FC<Props> = ({ handleUploadAssets, assets }) => ( | ||
<> | ||
<Vertical className="items-center"> | ||
<Typography className="text-lg font-bold">アセット</Typography> | ||
<Typography className="text-red-500" variant="body2"> | ||
必須 | ||
</Typography> | ||
</Vertical> | ||
<Horizontal className="gap-0 items-start -mt-4"> | ||
<Typography variant="body2" className="text-gray-500"> | ||
対応形式: | ||
</Typography> | ||
<Typography variant="body2" className="text-xs text-gray-500 mx-4"> | ||
画像 [ .png .jpg .jpeg .bmp .gif ] | ||
</Typography> | ||
<Typography variant="body2" className="text-xs text-gray-500 mx-4"> | ||
動画 [ .mp4 .mov ] | ||
</Typography> | ||
<Typography variant="body2" className="text-xs text-gray-500 mx-4"> | ||
音源 [ .mp3 .wav .m4a ] | ||
</Typography> | ||
<Typography variant="body2" className="text-xs text-gray-500 mx-4"> | ||
モデル [ .gltf .fbx ] | ||
</Typography> | ||
<Typography variant="body2" className="text-xs text-gray-500 mx-4"> | ||
zip[ .zip ] | ||
</Typography> | ||
</Horizontal> | ||
<Vertical className="gap-2 w-full overflow-scroll"> | ||
{assets.map((asset) => AssetRender(asset, 'w-24 p-0'))} | ||
</Vertical> | ||
<DropImage | ||
onDrop={(e) => { | ||
void handleUploadAssets(e); | ||
}} | ||
className="rounded-md relative w-full h-64 border-2 border-orange-pop" | ||
> | ||
<Center className="h-full -z-20 absolute flex flex-col"> | ||
<div | ||
className={cn('bg-pale-red/25 w-full absolute h-0 bottom-0 -z-30', { | ||
'h-full': assets.length > 0, | ||
})} | ||
/> | ||
<Typography variant="body1"> | ||
クリック または ドラッグ&ドロップ | ||
</Typography> | ||
<Typography variant="body2" className="text-gray-500"> | ||
{assets.length > 0 | ||
? `${assets.length}件のアセットをアップロード済み` | ||
: 'アセットをアップロードしてください'} | ||
export const AssetUpload: FC<Props> = ({ handleUploadAssets, assets }) => { | ||
console.log('asset: ', ASSET_ACCEPT_EXTENSIONS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. console.logは消してください There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ごめんなさい |
||
return ( | ||
<> | ||
<Vertical className="items-center"> | ||
<Typography className="text-lg font-bold">アセット</Typography> | ||
<Typography className="text-red-500" variant="body2"> | ||
必須 | ||
</Typography> | ||
</Center> | ||
<Input | ||
className="cursor-pointer opacity-0 h-full" | ||
onChange={(e) => { | ||
if (!e.target.files?.length || !e.target.files[0]) { | ||
return; | ||
} | ||
void handleUploadAssets(e.target.files); | ||
<SupportExtPopOver supportedExts={ASSET_EXTENSIONS} /> | ||
</Vertical> | ||
<Vertical className="gap-2 w-full overflow-scroll"> | ||
{assets.map((asset) => AssetRender(asset, 'w-24 p-0'))} | ||
</Vertical> | ||
<DropImage | ||
onDrop={(e) => { | ||
void handleUploadAssets(e); | ||
}} | ||
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" | ||
type="file" | ||
/> | ||
</DropImage> | ||
</> | ||
); | ||
className="rounded-md relative w-full h-64 border-2 border-orange-pop" | ||
> | ||
<Center className="h-full -z-20 absolute flex flex-col"> | ||
<div | ||
className={cn('bg-pale-red/25 w-full absolute h-0 bottom-0 -z-30', { | ||
'h-full': assets.length > 0, | ||
})} | ||
/> | ||
<Typography variant="body1"> | ||
クリック または ドラッグ&ドロップ | ||
</Typography> | ||
<Typography variant="body2" className="text-gray-500"> | ||
{assets.length > 0 | ||
? `${assets.length}件のアセットをアップロード済み` | ||
: 'アセットをアップロードしてください'} | ||
</Typography> | ||
</Center> | ||
<Input | ||
className="cursor-pointer opacity-0 h-full" | ||
onChange={(e) => { | ||
if (!e.target.files?.length || !e.target.files[0]) { | ||
return; | ||
} | ||
void handleUploadAssets(e.target.files); | ||
}} | ||
multiple | ||
accept={ASSET_ACCEPT_EXTENSIONS} | ||
type="file" | ||
/> | ||
</DropImage> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { FC } from 'react'; | ||
|
||
import { Info } from 'lucide-react'; | ||
|
||
import { Horizontal } from '@/components/Layout/Horizontal'; | ||
import { Vertical } from '@/components/Layout/Vertical'; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from '@/components/ui/Tooltip'; | ||
import { Typography } from '@/components/ui/Typography'; | ||
|
||
type Props = { | ||
supportedExts: { category: string; exts: string[] }[]; | ||
}; | ||
|
||
export const SupportExtPopOver: FC<Props> = ({ supportedExts }) => ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<Info size={16} color="#757575" /> | ||
</TooltipTrigger> | ||
|
||
<TooltipContent className="rounded-md relative border-2 bg-white border-orange-pop text-[10px]"> | ||
<Horizontal className="gap-1"> | ||
<Typography variant="strong">対応形式:</Typography> | ||
{supportedExts.map(({ category, exts }) => ( | ||
<Vertical key={category} className="pl-4 gap-1"> | ||
<Typography variant="strong">{category}</Typography> | ||
<Typography variant="strong"> | ||
<Vertical className="gap-1"> | ||
[ | ||
<Vertical className="gap-1"> | ||
{exts.map((ext) => ( | ||
<span key={ext}>.{ext}</span> | ||
))} | ||
</Vertical> | ||
] | ||
</Vertical> | ||
</Typography> | ||
</Vertical> | ||
))} | ||
</Horizontal> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as constをつけてください
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as constをつける理由
https://typescriptbook.jp/reference/values-types-variables/const-assertion