1.0.0 • Published 5 months ago

@cognam/app-button v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

AppButton Component

A reusable Material-UI Button component wrapper for React applications.

Installation

npm install @cognam/app-button

Usage

import AppButton from '@cognam/app-button';
// or
import { AppButton } from '@cognam/app-button';

function MyComponent() {
  return (
    <AppButton 
      variant="contained" 
      color="primary" 
      onClick={() => console.log('Clicked!')}
    >
      Click Me
    </AppButton>
  );
}

Props

PropTypeDefaultDescription
sizestring-Button size (small, medium, large)
styleobject-Custom styles
variantstring-Button variant (text, outlined, contained)
classNamestring-CSS class name
colorstring"primary"Button color
disabledbooleanfalseWhether button is disabled
onClickfunction-Click handler
childrennode-Button content

Requirements

  • React 17+ or 18+
  • Material-UI 5+
  • Emotion (React and Styled)
## Step 7: Build and Publish

1. **Install dependencies:**
```bash
npm install
  1. Build the package:
npm run build
  1. Test locally (optional):
npm link

Then in your test project:

npm link @cognam/app-button
  1. Publish to NPM:
npm login
npm publish --access public

Step 8: Using in Your New Project

In your new project, install the package:

npm install @cognam/app-button

Then use it:

import AppButton from '@cognam/app-button';

function MyApp() {
  return (
    <div>
      <AppButton variant="contained" color="primary">
        My Button
      </AppButton>
    </div>
  );
}

Key Benefits of This Approach:

  1. Peer Dependencies: Material-UI and React are peer dependencies, so they won't be bundled
  2. Tree Shaking: ESM build supports tree shaking
  3. Multiple Formats: Both CommonJS and ESM builds
  4. Optimized: Direct imports for Material-UI components
  5. Reusable: Can be used across multiple projects

This setup will create a professional NPM package that you can reuse across all your projects while maintaining the same Material-UI and React versions.

1.0.0

5 months ago