-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@uppy/provider-views: migrate to TS (#4919)
Co-authored-by: Antoine du Hamel <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,186 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { UnknownProviderPluginState } from '@uppy/core/lib/Uppy' | ||
import { h, Fragment } from 'preact' | ||
import type { Body, Meta } from '@uppy/utils/lib/UppyFile' | ||
import type ProviderView from './ProviderView' | ||
|
||
type BreadcrumbProps = { | ||
getFolder: () => void | ||
title: string | ||
isLast: boolean | ||
} | ||
|
||
const Breadcrumb = (props: BreadcrumbProps) => { | ||
const { getFolder, title, isLast } = props | ||
|
||
return ( | ||
<Fragment> | ||
<button | ||
type="button" | ||
className="uppy-u-reset uppy-c-btn" | ||
onClick={getFolder} | ||
> | ||
{title} | ||
</button> | ||
{!isLast ? ' / ' : ''} | ||
</Fragment> | ||
) | ||
} | ||
|
||
type BreadcrumbsProps<M extends Meta, B extends Body> = { | ||
getFolder: ProviderView<M, B>['getFolder'] | ||
title: string | ||
breadcrumbsIcon: JSX.Element | ||
breadcrumbs: UnknownProviderPluginState['breadcrumbs'] | ||
} | ||
|
||
export default function Breadcrumbs<M extends Meta, B extends Body>( | ||
props: BreadcrumbsProps<M, B>, | ||
): JSX.Element { | ||
const { getFolder, title, breadcrumbsIcon, breadcrumbs } = props | ||
|
||
return ( | ||
<div className="uppy-Provider-breadcrumbs"> | ||
<div className="uppy-Provider-breadcrumbsIcon">{breadcrumbsIcon}</div> | ||
{breadcrumbs.map((directory, i) => ( | ||
<Breadcrumb | ||
key={directory.id} | ||
getFolder={() => getFolder(directory.requestPath, directory.name)} | ||
title={i === 0 ? title : directory.name} | ||
isLast={i + 1 === breadcrumbs.length} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../@uppy/provider-views/src/CloseWrapper.js → .../@uppy/provider-views/src/CloseWrapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { h } from 'preact' | ||
import type { I18n } from '@uppy/utils/lib/Translator' | ||
|
||
export default function FooterActions({ | ||
cancel, | ||
done, | ||
i18n, | ||
selected, | ||
}: { | ||
cancel: () => void | ||
done: () => void | ||
i18n: I18n | ||
selected: number | ||
}): JSX.Element { | ||
return ( | ||
<div className="uppy-ProviderBrowser-footer"> | ||
<button | ||
className="uppy-u-reset uppy-c-btn uppy-c-btn-primary" | ||
onClick={done} | ||
type="button" | ||
> | ||
{i18n('selectX', { | ||
smart_count: selected, | ||
})} | ||
</button> | ||
<button | ||
className="uppy-u-reset uppy-c-btn uppy-c-btn-link" | ||
onClick={cancel} | ||
type="button" | ||
> | ||
{i18n('cancel')} | ||
</button> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.