npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ui-maxxi-upload

v1.0.2

Published

<p align="center"><img src="https://s3.amazonaws.com/gupy5/production/companies/1925/career/3121/images/2022-01-12_18-37_logo.png" width="100" alt="Maxxi Logo" /></a> </p>

Downloads

5

Readme

Exemplo de utilização da "FileUploader"

Nesse exemplo ira entender como utilizar o componente "FileUploader".

Instalação

yarn add ui-maxxi-upload

Como importar

import { FileUploader, EMaxxiUploadType, FileData } from "ui-maxxi-upload";

Parametros do "FileUploader"

  • handleFile (optional) - Função usada para sobrescrever a funcionalidade padrão de upload do botão (list: FileList) => {}.
  • title - Titulo do botão de upload string.
  • baseUrl - Url do serviço string.
  • onUploaded (optional) - Função usada para receber os dados do arquivo salvo no servidor (listOfUploadFiles: Array<FileData>): void => {}.
  • styledButton (optional) - Configuração de estilo para o componente styled.button.
  • type (optional) - Expecifica a funcionalidade do botão.
    • S3_BY_SERVER - Faz o upload do arquivo para o S3 mas o front envia primeiro para o back e este para o S3.
    • S3_DIRECT - Faz o upload do arquivo direto para o S3 sem passar pelo back.
    • DEFAULT - Faz o upload do arquivo na pasta maxxi-upload no back.

Upload de arquivos para S3 através do servidor

Para fazer upload de um arquivo ao S3 enviando o arquivo primeiro para o 'service-maxxi-upload' e depois enviar para um bucket no S3.

<FileUploader
  baseUrl="https://demo-api.appsmaxxidata.com"
  title="Upload a file"
  type={EMaxxiUploadType.S3_BY_SERVER}
/>

Upload de arquivos ditero para S3

Para fazer upload de um arquivo direto para S3 sem necessidade de passar polo back.

const onUploaded = (listOfUploadFiles: Array<FileData>): void => {
  console.log(listOfUploadFiles);
};
<FileUploader
  baseUrl="https://demo-api.appsmaxxidata.com"
  type={EMaxxiUploadType.S3_DIRECT}
  title="Upload to S3"
  onUploaded={onUploaded}
/>

Upload de arquivos usando a função de upload customizada

const handleFile = (list: FileList) => {
  for (let index = 0; index < list.length; index++) {
    const file = list[index];
    const data = new FormData();
    data.append('maxxi-upload-file', file);
    fetch('https://demo-api.appsmaxxidata.com/upload', {
      method: 'POST',
      body: data,
    })
      .then(res => {
        console.log(res);
      })
      .catch(err => {
        console.error(err);
      });
  }
};
<FileUploader
  handleFile={handleFile}
  baseUrl=""
  title="Upload a file with handler"
/>

Customizando botão

1 - Usando styled components

import styled from 'styled-components';

const CustomButton = styled.button`
  background-color: black;
  color: white;
  font-size: 20px;
  padding: 10px 60px;
  border-radius: 5px;
  margin: 10px 0px;
  cursor: pointer;
`;
<FileUploader
  baseUrl="https://demo-api.appsmaxxidata.com"
  title="Upload a file"
  styledButton={CustomButton}
/>

1 - Usando CSS


.button-upload {
    color: #7396FF;
    border: none;
    background-color: transparent;
    padding: 0px;
    cursor: pointer;
}

.text-size-14 {
    font-size: 14px;
    font-family: Roboto;
    font-weight: 500;
    word-wrap: break-word;
}
<FileUploader
  baseUrl="https://demo-api.appsmaxxidata.com"
  title="Upload a file"
  className="button-upload text-size-14"
/>