@affinda/react 0.0.9 → 0.0.11

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 ADDED
@@ -0,0 +1,223 @@
1
+ # @affinda/react
2
+
3
+ React components for Affinda UI - built on web components with Stencil.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @affinda/react
9
+ # or
10
+ pnpm add @affinda/react
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Import Components
16
+
17
+ All components are available with or without the `Af` prefix:
18
+
19
+ ```tsx
20
+ // With Af prefix
21
+ import { AfButton, AfHeading, AfTypographyLockup } from '@affinda/react';
22
+
23
+ // Without prefix (cleaner)
24
+ import { Button, Heading, TypographyLockup } from '@affinda/react';
25
+ ```
26
+
27
+ ### Available Components
28
+
29
+ - **Button** / AfButton - Primary buttons with variants and icons
30
+ - **ButtonGroup** / AfButtonGroup - Group multiple buttons together
31
+ - **IconButton** / AfIconButton - Icon-only buttons
32
+ - **Heading** / AfHeading - Typography headings (H1-H6)
33
+ - **Text** / AfText - Body text components
34
+ - **TypographyLockup** / AfTypographyLockup - Composite heading + text + button layouts
35
+ - **Container** / AfContainer - Layout containers with max-width
36
+ - **AspectRatio** / AfAspectRatio - Maintain aspect ratios for media
37
+ - **ColorSwatch** / AfColorSwatch - Display color swatches
38
+ - **Logo** / AfLogo - Affinda logo component
39
+ - **Navbar** / AfNavbar - Navigation bar
40
+ - **NavItem** / AfNavItem - Navigation items
41
+
42
+ ### Icons
43
+
44
+ All Affinda icons are also exported:
45
+
46
+ ```tsx
47
+ import {
48
+ AccountIcon,
49
+ ArrowRightIcon,
50
+ CheckCircleIcon,
51
+ MenuIcon
52
+ } from '@affinda/react';
53
+ ```
54
+
55
+ ## Example Usage
56
+
57
+ ### Basic Button
58
+
59
+ ```tsx
60
+ import { Button } from '@affinda/react';
61
+
62
+ function App() {
63
+ return (
64
+ <Button variant="primary" size="default">
65
+ Click me
66
+ </Button>
67
+ );
68
+ }
69
+ ```
70
+
71
+ ### Button with Icons
72
+
73
+ ```tsx
74
+ import { Button, ArrowRightIcon } from '@affinda/react';
75
+
76
+ function App() {
77
+ return (
78
+ <Button variant="primary">
79
+ <svg slot="icon-left">
80
+ <ArrowRightIcon />
81
+ </svg>
82
+ Get Started
83
+ <svg slot="icon-right">
84
+ <ArrowRightIcon />
85
+ </svg>
86
+ </Button>
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### Typography Lockup
92
+
93
+ ```tsx
94
+ import { TypographyLockup, Button } from '@affinda/react';
95
+
96
+ function Hero() {
97
+ return (
98
+ <TypographyLockup
99
+ headingSize={1}
100
+ breakpoint="desktop"
101
+ textAlignment="center"
102
+ buttonAlignment="vertical"
103
+ >
104
+ <h1>Welcome to Affinda</h1>
105
+ <p slot="description">
106
+ Extract data from documents with AI-powered accuracy
107
+ </p>
108
+ <div slot="buttons">
109
+ <Button variant="primary">Get Started</Button>
110
+ <Button variant="secondary">Learn More</Button>
111
+ </div>
112
+ </TypographyLockup>
113
+ );
114
+ }
115
+ ```
116
+
117
+ ### Navigation
118
+
119
+ ```tsx
120
+ import { Navbar, NavItem, Logo } from '@affinda/react';
121
+
122
+ function Header() {
123
+ return (
124
+ <Navbar>
125
+ <Logo slot="logo" />
126
+ <NavItem hierarchy="primary" variant="01" href="/">
127
+ Home
128
+ </NavItem>
129
+ <NavItem hierarchy="primary" variant="01" href="/products">
130
+ Products
131
+ </NavItem>
132
+ <NavItem hierarchy="primary" variant="02" href="/docs">
133
+ Documentation
134
+ </NavItem>
135
+ </Navbar>
136
+ );
137
+ }
138
+ ```
139
+
140
+ ## Accessing Affinda Colors
141
+
142
+ Colors are available from the `@affinda/tokens` package (automatically installed as a dependency):
143
+
144
+ ```tsx
145
+ // Via CSS custom properties
146
+ import '@affinda/tokens/tokens.css';
147
+
148
+ const MyComponent = () => (
149
+ <div style={{
150
+ backgroundColor: 'var(--colour-brand-mist-green)',
151
+ color: 'var(--colour-brand-inkwell)'
152
+ }}>
153
+ Affinda branded content
154
+ </div>
155
+ );
156
+ ```
157
+
158
+ ```tsx
159
+ // Via JavaScript
160
+ import { tokens } from '@affinda/tokens';
161
+
162
+ const MyComponent = () => (
163
+ <div style={{
164
+ backgroundColor: tokens.color.brand.mistGreen.value,
165
+ color: tokens.color.brand.inkwell.value
166
+ }}>
167
+ Affinda branded content
168
+ </div>
169
+ );
170
+ ```
171
+
172
+ ### Available Affinda Colors
173
+
174
+ **Brand Colors:**
175
+ - Mist Green: `#C6D5D1` - `var(--colour-brand-mist-green)`
176
+ - Inkwell: `#14343B` - `var(--colour-brand-inkwell)`
177
+ - Soft Clay: `#B09670` - `var(--colour-brand-soft-clay)`
178
+ - Ice: `#A6FFF8` - `var(--colour-brand-ice)`
179
+ - Azure: `#7FE2D4` - `var(--colour-brand-azure)`
180
+ - Ivory Paper: `#FFF9E1` - `var(--colour-brand-ivory-paper)`
181
+ - White: `#FFFFFF` - `var(--colour-brand-white)`
182
+
183
+ **Tints:** Each color has tints from 20 (lightest) to 800 (darkest)
184
+ - `var(--colour-tints-mist-green-20)` through `var(--colour-tints-mist-green-800)`
185
+ - `var(--colour-tints-inkwell-20)` through `var(--colour-tints-inkwell-800)`
186
+ - And more...
187
+
188
+ See the [@affinda/tokens documentation](https://www.npmjs.com/package/@affinda/tokens) for the complete color palette.
189
+
190
+ ## TypeScript Support
191
+
192
+ Full TypeScript type definitions are included for all components and props.
193
+
194
+ ## For AI Agents
195
+
196
+ When generating Affinda UI code:
197
+
198
+ 1. **Always use Affinda brand colors:**
199
+ - Primary: Mist Green (`#C6D5D1`)
200
+ - Text: Inkwell (`#14343B`)
201
+ - Accent: Soft Clay (`#B09670`)
202
+ - Bright: Ice (`#A6FFF8`)
203
+
204
+ 2. **Use CSS custom properties:**
205
+ ```css
206
+ background: var(--colour-brand-mist-green);
207
+ color: var(--colour-brand-inkwell);
208
+ ```
209
+
210
+ 3. **Import the tokens CSS:**
211
+ ```tsx
212
+ import '@affinda/tokens/tokens.css';
213
+ ```
214
+
215
+ 4. **Never use purple colors** - those were placeholder colors and have been removed
216
+
217
+ ## Related Packages
218
+
219
+ - **@affinda/wc** - Core web components (used internally)
220
+ - **@affinda/tokens** - Design tokens (colors, spacing, typography)
221
+ - **@affinda/icons** - Icon library
222
+ - **@affinda/illustrations** - Illustration assets
223
+ - **@affinda/css** - Base CSS styles
@@ -5,6 +5,7 @@
5
5
  import { AfAspectRatio as AfAspectRatioElement } from "@affinda/wc/dist/components/af-aspect-ratio.js";
6
6
  import { AfButtonGroup as AfButtonGroupElement } from "@affinda/wc/dist/components/af-button-group.js";
7
7
  import { AfButton as AfButtonElement } from "@affinda/wc/dist/components/af-button.js";
8
+ import { AfCard as AfCardElement } from "@affinda/wc/dist/components/af-card.js";
8
9
  import { AfColorSwatch as AfColorSwatchElement } from "@affinda/wc/dist/components/af-color-swatch.js";
9
10
  import { AfContainer as AfContainerElement } from "@affinda/wc/dist/components/af-container.js";
10
11
  import { AfHeading as AfHeadingElement } from "@affinda/wc/dist/components/af-heading.js";
@@ -21,6 +22,8 @@ export type AfButtonEvents = NonNullable<unknown>;
21
22
  export declare const AfButton: StencilReactComponent<AfButtonElement, AfButtonEvents>;
22
23
  export type AfButtonGroupEvents = NonNullable<unknown>;
23
24
  export declare const AfButtonGroup: StencilReactComponent<AfButtonGroupElement, AfButtonGroupEvents>;
25
+ export type AfCardEvents = NonNullable<unknown>;
26
+ export declare const AfCard: StencilReactComponent<AfCardElement, AfCardEvents>;
24
27
  export type AfColorSwatchEvents = NonNullable<unknown>;
25
28
  export declare const AfColorSwatch: StencilReactComponent<AfColorSwatchElement, AfColorSwatchEvents>;
26
29
  export type AfContainerEvents = NonNullable<unknown>;
@@ -7,6 +7,7 @@
7
7
  import { AfAspectRatio as AfAspectRatioElement, defineCustomElement as defineAfAspectRatio } from "@affinda/wc/dist/components/af-aspect-ratio.js";
8
8
  import { AfButtonGroup as AfButtonGroupElement, defineCustomElement as defineAfButtonGroup } from "@affinda/wc/dist/components/af-button-group.js";
9
9
  import { AfButton as AfButtonElement, defineCustomElement as defineAfButton } from "@affinda/wc/dist/components/af-button.js";
10
+ import { AfCard as AfCardElement, defineCustomElement as defineAfCard } from "@affinda/wc/dist/components/af-card.js";
10
11
  import { AfColorSwatch as AfColorSwatchElement, defineCustomElement as defineAfColorSwatch } from "@affinda/wc/dist/components/af-color-swatch.js";
11
12
  import { AfContainer as AfContainerElement, defineCustomElement as defineAfContainer } from "@affinda/wc/dist/components/af-container.js";
12
13
  import { AfHeading as AfHeadingElement, defineCustomElement as defineAfHeading } from "@affinda/wc/dist/components/af-heading.js";
@@ -42,6 +43,14 @@ export const AfButtonGroup = /*@__PURE__*/ createComponent({
42
43
  events: {},
43
44
  defineCustomElement: defineAfButtonGroup
44
45
  });
46
+ export const AfCard = /*@__PURE__*/ createComponent({
47
+ tagName: 'af-card',
48
+ elementClass: AfCardElement,
49
+ // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
50
+ react: React,
51
+ events: {},
52
+ defineCustomElement: defineAfCard
53
+ });
45
54
  export const AfColorSwatch = /*@__PURE__*/ createComponent({
46
55
  tagName: 'af-color-swatch',
47
56
  elementClass: AfColorSwatchElement,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './generated/components.js';
2
- export * from '@affinda/wc/loader/index.js';
3
- export { AfAspectRatio as AspectRatio, AfButton as Button, AfButtonGroup as ButtonGroup, AfColorSwatch as ColorSwatch, AfContainer as Container, AfHeading as Heading, AfIconButton as IconButton, AfLogo as Logo, AfNavItem as NavItem, AfNavbar as Navbar, AfText as Text, AfTypographyLockup as TypographyLockup } from './generated/components.js';
2
+ export { AfAspectRatio as AspectRatio, AfButton as Button, AfButtonGroup as ButtonGroup, AfCard as Card, AfColorSwatch as ColorSwatch, AfContainer as Container, AfHeading as Heading, AfIconButton as IconButton, AfLogo as Logo, AfNavItem as NavItem, AfNavbar as Navbar, AfText as Text, AfTypographyLockup as TypographyLockup } from './generated/components.js';
4
3
  export * from '@affinda/icons/react';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Export everything from generated components (includes Af-prefixed names)
2
2
  export * from './generated/components.js';
3
- export * from '@affinda/wc/loader/index.js';
3
+ // Note: defineCustomElements should be imported directly from @affinda/wc/loader/index.js in your app
4
4
  // Re-export components without the 'Af' prefix for cleaner React usage
5
- export { AfAspectRatio as AspectRatio, AfButton as Button, AfButtonGroup as ButtonGroup, AfColorSwatch as ColorSwatch, AfContainer as Container, AfHeading as Heading, AfIconButton as IconButton, AfLogo as Logo, AfNavItem as NavItem, AfNavbar as Navbar, AfText as Text, AfTypographyLockup as TypographyLockup } from './generated/components.js';
5
+ export { AfAspectRatio as AspectRatio, AfButton as Button, AfButtonGroup as ButtonGroup, AfCard as Card, AfColorSwatch as ColorSwatch, AfContainer as Container, AfHeading as Heading, AfIconButton as IconButton, AfLogo as Logo, AfNavItem as NavItem, AfNavbar as Navbar, AfText as Text, AfTypographyLockup as TypographyLockup } from './generated/components.js';
6
6
  // Re-export React icon components from icons package
7
7
  export * from '@affinda/icons/react';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@affinda/react",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "private": false,
5
5
  "type": "module",
6
- "files": ["dist"],
6
+ "files": ["dist", "README.md"],
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@affinda/icons": "^0.0.3",
16
- "@affinda/wc": "^0.0.4",
16
+ "@affinda/wc": "^0.0.5",
17
17
  "@stencil/react-output-target": "^1.2.0"
18
18
  },
19
19
  "scripts": {