Skip to content

feat: useUploadThingInputProps #729

Closed as not planned
Closed as not planned

Description

@t3dotgg

Describe the feature you'd like to request

Making custom upload buttons is too hard

Describe the solution you'd like to see

// inferred input off useUploadThing
type Input = Parameters<typeof useUploadThing>;

const useUploadThingInputProps = (...args: Input) => {
  const $ut = useUploadThing(...args);

  const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
    if (!e.target.files) return;

    const selectedFiles = Array.from(e.target.files);
    const result = await $ut.startUpload(selectedFiles);
  };

  return {
    inputProps: {
      handleChange,
      multiple: ($ut.permittedFileInfo?.config?.image?.maxFileCount ?? 1) > 1,
      accept: generateMimeTypes(fileTypes ?? [])?.join(", "),
    },
    isUploading: $ut.isUploading,
  };
};

Can I have this pls <3

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR implementing this feature!

Activity

  1. added
    ✨ enhancement
    on Mar 24, 2024
  2. added
    status: in progress
    on Apr 10, 2024
  3. github-actions commented on Oct 15, 2024

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity for 10 days. It will be closed in 5 days if no further activity occurs.

  4. added
    stale
    on Oct 15, 2024
  5. github-actions commented on Oct 20, 2024

    @github-actions
    Contributor

    This issue has been closed because it has not had any activity for 5 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stalestatus: in progress✨ enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions