0.0.16 • Published 8 months ago

@inderjotpujara/cosmos-ui v0.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@inderjotpujara/cosmos-ui

A modern UI component library for Angular applications, built on top of PrimeNG.

Installation

npm install @inderjotpujara/cosmos-ui

All required dependencies (PrimeNG, FontAwesome, etc.) will be automatically installed.

Usage

Import the components you need in your standalone components:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ButtonComponent, CheckboxComponent } from '@inderjotpujara/cosmos-ui';

@Component({
  selector: 'app-example',
  standalone: true,
  imports: [
    CommonModule,
    ButtonComponent,
    CheckboxComponent
  ],
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss']
})
export class ExampleComponent { }

For applications using the Angular bootstrapApplication method:

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { appConfig } from './app.config';

bootstrapApplication(AppComponent, appConfig)
  .catch(err => console.error(err));

Available Components

Button Component

A versatile button component with extensive customization options.

<lib-button 
  label="Submit" 
  severity="primary" 
  [raised]="true"
  [loading]="isLoading"
  (onClick)="handleClick($event)">
</lib-button>

Button Properties

PropertyTypeDefaultDescription
labelstringundefinedText to display inside the button
severity'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'danger'undefinedVisual style of the button
size'small' | 'medium' | 'large''medium'Size of the button
disabledbooleanfalseWhen true, the button will be disabled
loadingbooleanfalseWhen true, shows a loading state
raisedbooleanfalseWhen true, adds a raised effect
roundedbooleanfalseWhen true, adds rounded corners
textbooleanfalseWhen true, renders as a text button
outlinedbooleanfalseWhen true, adds an outline style
iconPos'left' | 'right''left'Position of the icon relative to the label
ripplebooleantrueWhen true, adds a ripple effect on click

Button Events

EventDescription
onClickEmitted when the button is clicked
onFocusEmitted when the button receives focus
onBlurEmitted when the button loses focus

Checkbox Component

A customizable checkbox component that supports template-driven and reactive forms.

<lib-checkbox 
  label="I agree to the terms" 
  [(ngModel)]="agreed"
  [required]="true"
  (onChange)="handleChange($event)">
</lib-checkbox>

Checkbox Properties

PropertyTypeDefaultDescription
labelstringundefinedLabel text for the checkbox
checkedbooleanfalseWhen true, the checkbox will be checked
disabledbooleanfalseWhen true, the checkbox will be disabled
requiredbooleanfalseWhen true, the checkbox will be required
size'small' | 'medium' | 'large''medium'Size of the checkbox
labelPosition'left' | 'right''right'Position of the label relative to the checkbox
binarybooleanfalseWhen true, the checkbox will be used as a binary input
readonlybooleanfalseWhen true, the checkbox will be read-only

Checkbox Events

EventDescription
onChangeEmitted when the checkbox state changes
onFocusEmitted when the checkbox receives focus
onBlurEmitted when the checkbox loses focus

Theming

Setting up the Theme

To use the theming system, you need to import the theme styles in your angular.json file:

"styles": [
  "node_modules/@inderjotpujara/cosmos-ui/styles/styles.scss",
  "src/styles.scss"
]

Alternatively, you can import the styles in your styles.scss file:

@import '@inderjotpujara/cosmos-ui/styles/styles.scss';

Theme Variables

The library provides theme variables that you can use in your components:

import { THEME_VARIABLES, AD_THEME_VARIABLES } from '@inderjotpujara/cosmos-ui';

// Use theme variables
const primaryColor = THEME_VARIABLES.primaryColor;
const accentColor = AD_THEME_VARIABLES.accent;

Development

Building the Library

To build the library:

npm run build:lib

For production build:

npm run build:lib:prod

Storybook

This library includes a Storybook instance to showcase and document the components. To run Storybook:

npm run storybook

This will start the Storybook server at http://localhost:6007.

To build the Storybook static site:

npm run build-storybook

This will generate the static Storybook site in the dist/storybook/ui-lib directory.

Project Structure

projects/ui-lib/
├── src/
│   └── lib/
│       ├── button/          # Button component
│       ├── checkbox/        # Checkbox component
│       ├── services/        # Shared services
│       ├── styles/          # Global styles and theme variables
│       └── theme.module.ts  # Theme module
├── package.json            # Library package configuration
└── ng-package.json         # Angular library build configuration

Publishing

For detailed instructions on how to publish a new version of the library, see PUBLISHING.md.

Quick Publishing Steps

Method 1: Using npm scripts (Recommended)

# 1. Update version
cd projects/ui-lib
npm version patch

# 2. Build and publish
cd ../..
npm run build:lib:prod
npm run publish:lib

Method 2: Manual Steps

# 1. Update version
cd projects/ui-lib
npm version patch

# 2. Build
cd ../..
npm run build:lib:prod

# 3. Publish
cd dist/ui-lib
npm publish --access public

License

MIT

Troubleshooting

Import Issues

If you are having trouble importing components from the library, try these solutions:

  1. Clear npm cache and reinstall:

    npm cache clean --force
    npm install @inderjotpujara/cosmos-ui@latest
  2. Check TypeScript paths: Make sure your tsconfig.json has proper path mappings if needed:

    {
      "compilerOptions": {
        "paths": {
          "@inderjotpujara/cosmos-ui": ["node_modules/@inderjotpujara/cosmos-ui"]
        }
      }
    }
  3. Import components and modules correctly:

    // Import specific components
    import { Button, Checkbox } from '@inderjotpujara/cosmos-ui';
    
    // Import modules for use in NgModule imports
    import { ButtonModule, CheckboxModule } from '@inderjotpujara/cosmos-ui';
  4. Make sure Angular compiler options are compatible: In your app's tsconfig.json, ensure compatibility with the library:

    {
      "compilerOptions": {
        "skipLibCheck": true
      }
    }
0.0.16

8 months ago

0.0.15

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago