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 🙏

© 2025 – Pkg Stats / Ryan Hefner

redefine-ui-library

v0.1.10

Published

A reusable component library for our company

Readme


Code Structure and Conventions

This document outlines the coding standards and structure rules for this Next.js application to ensure consistency, readability, and maintainability across the codebase.

General JavaScript/TypeScript Conventions

  1. Variable Naming: Use camelCase for variable and function names.
    const userName = 'John';
    function fetchData() {}
  2. Constants: Use UPPER_SNAKE_CASE for constants.
    const API_BASE_URL = 'https://example.com/api';
  3. Class Names: Use PascalCase for React components and classes.
    class UserProfile {}
    export default function UserCard() {}
  4. File Names: Use camelCase for file names.
    components/userCard.js
    pages/dashboard.js

Folder Structure

Organize the project into the following structure:

src/
├── app/                 # Application routing and layout structure
│   ├── api/             # API routes
│   │   ├── [route]/     # Dynamic API routes
│   │   └── route.js     # API route definitions
│   ├── layout.js        # Root layout component
│   ├── page.js          # Homepage (default route)
│   ├── [slug]/          # Dynamic route folder
│   │   ├── page.js      # Page for the dynamic route
│   │   ├── layout.js    # Layout specific to this route (optional)
│   │   └── loading.js   # Loading state for the route (optional)
│   └── dashboard/       # Nested route folder (e.g., `/dashboard`)
│       ├── page.js      # Dashboard main page
│       └── settings/    # Nested sub-route (e.g., `/dashboard/settings`)
│           └── page.js  # Settings page
├── components/          # Reusable UI components with stories
│   ├── Button/          # Folder for the Button component
│   │   ├── Button.tsx   # Button component implementation
│   │   ├── Button.stories.tsx # Storybook stories for Button
│   │   ├── Button.types.ts    # Type definitions for Button
│   ├── Card/            # Folder for the Card component
│   │   ├── Card.tsx     # Card component implementation
│   │   ├── Card.stories.tsx   # Storybook stories for Card
│   │   ├── Card.types.ts      # Type definitions for Card
│   ├── Input/           # Folder for the Input component
│   │   ├── Input.tsx    # Input component implementation
│   │   ├── Input.stories.tsx  # Storybook stories for Input
│   │   ├── Input.types.ts     # Type definitions for Input
│   └── index.ts         # Barrel file for exporting components
├── styles/              # Global and component-specific styles
├── hooks/               # Custom React hooks
├── public/              # Static assets like images, icons, and fonts
├── types/               # TypeScript type definitions


Component-Specific Rules

  1. Functional Components: Use functional components over class components.
    const UserCard = () => {
      return <div>User Card</div>;
    };
    export default UserCard;
  2. Component Files: Each file should contain one component. Name the file after the component (e.g., UserCarduser-card.js).
  3. Props: Destructure props in function arguments for clarity.
    const UserCard = ({ name, age }) => (
      <div>
        {name}, {age}
      </div>
    );

CSS/Styling

  1. Use Tailwind CSS for styling wherever possible:
    <div className="p-4 bg-gray-100 rounded-md"></div>
  2. For custom CSS, follow the BEM methodology or use camelCase for class names:
    .user-card__title {
      font-size: 16px;
    }

TypeScript (if applicable)

  1. Use PascalCase with i at the start for types and interfaces.
    interface iUserProfile {
      id: number;
      name: string;
    }
  2. Store all type definitions in a types/ folder.

Linting and Formatting

  1. Use Prettier for code formatting.

  2. Extend the configuration with VSCode settings:

    // .vscode/settings.json
    {
      "editor.formatOnSave": true,
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    }

Dynamic Imports

Use dynamic imports for heavy components or libraries to optimize performance.

const Chart = dynamic(() => import('../components/Chart'), { ssr: false });

Alias Imports

Set up aliases in tsconfig.json or jsconfig.json for cleaner imports:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/components/*": ["./src/components/*"],
      "@/lib/*": ["./src/lib/*"]
    }
  }
}

Usage:

import UserCard from '@/components/usercard';

By following these conventions, the codebase will remain clean, maintainable, and easy to navigate for all contributors. For further clarifications or updates to these rules, refer to the contributing guidelines.