|
1 | | -# UI Kit for Cube Dev Projects |
| 1 | +# Cube UI Kit |
2 | 2 |
|
3 | | -Based on React Aria and `tasty` styling library. |
| 3 | +[](https://www.npmjs.com/package/@cube-dev/ui-kit) |
| 4 | +[](https://github.com/cube-js/cube-ui-kit/blob/main/LICENSE) |
4 | 5 |
|
5 | | -## Available Scripts |
| 6 | +An open-source React component library that powers [Cube Cloud](https://cubecloud.dev) and other [Cube Dev](https://cube.dev) products. While built for Cube's own interfaces, it is a general-purpose kit you can use freely in any application where it fits your needs. |
6 | 7 |
|
7 | | -### pnpm start |
| 8 | +**[Live Storybook](https://cube-ui-kit.vercel.app/)** · **[Tasty Docs](https://github.com/tenphi/tasty)** |
8 | 9 |
|
9 | | -Runs the test page in the development mode. |
10 | | -Open http://localhost:8080 to view it in the browser. |
| 10 | +## Highlights |
11 | 11 |
|
12 | | -The page will reload if you make edits. |
13 | | -You will also see any lint errors in the console. |
| 12 | +- **100+ production-ready components** — primitives (Button, Input), layout (Grid, Flex, Space), fields (Select, ComboBox, DatePicker), overlays (Dialog, Toast), and complex organisms (CommandMenu, FilterPicker, FileTabs). |
| 13 | +- **Accessible by default** — built on [React Aria](https://react-spectrum.adobe.com/react-aria/) with keyboard navigation, focus management, and screen reader support out of the box. |
| 14 | +- **Tasty styling engine** — declarative, token-aware styles with state-driven values, design tokens, responsive breakpoints, and zero specificity conflicts. See the [Tasty documentation](https://github.com/tenphi/tasty). |
| 15 | +- **Integrated form system** — async rule-based validation with field-level and form-level state management; fields plug in directly without extra wrapper components. |
| 16 | +- **TypeScript-first** — complete type definitions with autocomplete for tokens and style props. |
| 17 | +- **Tree-shakeable** — unbundled ESM output; import only what you use. |
14 | 18 |
|
15 | | -### pnpm storybook |
| 19 | +## Installation |
16 | 20 |
|
17 | | -Run storybook with all the components of UI Kit. |
| 21 | +```bash |
| 22 | +pnpm add @cube-dev/ui-kit |
| 23 | +``` |
18 | 24 |
|
19 | | -Deployed version of the Storybook from the `main` branch is here: https://cube-uikit-storybook.netlify.app/ |
| 25 | +Peer dependencies: |
20 | 26 |
|
21 | | -### pnpm build |
| 27 | +```bash |
| 28 | +pnpm add react react-dom |
| 29 | +``` |
22 | 30 |
|
23 | | -Builds a static copy of UIKit to the `dist/` folder. |
24 | | -Your app is ready to be deployed! |
| 31 | +React 18 and 19 are both supported. |
25 | 32 |
|
26 | | -### pnpm test |
| 33 | +## Quick Start |
27 | 34 |
|
28 | | -Not yet implemented |
| 35 | +Wrap your application with `Root` to initialize the design system: |
| 36 | + |
| 37 | +```tsx |
| 38 | +import { Root, Button, TextInput, Space } from '@cube-dev/ui-kit'; |
| 39 | + |
| 40 | +function App() { |
| 41 | + return ( |
| 42 | + <Root> |
| 43 | + <Space flow="column" gap="2x" padding="4x"> |
| 44 | + <TextInput label="Name" placeholder="Enter your name" /> |
| 45 | + <Button type="primary" onPress={() => console.log('clicked')}> |
| 46 | + Submit |
| 47 | + </Button> |
| 48 | + </Space> |
| 49 | + </Root> |
| 50 | + ); |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## Components |
| 55 | + |
| 56 | +| Category | Components | |
| 57 | +|----------|------------| |
| 58 | +| **Layout** | Flex, Grid, Space, Flow, Panel, ResizablePanel, Prefix, Suffix | |
| 59 | +| **Actions** | Button, Button.Group, Button.Split, Link, Menu, CommandMenu | |
| 60 | +| **Content** | Text, Title, Paragraph, Card, Badge, Tag, Avatar, Alert, Skeleton, Placeholder, Disclosure, Divider, CopySnippet, PrismCode | |
| 61 | +| **Fields** | TextInput, NumberInput, PasswordInput, SearchInput, TextArea, Select, ComboBox, Checkbox, RadioGroup, Switch, Slider, DatePicker, FileInput, ListBox, FilterListBox, FilterPicker, Picker | |
| 62 | +| **Form** | Form, FieldWrapper, SubmitButton, ResetButton | |
| 63 | +| **Overlays** | Dialog, AlertDialog, Modal, Tooltip, Toast, Notifications | |
| 64 | +| **Navigation** | Tabs, FileTabs | |
| 65 | +| **Status** | Spin, LoadingAnimation | |
| 66 | + |
| 67 | +Browse all components with live examples in the [Storybook](https://cube-ui-kit.vercel.app/). |
| 68 | + |
| 69 | +## Styling with Tasty |
| 70 | + |
| 71 | +Cube UI Kit uses [Tasty](https://github.com/tenphi/tasty) — a styling engine that generates conflict-free CSS using mutually exclusive selectors. Tasty documentation is included in this package under [`docs/tasty/`](./docs/tasty) and covers: |
| 72 | + |
| 73 | +- [Usage](./docs/tasty/usage.md) — component creation, state mappings, sub-elements, variants |
| 74 | +- [Configuration](./docs/tasty/configuration.md) — tokens, recipes, custom units, TypeScript extensions |
| 75 | +- [Style Properties](./docs/tasty/styles.md) — complete reference for all enhanced style properties |
| 76 | + |
| 77 | +Create custom styled components: |
| 78 | + |
| 79 | +```tsx |
| 80 | +import { tasty } from '@cube-dev/ui-kit'; |
| 81 | + |
| 82 | +const Card = tasty({ |
| 83 | + styles: { |
| 84 | + display: 'flex', |
| 85 | + flow: 'column', |
| 86 | + padding: '4x', |
| 87 | + gap: '2x', |
| 88 | + fill: '#surface', |
| 89 | + border: '#border', |
| 90 | + radius: '1r', |
| 91 | + |
| 92 | + Title: { preset: 'h3', color: '#primary' }, |
| 93 | + Content: { preset: 't2', color: '#text' }, |
| 94 | + }, |
| 95 | + elements: { Title: 'h2', Content: 'div' }, |
| 96 | +}); |
| 97 | +``` |
| 98 | + |
| 99 | +Style properties support state-driven values: |
| 100 | + |
| 101 | +```tsx |
| 102 | +const StatusBadge = tasty({ |
| 103 | + styles: { |
| 104 | + padding: '1x 2x', |
| 105 | + radius: 'round', |
| 106 | + fill: { |
| 107 | + '': '#surface', |
| 108 | + 'type=success': '#success-bg', |
| 109 | + 'type=error': '#danger-bg', |
| 110 | + }, |
| 111 | + }, |
| 112 | +}); |
| 113 | +``` |
| 114 | + |
| 115 | +## Development |
| 116 | + |
| 117 | +### Prerequisites |
| 118 | + |
| 119 | +- Node.js >= 22.14.0 |
| 120 | +- pnpm >= 10 |
| 121 | + |
| 122 | +### Scripts |
| 123 | + |
| 124 | +```bash |
| 125 | +pnpm storybook # Start Storybook dev server on port 6060 |
| 126 | +pnpm build # Build the library (tsdown, unbundled ESM) |
| 127 | +pnpm test # Run all tests (Vitest) |
| 128 | +pnpm test -- Button # Run tests matching "Button" |
| 129 | +pnpm fix # Lint and format (ESLint + Prettier) |
| 130 | +pnpm size # Check bundle size limits |
| 131 | +pnpm chromatic # Run visual regression tests |
| 132 | +``` |
| 133 | + |
| 134 | +### Project Structure |
| 135 | + |
| 136 | +``` |
| 137 | +src/ |
| 138 | +├── components/ |
| 139 | +│ ├── actions/ # Button, Link, Menu, CommandMenu, ... |
| 140 | +│ ├── content/ # Card, Badge, Tag, Alert, Skeleton, ... |
| 141 | +│ ├── fields/ # TextInput, Select, ComboBox, ... |
| 142 | +│ ├── form/ # Form, FieldWrapper, SubmitButton, ... |
| 143 | +│ ├── layout/ # Flex, Grid, Space, Flow, Panel, ... |
| 144 | +│ ├── navigation/ # Tabs |
| 145 | +│ ├── organisms/ # FileTabs, StatsCard |
| 146 | +│ ├── overlays/ # Dialog, Tooltip, Toast, ... |
| 147 | +│ └── status/ # Spin, LoadingAnimation |
| 148 | +├── icons/ # 130+ icon components (Tabler-based + custom) |
| 149 | +├── stories/ # Storybook guides and documentation |
| 150 | +├── tasty/ # Tasty integration utilities |
| 151 | +├── tokens/ # Design tokens |
| 152 | +└── index.ts # Public API barrel export |
| 153 | +docs/ |
| 154 | +└── tasty/ # Tasty styling engine documentation |
| 155 | +``` |
| 156 | + |
| 157 | +Each component follows a standard file layout: |
| 158 | + |
| 159 | +``` |
| 160 | +ComponentName/ |
| 161 | +├── ComponentName.tsx # Implementation |
| 162 | +├── ComponentName.stories.tsx # Storybook stories |
| 163 | +├── ComponentName.docs.mdx # Documentation |
| 164 | +├── ComponentName.test.tsx # Tests |
| 165 | +└── index.tsx # Re-exports |
| 166 | +``` |
| 167 | + |
| 168 | +## Contributing |
| 169 | + |
| 170 | +See [CONTRIBUTING.md](./CONTRIBUTING.md) for commit conventions, branch naming, PR workflow, and changeset instructions. |
29 | 171 |
|
30 | 172 | ## License |
31 | 173 |
|
32 | | -This project is licensed under the MIT License - see the LICENSE file for details. |
| 174 | +[MIT](./LICENSE) — Cube Dev, Inc. |
0 commit comments