@shortstravelmgmt/component-lib 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -0
- package/dist/index.d.ts +2146 -0
- package/dist/index.esm.js +2163 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2296 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.css.map +1 -0
- package/package.json +118 -0
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @shortstravelmgmt/component-lib
|
|
2
|
+
|
|
3
|
+
A reusable React component library built with Storybook, designed for the STM Hub travel management platform. This library provides a consistent design system with accessible, customizable components organized using [Atomic Design](https://atomicdesign.bradfrost.com/) methodology.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@shortstravelmgmt/component-lib)
|
|
6
|
+
[](https://github.com/ShortsTravel/component-lib/actions/workflows/chromatic.yml)
|
|
7
|
+
[](https://github.com/ShortsTravel/component-lib/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
## ๐ Features
|
|
10
|
+
|
|
11
|
+
- **Atomic Design** - Organized into atoms, molecules, organisms, templates, and pages
|
|
12
|
+
- **React 18+** - Built with modern React features
|
|
13
|
+
- **TypeScript** - Full type safety and IntelliSense support
|
|
14
|
+
- **Storybook** - Interactive component documentation and testing
|
|
15
|
+
- **Chromatic** - Visual regression testing and review
|
|
16
|
+
- **Accessible** - WCAG 2.1 AA compliant components
|
|
17
|
+
- **Themeable** - CSS custom properties for easy theming
|
|
18
|
+
- **Tree-shakeable** - Only import what you need
|
|
19
|
+
|
|
20
|
+
## ๐ฆ Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @shortstravelmgmt/component-lib
|
|
24
|
+
# or
|
|
25
|
+
yarn add @shortstravelmgmt/component-lib
|
|
26
|
+
# or
|
|
27
|
+
pnpm add @shortstravelmgmt/component-lib
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## ๐ฏ Quick Start
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
// Atoms
|
|
35
|
+
Button,
|
|
36
|
+
Badge,
|
|
37
|
+
Avatar,
|
|
38
|
+
// Organisms
|
|
39
|
+
Card,
|
|
40
|
+
CardHeader,
|
|
41
|
+
CardBody,
|
|
42
|
+
// Molecules
|
|
43
|
+
SearchField,
|
|
44
|
+
FormField,
|
|
45
|
+
} from '@shortstravelmgmt/component-lib';
|
|
46
|
+
import '@shortstravelmgmt/component-lib/styles.css';
|
|
47
|
+
|
|
48
|
+
function App() {
|
|
49
|
+
return (
|
|
50
|
+
<Card>
|
|
51
|
+
<CardHeader>Trip Details</CardHeader>
|
|
52
|
+
<CardBody>
|
|
53
|
+
<Badge variant="success">Confirmed</Badge>
|
|
54
|
+
<Button variant="primary">View Itinerary</Button>
|
|
55
|
+
</CardBody>
|
|
56
|
+
</Card>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## ๐งฌ Atomic Design Structure
|
|
62
|
+
|
|
63
|
+
This library follows [Atomic Design](https://atomicdesign.bradfrost.com/) methodology by Brad Frost:
|
|
64
|
+
|
|
65
|
+
### ๐ต Atoms
|
|
66
|
+
Basic building blocks - the smallest functional units.
|
|
67
|
+
|
|
68
|
+
- **Button** - Primary interaction element with variants and sizes
|
|
69
|
+
- **Badge** - Status indicators and labels
|
|
70
|
+
- **Avatar** - User profile images or initials
|
|
71
|
+
- **Input / Textarea** - Text entry fields
|
|
72
|
+
- **Icons** - Visual symbols (30+ icons)
|
|
73
|
+
|
|
74
|
+
### ๐งช Molecules
|
|
75
|
+
Simple groups of atoms working together as a unit.
|
|
76
|
+
|
|
77
|
+
- **SearchField** - Search input with icon, clear button, and submit
|
|
78
|
+
- **FormField** - Label, input, helper text, and error message
|
|
79
|
+
- **NavItem** - Icon, label, and optional badge
|
|
80
|
+
|
|
81
|
+
### ๐ฆ Organisms
|
|
82
|
+
Complex components composed of molecules and atoms.
|
|
83
|
+
|
|
84
|
+
- **Card** - Content container with header, body, and footer
|
|
85
|
+
- **Sidenav** - Collapsible side navigation
|
|
86
|
+
- **Topbar** - Application header with account selector
|
|
87
|
+
|
|
88
|
+
### ๐ Templates
|
|
89
|
+
Page-level layouts defining content structure.
|
|
90
|
+
|
|
91
|
+
- **AppLayout** - Main application layout with Sidenav + Topbar
|
|
92
|
+
|
|
93
|
+
### ๐ฑ Pages
|
|
94
|
+
Templates with real representative content.
|
|
95
|
+
|
|
96
|
+
- **DashboardPage** - Example dashboard with stats and data tables
|
|
97
|
+
|
|
98
|
+
### Icons
|
|
99
|
+
- Travel icons (Plane, Car, Hotel, Bus, Rail, Limo)
|
|
100
|
+
- UI icons (Search, Filter, Calendar, Download, etc.)
|
|
101
|
+
- Navigation icons (Chevrons, Arrows)
|
|
102
|
+
- Status icons (Check, Warning, X)
|
|
103
|
+
|
|
104
|
+
## ๐ Documentation
|
|
105
|
+
|
|
106
|
+
Visit our [Storybook](https://storybook.stm-hub.com) for interactive documentation, examples, and API reference.
|
|
107
|
+
|
|
108
|
+
## ๐จ Theming
|
|
109
|
+
|
|
110
|
+
The library uses CSS custom properties for theming. Override them in your CSS:
|
|
111
|
+
|
|
112
|
+
```css
|
|
113
|
+
:root {
|
|
114
|
+
/* Primary colors */
|
|
115
|
+
--color-primary: #0A53EF;
|
|
116
|
+
--color-primary-dark: #1A43D1;
|
|
117
|
+
--color-primary-light: #E6ECFB;
|
|
118
|
+
|
|
119
|
+
/* Neutral colors */
|
|
120
|
+
--color-basecolor: #F5F5F5;
|
|
121
|
+
--border-color: #EDEDED;
|
|
122
|
+
|
|
123
|
+
/* Typography */
|
|
124
|
+
--font-family-base: 'Roboto Flex', system-ui, sans-serif;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
See `src/styles/tokens.css` for the complete list of design tokens.
|
|
129
|
+
|
|
130
|
+
## ๐ Development
|
|
131
|
+
|
|
132
|
+
### Prerequisites
|
|
133
|
+
|
|
134
|
+
- Node.js 18+
|
|
135
|
+
- npm 9+
|
|
136
|
+
|
|
137
|
+
### Setup
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Clone the repository
|
|
141
|
+
git clone https://github.com/ShortsTravel/component-lib.git
|
|
142
|
+
cd component-lib
|
|
143
|
+
|
|
144
|
+
# Install dependencies
|
|
145
|
+
npm install
|
|
146
|
+
|
|
147
|
+
# Start Storybook
|
|
148
|
+
npm run storybook
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Available Scripts
|
|
152
|
+
|
|
153
|
+
| Script | Description |
|
|
154
|
+
|--------|-------------|
|
|
155
|
+
| `npm run storybook` | Start Storybook dev server |
|
|
156
|
+
| `npm run build-storybook` | Build static Storybook |
|
|
157
|
+
| `npm run build:lib` | Build the library for publishing |
|
|
158
|
+
| `npm run lint` | Run ESLint |
|
|
159
|
+
| `npm test` | Run tests |
|
|
160
|
+
| `npm run chromatic` | Run visual regression tests |
|
|
161
|
+
|
|
162
|
+
## ๐ค Publishing
|
|
163
|
+
|
|
164
|
+
The package is automatically published to npm when a release is created:
|
|
165
|
+
|
|
166
|
+
1. Update version in `package.json`
|
|
167
|
+
2. Create a new GitHub release with the version tag
|
|
168
|
+
3. GitHub Actions will build and publish to npm
|
|
169
|
+
|
|
170
|
+
### Manual publishing
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npm run build:lib
|
|
174
|
+
npm publish --access public
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## ๐ CI/CD
|
|
178
|
+
|
|
179
|
+
- **CI Pipeline** - Runs on every push/PR: lint, typecheck, build
|
|
180
|
+
- **Chromatic** - Visual regression testing on every PR
|
|
181
|
+
- **Publish** - Automatic npm publishing on releases
|
|
182
|
+
|
|
183
|
+
## ๐ค Contributing
|
|
184
|
+
|
|
185
|
+
1. Fork the repository
|
|
186
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
187
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
188
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
189
|
+
5. Open a Pull Request
|
|
190
|
+
|
|
191
|
+
### Component Guidelines
|
|
192
|
+
|
|
193
|
+
- Use TypeScript for all components
|
|
194
|
+
- Include JSDoc comments for props
|
|
195
|
+
- Create Storybook stories for all variants
|
|
196
|
+
- Ensure accessibility (ARIA labels, keyboard navigation)
|
|
197
|
+
- Use CSS Modules for styling
|
|
198
|
+
- Export types alongside components
|
|
199
|
+
|
|
200
|
+
## ๐ License
|
|
201
|
+
|
|
202
|
+
MIT ยฉ [Short's Travel Management](https://stm-hub.com)
|
|
203
|
+
|
|
204
|
+
## ๐ Links
|
|
205
|
+
|
|
206
|
+
- [Storybook Documentation](https://storybook.stm-hub.com)
|
|
207
|
+
- [Chromatic Visual Tests](https://www.chromatic.com/library?appId=YOUR_APP_ID)
|
|
208
|
+
- [npm Package](https://www.npmjs.com/package/@shortstravelmgmt/component-lib)
|
|
209
|
+
- [GitHub Repository](https://github.com/ShortsTravel/component-lib)
|