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

castro-ui

v1.4.6

Published

A collection of reusable React components with Tailwind CSS and TypeScript.

Downloads

4

Readme

Castro UI

Castro UI é uma biblioteca de componentes React reutilizáveis, projetada para ser simples e flexível. Esta biblioteca utiliza TypeScript e Tailwind CSS para fornecer uma experiência de desenvolvimento consistente e estilizada. Ideal para quem busca componentes prontos e configuráveis para criar interfaces de usuário modernas.

Observação

Configurar arquivo de estilos geral para o Tailwind CSS:

@tailwind base;
@tailwind components;
@tailwind utilities;

Configure o arquivo tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx}",
    "./node_modules/castro-ui/dist/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};

Instalação

npm install castro-ui

Componentes

ActionButton

Dependências

Instale a biblioteca react-icons para usar os ícones:

npm install react-icons

Importação

Importe o componente da biblioteca:

import { FaBars, FaImage, FaLink, FaHome } from "react-icons/fa";
import { ActionButton } from "./castro-ui";

Configure o Código para Renderização

O componente deve conter a quantidade de botões que você deseja (máx. 3), o ícone principal, e os ícones e links dos botões adicionais.

return (
  <>
    <div>
      <ActionButton
        buttonCount={3}
        mainButtonIcon={<FaBars color="#000" />}
        content={[
          { icon: <FaImage color="#eee" />, link: "#" },
          { icon: <FaLink color="#eee" />, link: "#" },
          { icon: <FaHome color="#eee" />, link: "#" },
        ]}
      />
    </div>
  </>
);

Carousel

Dependências

Instale a biblioteca react-icons para usar os ícones:

npm install react-icons

Importação

Importe o componente da biblioteca:

import { IoIosArrowDropleft, IoIosArrowDropright } from "react-icons/io";
import { Carousel } from "./castro-ui";
const images = [
  "https://dummyimage.com/600x400/000/fff&text=1",
  "https://dummyimage.com/600x400/000/fff&text=2",
  "https://dummyimage.com/600x400/000/fff&text=3",
  "https://dummyimage.com/600x400/000/fff&text=4",
];
return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <div className="w-[500px]">
        <Carousel items={images} />
      </div>
    </div>
  </>
);

CodeBlock

Dependências

Instale a biblioteca react-icons para usar os ícones:

npm install react-icons

Importação

Importe o componente da biblioteca:

import { PiCopy, PiSpinner } from "react-icons/pi";
import { CodeBlock } from "./castro-ui";
let code = `import React from 'react';

const MyComponent = () => {
  const [count, setCount] = React.useState(0);

  return (
    <>
    <div>
      <p>Current count: {count}</p>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
    </div>
    </>
  );
};

export default MyComponent;`;
return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <CodeBlock code={code} maxHeight="300" maxWidth="380" />
    </div>
  </>
);

CustomAlert

Importação

Importe o componente da biblioteca no arquivo principal:

import { CustomAlert } from "./castro-ui";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <App />
    <CustomAlert />
  </React.StrictMode>
);

Configuração para Mostrar o Alerta

Configure a ação para mostrar o alerta em determinadas ocasiões:

import { showCustomAlert } from "./castro-ui";
const handleAlert = () => {
  showCustomAlert({
    title: "Title",
    message: "Text message",
    textClose: "Close",
  });
};

return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <button onClick={handleAlert}>Show Alert</button>
    </div>
  </>
);

CustomPagination

Importação

Importe o componente da biblioteca:

import { CustomPagination } from "./castro-ui";

Configuração do Componente


const [currentItems, setCurrentItems] = useState<any[]>([]);
const items = ["item 1", "item 2", ...];
const itemsPerPage = 10;

const handlePageChange = (page: number) => {
const startIndex = (page - 1) * itemsPerPage;
    const endIndex = startIndex + itemsPerPage;
    setCurrentItems(items.slice(startIndex, endIndex));
};

return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <CustomPagination
        items={items}
        itemsPerPage={itemsPerPage}
        onPageChange={handlePageChange}
      />
    </div>
  </>
);

Form

Importação

Importe o componente da biblioteca no arquivo principal:

import { Form } from "./castro-ui";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <App />
    <Form />
  </React.StrictMode>
);

Configuração para Mostrar o Formulario

Configure a ação para mostrar o formulario em determinadas ocasiões:

import { showCustomForm } from "./castro-ui";
const handleForm = () => {
  showCustomForm({
    title: "Create Project",
    message: "Deploy your project",
    labelOne: "Name",
    placeholder: "Enter your name",
    labelTwo: "Category",
    options: ["Auditor", "Programador", "Diretor"],
    textCancel: "Cancel",
    textDeploy: "Deploy",
    onDeploy: handleDeploy,
  });
};

const handleDeploy = (name: string, option: string) => {
  alert(`Name: ${name}, Category: ${option}`);
};

return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <button onClick={handleForm}>Show Form</button>
    </div>
  </>
);

PinField

Importação

Importe o componente da biblioteca:

import { PinField } from "./castro-ui";
return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <PinField
        length={5}
        onChange={(pin) => {
          alert(pin);
        }}
      />
    </div>
  </>
);

Search

Importação

Importe o componente da biblioteca:

import { Search } from "./castro-ui";
return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <Search
        onClick={() => alert("Hello World")}
        placeholder="Your placeholder"
      />
    </div>
  </>
);

Sidebar

Importação

Importe o componente da biblioteca:

import { Sidebar, SideAction, SideContent, SideTitle } from "./castro-ui";
return (
  <>
    <div className="flex items-center justify-center w-full h-screen">
      <Sidebar>
        <SideAction>
          <button>Open</button>
        </SideAction>
        <SideContent className="p-4">
          <SideTitle>Title of sidebar</SideTitle>
          <span>Content of sidebar</span>
        </SideContent>
      </Sidebar>
    </div>
  </>
);