### Development Setup and Scripts
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Instructions for setting up the development environment and common scripts for building, testing, and formatting the component library and documentation site.
```bash
git clone https://github.com/your-username/components.git
cd components
pnpm install
pnpm dev
pnpm build
pnpm --filter ./packages/lib test
pnpm --filter ./packages/lib test:watch
pnpm format
```
--------------------------------
### Add Live Component Examples
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
This code demonstrates how to create live examples for a component, allowing users to see different variations and states. It's written in React and TypeScript.
```tsx
import { MyComponent } from "@g4rcez/components/my-component";
export const MyComponentExample = () => {
return (
DefaultPrimary
);
};
```
--------------------------------
### Development Setup and Scripts
Source: https://github.com/g4rcez/components/blob/main/README.md
Instructions for setting up the development environment, including cloning the repository, installing dependencies with pnpm, and running development or build scripts.
```bash
# Clone the repository
git clone https://github.com/g4rcez/components.git
cd components
# Install dependencies
pnpm install
# Start development server (docs site)
pnpm dev
# Build the library
pnpm build
```
--------------------------------
### Install Tailwind CSS v4 and @g4rcez/components
Source: https://github.com/g4rcez/components/blob/main/docs/TAILWIND_V4_INTEGRATION.md
Installs the necessary packages for Tailwind CSS v4 and the @g4rcez/components library using npm.
```bash
# Install Tailwind CSS v4 (when available)
npm install tailwindcss@next
# Install the components library
npm install @g4rcez/components
```
--------------------------------
### Branching Strategy for Contributions
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Provides examples of Git commands for creating feature, bug fix, and documentation branches according to the project's workflow.
```bash
git checkout -b feature/component-name
git checkout -b fix/issue-description
git checkout -b docs/update-readme
```
--------------------------------
### Install G4rcez Components
Source: https://github.com/g4rcez/components/blob/main/docs/COMPONENT_INDEX.md
Installs the G4rcez components library using npm.
```bash
npm install @g4rcez/components
```
--------------------------------
### Basic Setup with ComponentsProvider
Source: https://github.com/g4rcez/components/blob/main/docs/COMPONENT_INDEX.md
Demonstrates the basic setup for using G4rcez components by wrapping the application with ComponentsProvider and importing the necessary CSS.
```tsx
import { ComponentsProvider } from "@g4rcez/components";
import "@g4rcez/components/index.css";
function App() {
return (
);
}
```
--------------------------------
### Global CSS Setup with Tailwind and @g4rcez/components
Source: https://github.com/g4rcez/components/blob/main/docs/TAILWIND_V4_INTEGRATION.md
Sets up global CSS by importing Tailwind CSS and @g4rcez/components, and defines custom CSS variables for theming and animations.
```css
/* styles/globals.css */
@import "tailwindcss";
@import "@g4rcez/components/index.css";
/* Custom CSS variables for theming */
@theme {
--color-brand-primary: #3b82f6;
--color-brand-secondary: #64748b;
--color-brand-accent: #8b5cf6;
--spacing-component: 1rem;
--radius-component: 0.5rem;
--shadow-component: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}
/* Custom animations */
@keyframes slideInRight {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes pulse-soft {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.8;
}
}
```
--------------------------------
### Add Component Documentation Page
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
This snippet shows how to create a documentation page for a component using React and TypeScript. It includes importing the component, displaying its description, and providing an example usage.
```tsx
import { MyComponent } from "@g4rcez/components/my-component";
export default function MyComponentPage() {
return (
MyComponent
Component description...
Examples
Example usage
API Reference
{/* Props table */}
);
}
```
--------------------------------
### Write Component Tests
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Provides examples of unit tests for a React component using Vitest and React Testing Library. Covers rendering, prop variations, and ref forwarding.
```tsx
// packages/lib/tests/components/my-component.test.tsx
import { render, screen } from "@testing-library/react";
import { MyComponent } from "../../src/components/category/my-component";
describe("MyComponent", () => {
it("renders with default props", () => {
render(Test content);
expect(screen.getByText("Test content")).toBeInTheDocument();
});
it("applies variant classes correctly", () => {
render(Test);
const element = screen.getByText("Test");
expect(element).toHaveClass("primary-classes");
});
it("forwards ref correctly", () => {
const ref = React.createRef();
render(Test);
expect(ref.current).toBeInstanceOf(HTMLDivElement);
});
});
```
--------------------------------
### Example: Basic Card
Source: https://github.com/g4rcez/components/blob/main/docs/components/Card.md
A simple example demonstrating a Card component with a heading and paragraph content.
```tsx
Welcome
This is a simple card with basic content.
```
--------------------------------
### Create a New React Component
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Demonstrates the creation of a new React component using TypeScript, CVA for styling variants, and forwardRef for ref forwarding. Includes prop definitions, JSDoc comments, and usage examples.
```tsx
// packages/lib/src/components/category/my-component.tsx
import React, { forwardRef } from "react";
import { cva } from "class-variance-authority";
import { css } from "../../lib/dom";
/**
* Component variant definitions
* @internal
*/
const variants = {
variant: {
default: "default-classes",
primary: "primary-classes",
},
size: {
sm: "small-classes",
md: "medium-classes",
},
};
/**
* Class variance authority configuration
* @internal
*/
const componentVariants = cva("base-classes", {
variants,
defaultVariants: { variant: "default", size: "md" },
});
/**
* Props for the MyComponent
*/
export interface MyComponentProps {
/** Component variant */
variant?: keyof typeof variants.variant;
/** Component size */
size?: keyof typeof variants.size;
/** Additional CSS classes */
className?: string;
/** Component children */
children?: React.ReactNode;
}
/**
* A description of what this component does.
*
* @example
* ```tsx
*
* Content
*
* ```
*/
export const MyComponent = forwardRef(
({ variant, size, className, children, ...props }, ref) => {
return (
{children}
);
},
);
MyComponent.displayName = "MyComponent";
```
--------------------------------
### Currency Input Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
Example of using the Input component with a currency mask and state management.
```tsx
setAmount(e.target.value)}
/>
```
--------------------------------
### Basic Text Input Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
A standard example of using the Input component for text input with state management.
```tsx
setName(e.target.value)}
/>
```
--------------------------------
### Installation
Source: https://github.com/g4rcez/components/blob/main/README.md
Provides instructions for installing the @g4rcez/components library using npm, yarn, or pnpm package managers.
```bash
npm install @g4rcez/components
# or
yarn add @g4rcez/components
# or
pnpm add @g4rcez/components
```
--------------------------------
### Project Structure Overview
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Illustrates the directory structure of the @g4rcez/components project, highlighting the main library ('lib') and documentation ('docs') packages.
```directory-structure
packages/
├── lib/ # Main component library
│ ├── src/
│ │ ├── components/
│ │ ├── hooks/
│ │ ├── lib/
│ │ ├── styles/
│ │ └── config/
│ ├── tests/
│ └── dist/
└── docs/ # Documentation site
├── src/app/docs/
└── src/components/examples/
```
--------------------------------
### Basic Dialog Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Modal.md
A complete example demonstrating how to use the Modal component as a basic dialog, including a button to open it and confirmation/cancel actions within the footer.
```tsx
const BasicDialog = () => {
const [open, setOpen] = useState(false);
return (
<>
Are you sure you want to proceed?
>
);
};
```
--------------------------------
### Tailwind CSS v4 Integration Examples
Source: https://github.com/g4rcez/components/blob/main/docs/COMPONENT_INDEX.md
Showcases examples of Tailwind CSS v4 features integrated into various project components. Demonstrates CSS variables, container queries, CSS Grid areas, color functions, modern animations, and responsive design patterns.
```APIDOC
Component Examples with Tailwind CSS v4:
Button:
Features: CSS variables, container queries, dynamic styling, custom animations
Input:
Features: Responsive forms, locale-aware styling, validation animations, multi-step layouts
Modal:
Features: Dynamic theming, container-based sizing, CSS Grid areas, modern animations
Card:
Features: Masonry layouts, hover effects, data visualization, adaptive components
Alert:
Features: Notification systems, progress indicators, stacking animations
Tabs:
Features: Vertical layouts, CSS Grid areas, animated transitions, responsive behavior
Select:
Features: Dynamic theming, responsive forms, advanced state styling
Checkbox:
Features: Task lists, priority styling, animated states, complex layouts
```
--------------------------------
### Alert Basic Variants Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Alert.md
Shows examples of using the Alert component with different themes like 'info', 'success', 'warn', and 'danger'.
```tsx
This is an informational message.
Your changes have been saved successfully.
Please review your input before proceeding.
Something went wrong. Please try again.
```
--------------------------------
### Date Input Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
Example of using the Input component with a date mask and state management.
```tsx
setDate(e.target.value)}
/>
```
--------------------------------
### Example: Basic Tabs
Source: https://github.com/g4rcez/components/blob/main/docs/components/Tabs.md
A functional example of the Tabs component, demonstrating how to manage the active tab state and render different content for each tab.
```tsx
const BasicTabs = () => {
const [active, setActive] = useState("overview");
return (
Project Overview
This is the overview of your project.
Project Details
Detailed information about your project.
Project Settings
Configure your project settings here.
);
};
```
--------------------------------
### Credit Card Input Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
Example of using the Input component with a credit card mask and state management.
```tsx
setCardNumber(e.target.value)}
/>
```
--------------------------------
### Run Component Tests
Source: https://github.com/g4rcez/components/blob/main/CONTRIBUTING.md
Commands to execute tests for the 'lib' package using pnpm, including running all tests, watching for changes, and generating a coverage report.
```bash
# Run all tests
pnpm --filter ./packages/lib test
# Watch mode
pnpm --filter ./packages/lib test:watch
# Coverage report
pnpm --filter ./packages/lib test --coverage
```
--------------------------------
### Percentage Mask Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
Demonstrates the usage of the percentage mask for the Input component.
```tsx
```
--------------------------------
### Example: Card as Different Elements
Source: https://github.com/g4rcez/components/blob/main/docs/components/Card.md
Demonstrates rendering the Card component as different HTML elements like 'article' or 'section' using the `as` prop.
```tsx
// As article
Blog post content...
// As section
Feature 1
Feature 2
```
--------------------------------
### Phone Number Input Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Input.md
Example of using the Input component with a phone number mask and state management.
```tsx
setPhone(e.target.value)}
/>
```
--------------------------------
### Basic Button Usage
Source: https://github.com/g4rcez/components/blob/main/docs/components/Button.md
Shows a simple example of how to render and use the Button component with default settings.
```tsx
```
--------------------------------
### Polymorph Basic Usage Examples
Source: https://github.com/g4rcez/components/blob/main/docs/components/Polymorph.md
Illustrates the basic usage of the Polymorph component, showing how to render it as different HTML elements like button, link, and div.
```tsx
Button ElementLink ElementDiv Element
```
--------------------------------
### Basic Select Example
Source: https://github.com/g4rcez/components/blob/main/docs/components/Select.md
An example demonstrating how to manage the selected value of the Select component using React's useState hook and handle changes.
```tsx
const [selectedValue, setSelectedValue] = useState("");