@solexllc/usx-react 0.4.0 → 0.5.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 +329 -274
- package/dist/index.js +329 -274
- package/package.json +5 -5
- package/src/components/attribution/config.json +5 -5
- package/src/components/banner/config.json +2 -2
- package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
- package/src/components/breadcrumb/config.json +11 -1
- package/src/components/button/button.html +2 -2
- package/src/components/button-group/button-group.django.html +1 -1
- package/src/components/calendar-date/calendar-date.django.html +3 -3
- package/src/components/callout/Callout.tsx +53 -0
- package/src/components/callout/callout.django.html +5 -0
- package/src/components/callout/callout.html +76 -0
- package/src/components/callout/config.json +74 -0
- package/src/components/card/Card.tsx +18 -34
- package/src/components/card/card.django.html +12 -10
- package/src/components/card/config.json +15 -40
- package/src/components/card-group/card-group.django.html +1 -1
- package/src/components/carousel/Carousel.tsx +3 -2
- package/src/components/carousel/carousel.django.html +13 -2
- package/src/components/carousel/config.json +2 -2
- package/src/components/character-count/config.json +2 -2
- package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
- package/src/components/checkbox-group/checkbox-group.django.html +10 -4
- package/src/components/checkbox-group/config.json +10 -5
- package/src/components/clickable/clickable.html +21 -39
- package/src/components/clickable/config.json +2 -2
- package/src/components/collection/Collection.tsx +5 -5
- package/src/components/collection/collection.django.html +2 -4
- package/src/components/collection/config.json +7 -6
- package/src/components/combobox/config.json +4 -4
- package/src/components/date-picker/config.json +4 -4
- package/src/components/date-range-picker/config.json +7 -7
- package/src/components/error-message/config.json +2 -2
- package/src/components/eyebrow/Eyebrow.tsx +2 -1
- package/src/components/eyebrow/config.json +2 -2
- package/src/components/fieldset/config.json +5 -5
- package/src/components/file-input/FileInput.tsx +3 -2
- package/src/components/file-input/config.json +5 -5
- package/src/components/file-list/FileList.tsx +2 -1
- package/src/components/file-list/config.json +2 -2
- package/src/components/footer/Footer.tsx +5 -5
- package/src/components/form-group/config.json +2 -2
- package/src/components/hero/Hero.tsx +8 -14
- package/src/components/hero/config.json +36 -27
- package/src/components/hero/hero.django.html +2 -2
- package/src/components/hint/config.json +2 -2
- package/src/components/in-page-nav/config.json +11 -1
- package/src/components/indicator/config.json +2 -2
- package/src/components/input/config.json +2 -2
- package/src/components/label/config.json +2 -2
- package/src/components/language-selector/config.json +2 -2
- package/src/components/layout/Layout.tsx +1 -1
- package/src/components/legend/config.json +3 -3
- package/src/components/link/config.json +2 -2
- package/src/components/memorable-date/config.json +9 -9
- package/src/components/misc-banner/MiscBanner.tsx +2 -1
- package/src/components/misc-banner/config.json +2 -2
- package/src/components/modal/config.json +2 -2
- package/src/components/page/Page.tsx +2 -1
- package/src/components/page/config.json +7 -7
- package/src/components/page/page.django.html +1 -1
- package/src/components/pagination/Pagination.tsx +2 -1
- package/src/components/pagination/container/PaginationContainer.tsx +2 -1
- package/src/components/prose/config.json +5 -1
- package/src/components/quote/Quote.tsx +58 -0
- package/src/components/quote/config.json +51 -0
- package/src/components/quote/quote.django.html +15 -0
- package/src/components/quote/quote.html +66 -0
- package/src/components/radio-buttons/config.json +3 -3
- package/src/components/range-slider/RangeSlider.tsx +2 -1
- package/src/components/range-slider/config.json +4 -4
- package/src/components/required/config.json +2 -2
- package/src/components/section/Section.tsx +6 -2
- package/src/components/section/config.json +19 -6
- package/src/components/section/section.django.html +9 -2
- package/src/components/select/config.json +2 -2
- package/src/components/site-alert/SiteAlert.tsx +5 -6
- package/src/components/skipnav/config.json +2 -2
- package/src/components/summary-box/config.json +3 -3
- package/src/components/swap/Swap.tsx +4 -3
- package/src/components/swap/config.json +4 -4
- package/src/components/switch/config.json +2 -2
- package/src/components/table/config.json +13 -3
- package/src/components/tag/config.json +2 -2
- package/src/components/tag-group/config.json +2 -2
- package/src/components/text-area/config.json +2 -2
- package/src/components/time-picker/config.json +4 -4
- package/src/components/toggle/Toggle.tsx +69 -40
- package/src/components/toggle/config.json +42 -10
- package/src/components/toggle/toggle.django.html +25 -17
- package/src/components/toggle/toggle.html +319 -85
- package/src/components/tooltip/config.json +2 -2
- package/src/components/villain/Villain.tsx +2 -1
- package/src/index.js +2 -1
- package/src/components/block/Block.tsx +0 -78
- package/src/components/block/block.django.html +0 -26
- package/src/components/block/block.html +0 -162
- package/src/components/block/config.json +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solexllc/usx-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React component library for USX.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@solexllc/usx": "0.
|
|
29
|
-
"@solexllc/usx-theme": "0.
|
|
30
|
-
"@solexllc/usx-uswds-fixes": "0.1.
|
|
28
|
+
"@solexllc/usx": "0.6.0",
|
|
29
|
+
"@solexllc/usx-theme": "0.7.0",
|
|
30
|
+
"@solexllc/usx-uswds-fixes": "0.1.11",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
32
32
|
"prop-types": "^15.8.1"
|
|
33
33
|
},
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "vite build",
|
|
47
|
-
"test": "pnpm build && node test/asset-url-check.mjs"
|
|
47
|
+
"test": "pnpm build && node test/toggle-check.mjs && node test/quote-check.mjs && node test/composition-check.mjs && node test/asset-url-check.mjs"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "attribution",
|
|
3
3
|
"template": "attribution/attribution.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"avatarProps": {
|
|
7
7
|
"type": "object",
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"component": "avatar"
|
|
10
10
|
},
|
|
11
11
|
"media": {
|
|
12
|
-
"type": "
|
|
12
|
+
"type": "slot",
|
|
13
13
|
"description": "HTML for the left media area (avatar image or initials badge)."
|
|
14
14
|
},
|
|
15
15
|
"primary": {
|
|
16
|
-
"type": "
|
|
16
|
+
"type": "slot",
|
|
17
17
|
"description": "Primary text shown in the top-right cell."
|
|
18
18
|
},
|
|
19
19
|
"secondary": {
|
|
20
|
-
"type": "
|
|
20
|
+
"type": "slot",
|
|
21
21
|
"description": "Secondary text shown in the bottom-right cell."
|
|
22
22
|
},
|
|
23
23
|
"children": {
|
|
24
|
-
"type": "
|
|
24
|
+
"type": "slot",
|
|
25
25
|
"description": "Optional full custom markup. When provided, it overrides media/primary/secondary."
|
|
26
26
|
},
|
|
27
27
|
"className": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "banner",
|
|
3
3
|
"template": "banner/banner.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"props": {
|
|
6
6
|
"staticBaseUrl": {
|
|
7
7
|
"type": "string",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"description": "Heading text for HTTPS section."
|
|
45
45
|
},
|
|
46
46
|
"httpsText": {
|
|
47
|
-
"type": "
|
|
47
|
+
"type": "slot",
|
|
48
48
|
"description": "Body text for the HTTPS section."
|
|
49
49
|
},
|
|
50
50
|
"className": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import ClassNames from 'classnames';
|
|
2
3
|
|
|
3
4
|
export interface BreadcrumbItem {
|
|
4
5
|
href?: string;
|
|
@@ -27,7 +28,7 @@ export default function Breadcrumb({
|
|
|
27
28
|
...props
|
|
28
29
|
}: BreadcrumbProps) {
|
|
29
30
|
if (!items || items.length === 0) {
|
|
30
|
-
const classes =
|
|
31
|
+
const classes = ClassNames('usx-breadcrumb', className);
|
|
31
32
|
return (
|
|
32
33
|
<div className={classes} {...props}>
|
|
33
34
|
{children || 'Breadcrumb'}
|
|
@@ -35,15 +36,13 @@ export default function Breadcrumb({
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
const navClasses =
|
|
39
|
+
const navClasses = ClassNames(
|
|
39
40
|
'usa-breadcrumb',
|
|
40
41
|
'usx-breadcrumb',
|
|
41
42
|
wrap ? 'usa-breadcrumb--wrap' : null,
|
|
42
43
|
truncate ? 'usa-breadcrumb--truncate' : null,
|
|
43
44
|
className,
|
|
44
|
-
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.join(' ');
|
|
45
|
+
);
|
|
47
46
|
|
|
48
47
|
return (
|
|
49
48
|
<nav className={navClasses} aria-label={ariaLabel} {...props}>
|
|
@@ -53,7 +52,7 @@ export default function Breadcrumb({
|
|
|
53
52
|
>
|
|
54
53
|
{items.map((item, idx) => {
|
|
55
54
|
const isCurrent = !!item.current;
|
|
56
|
-
const liClass =
|
|
55
|
+
const liClass = ClassNames('usa-breadcrumb__list-item', isCurrent ? 'usa-current' : null);
|
|
57
56
|
|
|
58
57
|
return (
|
|
59
58
|
<li
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "breadcrumb",
|
|
3
3
|
"template": "breadcrumb/breadcrumb.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 2,
|
|
5
5
|
"default": {
|
|
6
6
|
"items": [
|
|
7
7
|
{
|
|
@@ -69,6 +69,16 @@
|
|
|
69
69
|
"className": {
|
|
70
70
|
"type": "string",
|
|
71
71
|
"description": "Additional CSS classes to add to the nav element"
|
|
72
|
+
},
|
|
73
|
+
"children": {
|
|
74
|
+
"type": "slot",
|
|
75
|
+
"description": "Fallback content rendered when no breadcrumb items are supplied (React only).",
|
|
76
|
+
"renderers": {
|
|
77
|
+
"django": {
|
|
78
|
+
"supported": false,
|
|
79
|
+
"description": "The Django template does not consume children."
|
|
80
|
+
}
|
|
81
|
+
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
}
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
</button>
|
|
184
184
|
|
|
185
185
|
<h3 class="site-preview-heading">Outline inverse</h3>
|
|
186
|
-
<div class="bg-
|
|
186
|
+
<div class="bg-surface-inverse padding-1" style="max-width: fit-content">
|
|
187
187
|
<button
|
|
188
188
|
class="usa-button usx-button usa-button--outline usa-button--inverse"
|
|
189
189
|
type="button"
|
|
@@ -356,7 +356,7 @@
|
|
|
356
356
|
Copy
|
|
357
357
|
</button>
|
|
358
358
|
</div>
|
|
359
|
-
<div class="margin-bottom-3 bg-
|
|
359
|
+
<div class="margin-bottom-3 bg-surface-inverse padding-1">
|
|
360
360
|
<button class="usa-button usx-button usx-button--ghost usa-button--inverse" type="button">
|
|
361
361
|
Inverse
|
|
362
362
|
</button>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<ul class="usa-button-group usx-button-group {% if segmented %}usa-button-group--segmented{% endif %} {{ className }}">
|
|
4
4
|
{% for item in buttonProps %}
|
|
5
5
|
<li class="usa-button-group__item{% if item.itemClassName %} {{ item.itemClassName }}{% endif %}">
|
|
6
|
-
{% button
|
|
6
|
+
{% button props=item %}{{ item.children|safe }}{% endbutton %}
|
|
7
7
|
</li>
|
|
8
8
|
{% endfor %}
|
|
9
9
|
</ul>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{% load components %}
|
|
2
2
|
|
|
3
|
-
<div class="{% if
|
|
3
|
+
<div class="{% if underCollection %}usa-collection__calendar-date{% endif %} usx-calendar-date">
|
|
4
4
|
<time datetime="{{ datetime }}">
|
|
5
|
-
<span class="{% if
|
|
6
|
-
<span class="{% if
|
|
5
|
+
<span class="{% if underCollection %}usa-collection__calendar-date-month{% endif %} usx-calendar-date-month">{{ datetime|parse_iso|date:"M"|upper }}</span>
|
|
6
|
+
<span class="{% if underCollection %}usa-collection__calendar-date-day{% endif %} usx-calendar-date-day">{{ datetime|parse_iso|date:"j" }}</span>
|
|
7
7
|
</time>
|
|
8
8
|
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ClassNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
export interface CalloutProps extends Omit<React.HTMLAttributes<HTMLElement>, 'content' | 'color'> {
|
|
5
|
+
className?: string;
|
|
6
|
+
strokeColor?: string;
|
|
7
|
+
indent?: 'sm' | 'md' | 'lg' | 'xl' | null;
|
|
8
|
+
dedent?: boolean;
|
|
9
|
+
big?: boolean;
|
|
10
|
+
orientation?: 'horizontal' | 'vertical';
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
content?: React.ReactNode;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
element?: 'div' | 'section' | 'aside' | 'blockquote';
|
|
16
|
+
cite?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function Callout({
|
|
20
|
+
className,
|
|
21
|
+
strokeColor,
|
|
22
|
+
indent,
|
|
23
|
+
dedent,
|
|
24
|
+
big,
|
|
25
|
+
orientation = 'horizontal',
|
|
26
|
+
children,
|
|
27
|
+
content,
|
|
28
|
+
backgroundColor,
|
|
29
|
+
textColor,
|
|
30
|
+
element = 'div',
|
|
31
|
+
...props
|
|
32
|
+
}: CalloutProps) {
|
|
33
|
+
const Element = element;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Element
|
|
37
|
+
className={ClassNames(
|
|
38
|
+
'usx-callout',
|
|
39
|
+
orientation === 'vertical' && 'usx-callout--vertical',
|
|
40
|
+
strokeColor && `usx-border-${strokeColor}`,
|
|
41
|
+
indent && `usx-callout--indent-${indent}`,
|
|
42
|
+
dedent && 'usx-callout--dedent',
|
|
43
|
+
(big ?? orientation === 'horizontal') && 'usx-callout--big',
|
|
44
|
+
backgroundColor && `bg-${backgroundColor}`,
|
|
45
|
+
textColor && `text-${textColor}`,
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children ?? content}
|
|
51
|
+
</Element>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{% with tag=element|default:'div' %}
|
|
2
|
+
<{% if tag == 'section' or tag == 'aside' or tag == 'blockquote' %}{{ tag }}{% else %}div{% endif %} class="usx-callout{% if orientation == 'vertical' %} usx-callout--vertical{% endif %}{% if strokeColor %} usx-border-{{ strokeColor }}{% endif %}{% if indent %} usx-callout--indent-{{ indent }}{% endif %}{% if dedent %} usx-callout--dedent{% endif %}{% if big or orientation|default:'horizontal' == 'horizontal' %}{% if big is not False %} usx-callout--big{% endif %}{% endif %}{% if backgroundColor %} bg-{{ backgroundColor }}{% endif %}{% if textColor %} text-{{ textColor }}{% endif %}{% if className %} {{ className }}{% endif %}"{% if tag == 'blockquote' and cite %} cite="{{ cite }}"{% endif %}>
|
|
3
|
+
{% if children != None %}{{ children|safe }}{% elif content != None %}{{ content|safe }}{% endif %}
|
|
4
|
+
</{% if tag == 'section' or tag == 'aside' or tag == 'blockquote' %}{{ tag }}{% else %}div{% endif %}>
|
|
5
|
+
{% endwith %}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<div class="padding-3">
|
|
2
|
+
<section class="margin-bottom-4">
|
|
3
|
+
<h2>Default</h2>
|
|
4
|
+
<div class="usx-callout usx-callout--big">Related information goes here.</div>
|
|
5
|
+
</section>
|
|
6
|
+
|
|
7
|
+
<section class="margin-bottom-4">
|
|
8
|
+
<h2>Thin Horizontal</h2>
|
|
9
|
+
<div class="usx-callout usx-border-info">A horizontal callout with a thinner left border.</div>
|
|
10
|
+
</section>
|
|
11
|
+
|
|
12
|
+
<section class="margin-bottom-4">
|
|
13
|
+
<h2>Vertical</h2>
|
|
14
|
+
<div class="usx-callout usx-callout--vertical">A vertical callout with its default top border.</div>
|
|
15
|
+
</section>
|
|
16
|
+
|
|
17
|
+
<section class="margin-bottom-4">
|
|
18
|
+
<h2>Big Vertical</h2>
|
|
19
|
+
<div class="usx-callout usx-callout--vertical usx-border-info usx-callout--big">A vertical callout with a thicker top border.</div>
|
|
20
|
+
</section>
|
|
21
|
+
|
|
22
|
+
<section class="margin-bottom-4">
|
|
23
|
+
<h2>Colors</h2>
|
|
24
|
+
<div class="usx-callout usx-border-primary usx-callout--big bg-base-lightest text-primary padding-y-2 padding-right-2">Independent border, background, text, and spacing styles.</div>
|
|
25
|
+
</section>
|
|
26
|
+
|
|
27
|
+
<section class="margin-bottom-4">
|
|
28
|
+
<h2>Indent SM</h2>
|
|
29
|
+
<div class="usx-callout usx-callout--indent-sm usx-callout--big">Indent: sm.</div>
|
|
30
|
+
</section>
|
|
31
|
+
|
|
32
|
+
<section class="margin-bottom-4">
|
|
33
|
+
<h2>Indent MD</h2>
|
|
34
|
+
<div class="usx-callout usx-callout--indent-md usx-callout--big">Indent: md.</div>
|
|
35
|
+
</section>
|
|
36
|
+
|
|
37
|
+
<section class="margin-bottom-4">
|
|
38
|
+
<h2>Indent LG</h2>
|
|
39
|
+
<div class="usx-callout usx-callout--indent-lg usx-callout--big">Indent: lg.</div>
|
|
40
|
+
</section>
|
|
41
|
+
|
|
42
|
+
<section class="margin-bottom-4">
|
|
43
|
+
<h2>Indent XL</h2>
|
|
44
|
+
<div class="usx-callout usx-callout--indent-xl usx-callout--big">Indent: xl.</div>
|
|
45
|
+
</section>
|
|
46
|
+
|
|
47
|
+
<section class="margin-bottom-4">
|
|
48
|
+
<h2>Dedent</h2>
|
|
49
|
+
<div class="usx-callout usx-callout--dedent usx-callout--big">Pulled left beyond the normal content edge.</div>
|
|
50
|
+
</section>
|
|
51
|
+
|
|
52
|
+
<section class="margin-bottom-4">
|
|
53
|
+
<h2>Section</h2>
|
|
54
|
+
<section class="usx-callout usx-callout--big"><h3>Program details</h3><p>Related information in a semantic section.</p></section>
|
|
55
|
+
</section>
|
|
56
|
+
|
|
57
|
+
<section class="margin-bottom-4">
|
|
58
|
+
<h2>Aside</h2>
|
|
59
|
+
<aside class="usx-callout usx-callout--big">Supplementary information in an aside.</aside>
|
|
60
|
+
</section>
|
|
61
|
+
|
|
62
|
+
<section class="margin-bottom-4">
|
|
63
|
+
<h2>Blockquote</h2>
|
|
64
|
+
<blockquote class="usx-callout usx-callout--big" cite="https://example.com/report">A sourced quotation using the blockquote root.</blockquote>
|
|
65
|
+
</section>
|
|
66
|
+
|
|
67
|
+
<section class="margin-bottom-4">
|
|
68
|
+
<h2>Children Override</h2>
|
|
69
|
+
<div class="usx-callout usx-callout--big"><p><strong>Children win.</strong> Rich content can include <a class="usa-link usx-link usa-link--external" href="#details">links</a> and emphasis.</p></div>
|
|
70
|
+
</section>
|
|
71
|
+
|
|
72
|
+
<section class="margin-bottom-4">
|
|
73
|
+
<h2>Empty Children</h2>
|
|
74
|
+
<div class="usx-callout usx-callout--big padding-y-2"></div>
|
|
75
|
+
</section>
|
|
76
|
+
</div>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "callout",
|
|
3
|
+
"template": "callout/callout.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"props": {
|
|
6
|
+
"className": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Additional classes."
|
|
9
|
+
},
|
|
10
|
+
"strokeColor": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Border color token. Omit to leave the border color utility unset."
|
|
13
|
+
},
|
|
14
|
+
"indent": {
|
|
15
|
+
"type": "select",
|
|
16
|
+
"description": "Left indentation.",
|
|
17
|
+
"options": [
|
|
18
|
+
"sm",
|
|
19
|
+
"md",
|
|
20
|
+
"lg",
|
|
21
|
+
"xl"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"dedent": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Pull the callout left beyond the content edge.",
|
|
27
|
+
"default": false
|
|
28
|
+
},
|
|
29
|
+
"big": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"description": "Use a thicker border."
|
|
32
|
+
},
|
|
33
|
+
"orientation": {
|
|
34
|
+
"type": "select",
|
|
35
|
+
"description": "Horizontal uses a left border; vertical uses a top border.",
|
|
36
|
+
"options": [
|
|
37
|
+
"horizontal",
|
|
38
|
+
"vertical"
|
|
39
|
+
],
|
|
40
|
+
"default": "horizontal"
|
|
41
|
+
},
|
|
42
|
+
"children": {
|
|
43
|
+
"type": "slot",
|
|
44
|
+
"description": "Body content. Takes precedence over content when supplied."
|
|
45
|
+
},
|
|
46
|
+
"content": {
|
|
47
|
+
"type": "slot",
|
|
48
|
+
"description": "Fallback body content, ignored when children is supplied."
|
|
49
|
+
},
|
|
50
|
+
"backgroundColor": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Background utility token: bg-{backgroundColor}."
|
|
53
|
+
},
|
|
54
|
+
"textColor": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "Text utility token: text-{textColor}."
|
|
57
|
+
},
|
|
58
|
+
"element": {
|
|
59
|
+
"type": "select",
|
|
60
|
+
"description": "Root HTML element.",
|
|
61
|
+
"options": [
|
|
62
|
+
"div",
|
|
63
|
+
"section",
|
|
64
|
+
"aside",
|
|
65
|
+
"blockquote"
|
|
66
|
+
],
|
|
67
|
+
"default": "div"
|
|
68
|
+
},
|
|
69
|
+
"cite": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"description": "Source URL when the root element is blockquote."
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -2,32 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
3
|
import ButtonGroup from '../button-group/ButtonGroup';
|
|
4
4
|
import type { ButtonGroupItemProps } from '../button-group/ButtonGroup';
|
|
5
|
-
import Tag from '../tag/Tag';
|
|
6
|
-
import Image from '../image/Image';
|
|
5
|
+
import Tag, { type TagProps } from '../tag/Tag';
|
|
6
|
+
import Image, { type ImageProps } from '../image/Image';
|
|
7
7
|
import Carousel from '../carousel/Carousel';
|
|
8
8
|
|
|
9
|
-
export interface CardTag {
|
|
10
|
-
value: string;
|
|
11
|
-
color?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface CardAction {
|
|
15
|
-
children: string;
|
|
16
|
-
variant?: ButtonGroupItemProps['variant'];
|
|
17
|
-
onClick?: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface CardImage {
|
|
21
|
-
src: string;
|
|
22
|
-
alt: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
9
|
export interface CardProps extends React.HTMLAttributes<HTMLElement> {
|
|
26
10
|
title?: string;
|
|
27
11
|
description?: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
tagProps?: TagProps[];
|
|
13
|
+
buttonProps?: ButtonGroupItemProps[];
|
|
14
|
+
imageProps?: ImageProps[];
|
|
31
15
|
headerFirst?: boolean;
|
|
32
16
|
flag?: boolean;
|
|
33
17
|
mediaRight?: boolean;
|
|
@@ -42,9 +26,9 @@ export interface CardProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
42
26
|
export default function Card({
|
|
43
27
|
title,
|
|
44
28
|
description,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
tagProps,
|
|
30
|
+
buttonProps,
|
|
31
|
+
imageProps,
|
|
48
32
|
headerFirst = false,
|
|
49
33
|
flag = false,
|
|
50
34
|
mediaRight = false,
|
|
@@ -75,22 +59,22 @@ export default function Card({
|
|
|
75
59
|
}
|
|
76
60
|
);
|
|
77
61
|
|
|
78
|
-
const hasStructuredContent = title || description ||
|
|
62
|
+
const hasStructuredContent = title || description || tagProps || buttonProps || imageProps;
|
|
79
63
|
const shouldRenderStructured = hasStructuredContent && !children;
|
|
80
64
|
|
|
81
|
-
const hasImages =
|
|
82
|
-
const useCarousel =
|
|
65
|
+
const hasImages = imageProps && imageProps.length > 0;
|
|
66
|
+
const useCarousel = imageProps && imageProps.length > 1;
|
|
83
67
|
const media = useCarousel ? (
|
|
84
68
|
<Carousel
|
|
85
69
|
id={`${props.id || 'card'}-carousel`}
|
|
86
70
|
showDots={showCarouselDots}
|
|
87
71
|
className="usx-card__carousel"
|
|
88
|
-
slides={
|
|
89
|
-
content: <Image key={index}
|
|
72
|
+
slides={imageProps?.map((img, index) => ({
|
|
73
|
+
content: <Image key={index} hideCaption={true} {...img} />,
|
|
90
74
|
}))}
|
|
91
75
|
/>
|
|
92
76
|
) : hasImages ? (
|
|
93
|
-
<Image {...
|
|
77
|
+
<Image hideCaption={true} {...imageProps[0]} className={ClassNames('usa-card__img', imageProps[0].className)} />
|
|
94
78
|
) : null;
|
|
95
79
|
|
|
96
80
|
return (
|
|
@@ -111,9 +95,9 @@ export default function Card({
|
|
|
111
95
|
)}
|
|
112
96
|
|
|
113
97
|
<div className="usa-card__body">
|
|
114
|
-
{
|
|
98
|
+
{tagProps && tagProps.length > 0 && (
|
|
115
99
|
<div className="usx-tag-group">
|
|
116
|
-
{
|
|
100
|
+
{tagProps.map((tag, index) => (
|
|
117
101
|
<Tag key={index} {...tag} />
|
|
118
102
|
))}
|
|
119
103
|
</div>
|
|
@@ -123,9 +107,9 @@ export default function Card({
|
|
|
123
107
|
)}
|
|
124
108
|
</div>
|
|
125
109
|
|
|
126
|
-
{
|
|
110
|
+
{buttonProps && buttonProps.length > 0 && (
|
|
127
111
|
<div className="usa-card__footer">
|
|
128
|
-
<ButtonGroup buttonProps={
|
|
112
|
+
<ButtonGroup buttonProps={buttonProps} className="flex-wrap" />
|
|
129
113
|
</div>
|
|
130
114
|
)}
|
|
131
115
|
</>
|
|
@@ -3,26 +3,28 @@
|
|
|
3
3
|
<div class="usa-card__container">
|
|
4
4
|
{% if children %}
|
|
5
5
|
{{ children }}
|
|
6
|
-
{% elif title or description or
|
|
6
|
+
{% elif title or description or tagProps or buttonProps or imageProps %}
|
|
7
7
|
{% if title %}
|
|
8
8
|
<div class="usa-card__header">
|
|
9
9
|
<h4 class="usa-card__heading">{{ title }}</h4>
|
|
10
10
|
</div>
|
|
11
11
|
{% endif %}
|
|
12
|
-
{% if
|
|
12
|
+
{% if imageProps and imageProps|length > 1 %}
|
|
13
13
|
<div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
|
|
14
|
-
{% carousel slides=
|
|
14
|
+
{% carousel slides=imageProps id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
|
|
15
15
|
</div>
|
|
16
|
-
{% elif
|
|
16
|
+
{% elif imageProps and imageProps.0 %}
|
|
17
17
|
<div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
|
|
18
|
-
{%
|
|
18
|
+
{% with imageClass=imageProps.0.className|default:'' %}
|
|
19
|
+
{% image props=imageProps.0 hideCaption=imageProps.0.hideCaption|default_bool:True className='usa-card__img '|add:imageClass %}{{ imageProps.0.children|safe }}{% endimage %}
|
|
20
|
+
{% endwith %}
|
|
19
21
|
</div>
|
|
20
22
|
{% endif %}
|
|
21
23
|
<div class="usa-card__body">
|
|
22
|
-
{% if
|
|
24
|
+
{% if tagProps %}
|
|
23
25
|
<div class="usx-tag-group">
|
|
24
|
-
{% for tag in
|
|
25
|
-
{% tag
|
|
26
|
+
{% for tag in tagProps %}
|
|
27
|
+
{% tag props=tag %}{{ tag.children|safe }}{% endtag %}
|
|
26
28
|
{% endfor %}
|
|
27
29
|
</div>
|
|
28
30
|
{% endif %}
|
|
@@ -30,9 +32,9 @@
|
|
|
30
32
|
<p>{{ description }}</p>
|
|
31
33
|
{% endif %}
|
|
32
34
|
</div>
|
|
33
|
-
{% if
|
|
35
|
+
{% if buttonProps %}
|
|
34
36
|
<div class="usa-card__footer">
|
|
35
|
-
{% button_group buttonProps=
|
|
37
|
+
{% button_group buttonProps=buttonProps className='flex-wrap' %}{% endbutton_group %}
|
|
36
38
|
</div>
|
|
37
39
|
{% endif %}
|
|
38
40
|
{% else %}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "card",
|
|
3
3
|
"template": "card/card.django.html",
|
|
4
|
-
"version":
|
|
4
|
+
"version": 3,
|
|
5
5
|
"props": {
|
|
6
6
|
"id": {
|
|
7
7
|
"type": "string",
|
|
@@ -15,62 +15,37 @@
|
|
|
15
15
|
"type": "string",
|
|
16
16
|
"description": "The description text displayed in the card body"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"tagProps": {
|
|
19
19
|
"type": "array",
|
|
20
|
-
"description": "
|
|
20
|
+
"description": "Props for each tag component.",
|
|
21
21
|
"items": {
|
|
22
22
|
"type": "object",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"value": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"description": "Tag text"
|
|
28
|
-
},
|
|
29
|
-
"color": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"description": "Tag color variant"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
23
|
+
"component": "tag",
|
|
24
|
+
"description": "Props passed to the tag component."
|
|
34
25
|
}
|
|
35
26
|
},
|
|
36
|
-
"
|
|
27
|
+
"buttonProps": {
|
|
37
28
|
"type": "array",
|
|
38
|
-
"description": "
|
|
29
|
+
"description": "Props for each button component.",
|
|
39
30
|
"items": {
|
|
40
31
|
"type": "object",
|
|
41
|
-
"
|
|
32
|
+
"component": "button",
|
|
33
|
+
"description": "Props passed to the button component.",
|
|
42
34
|
"properties": {
|
|
43
|
-
"
|
|
44
|
-
"type": "string",
|
|
45
|
-
"description": "Button text"
|
|
46
|
-
},
|
|
47
|
-
"variant": {
|
|
35
|
+
"itemClassName": {
|
|
48
36
|
"type": "string",
|
|
49
|
-
"description": "
|
|
50
|
-
},
|
|
51
|
-
"onClick": {
|
|
52
|
-
"type": "function",
|
|
53
|
-
"description": "Click handler"
|
|
37
|
+
"description": "Additional classes for the button group list item."
|
|
54
38
|
}
|
|
55
39
|
}
|
|
56
40
|
}
|
|
57
41
|
},
|
|
58
|
-
"
|
|
42
|
+
"imageProps": {
|
|
59
43
|
"type": "array",
|
|
60
|
-
"description": "
|
|
44
|
+
"description": "Props for each image component.",
|
|
61
45
|
"items": {
|
|
62
46
|
"type": "object",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"src": {
|
|
66
|
-
"type": "string",
|
|
67
|
-
"description": "Image source URL"
|
|
68
|
-
},
|
|
69
|
-
"alt": {
|
|
70
|
-
"type": "string",
|
|
71
|
-
"description": "Alt text for the image"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
47
|
+
"component": "image",
|
|
48
|
+
"description": "Props passed to the image component."
|
|
74
49
|
}
|
|
75
50
|
},
|
|
76
51
|
"headerFirst": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% load components %}
|
|
2
2
|
<ul class="usa-card-group usx-card-group{% if className %} {{ className }}{% endif %}">
|
|
3
3
|
{% for card in cardProps %}
|
|
4
|
-
{% card tag='li'
|
|
4
|
+
{% card props=card tag='li' %}{{ card.children|safe }}{% endcard %}
|
|
5
5
|
{% endfor %}
|
|
6
6
|
</ul>
|