How To Contribute
Follow the following guidelines to ensure the smooth collaboration
Thank you for your interest in contributing to the Inspira UI project! Your contributions help make this project better for everyone. Please take a moment to read through these guidelines to ensure a smooth collaboration.
Table of Contents
- Getting Started
- Code of Conduct
- How to Contribute
- Project Structure
- Style Guidelines
- Documentation Guidelines
- Testing
- License
Getting Started
- Fork the Repository: Create a personal fork of the project on GitHub.
- Clone Your Fork: Clone your forked repository to your local machine.
- Create a Branch: Create a new branch for your contribution (
git checkout -b feature/YourFeatureName
). - Install Dependencies: Run
pnpm install
to install all necessary dependencies.
Code of Conduct
By participating in this project, you agree to abide by the Code of Conduct, which aims to foster an open and welcoming environment.
How to Contribute
Reporting Bugs
If you find a bug, please open an issue and include:
- A clear and descriptive title.
- Steps to reproduce the issue.
- Expected and actual results.
- Screenshots or code snippets, if applicable.
Suggesting Enhancements
We welcome suggestions for new features or improvements. Please open an issue and include:
- A clear and descriptive title.
- A detailed description of the enhancement.
- Any relevant examples or mockups.
Adding New Components
We appreciate contributions that add new components to the library. Please ensure that:
- The component is generally useful and aligns with the project's goals.
- The component is compatible with both Nuxt and Vue.
- You follow the coding and documentation guidelines outlined below.
- You include unit tests for your component.
Components guidelines
- Create or Update
index.ts
Each folder undercomponents/content/inspira/ui/<component-folder-name>/
should have anindex.ts
that exports all Vue files. For example: - Registry Dependencies:
If your new component depends on (or uses) other Inspira UI components, you must update the
COMPONENT_DEPENDENCIES
map in~/scripts/crawl-content.ts
to reflect those relationships. This helps the library understand which components should be installed together when a user adds them via the CLI. - Nuxt-Only Features:
If your new component or its example uses Nuxt-only features such as
<ClientOnly>
, please mention this in the documentation. This ensures users know there may be limitations or additional steps when using the component outside of Nuxt.
This ensures that users can install the component through the CLI and that all dependencies are properly declared. - Avoid External Components:
When creating components, avoid using external UI components (like
<UiButton>
or similar) that are not part of the core Vue.js ecosystem. - Explicit Imports:
Even if you're using Nuxt's auto-imports feature during development, always include explicit imports in your component code. This ensures compatibility with Vue.js users who don't have auto-imports. For example:
- Icon Usage:
If you need icons in your demos or components, use the built-in
<Icon>
component rather than pasting raw SVGs into your templates.
Project Structure
Understanding the project structure is crucial for effective contribution:
- Components Directory:
- Main components should be placed in
components/content/inspira/ui/<component-folder-name>/
.- Include an
index.ts
file to export each component within that folder.
- Include an
- Example components should be placed in
components/content/inspira/examples/<component-folder-name>/
.
- Main components should be placed in
- Documentation:
- Documentation files are located in the
content/2.components/<category>/
directory. - After adding a component, write its documentation in this directory.
- Documentation files are located in the
Style Guidelines
Coding Standards
- Language: All components should be written in Vue.js with TypeScript support.
- Styling: Use Tailwind CSS classes for styling whenever possible.
- Naming Conventions: Use
PascalCase
for component names and filenames.
Component Format
Your Vue components should adhere to the following structure:
Props typing and code style
Refer to this Vue.js documentation page -> https://vuejs.org/api/sfc-script-setup#type-only-props-emit-declarations
Constants, interfaces, types and variants
For reusability purposes, you can also add an index.ts
file at the root of the component folder to export interfaces, constants, and other useful code elements. Keep in mind that developers will copy and paste the component code into their projects, so it should be very easy to customize according to their standards.
Contants have to be CAPS_CAMEL_CASE
in order to identify them clearly inside the code. And prefix
them.
Please never use Enums; use {} as const
instead. 😘
You can check the PatternBackground
component files components/content/inspira/ui/pattern-background
for a complete example.
Notes:
- Use
<script lang="ts" setup>
for TypeScript and the Composition API. - Keep styles scoped to prevent conflicts.
- Ensure compatibility with both Nuxt and Vue.
Commit Messages
- Use the Conventional Commits format.
- Begin with a type (
feat
,fix
,docs
, etc.) followed by a short description. - Example:
feat: add TextHoverEffect component
Documentation Guidelines
Proper documentation is crucial for users to understand and effectively use the components. Follow these guidelines when adding documentation for new components.
Steps to Add a New Component
- Create the Component
- Place the main component in
components/content/inspira/ui/<component-folder-name>/
. - Follow the Component Format specified above.
- If the component requires examples or demos, add demo components to
components/content/inspira/examples/<component-folder-name>/
.
- Place the main component in
- Write Documentation
- Add a new Markdown file in
content/2.components/<category>/
for your component's documentation. - Use the appropriate template based on whether your component is single-file or multi-file (see below).
- Add utility classes section if applicable to your component.
- Mention the Credits and source if the component is ported from any other UI library or taken inspiration from any other source.
- Add a new Markdown file in
- Ensure Compatibility
- Test your component in both Nuxt and Vue environments.
Single-File Components
For components that are contained within a single .vue
file, use the following template:
- Front Matter
Begin with YAML front matter that includes thetitle
anddescription
: - Preview Section
Use theComponentLoader
to display a live preview of the component. Theid
should be set to the folder name of your component incomponents/content/inspira/examples/
. In case, there is no folder, thenid
is not required. - Alerts
If your component has special requirements or dependencies, add an alert section before the installation instructions: - Installation
Include both CLI and manual installation instructions. If additional setup is required (e.g., dependencies, Tailwind config updates), use a stepper to list all needed steps. - API Documentation
Provide a table listing all props:
Example:
In this example, the id
used in both ComponentLoader
, CodeViewer
and InstallationCli
is text-hover-effect
, which matches the folder name where the component and its demo are stored.
Multi-File Components
For components that consist of multiple files, such as a main component and several sub-components or variants, use the following template:
- Front Matter
Begin with YAML front matter: - Preview Sections
Include multipleComponentLoader
sections for each example or variant. Theid
should be set to the folder name of your component incomponents/content/inspira/examples/
. - Alerts
If your component has special requirements or dependencies, add an alert section before the installation instructions: - Installation
Include both CLI and manual installation instructions. If additional setup is required (e.g., dependencies, Tailwind config updates), use a stepper to list all needed steps. - API Documentation
Provide comprehensive API documentation covering all components:
Example:
Testing
- Unit Tests: Write unit tests for your component if applicable.
- Cross-Environment Testing: Ensure that your component works correctly in both Nuxt and Vue environments.
- Visual Testing: Check the component visually to ensure it renders correctly.
- CLI Installation Testing: After updating the registry with
pnpm build:registry
, test the component installation in a separate project by referencing the local registry URL. For example:
Additional Notes
- Component Names: Use
PascalCase
for component filenames and names. - IDs: In
CodeViewer
,CodeViewerTab
, andComponentLoader
, theid
parameter should be set to the folder name where the component is stored incomponents/content/inspira/ui/<component-folder-name>/
andcomponents/content/inspira/examples/<component-folder-name>/
. This helps in correctly linking the code and examples in the documentation. - Demo Components: For each component, create a corresponding
Demo
component used in theComponentLoader
for previews, and place it incomponents/content/inspira/examples/<component-folder-name>/
. - Localization: If your component supports multiple languages, include details in the documentation.
License
By contributing, you agree that your contributions will be licensed under the MIT License.