mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
refactor to get LoadingIcon and Downloading for later folder loading
This commit is contained in:
+18
-18
@@ -16,7 +16,7 @@ import { getBaseUrl, treeList, downloadMultipleFiles, useProtectedSWRInfinite, s
|
|||||||
|
|
||||||
import { VideoPreview } from './previews/VideoPreview'
|
import { VideoPreview } from './previews/VideoPreview'
|
||||||
import { AudioPreview } from './previews/AudioPreview'
|
import { AudioPreview } from './previews/AudioPreview'
|
||||||
import Loading from './Loading'
|
import Loading, { LoadingIcon } from './Loading'
|
||||||
import FourOhFour from './FourOhFour'
|
import FourOhFour from './FourOhFour'
|
||||||
import Auth from './Auth'
|
import Auth from './Auth'
|
||||||
import TextPreview from './previews/TextPreview'
|
import TextPreview from './previews/TextPreview'
|
||||||
@@ -144,6 +144,22 @@ const Checkbox: FunctionComponent<{
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Downloading: FunctionComponent<{ title: string }> = ({ title }) => {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
title={title}
|
||||||
|
className="p-2 rounded"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
|
<LoadingIcon
|
||||||
|
// Use fontawesome far theme via class `svg-inline--fa` to get style `vertical-align` only
|
||||||
|
// for consistent icon alignment, as class `align-*` cannot satisfy it
|
||||||
|
className="animate-spin w-4 h-4 inline-block svg-inline--fa"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const FileListing: FunctionComponent<{ query?: ParsedUrlQuery }> = ({ query }) => {
|
const FileListing: FunctionComponent<{ query?: ParsedUrlQuery }> = ({ query }) => {
|
||||||
const [imageViewerVisible, setImageViewerVisibility] = useState(false)
|
const [imageViewerVisible, setImageViewerVisibility] = useState(false)
|
||||||
const [activeImageIdx, setActiveImageIdx] = useState(0)
|
const [activeImageIdx, setActiveImageIdx] = useState(0)
|
||||||
@@ -316,23 +332,7 @@ const FileListing: FunctionComponent<{ query?: ParsedUrlQuery }> = ({ query }) =
|
|||||||
title={'Select files'}
|
title={'Select files'}
|
||||||
/>
|
/>
|
||||||
{totalGenerating ? (
|
{totalGenerating ? (
|
||||||
<span title="Downloading selected files, refresh page to cancel" className="p-2 rounded" role="status">
|
<Downloading title="Downloading selected files, refresh page to cancel" />
|
||||||
<svg
|
|
||||||
// Use fontawesome far theme via class `svg-inline--fa` to get style `vertical-align` only
|
|
||||||
// for consistent icon alignment, as class `align-*` cannot satisfy it
|
|
||||||
className="animate-spin w-4 h-4 inline-block svg-inline--fa"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
||||||
<path
|
|
||||||
className="opacity-75"
|
|
||||||
fill="currentColor"
|
|
||||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
) : (
|
) : (
|
||||||
<button
|
<button
|
||||||
title="Download selected files"
|
title="Download selected files"
|
||||||
|
|||||||
+20
-13
@@ -3,22 +3,29 @@ import { FunctionComponent } from 'react'
|
|||||||
const Loading: FunctionComponent<{ loadingText: string }> = ({ loadingText }) => {
|
const Loading: FunctionComponent<{ loadingText: string }> = ({ loadingText }) => {
|
||||||
return (
|
return (
|
||||||
<div className="dark:text-white flex items-center justify-center py-32 space-x-1 rounded">
|
<div className="dark:text-white flex items-center justify-center py-32 space-x-1 rounded">
|
||||||
<svg
|
<LoadingIcon className="animate-spin w-5 h-5 mr-3 -ml-1" />
|
||||||
className="animate-spin w-5 h-5 mr-3 -ml-1"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
||||||
<path
|
|
||||||
className="opacity-75"
|
|
||||||
fill="currentColor"
|
|
||||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
<div>{loadingText}</div>
|
<div>{loadingText}</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As there is no CSS-in-JS styling system, pass class list to override styles
|
||||||
|
export const LoadingIcon: FunctionComponent<{ className?: string }> = ({ className }) => {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className={className}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
||||||
|
<path
|
||||||
|
className="opacity-75"
|
||||||
|
fill="currentColor"
|
||||||
|
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default Loading
|
export default Loading
|
||||||
|
|||||||
Reference in New Issue
Block a user