@affinda/react 0.0.11 → 0.0.13

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 CHANGED
@@ -5,11 +5,65 @@ React components for Affinda UI - built on web components with Stencil.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @affinda/react
8
+ npm install @affinda/react @affinda/css
9
9
  # or
10
- pnpm add @affinda/react
10
+ pnpm add @affinda/react @affinda/css
11
11
  ```
12
12
 
13
+ ## Quick Start
14
+
15
+ ### 1. Import Styles and Initialize Components
16
+
17
+ ```tsx
18
+ // In your main.tsx or index.tsx
19
+ import '@affinda/css'; // Loads reset, fonts, tokens, base styles
20
+ import { defineCustomElements } from '@affinda/wc/loader';
21
+
22
+ // Initialize web components
23
+ defineCustomElements();
24
+ ```
25
+
26
+ ### 2. Use Components
27
+
28
+ ```tsx
29
+ import { Button, Navbar, Card } from '@affinda/react';
30
+
31
+ function App() {
32
+ return (
33
+ <div>
34
+ <Navbar>
35
+ <Button variant="primary">Get Started</Button>
36
+ </Navbar>
37
+ </div>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ### 3. Load NeuSans Font (Recommended)
43
+
44
+ Affinda components use the **NeuSans** font family. To get the authentic Affinda look:
45
+
46
+ 1. Obtain NeuSans font files (contact Affinda or your design team)
47
+ 2. Add @font-face declarations in your global CSS:
48
+
49
+ ```css
50
+ @font-face {
51
+ font-family: 'NeuSans';
52
+ font-style: normal;
53
+ font-weight: 500; /* Book weight for headings */
54
+ src: url('/fonts/NeuSans-Book.woff2') format('woff2');
55
+ }
56
+
57
+ @font-face {
58
+ font-family: 'NeuSans';
59
+ font-style: normal;
60
+ font-weight: 400; /* Regular weight */
61
+ src: url('/fonts/NeuSans-Regular.woff2') format('woff2');
62
+ }
63
+ ```
64
+
65
+ **Don't have NeuSans?** The components will gracefully fall back to Inter and system fonts.
66
+
13
67
  ## Usage
14
68
 
15
69
  ### Import Components
@@ -34,10 +88,230 @@ import { Button, Heading, TypographyLockup } from '@affinda/react';
34
88
  - **TypographyLockup** / AfTypographyLockup - Composite heading + text + button layouts
35
89
  - **Container** / AfContainer - Layout containers with max-width
36
90
  - **AspectRatio** / AfAspectRatio - Maintain aspect ratios for media
91
+ - **Card** / AfCard - Content cards with optional borders and shadows
37
92
  - **ColorSwatch** / AfColorSwatch - Display color swatches
38
93
  - **Logo** / AfLogo - Affinda logo component
39
94
  - **Navbar** / AfNavbar - Navigation bar
40
95
  - **NavItem** / AfNavItem - Navigation items
96
+ - **Testimonial** / AfTestimonial - Customer testimonials with background images, stats, and quotes
97
+ - **TestimonialCarousel** / AfTestimonialCarousel - Carousel for sliding between multiple testimonials
98
+ - **TestimonialStat** / AfTestimonialStat - Individual statistics within testimonials
99
+
100
+ ## Component Guide
101
+
102
+ ### When to Use Each Component
103
+
104
+ #### Layout & Structure
105
+
106
+ **Container**
107
+ - Use for all page sections to maintain consistent max-width and horizontal padding
108
+ - Creates responsive layouts that don't span the full viewport on large screens
109
+ - Best practice: Wrap each major section of your page in a Container
110
+
111
+ ```tsx
112
+ <Container>
113
+ <Heading level="2">Section Title</Heading>
114
+ <Text>Section content goes here...</Text>
115
+ </Container>
116
+ ```
117
+
118
+ **AspectRatio**
119
+ - Maintain consistent dimensions for images, videos, or media
120
+ - Prevents layout shift during content loading
121
+ - Common ratios: `16/9` (video), `1/1` (square), `4/3` (legacy video)
122
+
123
+ ```tsx
124
+ <AspectRatio ratio="16/9">
125
+ <img src="video-thumbnail.jpg" alt="Preview" />
126
+ </AspectRatio>
127
+ ```
128
+
129
+ **Card**
130
+ - Group related content with visual separation
131
+ - Use for feature highlights, product listings, or content previews
132
+ - Supports borders and elevation for depth
133
+
134
+ ```tsx
135
+ <Card>
136
+ <Heading level="3">Feature Title</Heading>
137
+ <Text>Feature description...</Text>
138
+ </Card>
139
+ ```
140
+
141
+ #### Typography
142
+
143
+ **Heading**
144
+ - Use semantic heading levels (1-6) for SEO and accessibility
145
+ - Level 1: Page title (use once per page)
146
+ - Level 2: Major sections
147
+ - Level 3-4: Subsections
148
+ - Never skip heading levels
149
+
150
+ ```tsx
151
+ <Heading level="1">Page Title</Heading>
152
+ <Heading level="2">Section Title</Heading>
153
+ <Heading level="3">Subsection</Heading>
154
+ ```
155
+
156
+ **Text**
157
+ - Use for all body text, descriptions, and paragraphs
158
+ - Variants: `default`, `small`, `large`
159
+ - Automatically uses NeuSans font
160
+
161
+ ```tsx
162
+ <Text variant="large">Introductory paragraph with emphasis</Text>
163
+ <Text>Standard body text</Text>
164
+ <Text variant="small">Fine print or captions</Text>
165
+ ```
166
+
167
+ **TypographyLockup**
168
+ - Composite component for hero sections and major content blocks
169
+ - Automatically handles heading + description + buttons layout
170
+ - Supports different breakpoints and alignments
171
+ - Use for: Hero sections, feature highlights, CTAs
172
+
173
+ ```tsx
174
+ <TypographyLockup
175
+ headingSize={1}
176
+ textAlignment="center"
177
+ buttonAlignment="horizontal"
178
+ >
179
+ <Heading level="1">Automate Your Workflow</Heading>
180
+ <Text slot="description">Extract data from documents in seconds</Text>
181
+ <div slot="buttons">
182
+ <Button variant="primary">Get Started</Button>
183
+ <Button variant="secondary">Learn More</Button>
184
+ </div>
185
+ </TypographyLockup>
186
+ ```
187
+
188
+ #### Buttons & Actions
189
+
190
+ **Button**
191
+ - Primary actions: Use `variant="primary"` (sparingly, 1-2 per screen)
192
+ - Secondary actions: Use `variant="secondary"`
193
+ - Sizes: `small`, `default`, `large`
194
+ - Can include icons in left or right slots
195
+
196
+ ```tsx
197
+ <Button variant="primary" size="large">Sign Up Now</Button>
198
+ <Button variant="secondary">Learn More</Button>
199
+ ```
200
+
201
+ **ButtonGroup**
202
+ - Group related buttons with consistent spacing
203
+ - Maintains visual hierarchy and alignment
204
+
205
+ ```tsx
206
+ <ButtonGroup>
207
+ <Button variant="primary">Save</Button>
208
+ <Button variant="secondary">Cancel</Button>
209
+ </ButtonGroup>
210
+ ```
211
+
212
+ **IconButton**
213
+ - Use for toolbar actions, navigation controls, or when space is limited
214
+ - Always include aria-label for accessibility
215
+ - Common uses: Close buttons, navigation arrows, menu toggles
216
+
217
+ ```tsx
218
+ <IconButton variant="secondary" aria-label="Close dialog">
219
+ <svg>...</svg>
220
+ </IconButton>
221
+ ```
222
+
223
+ #### Navigation
224
+
225
+ **Navbar**
226
+ - Site-wide navigation header
227
+ - Responsive design with mobile menu support
228
+ - Include Logo in the `logo` slot
229
+
230
+ ```tsx
231
+ <Navbar>
232
+ <Logo slot="logo" />
233
+ <NavItem hierarchy="primary" href="/">Home</NavItem>
234
+ <NavItem hierarchy="primary" href="/about">About</NavItem>
235
+ <NavItem hierarchy="secondary" href="/login">Log In</NavItem>
236
+ </Navbar>
237
+ ```
238
+
239
+ **NavItem**
240
+ - Individual navigation links
241
+ - Hierarchy: `primary` (main nav), `secondary` (utility nav)
242
+ - Variant: Controls visual style
243
+
244
+ #### Social Proof & Testimonials
245
+
246
+ **Testimonial**
247
+ - Showcase customer success stories with rich media
248
+ - Include: background image, logo, quote, attribution, and statistics
249
+ - Use within TestimonialCarousel for multiple testimonials
250
+
251
+ ```tsx
252
+ <Testimonial
253
+ backgroundImage="https://example.com/background.jpg"
254
+ logoImage="https://example.com/company-logo.png"
255
+ quote="Affinda transformed our document processing workflow."
256
+ attribution="– Jane Doe, CEO, Company Name"
257
+ readMoreLink="https://example.com/case-study"
258
+ >
259
+ <div slot="stats">
260
+ <TestimonialStat value="95%" description="reduction in processing time" />
261
+ <TestimonialStat value="10×" description="increase in throughput" />
262
+ </div>
263
+ </Testimonial>
264
+ ```
265
+
266
+ **TestimonialCarousel**
267
+ - Automatically handles navigation between multiple testimonials
268
+ - Includes slide animations and progress indicators
269
+ - Navigation buttons positioned for optimal UX
270
+ - Just wrap multiple Testimonial components
271
+
272
+ ```tsx
273
+ <TestimonialCarousel>
274
+ <Testimonial {...testimonial1Props}>
275
+ <div slot="stats">...</div>
276
+ </Testimonial>
277
+ <Testimonial {...testimonial2Props}>
278
+ <div slot="stats">...</div>
279
+ </Testimonial>
280
+ </TestimonialCarousel>
281
+ ```
282
+
283
+ **TestimonialStat**
284
+ - Display key metrics within testimonials
285
+ - Use 2-4 stats per testimonial for best impact
286
+ - Optional accent border for qualitative statements
287
+
288
+ ```tsx
289
+ <TestimonialStat value="99%" description="accuracy rate" />
290
+ <TestimonialStat
291
+ value=""
292
+ description="Reduced manual errors significantly"
293
+ accentBorder={true}
294
+ />
295
+ ```
296
+
297
+ #### Branding
298
+
299
+ **Logo**
300
+ - Affinda logo component with consistent sizing
301
+ - Use in Navbar and footer
302
+ - Automatically handles light/dark variants
303
+
304
+ ```tsx
305
+ <Logo />
306
+ ```
307
+
308
+ **ColorSwatch**
309
+ - Display color palettes or design tokens
310
+ - Useful for style guides and documentation
311
+
312
+ ```tsx
313
+ <ColorSwatch color="#C6D5D1" label="Mist Green" />
314
+ ```
41
315
 
42
316
  ### Icons
43
317
 
@@ -13,6 +13,9 @@ import { AfIconButton as AfIconButtonElement } from "@affinda/wc/dist/components
13
13
  import { AfLogo as AfLogoElement } from "@affinda/wc/dist/components/af-logo.js";
14
14
  import { AfNavItem as AfNavItemElement } from "@affinda/wc/dist/components/af-nav-item.js";
15
15
  import { AfNavbar as AfNavbarElement } from "@affinda/wc/dist/components/af-navbar.js";
16
+ import { AfTestimonialCarousel as AfTestimonialCarouselElement } from "@affinda/wc/dist/components/af-testimonial-carousel.js";
17
+ import { AfTestimonialStat as AfTestimonialStatElement } from "@affinda/wc/dist/components/af-testimonial-stat.js";
18
+ import { AfTestimonial as AfTestimonialElement } from "@affinda/wc/dist/components/af-testimonial.js";
16
19
  import { AfText as AfTextElement } from "@affinda/wc/dist/components/af-text.js";
17
20
  import { AfTypographyLockup as AfTypographyLockupElement } from "@affinda/wc/dist/components/af-typography-lockup.js";
18
21
  import type { StencilReactComponent } from '@stencil/react-output-target/runtime';
@@ -38,6 +41,12 @@ export type AfNavItemEvents = NonNullable<unknown>;
38
41
  export declare const AfNavItem: StencilReactComponent<AfNavItemElement, AfNavItemEvents>;
39
42
  export type AfNavbarEvents = NonNullable<unknown>;
40
43
  export declare const AfNavbar: StencilReactComponent<AfNavbarElement, AfNavbarEvents>;
44
+ export type AfTestimonialEvents = NonNullable<unknown>;
45
+ export declare const AfTestimonial: StencilReactComponent<AfTestimonialElement, AfTestimonialEvents>;
46
+ export type AfTestimonialCarouselEvents = NonNullable<unknown>;
47
+ export declare const AfTestimonialCarousel: StencilReactComponent<AfTestimonialCarouselElement, AfTestimonialCarouselEvents>;
48
+ export type AfTestimonialStatEvents = NonNullable<unknown>;
49
+ export declare const AfTestimonialStat: StencilReactComponent<AfTestimonialStatElement, AfTestimonialStatEvents>;
41
50
  export type AfTextEvents = NonNullable<unknown>;
42
51
  export declare const AfText: StencilReactComponent<AfTextElement, AfTextEvents>;
43
52
  export type AfTypographyLockupEvents = NonNullable<unknown>;
@@ -15,6 +15,9 @@ import { AfIconButton as AfIconButtonElement, defineCustomElement as defineAfIco
15
15
  import { AfLogo as AfLogoElement, defineCustomElement as defineAfLogo } from "@affinda/wc/dist/components/af-logo.js";
16
16
  import { AfNavItem as AfNavItemElement, defineCustomElement as defineAfNavItem } from "@affinda/wc/dist/components/af-nav-item.js";
17
17
  import { AfNavbar as AfNavbarElement, defineCustomElement as defineAfNavbar } from "@affinda/wc/dist/components/af-navbar.js";
18
+ import { AfTestimonialCarousel as AfTestimonialCarouselElement, defineCustomElement as defineAfTestimonialCarousel } from "@affinda/wc/dist/components/af-testimonial-carousel.js";
19
+ import { AfTestimonialStat as AfTestimonialStatElement, defineCustomElement as defineAfTestimonialStat } from "@affinda/wc/dist/components/af-testimonial-stat.js";
20
+ import { AfTestimonial as AfTestimonialElement, defineCustomElement as defineAfTestimonial } from "@affinda/wc/dist/components/af-testimonial.js";
18
21
  import { AfText as AfTextElement, defineCustomElement as defineAfText } from "@affinda/wc/dist/components/af-text.js";
19
22
  import { AfTypographyLockup as AfTypographyLockupElement, defineCustomElement as defineAfTypographyLockup } from "@affinda/wc/dist/components/af-typography-lockup.js";
20
23
  import { createComponent } from '@stencil/react-output-target/runtime';
@@ -107,6 +110,30 @@ export const AfNavbar = /*@__PURE__*/ createComponent({
107
110
  events: {},
108
111
  defineCustomElement: defineAfNavbar
109
112
  });
113
+ export const AfTestimonial = /*@__PURE__*/ createComponent({
114
+ tagName: 'af-testimonial',
115
+ elementClass: AfTestimonialElement,
116
+ // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
117
+ react: React,
118
+ events: {},
119
+ defineCustomElement: defineAfTestimonial
120
+ });
121
+ export const AfTestimonialCarousel = /*@__PURE__*/ createComponent({
122
+ tagName: 'af-testimonial-carousel',
123
+ elementClass: AfTestimonialCarouselElement,
124
+ // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
125
+ react: React,
126
+ events: {},
127
+ defineCustomElement: defineAfTestimonialCarousel
128
+ });
129
+ export const AfTestimonialStat = /*@__PURE__*/ createComponent({
130
+ tagName: 'af-testimonial-stat',
131
+ elementClass: AfTestimonialStatElement,
132
+ // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
133
+ react: React,
134
+ events: {},
135
+ defineCustomElement: defineAfTestimonialStat
136
+ });
110
137
  export const AfText = /*@__PURE__*/ createComponent({
111
138
  tagName: 'af-text',
112
139
  elementClass: AfTextElement,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * 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';
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, AfTestimonial as Testimonial, AfTestimonialCarousel as TestimonialCarousel, AfTestimonialStat as TestimonialStat, AfTypographyLockup as TypographyLockup } from './generated/components.js';
3
3
  export * from '@affinda/icons/react';
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@
2
2
  export * from './generated/components.js';
3
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, 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';
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, AfTestimonial as Testimonial, AfTestimonialCarousel as TestimonialCarousel, AfTestimonialStat as TestimonialStat, 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@affinda/react",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": ["dist", "README.md"],
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@affinda/icons": "^0.0.3",
16
- "@affinda/wc": "^0.0.5",
16
+ "@affinda/wc": "^0.0.7",
17
17
  "@stencil/react-output-target": "^1.2.0"
18
18
  },
19
19
  "scripts": {