blocks-design-system
v1.0.0
Published
The React Design System for all the superblocks suite of application frontends.
Downloads
4
Maintainers
Readme
blocks-design-system
The React Design System for all the superblocks suite of application frontends.
A comprehensive, type-safe React component library built with TypeScript, designed to provide consistent UI components across all Superblocks applications.
Features
- 🎨 Modern React Components - Built with React and TypeScript
- 📦 Tree-shakeable - Import only what you need
- 🎯 Type-safe - Full TypeScript support with type definitions
- 🧪 Well-tested - Comprehensive test coverage with Jest and React Testing Library
- 📱 Responsive - Mobile-first design approach
- 🎭 Customizable - Easy to customize with inline styles or CSS
Installation
npm install blocks-design-systemor with yarn:
yarn add blocks-design-systemUsage
Button Component
import { Button } from 'blocks-design-system';
function App() {
return (
<div>
<Button variant="primary" size="md" onClick={() => alert('Clicked!')}>
Click Me
</Button>
<Button variant="secondary" size="lg" fullWidth>
Full Width Button
</Button>
<Button variant="danger" size="sm" disabled>
Disabled Button
</Button>
</div>
);
}Button Props
variant:'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info'- Button style variant (default:'primary')size:'sm' | 'md' | 'lg'- Button size (default:'md')disabled:boolean- Whether the button is disabled (default:false)fullWidth:boolean- Whether the button should take full width (default:false)- All standard HTML button attributes are also supported
Typography Component
import { Typography } from 'blocks-design-system';
function App() {
return (
<div>
<Typography variant="h1">Heading 1</Typography>
<Typography variant="h2" color="blue">Heading 2 (Blue)</Typography>
<Typography variant="p" weight="bold" align="center">
Bold centered paragraph
</Typography>
<Typography variant="span" color="#ff0000">
Custom colored span
</Typography>
</div>
);
}Typography Props
variant:'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span'- HTML tag to render (default:'p')color:string- Text color (any valid CSS color)weight:'light' | 'normal' | 'medium' | 'semibold' | 'bold'- Font weight (default:'normal')align:'left' | 'center' | 'right' | 'justify'- Text alignment (default:'left')style:CSSProperties- Custom inline stylesclassName:string- Custom CSS class name
Theme Utilities
The design system also exports theme utilities for consistent styling:
import { colors, spacing, fontSizes, fontWeights, borderRadius, breakpoints } from 'blocks-design-system';
// Use theme values in your components
const customStyle = {
color: colors.primary,
padding: spacing.md,
fontSize: fontSizes.lg,
fontWeight: fontWeights.bold,
borderRadius: borderRadius.md,
};Development
Prerequisites
- Node.js >= 18
- npm or yarn
Getting Started
- Clone the repository
- Install dependencies:
npm install- Run tests:
npm test- Build the library:
npm run buildAvailable Scripts
npm run build- Build the library for productionnpm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage reportnpm run lint- Lint the codenpm run lint:fix- Lint and fix issuesnpm run format- Format code with Prettiernpm run format:check- Check code formattingnpm run typecheck- Run TypeScript type checking
Publishing to npm
Follow these steps to publish a release to npm. The project already includes a prepublishOnly script that runs npm run build before publishing.
- (Optional) Bump the package version and create a git tag:
npm version patch # or minor / major
git push --follow-tags- Build and inspect the package contents locally:
npm run build
npm pack --dry-run- Login and publish (interactive):
npm login
npm publish
# If your package is scoped and public, use:
# npm publish --access public- Publish using an npm automation token (CI or if you prefer non-interactive):
Set the token in your environment (Linux/macOS zsh):
export NPM_TOKEN="<your-token-here>"Create or update ~/.npmrc for the publish user (CI pipelines usually write this):
//registry.npmjs.org/:_authToken=${NPM_TOKEN}Then run:
npm publish- Verify the published version:
npm view blocks-design-system versions --json
npm info blocks-design-system- (Optional) Install the published package into the example app or a test project to smoke test:
cd example
npm install blocks-design-system@latest
npm run buildNotes
- Ensure
package.jsonnameandversionare correct before publishing. - If publishing a scoped package (e.g.,
@your-org/blocks-design-system) you must usenpm publish --access publicfor public scopes. - The repo already includes
files: ["dist"]so only thedistdirectory, README and package.json will be included in the published tarball.
Project Structure
blocks-design-system/
├── src/
│ ├── components/
│ │ ├── Button/
│ │ │ ├── Button.tsx
│ │ │ ├── Button.test.tsx
│ │ │ └── index.ts
│ │ └── Typography/
│ │ ├── Typography.tsx
│ │ ├── Typography.test.tsx
│ │ └── index.ts
│ ├── styles/
│ │ └── theme.ts
│ ├── index.ts
│ └── setupTests.ts
├── dist/ # Build output (generated)
├── .eslintrc.js # ESLint configuration
├── .prettierrc.json # Prettier configuration
├── jest.config.js # Jest configuration
├── rollup.config.js # Rollup bundler configuration
├── tsconfig.json # TypeScript configuration
└── package.jsonContributing
- Create a new branch for your feature
- Write tests for your changes
- Ensure all tests pass with
npm test - Ensure code is properly formatted with
npm run format - Ensure no linting errors with
npm run lint - Submit a pull request
License
ISC
