@capra/core 1.5.3 → 1.7.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/dist/index.cjs +42 -78
- package/dist/index.d.cts +8 -2
- package/dist/index.d.mts +8 -2
- package/dist/index.mjs +42 -78
- package/dist/style.css +62 -32
- package/docs/conventions--docs.md +186 -0
- package/docs/core-alert--design.md +110 -0
- package/docs/core-alert--usage.md +13 -0
- package/docs/core-anchor--design.md +39 -0
- package/docs/core-anchor--usage.md +39 -0
- package/docs/core-autocompletefield--design.md +91 -0
- package/docs/core-autocompletefield--usage.md +18 -0
- package/docs/core-badge--design.md +70 -0
- package/docs/core-badge--usage.md +13 -0
- package/docs/core-breadcrumbs--design.md +65 -0
- package/docs/core-breadcrumbs--usage.md +16 -0
- package/docs/core-button--design.md +97 -0
- package/docs/core-button--usage.md +17 -0
- package/docs/core-buttonlink--design.md +7 -0
- package/docs/core-buttonlink--usage.md +24 -0
- package/docs/core-card--design.md +100 -0
- package/docs/core-card--usage.md +5 -0
- package/docs/core-checkbox--design.md +66 -0
- package/docs/core-checkbox--usage.md +34 -0
- package/docs/core-collapse--design.md +28 -0
- package/docs/core-collapse--usage.md +20 -0
- package/docs/core-datepickerfield--design.md +71 -0
- package/docs/core-datepickerfield--usage.md +57 -0
- package/docs/core-daterangepickerfield--design.md +76 -0
- package/docs/core-daterangepickerfield--usage.md +62 -0
- package/docs/core-divider--design.md +35 -0
- package/docs/core-divider--usage.md +8 -0
- package/docs/core-drawer--design.md +87 -0
- package/docs/core-drawer--usage.md +9 -0
- package/docs/core-emptystate--design.md +45 -0
- package/docs/core-emptystate--usage.md +13 -0
- package/docs/core-helpertext--design.md +30 -0
- package/docs/core-helpertext--usage.md +11 -0
- package/docs/core-iconbutton--design.md +87 -0
- package/docs/core-iconbutton--usage.md +15 -0
- package/docs/core-inputrow--design.md +85 -0
- package/docs/core-inputrow--usage.md +6 -0
- package/docs/core-label--design.md +27 -0
- package/docs/core-label--usage.md +17 -0
- package/docs/core-link--design.md +58 -0
- package/docs/core-link--usage.md +16 -0
- package/docs/core-listitem--design.md +70 -0
- package/docs/core-listitem--usage.md +6 -0
- package/docs/core-menu--design.md +106 -0
- package/docs/core-menu--usage.md +16 -0
- package/docs/core-modal--design.md +39 -0
- package/docs/core-modal--usage.md +11 -0
- package/docs/core-numberfield--design.md +12 -0
- package/docs/core-numberfield--usage.md +14 -0
- package/docs/core-pagination--design.md +30 -0
- package/docs/core-pagination--usage.md +13 -0
- package/docs/core-passwordfield--design.md +7 -0
- package/docs/core-passwordfield--usage.md +3 -0
- package/docs/core-pill--design.md +94 -0
- package/docs/core-pill--usage.md +10 -0
- package/docs/core-popover--design.md +25 -0
- package/docs/core-popover--usage.md +8 -0
- package/docs/core-radio--design.md +39 -0
- package/docs/core-radio--usage.md +8 -0
- package/docs/core-radiogroup--design.md +5 -0
- package/docs/core-radiogroup--usage.md +12 -0
- package/docs/core-radiotile--design.md +5 -0
- package/docs/core-radiotile--usage.md +10 -0
- package/docs/core-ribbon--design.md +39 -0
- package/docs/core-ribbon--usage.md +12 -0
- package/docs/core-skeleton--design.md +88 -0
- package/docs/core-skeleton--usage.md +13 -0
- package/docs/core-skeletongroup--design.md +50 -0
- package/docs/core-skeletongroup--usage.md +10 -0
- package/docs/core-spinner--design.md +99 -0
- package/docs/core-spinner--usage.md +11 -0
- package/docs/core-switch--design.md +145 -0
- package/docs/core-switch--usage.md +8 -0
- package/docs/core-tabnav--design.md +77 -0
- package/docs/core-tabnav--usage.md +63 -0
- package/docs/core-tag--design.md +21 -0
- package/docs/core-tag--usage.md +11 -0
- package/docs/core-text--design.md +32 -0
- package/docs/core-text--usage.md +10 -0
- package/docs/core-textarea--design.md +74 -0
- package/docs/core-textarea--usage.md +18 -0
- package/docs/core-textfield--design.md +81 -0
- package/docs/core-textfield--usage.md +12 -0
- package/docs/core-textinput--design.md +72 -0
- package/docs/core-textinput--usage.md +19 -0
- package/docs/core-toast--design.md +100 -0
- package/docs/core-toast--usage.md +11 -0
- package/docs/core-tooltip--design.md +61 -0
- package/docs/core-tooltip--usage.md +48 -0
- package/docs/core-topnav--design.md +75 -0
- package/docs/core-topnav--usage.md +6 -0
- package/docs/core-verticalnavigation--design.md +31 -0
- package/docs/core-verticalnavigation--usage.md +17 -0
- package/docs/core-visuallyhidden--design.md +87 -0
- package/docs/core-visuallyhidden--usage.md +35 -0
- package/docs/history-changelogs-capra-core--docs.md +60 -0
- package/docs/index.md +110 -0
- package/docs/using-capra--docs.md +39 -0
- package/package.json +5 -4
package/dist/style.css
CHANGED
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
position: absolute;
|
|
343
343
|
overflow: hidden;
|
|
344
344
|
}
|
|
345
|
-
.capra-TextInput-module-
|
|
345
|
+
.capra-TextInput-module-pTHfnG-wrapper {
|
|
346
346
|
border: var(--cds2-border-default);
|
|
347
347
|
border-color: var(--cds2-temporary-input-border-primary);
|
|
348
348
|
border-radius: var(--cds2-radius-md);
|
|
@@ -371,7 +371,7 @@
|
|
|
371
371
|
border-color: var(--cds2-temporary-input-border-disabled);
|
|
372
372
|
color: var(--cds2-temporary-input-foreground-disabled);
|
|
373
373
|
|
|
374
|
-
& .capra-TextInput-module-
|
|
374
|
+
& .capra-TextInput-module-pTHfnG-leadingSlot, & .capra-TextInput-module-pTHfnG-trailingSlot {
|
|
375
375
|
color: var(--cds2-temporary-input-foreground-disabled);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
&:has( > input:read-only) {
|
|
380
380
|
cursor: default;
|
|
381
381
|
|
|
382
|
-
& .capra-TextInput-module-
|
|
382
|
+
& .capra-TextInput-module-pTHfnG-input {
|
|
383
383
|
cursor: default;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
@@ -387,12 +387,12 @@
|
|
|
387
387
|
&:has( > input:disabled) {
|
|
388
388
|
cursor: not-allowed;
|
|
389
389
|
|
|
390
|
-
& .capra-TextInput-module-
|
|
390
|
+
& .capra-TextInput-module-pTHfnG-input {
|
|
391
391
|
cursor: not-allowed;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
& .capra-TextInput-module-
|
|
395
|
+
& .capra-TextInput-module-pTHfnG-input {
|
|
396
396
|
min-width: 0;
|
|
397
397
|
color: inherit;
|
|
398
398
|
font: inherit;
|
|
@@ -408,26 +408,56 @@
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
&[data-size="sm"] {
|
|
411
|
-
padding-inline: var(--cds2-spacing-md);
|
|
412
411
|
gap: var(--cds2-spacing-sm);
|
|
413
412
|
|
|
414
|
-
|
|
413
|
+
&:not(:has(.capra-TextInput-module-pTHfnG-leadingSlot)) .capra-TextInput-module-pTHfnG-input {
|
|
414
|
+
padding-inline-start: var(--cds2-spacing-md);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
&:not(:has(.capra-TextInput-module-pTHfnG-trailingSlot)) .capra-TextInput-module-pTHfnG-input {
|
|
418
|
+
padding-inline-end: var(--cds2-spacing-md);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
& .capra-TextInput-module-pTHfnG-input {
|
|
415
422
|
height: calc(var(--cds2-dimension-component-sm) - 2px);
|
|
416
423
|
font: var(--cds2-typography-body-sm-normal);
|
|
417
424
|
}
|
|
425
|
+
|
|
426
|
+
& .capra-TextInput-module-pTHfnG-leadingSlot {
|
|
427
|
+
padding-inline-start: var(--cds2-spacing-md);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
& .capra-TextInput-module-pTHfnG-trailingSlot {
|
|
431
|
+
padding-inline-end: var(--cds2-spacing-md);
|
|
432
|
+
}
|
|
418
433
|
}
|
|
419
434
|
|
|
420
435
|
&[data-size="md"] {
|
|
421
|
-
padding-inline: var(--cds2-spacing-md);
|
|
422
436
|
gap: var(--cds2-spacing-md);
|
|
423
437
|
|
|
424
|
-
|
|
438
|
+
&:not(:has(.capra-TextInput-module-pTHfnG-leadingSlot)) .capra-TextInput-module-pTHfnG-input {
|
|
439
|
+
padding-inline-start: var(--cds2-spacing-md);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
&:not(:has(.capra-TextInput-module-pTHfnG-trailingSlot)) .capra-TextInput-module-pTHfnG-input {
|
|
443
|
+
padding-inline-end: var(--cds2-spacing-md);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
& .capra-TextInput-module-pTHfnG-input {
|
|
425
447
|
height: calc(var(--cds2-dimension-component-md) - 2px);
|
|
426
448
|
font: var(--cds2-typography-body-md-normal);
|
|
427
449
|
}
|
|
450
|
+
|
|
451
|
+
& .capra-TextInput-module-pTHfnG-leadingSlot {
|
|
452
|
+
padding-inline-start: var(--cds2-spacing-md);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
& .capra-TextInput-module-pTHfnG-trailingSlot {
|
|
456
|
+
padding-inline-end: var(--cds2-spacing-md);
|
|
457
|
+
}
|
|
428
458
|
}
|
|
429
459
|
|
|
430
|
-
& .capra-TextInput-module-
|
|
460
|
+
& .capra-TextInput-module-pTHfnG-leadingSlot, & .capra-TextInput-module-pTHfnG-trailingSlot {
|
|
431
461
|
align-items: center;
|
|
432
462
|
gap: var(--cds2-spacing-xs);
|
|
433
463
|
color: var(--cds2-color-foreground-subtle);
|
|
@@ -435,7 +465,7 @@
|
|
|
435
465
|
display: inline-flex;
|
|
436
466
|
}
|
|
437
467
|
|
|
438
|
-
& .capra-TextInput-module-
|
|
468
|
+
& .capra-TextInput-module-pTHfnG-errorIndicator {
|
|
439
469
|
color: var(--cds2-color-foreground-danger-default);
|
|
440
470
|
flex-shrink: 0;
|
|
441
471
|
justify-content: center;
|
|
@@ -443,7 +473,7 @@
|
|
|
443
473
|
display: inline-flex;
|
|
444
474
|
}
|
|
445
475
|
|
|
446
|
-
& .capra-TextInput-module-
|
|
476
|
+
& .capra-TextInput-module-pTHfnG-warningIndicator {
|
|
447
477
|
color: var(--cds2-color-foreground-warning-default);
|
|
448
478
|
flex-shrink: 0;
|
|
449
479
|
justify-content: center;
|
|
@@ -2232,15 +2262,15 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2232
2262
|
color: var(--cds2-color-foreground-warning-default);
|
|
2233
2263
|
}
|
|
2234
2264
|
}
|
|
2235
|
-
.capra-Modal-module-
|
|
2265
|
+
.capra-Modal-module-j-u8iq-overlay {
|
|
2236
2266
|
background-color: var(--cds2-color-background-scrim);
|
|
2237
|
-
animation: capra-Modal-module-
|
|
2238
|
-
z-index:
|
|
2267
|
+
animation: capra-Modal-module-j-u8iq-overlayShow var(--cds2-motion-duration-medium-1) var(--cds2-motion-easing-standard);
|
|
2268
|
+
z-index: 10000;
|
|
2239
2269
|
position: fixed;
|
|
2240
2270
|
inset: 0;
|
|
2241
2271
|
}
|
|
2242
2272
|
|
|
2243
|
-
.capra-Modal-module-
|
|
2273
|
+
.capra-Modal-module-j-u8iq-surface {
|
|
2244
2274
|
background-color: var(--cds2-color-background-panel-solid);
|
|
2245
2275
|
border-radius: var(--cds2-radius-lg);
|
|
2246
2276
|
border: var(--cds2-border-default);
|
|
@@ -2248,7 +2278,7 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2248
2278
|
box-shadow: var(--cds2-shadow-high-down);
|
|
2249
2279
|
max-width: 100%;
|
|
2250
2280
|
max-height: min(80vh, 100vh - 48px);
|
|
2251
|
-
animation: capra-Modal-module-
|
|
2281
|
+
animation: capra-Modal-module-j-u8iq-contentShow var(--cds2-motion-duration-medium-1) var(--cds2-motion-easing-standard);
|
|
2252
2282
|
flex-direction: column;
|
|
2253
2283
|
padding: 0;
|
|
2254
2284
|
display: flex;
|
|
@@ -2271,7 +2301,7 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2271
2301
|
}
|
|
2272
2302
|
}
|
|
2273
2303
|
|
|
2274
|
-
.capra-Modal-module-
|
|
2304
|
+
.capra-Modal-module-j-u8iq-header {
|
|
2275
2305
|
padding: var(--cds2-spacing-md) var(--cds2-spacing-lg);
|
|
2276
2306
|
border-bottom: var(--cds2-border-default);
|
|
2277
2307
|
border-color: var(--cds2-color-border-neutral-subtle);
|
|
@@ -2282,21 +2312,21 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2282
2312
|
display: flex;
|
|
2283
2313
|
}
|
|
2284
2314
|
|
|
2285
|
-
.capra-Modal-module-
|
|
2315
|
+
.capra-Modal-module-j-u8iq-headerLeading {
|
|
2286
2316
|
align-items: center;
|
|
2287
2317
|
gap: var(--cds2-spacing-md);
|
|
2288
2318
|
flex: 1;
|
|
2289
2319
|
display: flex;
|
|
2290
2320
|
}
|
|
2291
2321
|
|
|
2292
|
-
.capra-Modal-module-
|
|
2322
|
+
.capra-Modal-module-j-u8iq-expandedTitleLayout {
|
|
2293
2323
|
align-items: center;
|
|
2294
2324
|
gap: var(--cds2-spacing-md);
|
|
2295
2325
|
flex-direction: row;
|
|
2296
2326
|
display: flex;
|
|
2297
2327
|
}
|
|
2298
2328
|
|
|
2299
|
-
.capra-Modal-module-
|
|
2329
|
+
.capra-Modal-module-j-u8iq-content {
|
|
2300
2330
|
padding: var(--cds2-spacing-lg);
|
|
2301
2331
|
flex-direction: column;
|
|
2302
2332
|
flex: 1;
|
|
@@ -2304,14 +2334,14 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2304
2334
|
overflow-y: auto;
|
|
2305
2335
|
}
|
|
2306
2336
|
|
|
2307
|
-
.capra-Modal-module-
|
|
2337
|
+
.capra-Modal-module-j-u8iq-footer {
|
|
2308
2338
|
padding: var(--cds2-spacing-md) var(--cds2-spacing-lg);
|
|
2309
2339
|
border-top: var(--cds2-border-default);
|
|
2310
2340
|
border-color: var(--cds2-color-border-neutral-subtle);
|
|
2311
2341
|
background-color: var(--cds2-color-background-neutral-subtle);
|
|
2312
2342
|
}
|
|
2313
2343
|
|
|
2314
|
-
.capra-Modal-module-
|
|
2344
|
+
.capra-Modal-module-j-u8iq-expandedFooterLayout {
|
|
2315
2345
|
justify-content: space-between;
|
|
2316
2346
|
align-items: center;
|
|
2317
2347
|
gap: var(--cds2-spacing-md);
|
|
@@ -2319,7 +2349,7 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2319
2349
|
display: flex;
|
|
2320
2350
|
}
|
|
2321
2351
|
|
|
2322
|
-
.capra-Modal-module-
|
|
2352
|
+
.capra-Modal-module-j-u8iq-footerActions {
|
|
2323
2353
|
justify-content: flex-end;
|
|
2324
2354
|
align-items: center;
|
|
2325
2355
|
gap: var(--cds2-spacing-md);
|
|
@@ -2328,20 +2358,20 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2328
2358
|
display: flex;
|
|
2329
2359
|
}
|
|
2330
2360
|
|
|
2331
|
-
.capra-Modal-module-
|
|
2361
|
+
.capra-Modal-module-j-u8iq-confirmationSurface {
|
|
2332
2362
|
border-radius: var(--cds2-radius-md);
|
|
2333
2363
|
width: min(400px, 100vw - 48px);
|
|
2334
2364
|
box-shadow: var(--cds2-shadow-high-down);
|
|
2335
2365
|
padding: var(--cds2-spacing-2xl) var(--cds2-spacing-2xl) var(--cds2-spacing-xl);
|
|
2336
2366
|
}
|
|
2337
2367
|
|
|
2338
|
-
.capra-Modal-module-
|
|
2368
|
+
.capra-Modal-module-j-u8iq-confirmationLayout {
|
|
2339
2369
|
align-items: flex-start;
|
|
2340
2370
|
gap: var(--cds2-spacing-lg);
|
|
2341
2371
|
display: flex;
|
|
2342
2372
|
}
|
|
2343
2373
|
|
|
2344
|
-
.capra-Modal-module-
|
|
2374
|
+
.capra-Modal-module-j-u8iq-confirmationIcon {
|
|
2345
2375
|
width: var(--cds2-dimension-component-sm);
|
|
2346
2376
|
height: var(--cds2-dimension-component-sm);
|
|
2347
2377
|
flex-shrink: 0;
|
|
@@ -2370,19 +2400,19 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2370
2400
|
}
|
|
2371
2401
|
}
|
|
2372
2402
|
|
|
2373
|
-
.capra-Modal-module-
|
|
2403
|
+
.capra-Modal-module-j-u8iq-confirmationBody {
|
|
2374
2404
|
gap: var(--cds2-spacing-md);
|
|
2375
2405
|
flex-direction: column;
|
|
2376
2406
|
flex: 1;
|
|
2377
2407
|
display: flex;
|
|
2378
2408
|
}
|
|
2379
2409
|
|
|
2380
|
-
.capra-Modal-module-
|
|
2410
|
+
.capra-Modal-module-j-u8iq-confirmationMessage {
|
|
2381
2411
|
font: var(--cds2-typography-body-md-normal);
|
|
2382
2412
|
margin: 0;
|
|
2383
2413
|
}
|
|
2384
2414
|
|
|
2385
|
-
.capra-Modal-module-
|
|
2415
|
+
.capra-Modal-module-j-u8iq-confirmationActions {
|
|
2386
2416
|
justify-content: flex-end;
|
|
2387
2417
|
gap: var(--cds2-spacing-md);
|
|
2388
2418
|
width: 100%;
|
|
@@ -2390,7 +2420,7 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2390
2420
|
display: flex;
|
|
2391
2421
|
}
|
|
2392
2422
|
|
|
2393
|
-
@keyframes capra-Modal-module-
|
|
2423
|
+
@keyframes capra-Modal-module-j-u8iq-overlayShow {
|
|
2394
2424
|
from {
|
|
2395
2425
|
opacity: 0;
|
|
2396
2426
|
}
|
|
@@ -2400,7 +2430,7 @@ input:disabled + .capra-Radio-module-ZI7rzq-inner:after {
|
|
|
2400
2430
|
}
|
|
2401
2431
|
}
|
|
2402
2432
|
|
|
2403
|
-
@keyframes capra-Modal-module-
|
|
2433
|
+
@keyframes capra-Modal-module-j-u8iq-contentShow {
|
|
2404
2434
|
from {
|
|
2405
2435
|
opacity: 0;
|
|
2406
2436
|
transform: translate(-50%, -20px) scale(.96);
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Conventions
|
|
2
|
+
|
|
3
|
+
When building and consuming Capra components, we follow specific conventions to maintain a healthy codebase.
|
|
4
|
+
|
|
5
|
+
### Semantic Properties
|
|
6
|
+
|
|
7
|
+
Certain properties of Capra components have well-defined, consistent uses.
|
|
8
|
+
|
|
9
|
+
| Prop | Purpose | Possible Values |
|
|
10
|
+
| ------------ | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- |
|
|
11
|
+
| `appearance` | Change the colors of a component using semantic intent, e.g. a danger `Button` when deleting | `default`, `info`, `danger`, `warning`, `success`, `highlight` |
|
|
12
|
+
| `color` | Change the color of a component to a specific color, e.g. a teal `Ribbon` | Component-specific |
|
|
13
|
+
| `layout` | Alter the component's layout, e.g. a horizontal input field with label | Component-specific |
|
|
14
|
+
| `size` | Specify the size of the component | `xs`, `sm`, `md`, `lg`, `xl` |
|
|
15
|
+
| `variant` | Specify a different visual treatment for the component, e.g. a dot `Badge` vs. a counter `Badge` | Component-specific |
|
|
16
|
+
|
|
17
|
+
For props where the possible values are pre-defined, a component may utilize the full set or a subset of the possible values.
|
|
18
|
+
|
|
19
|
+
### Styling Overrides
|
|
20
|
+
|
|
21
|
+
Capra components are built according to our design system specifications. They should rarely need to be styled differently than what is provided out-of-the-box. In the event custom styling is required, we provide a consistent escape hatch across all of our components for passing a CSS class name: `FORCE__className`.
|
|
22
|
+
|
|
23
|
+
In your application, you can apply a style override like this:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { Text } from '@capra/core';
|
|
27
|
+
import styles from './Component.modules.css';
|
|
28
|
+
|
|
29
|
+
export function Component(props) {
|
|
30
|
+
return <Text FORCE__className={styles.text}>Hello world</Text>;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Note that using this prop should be a rarity. Adding styles here is also somewhat brittle. While we do provide this escape hatch, we make no guarantees that the styles applied will apply correctly across version updates, e.g. a style override targeting a specific HTML structure within a Capra component breaks because the component was refactored to use a different HTML structure. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. Please use it responsibly.
|
|
35
|
+
|
|
36
|
+
## Client-side Routing
|
|
37
|
+
|
|
38
|
+
Capra components such as `Link` and `ButtonLink` render links that perform navigation when the user interacts with them. Each component that supports link behavior accepts an `href` prop, which is passed to the underlying `<a>` element.
|
|
39
|
+
|
|
40
|
+
By default, links perform native browser navigation when they are interacted with. However, Capra supports overriding this behavior using a client-side router of your choice. Set this up once in the root of your app, and any Capra link component will automatically navigate using your router.
|
|
41
|
+
|
|
42
|
+
Note that external links to different origins will not trigger client side routing, and will use native browser navigation. Additionally, if the link has a target other than `"_self"`, uses the `download` attribute, or the user presses modifier keys such as `Command` or `Alt` to change the default behavior, browser native navigation will occur instead of client side routing.
|
|
43
|
+
|
|
44
|
+
### `RouterProvider`
|
|
45
|
+
|
|
46
|
+
The `RouterProvider` component accepts two props: `navigate` and `useHref`. `navigate` should be set to a function received from your router for performing a client side navigation programmatically. `useHref` is an optional prop that converts a router-specific href to a native HTML href, e.g. prepending a base path. The following example shows the general pattern. Framework-specific examples are shown below.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import {RouterProvider} from '@capra/core';
|
|
50
|
+
import {useNavigate, useHref} from 'your-router';
|
|
51
|
+
|
|
52
|
+
function App() {
|
|
53
|
+
const navigate = useNavigate();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<RouterProvider navigate={navigate} useHref={useHref}>
|
|
57
|
+
{/* ... */}
|
|
58
|
+
</RouterProvider>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Router Options
|
|
64
|
+
|
|
65
|
+
All Capra link components accept a `routerOptions` prop, which is an object that is passed through to the client side router's `navigate` function as the second argument. This can be used to control any router-specific behaviors, such as scrolling, replacing instead of pushing to the history, etc.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<Link href="/login" routerOptions={{replace: true}}>{/* ...*/}</Link>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
When using TypeScript, you can configure the `RouterConfig` type globally so that all link components have auto complete and type safety using a type provided by your router.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import type {RouterOptions} from 'your-router';
|
|
75
|
+
|
|
76
|
+
declare module '@capra/core' {
|
|
77
|
+
interface RouterConfig {
|
|
78
|
+
routerOptions: RouterOptions
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### React Router
|
|
84
|
+
|
|
85
|
+
The [useNavigate](https://reactrouter.com/en/main/hooks/use-navigate) hook from `react-router-dom` returns a `navigate` function you can pass to `RouterProvider`. The [useHref](https://reactrouter.com/en/main/hooks/use-href) hook can also be provided if you're using React Router's `basename` option. Ensure that the component that calls `useNavigate` and renders `RouterProvider` is inside the router component (e.g. `BrowserRouter`) so that it has access to React Router's internal context. The React Router `<Routes>` element should also be defined inside Capra's `<RouterProvider>` so that links inside the rendered routes have access to the router.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import {BrowserRouter, useNavigate, useHref, type NavigateOptions} from 'react-router-dom';
|
|
89
|
+
import {RouterProvider} from '@capra/core';
|
|
90
|
+
|
|
91
|
+
declare module '@capra/core' {
|
|
92
|
+
interface RouterConfig {
|
|
93
|
+
routerOptions: NavigateOptions
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function App() {
|
|
98
|
+
const navigate = useNavigate();
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<RouterProvider navigate={navigate} useHref={useHref}>
|
|
102
|
+
{/* Your app here... */}
|
|
103
|
+
<Routes>
|
|
104
|
+
<Route path="/" element={<HomePage />} />
|
|
105
|
+
{/* ... */}
|
|
106
|
+
</Routes>
|
|
107
|
+
</RouterProvider>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
<BrowserRouter>
|
|
112
|
+
<App />
|
|
113
|
+
</BrowserRouter>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Next.js App Router
|
|
117
|
+
|
|
118
|
+
The [useRouter](https://nextjs.org/docs/app/api-reference/functions/use-router) hook from `next/navigation` returns a router object that can be used to perform navigation. `RouterProvider` should be rendered from a client component at the root of each page or layout that includes Capra links. You can create a new client component for this, or combine it with other top-level providers as described in the [Next.js docs](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#using-context-providers).
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
// app/provider.tsx
|
|
122
|
+
"use client";
|
|
123
|
+
|
|
124
|
+
import {useRouter} from 'next/navigation';
|
|
125
|
+
import {RouterProvider} from '@capra/core';
|
|
126
|
+
|
|
127
|
+
declare module '@capra/core' {
|
|
128
|
+
interface RouterConfig {
|
|
129
|
+
routerOptions: NonNullable<Parameters<ReturnType<typeof useRouter>['push']>[1]>
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function ClientProviders({children}) {
|
|
134
|
+
const router = useRouter();
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<RouterProvider navigate={router.push}>
|
|
138
|
+
{children}
|
|
139
|
+
</RouterProvider>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Then, in your page or layout server component, wrap your app in the `ClientProviders` component that you defined.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
// app/layout.tsx
|
|
148
|
+
import {ClientProviders} from './provider';
|
|
149
|
+
|
|
150
|
+
export default function RootLayout({children}) {
|
|
151
|
+
return (
|
|
152
|
+
<html>
|
|
153
|
+
<body>
|
|
154
|
+
<ClientProviders>{children}</ClientProviders>
|
|
155
|
+
</body>
|
|
156
|
+
</html>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Next.js Pages Router
|
|
162
|
+
|
|
163
|
+
The [useRouter](https://nextjs.org/docs/pages/api-reference/functions/use-router) hook from `next/router` returns a router object that can be used to perform navigation. `RouterProvider` should be rendered at the root of each page that includes Capra links, or in `pages/_app.tsx` to add it to all pages.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
// pages/_app.tsx
|
|
167
|
+
import type { AppProps } from 'next/app';
|
|
168
|
+
import {useRouter, type NextRouter} from 'next/router';
|
|
169
|
+
import {RouterProvider} from '@capra/core';
|
|
170
|
+
|
|
171
|
+
declare module '@capra/core' {
|
|
172
|
+
interface RouterConfig {
|
|
173
|
+
routerOptions: NonNullable<Parameters<NextRouter['push']>[2]>
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default function MyApp({Component, pageProps}: AppProps) {
|
|
178
|
+
const router = useRouter();
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<RouterProvider navigate={(href, opts) => router.push(href, undefined, opts)}>
|
|
182
|
+
<Component {...pageProps} />
|
|
183
|
+
</RouterProvider>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Core/Alert - Design
|
|
2
|
+
|
|
3
|
+
Alerts are used to communicate important information to the user.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use an Alert to surface contextual feedback in the page: the outcome of an action (success or failure), a condition that needs attention before the user continues, or information that should stay visible while they keep working in the same view.
|
|
8
|
+
|
|
9
|
+
Keep alerts scoped to the page or region they refer to. Prefer one alert per region so the message stays easy to scan; when several conditions apply at once, combine them into a single alert when it makes sense.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Appearances
|
|
14
|
+
|
|
15
|
+
### Info
|
|
16
|
+
|
|
17
|
+
General information like recommend actions to accelerate a user's workflow, helpful information, or tips.
|
|
18
|
+
|
|
19
|
+
### Error
|
|
20
|
+
|
|
21
|
+
Problems that must be resolved before the user can complete a task, such as an error on a form.
|
|
22
|
+
|
|
23
|
+
### Warning
|
|
24
|
+
|
|
25
|
+
Notify users of cautionary/temporary information affecting the user's workflow, but does not block a user from
|
|
26
|
+
completing the action or workflow.
|
|
27
|
+
|
|
28
|
+
### Success
|
|
29
|
+
|
|
30
|
+
Brings special attention to the user that an action has been completed, or a status has been updated.
|
|
31
|
+
|
|
32
|
+
### Layout
|
|
33
|
+
|
|
34
|
+
### Section
|
|
35
|
+
|
|
36
|
+
Section notifications communicate the status of a section to the user.
|
|
37
|
+
|
|
38
|
+
### Inline
|
|
39
|
+
|
|
40
|
+
Inline notifications are low-priority messages about a single element, like a tile or row item.
|
|
41
|
+
|
|
42
|
+
### Additional properties
|
|
43
|
+
|
|
44
|
+
### Title
|
|
45
|
+
|
|
46
|
+
A title is recommended, but optional. Use a title to quickly summarize the purpose of the notification. Keep titles
|
|
47
|
+
short, no more than 60 characters, and avoid repeating the body text.
|
|
48
|
+
|
|
49
|
+
### Body
|
|
50
|
+
|
|
51
|
+
The body text is required for all notifications. If the notification is actionable, the text should inform the user
|
|
52
|
+
of the next step.
|
|
53
|
+
|
|
54
|
+
### Action
|
|
55
|
+
|
|
56
|
+
Actionable notifications are recommended to help the user resolve the issue.
|
|
57
|
+
|
|
58
|
+
### Dismiss
|
|
59
|
+
|
|
60
|
+
Alert banners can include a dismiss button that removes the notice from the page layout. Error banners can not be
|
|
61
|
+
dismissed.
|
|
62
|
+
|
|
63
|
+
## Layout and spacing
|
|
64
|
+
|
|
65
|
+
* Alerts span the full width of their container.
|
|
66
|
+
|
|
67
|
+
## Behavior
|
|
68
|
+
|
|
69
|
+
* Alerts are static by default; they do not auto-dismiss.
|
|
70
|
+
* If the user triggers an action that resolves the alert condition, remove the alert programmatically.
|
|
71
|
+
* When an alert is injected into the DOM, announce it to screen readers via `aria-live`.
|
|
72
|
+
|
|
73
|
+
## Content
|
|
74
|
+
|
|
75
|
+
* Title: sentence case, no trailing punctuation, max 60 characters.
|
|
76
|
+
* Body: one to two sentences. State the problem and the resolution path. Use punctuation.
|
|
77
|
+
* Action label: verb-first, 1-3 words (e.g., "Retry", "View details").
|
|
78
|
+
* Avoid technical jargon in user-facing alert text.
|
|
79
|
+
|
|
80
|
+
## Best Practices
|
|
81
|
+
|
|
82
|
+
Do:
|
|
83
|
+
|
|
84
|
+
* Do use `appearance="danger"` for blocking error states.
|
|
85
|
+
* Do provide an action when the user has a clear path to resolution.
|
|
86
|
+
|
|
87
|
+
Don't:
|
|
88
|
+
|
|
89
|
+
* Don't use Alert for transient, auto-dismissing notifications — use Toast.
|
|
90
|
+
* Don't use Alert for individual form field validation errors — use the field's error state.
|
|
91
|
+
* Don't use Alert when the message isn't tied to the current page or task context.
|
|
92
|
+
* Don't stack Alerts in the same region.
|
|
93
|
+
* Don't make `appearance="danger"` Alerts dismissable — the component prevents this automatically.
|
|
94
|
+
|
|
95
|
+
## Accessibility
|
|
96
|
+
|
|
97
|
+
* Use `role="alert"` for errors and warnings so they are announced immediately by screen readers.
|
|
98
|
+
* Use `role="status"` for informational and success alerts, which are announced at a lower priority.
|
|
99
|
+
* Don't rely solely on color to convey alert type — the icon and/or title must distinguish the appearance.
|
|
100
|
+
* Ensure the dismiss button has an accessible label (e.g., `aria-label="Dismiss alert"`).
|
|
101
|
+
|
|
102
|
+
### Keyboard interaction
|
|
103
|
+
|
|
104
|
+
* Alerts exist in the page's natural tab sequence, their actions reachable via `tab` and `shift`+`tab` keys.
|
|
105
|
+
|
|
106
|
+
## Related components
|
|
107
|
+
|
|
108
|
+
* [Toast](?path=/docs/core-toast--design) — For non-blocking, auto-dismissing notifications.
|
|
109
|
+
* [Pill](?path=/docs/core-pill--design) — For inline semantic status indicators without body copy.
|
|
110
|
+
* [Modal](?path=/docs/core-modal--design) — When the error or warning requires an immediate blocking decision.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Core/Alert - Usage
|
|
2
|
+
|
|
3
|
+
Alerts are used to communicate important information to the user.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `layout` | `(typeof layouts)[number]` | No | 'section' | The layout of the alert.<br><br>@default 'section'<br><br><ul><br> <li>'section' - The alert is displayed in a full width container.</li><br> <li>'compact' - @deprecated Use 'section' instead. Will be removed in a future version.</li><br> <li>'inline' - Inline notifications are low-priority messages about a single element, like a tile or row item.</li><br></ul> |
|
|
8
|
+
| `appearance` | `(typeof appearances)[number]` | No | 'info' | The appearance of the alert.<br><br>@default 'info'<br><br><ul><br> <li>'info' - Informational alerts provide general information or an important property.</li><br> <li>'warning' - Warning alerts notify users of cautionary information.</li><br> <li>'danger' - Danger alerts indicate problems that must be resolved.</li><br> <li>'success' - Success alerts confirm an action has been completed.</li><br></ul> |
|
|
9
|
+
| `title` | `string` | No | `--` | The title of the alert. This is optional. |
|
|
10
|
+
| `children` | `React.ReactNode` | Yes | `--` | The description of the alert. This is required.<br><br>@required |
|
|
11
|
+
| `action` | `{ label: string; onClick: (e: React.MouseEvent<HTMLButtonElement>) => void; } \| React.ReactElement` | No | `--` | The configuration of the action button. The object must contain a label displayed on the button and an onClick callback function. This is optional.<br><br>When the object is not provided, the alert will not render the action button. |
|
|
12
|
+
| `onDismiss` | `true \| (() => void)` | No | `--` | Optional function to call when the user dismisses the alert.<br><br>If this is not provided, the alert will not render the dismiss button.<br><br>Alerts with `appearance="danger"` cannot be dismissed and will not render the dismiss button.<br><br>**Integration note:** while the `Alert` will handle its own dismissal, this is non-persistent.<br>Persistent dismissal should be handled by the parent component. |
|
|
13
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Core/Anchor - Design
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
Anchors are used to navigate users to a different section within the current page.
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
### Label
|
|
10
|
+
|
|
11
|
+
Labels should be concise and descriptive, m Use title case (e.g., "Dashboard", "Settings"). Labels should ideally be
|
|
12
|
+
less than 12 characters, with a maximum of 32 characters.atching the destination heading.
|
|
13
|
+
|
|
14
|
+
## Best Practices
|
|
15
|
+
|
|
16
|
+
Do:
|
|
17
|
+
|
|
18
|
+
* Do match the label to the section heading the anchor points to.
|
|
19
|
+
* Do use the active state for the current page in a navigation region.
|
|
20
|
+
* Do use the disabled state when navigation is temporarily unavailable.
|
|
21
|
+
|
|
22
|
+
Don't:
|
|
23
|
+
|
|
24
|
+
* Don't mark more than one anchor as active in the same navigation context.
|
|
25
|
+
* Don't hide anchors instead of disabling them when a destination exists but is unavailable.
|
|
26
|
+
* Don't use confuse Anchor with Tab.
|
|
27
|
+
|
|
28
|
+
## Accessibility
|
|
29
|
+
|
|
30
|
+
### Keyboard interaction
|
|
31
|
+
|
|
32
|
+
| Key | Function |
|
|
33
|
+
| ------- | --------------------------------------------------------------------- |
|
|
34
|
+
| `Tab` | Moves focus to the anchor when navigating through focusable elements. |
|
|
35
|
+
| `Enter` | Activates the anchor when focused. |
|
|
36
|
+
|
|
37
|
+
### ARIA attributes
|
|
38
|
+
|
|
39
|
+
* `aria-current="page"`: Applied when the anchor is active, indicating the current page in navigation.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Core/Anchor - Usage
|
|
2
|
+
|
|
3
|
+
| Prop | Type | Required | Default | Description |
|
|
4
|
+
| --- | --- | --- | --- | --- |
|
|
5
|
+
| `children` | `React.ReactNode` | Yes | `--` | The label text to display in the anchor. Anchor labels should be one or two words, using title case (Tab Label). Labels should be less than 12 characters, with a maximum of 32 characters. |
|
|
6
|
+
| `href` | `string` | No | `--` | The href attribute of the anchor. |
|
|
7
|
+
| `isActive` | `boolean` | No | `--` | Whether the anchor is active. |
|
|
8
|
+
| `isDisabled` | `boolean` | No | `--` | Whether the anchor is disabled. |
|
|
9
|
+
| `as` | `As` | No | `--` | The underlying element rendered by the anchor. Defaults to `a`. |
|
|
10
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Anchor } from '@cribl/capra-core';
|
|
16
|
+
|
|
17
|
+
// Basic usage
|
|
18
|
+
<Anchor href="/dashboard">Dashboard</Anchor>
|
|
19
|
+
|
|
20
|
+
// Active state
|
|
21
|
+
<Anchor href="/settings" isActive>Settings</Anchor>
|
|
22
|
+
|
|
23
|
+
// Disabled state
|
|
24
|
+
<Anchor href="/admin" isDisabled>Admin</Anchor>
|
|
25
|
+
|
|
26
|
+
// Polymorphic - render as button
|
|
27
|
+
<Anchor as="button" onClick={handleClick}>Action</Anchor>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Polymorphic Component
|
|
31
|
+
|
|
32
|
+
The Anchor component supports the `as` prop, allowing it to be rendered as different HTML elements or custom components. This is particularly useful when integrating with routing libraries like React Router.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Link } from 'react-router-dom';
|
|
36
|
+
|
|
37
|
+
// Using with React Router
|
|
38
|
+
<Anchor as={Link} to="/dashboard">Dashboard</Anchor>
|
|
39
|
+
```
|