@@ -3,13 +3,13 @@ import {Box, Button, Flex, Inline, Stack, Text} from '@sanity/ui'
33import { Asset , AssetItem } from '@types'
44import format from 'date-fns/format'
55import filesize from 'filesize'
6+ import { ReactNode , useState } from 'react'
7+ import Select from 'react-select'
68import { useColorScheme } from 'sanity'
7- import React , { useState , ReactNode } from 'react'
9+ import { reactSelectComponents , reactSelectStyles } from '../../styled/ react-select/alt '
810import getAssetResolution from '../../utils/getAssetResolution'
911import { isImageAsset } from '../../utils/typeGuards'
1012import ButtonAssetCopy from '../ButtonAssetCopy'
11- import Select from 'react-select'
12- import { reactSelectComponents , reactSelectStyles } from '../../styled/react-select/alt'
1313
1414type Props = {
1515 asset : Asset
@@ -56,10 +56,10 @@ const AssetMetadata = (props: Props) => {
5656 { value : 1080 , label : '1080w' } ,
5757 { value : 720 , label : '720w' }
5858 ]
59- const handleSizeSelect = ( option : Option ) => {
59+ const handleSizeSelect = ( option : Option [ ] ) => {
6060 setOption ( option )
6161 }
62- const [ option , setOption ] = useState ( options [ 0 ] )
62+ const [ option , setOption ] = useState ( [ options [ 0 ] ] )
6363 interface Option {
6464 label : string
6565 value : number
@@ -80,11 +80,13 @@ const AssetMetadata = (props: Props) => {
8080
8181 // Callbacks
8282 const handleDownload = ( ) => {
83- if ( option . value == 0 ) {
84- window . location . href = `${ asset . url } ?dl=${ asset . originalFilename } `
85- } else {
86- window . location . href = `${ asset . url } ?w=${ option . value } &dl=${ asset . originalFilename } `
87- }
83+ option . forEach ( file => {
84+ if ( file . value == 0 ) {
85+ window . open ( `${ asset . url } ?dl=${ asset . originalFilename } ` )
86+ } else {
87+ window . open ( `${ asset . url } ?w=${ file . value } &dl=${ asset . originalFilename } ` )
88+ }
89+ } )
8890 }
8991
9092 return (
@@ -162,10 +164,11 @@ const AssetMetadata = (props: Props) => {
162164 isSearchable
163165 name = "downloadSize"
164166 options = { options }
167+ isMulti
165168 defaultValue = { options [ 0 ] }
166169 menuPlacement = "top"
167170 styles = { reactSelectStyles ( scheme ) }
168- onChange = { value => handleSizeSelect ( value as Option ) }
171+ onChange = { value => handleSizeSelect ( value as Option [ ] ) }
169172 />
170173 </ Flex >
171174 { /* Copy to clipboard */ }
0 commit comments