onecart-ui 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 +186 -0
- package/dist/Button/Button.mobile.d.ts +4 -0
- package/dist/Button/Button.types.d.ts +43 -0
- package/dist/Button/Button.web.d.ts +4 -0
- package/dist/Button/buttonStyles.d.ts +12 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Button/index.mobile.d.ts +1 -0
- package/dist/Typography/Body/index.d.ts +3 -0
- package/dist/Typography/Display/index.d.ts +3 -0
- package/dist/Typography/Heading/index.d.ts +3 -0
- package/dist/Typography/Utility/index.d.ts +3 -0
- package/dist/Typography/index.d.ts +4 -0
- package/dist/components/Button.d.ts +1 -0
- package/dist/components/Icon.d.ts +10 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2057 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mobile.js +1803 -0
- package/dist/index.mobile.js.map +1 -0
- package/dist/mobile/index.d.ts +2 -0
- package/dist/src/Button/Button.mobile.d.ts +4 -0
- package/dist/src/Button/Button.types.d.ts +43 -0
- package/dist/src/Button/Button.web.d.ts +4 -0
- package/dist/src/Button/buttonStyles.d.ts +12 -0
- package/dist/src/Button/index.d.ts +2 -0
- package/dist/src/Button/index.mobile.d.ts +2 -0
- package/dist/src/Typography/Body/Body.mobile.d.ts +3 -0
- package/dist/src/Typography/Body/Body.web.d.ts +3 -0
- package/dist/src/Typography/Body/index.d.ts +1 -0
- package/dist/src/Typography/Body/index.mobile.d.ts +1 -0
- package/dist/src/Typography/Display/Display.mobile.d.ts +3 -0
- package/dist/src/Typography/Display/Display.web.d.ts +3 -0
- package/dist/src/Typography/Display/index.d.ts +1 -0
- package/dist/src/Typography/Display/index.mobile.d.ts +1 -0
- package/dist/src/Typography/Heading/Heading.mobile.d.ts +3 -0
- package/dist/src/Typography/Heading/Heading.web.d.ts +3 -0
- package/dist/src/Typography/Heading/index.d.ts +1 -0
- package/dist/src/Typography/Heading/index.mobile.d.ts +1 -0
- package/dist/src/Typography/Typography.types.d.ts +51 -0
- package/dist/src/Typography/Utility/Utility.mobile.d.ts +3 -0
- package/dist/src/Typography/Utility/Utility.web.d.ts +3 -0
- package/dist/src/Typography/Utility/index.d.ts +1 -0
- package/dist/src/Typography/Utility/index.mobile.d.ts +1 -0
- package/dist/src/Typography/index.d.ts +5 -0
- package/dist/src/Typography/index.mobile.d.ts +5 -0
- package/dist/src/components/Button.d.ts +1 -0
- package/dist/src/components/Icon.d.ts +10 -0
- package/dist/src/components/index.d.ts +4 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/styles/tokens/typography.d.ts +138 -0
- package/dist/src/theme/ThemeProvider.d.ts +5 -0
- package/dist/src/tokens/design-tokens.d.ts +54 -0
- package/dist/styles/tokens/typography.d.ts +138 -0
- package/dist/theme/ThemeProvider.d.ts +5 -0
- package/dist/tokens/design-tokens.d.ts +54 -0
- package/dist/types/Button.d.ts +24 -0
- package/dist/types/Typography.d.ts +32 -0
- package/package.json +102 -0
- package/tokens/tokens.css +7 -0
- package/tokens/tokens.d.ts +2 -0
- package/tokens/tokens.js +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# OneCart UI
|
|
2
|
+
|
|
3
|
+
Cross-platform design system with React & React Native components and design tokens.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install onecart-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### For Web Projects (React)
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Import components
|
|
17
|
+
import { Button, Typography } from 'onecart-ui';
|
|
18
|
+
// Import tokens
|
|
19
|
+
import { tokens } from 'onecart-ui/tokens';
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<Typography.Heading size="xl">Welcome</Typography.Heading>
|
|
25
|
+
<Typography.Body size="md">This is a web component</Typography.Body>
|
|
26
|
+
<Button variant="primary" onClick={() => alert('Clicked!')}>
|
|
27
|
+
Click Me
|
|
28
|
+
</Button>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### For Mobile Projects (React Native)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Import mobile components
|
|
38
|
+
import { Button, Typography } from 'onecart-ui/mobile';
|
|
39
|
+
// Import tokens
|
|
40
|
+
import { tokens } from 'onecart-ui/tokens';
|
|
41
|
+
|
|
42
|
+
function App() {
|
|
43
|
+
return (
|
|
44
|
+
<View>
|
|
45
|
+
<Typography.Heading size="xl">Welcome</Typography.Heading>
|
|
46
|
+
<Typography.Body size="md">This is a mobile component</Typography.Body>
|
|
47
|
+
<Button variant="primary" onPress={() => alert('Pressed!')}>
|
|
48
|
+
Press Me
|
|
49
|
+
</Button>
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### For Mobile Projects (React Native)
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Web tokens
|
|
59
|
+
import { tokens } from 'onecart-ui/tokens/web';
|
|
60
|
+
|
|
61
|
+
// Mobile tokens
|
|
62
|
+
import { tokens } from 'onecart-ui/tokens/mobile';
|
|
63
|
+
|
|
64
|
+
// Use tokens in your styles
|
|
65
|
+
const styles = {
|
|
66
|
+
color: tokens.NEUTRAL_80,
|
|
67
|
+
fontSize: tokens.BODY_MD_FONT_SIZE,
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Components
|
|
72
|
+
|
|
73
|
+
- **Button**: Primary, secondary, and tertiary variants for web and mobile
|
|
74
|
+
- **Typography**: Body, Display, Heading, and Utility text components
|
|
75
|
+
- Each with multiple size options
|
|
76
|
+
- Platform-specific implementations (web/mobile)
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
This is a monorepo managed with npm workspaces and Turbo.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install dependencies
|
|
84
|
+
npm install
|
|
85
|
+
|
|
86
|
+
# Build all packages
|
|
87
|
+
npm run build
|
|
88
|
+
|
|
89
|
+
# Run development mode
|
|
90
|
+
npm run dev
|
|
91
|
+
|
|
92
|
+
# Generate design tokens
|
|
93
|
+
npm run generate-tokens
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Package Structure
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
onecart-ui/
|
|
100
|
+
dist/ # Built components (web & mobile)
|
|
101
|
+
tokens/ # Design tokens (CSS, JS)
|
|
102
|
+
packages/
|
|
103
|
+
tokens/ # Token source & generator
|
|
104
|
+
components/ # Component source
|
|
105
|
+
apps/
|
|
106
|
+
docs/ # Storybook documentation
|
|
107
|
+
```
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### For Mobile Projects (React Native)
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// Import components from /mobile
|
|
119
|
+
import { Button, Body, Display, Heading, Utility } from 'onecart-ui-components/mobile';
|
|
120
|
+
|
|
121
|
+
// Import types
|
|
122
|
+
import type { ButtonProps, BodyProps, DisplayProps, HeadingProps, UtilityProps } from 'onecart-ui-components/mobile';
|
|
123
|
+
|
|
124
|
+
// Usage
|
|
125
|
+
function App() {
|
|
126
|
+
return (
|
|
127
|
+
<View>
|
|
128
|
+
<Display size="2xl">Welcome to OneCart</Display>
|
|
129
|
+
<Body size="lg">A cross-platform design system</Body>
|
|
130
|
+
<Button
|
|
131
|
+
label="Get Started"
|
|
132
|
+
type="primary"
|
|
133
|
+
size="large"
|
|
134
|
+
onPress={() => console.log('Pressed!')}
|
|
135
|
+
/>
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Available Components
|
|
142
|
+
|
|
143
|
+
**Button**
|
|
144
|
+
|
|
145
|
+
- Types: `primary`, `outline`, `ghost`, `destructive`
|
|
146
|
+
- Sizes: `large`, `medium`, `small`
|
|
147
|
+
- Supports icons, full width, and platform-specific handlers
|
|
148
|
+
|
|
149
|
+
**Typography Components**
|
|
150
|
+
|
|
151
|
+
- **Body**: Text component with sizes `xl`, `lg`, `md`, `sm`
|
|
152
|
+
- **Display**: Large heading with sizes `2xl`, `xl`
|
|
153
|
+
- **Heading**: Semantic headings with sizes `xl`, `lg`, `md`, `sm`, `xs`, `2xs`
|
|
154
|
+
- **Utility**: Utility text with variants `button`, `link`, `caption`
|
|
155
|
+
|
|
156
|
+
All typography components support:
|
|
157
|
+
|
|
158
|
+
- `align`: Text alignment (`left`, `center`, `right`)
|
|
159
|
+
- `color`: Custom color override
|
|
160
|
+
- `truncate`: Single-line truncation with ellipsis
|
|
161
|
+
- `lineClamp`: Multi-line clamping
|
|
162
|
+
- `onClick` (web) / `onPress` (mobile): Click/press handlers
|
|
163
|
+
|
|
164
|
+
## Next Steps
|
|
165
|
+
|
|
166
|
+
See bottom of generated setup output for roadmap suggestions.
|
|
167
|
+
|
|
168
|
+
## Token Sync (Figma / Tokens Studio)
|
|
169
|
+
|
|
170
|
+
The tokens pipeline supports pulling design tokens from a Figma file using `figma-token-engine`.
|
|
171
|
+
|
|
172
|
+
1. Copy `.env.example` to `.env` at repo root.
|
|
173
|
+
2. Fill in:
|
|
174
|
+
|
|
175
|
+
- `FIGMA_PERSONAL_ACCESS_TOKEN`
|
|
176
|
+
- `FIGMA_FILE_ID`
|
|
177
|
+
|
|
178
|
+
3. Generate tokens:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run generate-tokens
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
4. Generated JSON will appear under `packages/tokens/src/styles/tokens/` (if the engine outputs there). Currently only generation is configured; Style Dictionary build scripts were removed temporarily and can be reintroduced later.
|
|
185
|
+
|
|
186
|
+
If sync fails, verify your PAT scopes and that the file ID matches the Figma URL segment after `/file/`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ButtonType = "primary" | "outline" | "ghost" | "destructive";
|
|
2
|
+
export type ButtonSize = "large" | "small" | "medium";
|
|
3
|
+
export type ButtonState = "default" | "hover" | "active" | "disabled";
|
|
4
|
+
export interface ButtonProps {
|
|
5
|
+
/** Visible text label (also used as accessible name fallback). */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Visual variant; defaults to `primary`. */
|
|
8
|
+
type?: ButtonType;
|
|
9
|
+
/** Size scale; defaults to `large`. */
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
/** Disables interaction and applies disabled styling. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Icon name rendered to the left of label (ignored if `icon` provided). */
|
|
14
|
+
leftIcon?: string;
|
|
15
|
+
/** Icon name rendered to the right of label (ignored if `icon` provided). */
|
|
16
|
+
rightIcon?: string;
|
|
17
|
+
/** Single icon (icon‑only button); when set, label text is visually hidden. */
|
|
18
|
+
icon?: string;
|
|
19
|
+
/** Stretches button to width:100%. */
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
/** Underlines text for `ghost` variant when not disabled (default true). */
|
|
22
|
+
ghostUnderline?: boolean;
|
|
23
|
+
/** Explicit accessible label (overrides fallback to `label`). */
|
|
24
|
+
accessibilityLabel?: string;
|
|
25
|
+
/** Test identifier (data-testid on web). */
|
|
26
|
+
testID?: string;
|
|
27
|
+
/** Additional CSS class name for web implementation only. */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Style override: React.CSSProperties (web) or RN style object (mobile). */
|
|
30
|
+
style?: React.CSSProperties | Record<string, unknown>;
|
|
31
|
+
/** Web click handler; executes alongside `onPress` if both supplied. */
|
|
32
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
/** Platform‑agnostic press handler (used by mobile; also invoked on web clicks). */
|
|
34
|
+
onPress?: () => void;
|
|
35
|
+
/** Mouse enter hook (web only). */
|
|
36
|
+
onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
37
|
+
/** Mouse leave hook (web only). */
|
|
38
|
+
onMouseLeave?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
39
|
+
/** Mouse down hook (web only). */
|
|
40
|
+
onMouseDown?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
41
|
+
/** Mouse up hook (web only). */
|
|
42
|
+
onMouseUp?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ButtonState, ButtonType, ButtonSize } from "./Button.types";
|
|
2
|
+
import type { ViewStyle, TextStyle } from "react-native";
|
|
3
|
+
export interface ComputedButtonStyles {
|
|
4
|
+
base: React.CSSProperties;
|
|
5
|
+
text: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
export declare const computeWebButtonStyles: (type: ButtonType, state: ButtonState, size: ButtonSize, isIconOnly: boolean, fullWidth: boolean, hasBothIcons: boolean, overrides?: Partial<React.CSSProperties>) => ComputedButtonStyles;
|
|
8
|
+
export interface MobileButtonStyles {
|
|
9
|
+
container: ViewStyle;
|
|
10
|
+
label: TextStyle;
|
|
11
|
+
}
|
|
12
|
+
export declare const computeMobileButtonStyles: (type: ButtonType, state: ButtonState, size: ButtonSize, overrides?: Partial<ViewStyle>) => MobileButtonStyles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Button.web";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Button.mobile";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from "../Button/Button.web";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Button";
|