Skip to content

Commit

Permalink
chore: move Uploader into react-uploader package
Browse files Browse the repository at this point in the history
I think it makes more sense to include these "headless UI" style
components in the @w3ui/react-* packages rather than bundling
them together in the react-ui package. It feels more intuitive given the
naming - if we do want to have the "no UI" style components in a separate
package I'd advocate for callling that package `react-uploader-provider`
or `react-uploader-api` or something, but given how much code this is
and the fact that tree shaking is pretty good, it seems ok to me to bundle
them together.

the react-ui package will be reserved for higher level "customizable UI"
style components and can now have opinions about the right way to
do customization at the top level rather than having two different
flavors of customizability in a single package.
  • Loading branch information
travis committed Dec 2, 2022
1 parent c4d74e6 commit d48675e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/react/ui/src/ContentPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Uploader, SimpleUploader } from '@w3ui/react-ui'
import { UploaderProvider, useUploader } from '@w3ui/react-uploader'
import { SimpleUploader } from '@w3ui/react-ui'
import { Uploader, UploaderProvider, useUploader } from '@w3ui/react-uploader'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { a11yDark } from 'react-syntax-highlighter/dist/esm/styles/prism';

Expand Down
1 change: 0 additions & 1 deletion packages/react-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './Uploader'
export * from './SimpleUploader'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, createContext, useState } from 'react'
import { useUploader, CARMetadata } from '@w3ui/react-uploader'
import { Link, Version } from 'multiformats'
import { CARMetadata } from '@w3ui/uploader-core'
import { useUploader } from './providers/Uploader'

export type UploaderContextValue = {
storedDAGShards?: CARMetadata[],
Expand All @@ -14,7 +15,7 @@ export type UploaderContextValue = {
}

export const UploaderContext = createContext<UploaderContextValue>({
setFile: () => {}
setFile: () => { }
})

export type UploaderProps = {
Expand Down Expand Up @@ -59,7 +60,7 @@ Uploader.Input = (props: any) => {
)
}

Uploader.Form = ({ children, ...props }: {children: React.ReactNode} & any) => {
Uploader.Form = ({ children, ...props }: { children: React.ReactNode } & any) => {
const { handleUploadSubmit } = useContext(UploaderContext)
return (
<form onSubmit={handleUploadSubmit} {...props}>
Expand Down

0 comments on commit d48675e

Please sign in to comment.