Skip to content

Commit

Permalink
Renames & eslint-disable react/require-default-props removal (#5251)
Browse files Browse the repository at this point in the history
* `eslint-disable react/require-default-props` - remove

* `GridItem.tsx`, `ListItem.tsx` - rename
  • Loading branch information
lakesare authored Jun 17, 2024
1 parent 151da8b commit 2ba00ec
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames'
import type { RestrictionError } from '@uppy/core/lib/Restricter'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'

type GridListItemProps<M extends Meta, B extends Body> = {
type GridItemProps<M extends Meta, B extends Body> = {
className: string
isDisabled: boolean
restrictionError?: RestrictionError<M, B> | null
Expand All @@ -18,8 +18,8 @@ type GridListItemProps<M extends Meta, B extends Body> = {
children?: ComponentChildren
}

function GridListItem<M extends Meta, B extends Body>(
props: GridListItemProps<M, B>,
function GridItem<M extends Meta, B extends Body>(
props: GridItemProps<M, B>,
): h.JSX.Element {
const {
className,
Expand Down Expand Up @@ -73,4 +73,4 @@ function GridListItem<M extends Meta, B extends Body>(
)
}

export default GridListItem
export default GridItem
12 changes: 7 additions & 5 deletions packages/@uppy/provider-views/src/Item/components/ItemIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/require-default-props */
import { h } from 'preact'

function FileIcon() {
Expand Down Expand Up @@ -44,11 +43,15 @@ function VideoIcon() {
)
}

export default function ItemIcon(props: {
type ItemIconProps = {
itemIconString: string
alt?: string
}): h.JSX.Element | null {
const { itemIconString } = props
}

export default function ItemIcon({
itemIconString,
alt = undefined,
}: ItemIconProps): h.JSX.Element | null {
if (itemIconString === null) return null

switch (itemIconString) {
Expand All @@ -59,7 +62,6 @@ export default function ItemIcon(props: {
case 'video':
return <VideoIcon />
default: {
const { alt } = props
return (
<img
src={itemIconString}
Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/provider-views/src/Item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type { CompanionFile } from '@uppy/utils/lib/CompanionFile'
import type { RestrictionError } from '@uppy/core/lib/Restricter'
import type { Meta, Body } from '@uppy/utils/lib/UppyFile'
import ItemIcon from './components/ItemIcon.tsx'
import GridListItem from './components/GridLi.tsx'
import ListItem from './components/ListLi.tsx'
import GridItem from './components/GridItem.tsx'
import ListItem from './components/ListItem.tsx'

type ItemProps<M extends Meta, B extends Body> = {
showTitles: boolean
Expand Down Expand Up @@ -46,7 +46,7 @@ export default function Item<M extends Meta, B extends Body>(
switch (viewType) {
case 'grid':
return (
<GridListItem<M, B>
<GridItem<M, B>
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
className={className}
Expand All @@ -64,7 +64,7 @@ export default function Item<M extends Meta, B extends Body>(
)
case 'unsplash':
return (
<GridListItem<M, B>
<GridItem<M, B>
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
className={className}
Expand All @@ -79,7 +79,7 @@ export default function Item<M extends Meta, B extends Body>(
>
{author!.name}
</a>
</GridListItem>
</GridItem>
)
default:
throw new Error(`There is no such type ${viewType}`)
Expand Down
21 changes: 8 additions & 13 deletions packages/@uppy/provider-views/src/ProviderView/AuthView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/require-default-props */
import { h } from 'preact'
import { useCallback } from 'preact/hooks'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
Expand Down Expand Up @@ -105,18 +104,14 @@ const defaultRenderForm = ({
onAuth: AuthViewProps<Meta, Body>['handleAuth']
}) => <DefaultForm pluginName={pluginName} i18n={i18n} onAuth={onAuth} />

export default function AuthView<M extends Meta, B extends Body>(
props: AuthViewProps<M, B>,
) {
const {
loading,
pluginName,
pluginIcon,
i18n,
handleAuth,
renderForm = defaultRenderForm,
} = props

export default function AuthView<M extends Meta, B extends Body>({
loading,
pluginName,
pluginIcon,
i18n,
handleAuth,
renderForm = defaultRenderForm,
}: AuthViewProps<M, B>) {
return (
<div className="uppy-Provider-auth">
<div className="uppy-Provider-authIcon">{pluginIcon()}</div>
Expand Down

0 comments on commit 2ba00ec

Please sign in to comment.