@solexllc/usx-react 0.10.0 → 0.11.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 +123 -66
- package/dist/index.js +123 -66
- package/package.json +4 -4
- package/src/components/code/code.django-snapshot.html +4 -6
- package/src/components/code/code.html +2 -2
- package/src/components/code/code.react-snapshot.html +2 -4
- package/src/components/header/header.django-snapshot.html +5 -7
- package/src/components/header/header.html +1 -11
- package/src/components/header/header.react-snapshot.html +3 -6
- package/src/components/icon-list/IconList.tsx +10 -2
- package/src/components/icon-list/config.json +5 -1
- package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
- package/src/components/icon-list/icon-list.django.html +2 -0
- package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
- package/src/components/list/List.tsx +10 -2
- package/src/components/list/config.json +5 -1
- package/src/components/list/list.django-snapshot.html +26 -0
- package/src/components/list/list.django.html +2 -0
- package/src/components/list/list.html +20 -0
- package/src/components/list/list.react-snapshot.html +20 -0
- package/src/components/page/Page.tsx +16 -0
- package/src/components/page/config.json +18 -1
- package/src/components/page/page.django-snapshot.html +74 -0
- package/src/components/page/page.django.html +8 -0
- package/src/components/page/page.html +60 -0
- package/src/components/page/page.react-snapshot.html +60 -0
- package/src/components/theme-picker/ThemePicker.tsx +95 -52
- package/src/components/theme-picker/config.json +7 -4
- package/src/components/theme-picker/theme-picker-select.django.html +7 -0
- package/src/components/theme-picker/theme-picker.django-snapshot.html +101 -21
- package/src/components/theme-picker/theme-picker.django.html +22 -24
- package/src/components/theme-picker/theme-picker.html +86 -56
- package/src/components/theme-picker/theme-picker.react-snapshot.html +74 -18
|
@@ -35,6 +35,66 @@
|
|
|
35
35
|
</div>
|
|
36
36
|
</main>
|
|
37
37
|
|
|
38
|
+
<h3 class="site-preview-heading">With Subtitle</h3>
|
|
39
|
+
<main class="usx-page">
|
|
40
|
+
<h1 class="usx-page__title">Benefits and services</h1>
|
|
41
|
+
<div class="usx-page__summary">
|
|
42
|
+
<p class="usx-page__subtitle">Find support for every stage of life</p>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="usx-page__content">
|
|
45
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
46
|
+
<p>Use this region for page-specific content.</p>
|
|
47
|
+
</div>
|
|
48
|
+
</main>
|
|
49
|
+
|
|
50
|
+
<h3 class="site-preview-heading">With Description</h3>
|
|
51
|
+
<main class="usx-page">
|
|
52
|
+
<h1 class="usx-page__title">Program overview</h1>
|
|
53
|
+
<div class="usx-page__summary">
|
|
54
|
+
<p class="usx-page__description">
|
|
55
|
+
Explore available services, eligibility, and the steps to apply.
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="usx-page__content">
|
|
59
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
60
|
+
<p>Use this region for page-specific content.</p>
|
|
61
|
+
</div>
|
|
62
|
+
</main>
|
|
63
|
+
|
|
64
|
+
<h3 class="site-preview-heading">With Tags</h3>
|
|
65
|
+
<main class="usx-page">
|
|
66
|
+
<h1 class="usx-page__title">Program updates</h1>
|
|
67
|
+
<div class="usx-page__summary">
|
|
68
|
+
<div class="usx-tag-group usx-page__tags">
|
|
69
|
+
<span class="usa-tag usx-tag"> New</span
|
|
70
|
+
><span class="usa-tag usx-tag usx-tag--outline"> Public notice</span>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="usx-page__content">
|
|
74
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
75
|
+
<p>Use this region for page-specific content.</p>
|
|
76
|
+
</div>
|
|
77
|
+
</main>
|
|
78
|
+
|
|
79
|
+
<h3 class="site-preview-heading">With Summary</h3>
|
|
80
|
+
<main class="usx-page">
|
|
81
|
+
<h1 class="usx-page__title">
|
|
82
|
+
<span class="usx-eyebrow">Funding opportunities</span>Community grants
|
|
83
|
+
</h1>
|
|
84
|
+
<div class="usx-page__summary">
|
|
85
|
+
<p class="usx-page__subtitle">Support for local projects</p>
|
|
86
|
+
<div class="usx-tag-group usx-page__tags">
|
|
87
|
+
<span class="usa-tag usx-tag"> Open</span
|
|
88
|
+
><span class="usa-tag usx-tag usx-tag--outline"> Applications close June 30</span>
|
|
89
|
+
</div>
|
|
90
|
+
<p class="usx-page__description">Find grants that help communities plan, build, and grow.</p>
|
|
91
|
+
</div>
|
|
92
|
+
<div class="usx-page__content">
|
|
93
|
+
<p>This page wrapper provides consistent spacing between a site header and footer.</p>
|
|
94
|
+
<p>Use this region for page-specific content.</p>
|
|
95
|
+
</div>
|
|
96
|
+
</main>
|
|
97
|
+
|
|
38
98
|
<h3 class="site-preview-heading">With Classes</h3>
|
|
39
99
|
<main class="usx-page bg-violet text-white padding-2">
|
|
40
100
|
<h1 class="usx-page__title">Page with extra classes</h1>
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ClassNames from 'classnames';
|
|
3
|
-
|
|
4
3
|
import Icon from '../icon/Icon';
|
|
5
4
|
import Label from '../label/Label';
|
|
5
|
+
import Swap from '../swap/Swap';
|
|
6
6
|
|
|
7
7
|
export interface ThemePickerOption {
|
|
8
8
|
value: string;
|
|
9
9
|
label: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export type ThemePickerVariant = 'default' | 'swap' | 'ghost-select';
|
|
13
|
+
|
|
12
14
|
export interface ThemePickerProps {
|
|
13
15
|
id?: string;
|
|
14
16
|
name?: string;
|
|
15
17
|
label?: string;
|
|
16
18
|
themes?: ThemePickerOption[];
|
|
19
|
+
/** Swap uses the first option for light and the second for dark. */
|
|
20
|
+
variant?: ThemePickerVariant;
|
|
17
21
|
value?: string;
|
|
18
22
|
defaultValue?: string;
|
|
19
23
|
onChange?: (value: string) => void;
|
|
@@ -26,6 +30,7 @@ export default function ThemePicker({
|
|
|
26
30
|
name,
|
|
27
31
|
label = 'Theme',
|
|
28
32
|
themes = [],
|
|
33
|
+
variant = 'default',
|
|
29
34
|
value,
|
|
30
35
|
defaultValue,
|
|
31
36
|
onChange,
|
|
@@ -33,61 +38,99 @@ export default function ThemePicker({
|
|
|
33
38
|
extraAttributes,
|
|
34
39
|
}: ThemePickerProps) {
|
|
35
40
|
const selectId = id || 'theme-picker';
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const [localValue, setLocalValue] = React.useState(defaultValue ?? themes[0]?.value ?? '');
|
|
42
|
+
const selectedValue = value ?? localValue;
|
|
43
|
+
const selectedLabel = themes.find((option) => option.value === selectedValue)?.label ?? label;
|
|
44
|
+
const choose = (next: string) => {
|
|
45
|
+
if (value === undefined) setLocalValue(next);
|
|
46
|
+
onChange?.(next);
|
|
47
|
+
};
|
|
48
|
+
const select = (hidden = false) => (
|
|
49
|
+
<>
|
|
50
|
+
<Label htmlFor={selectId} screenReaderOnly>
|
|
51
|
+
{label}
|
|
52
|
+
</Label>
|
|
53
|
+
<select
|
|
54
|
+
id={selectId}
|
|
55
|
+
name={name}
|
|
56
|
+
className={ClassNames(
|
|
57
|
+
'usa-select usx-select',
|
|
58
|
+
hidden && 'usx-theme-picker__select--hidden'
|
|
59
|
+
)}
|
|
60
|
+
value={selectedValue}
|
|
61
|
+
onChange={(event) => choose(event.target.value)}
|
|
47
62
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
id={selectId}
|
|
56
|
-
name={name}
|
|
57
|
-
className="usa-select usx-select"
|
|
58
|
-
{...selection}
|
|
59
|
-
onChange={(event) => onChange?.(event.target.value)}
|
|
60
|
-
>
|
|
61
|
-
{themes.map((option) => (
|
|
62
|
-
<option key={option.value} value={option.value}>
|
|
63
|
-
{option.label}
|
|
64
|
-
</option>
|
|
65
|
-
))}
|
|
66
|
-
</select>
|
|
67
|
-
<button
|
|
68
|
-
type="button"
|
|
69
|
-
className="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
70
|
-
aria-label="Confirm theme"
|
|
71
|
-
>
|
|
72
|
-
<Icon name="close" className="usx-theme-picker__icon" />
|
|
73
|
-
</button>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
63
|
+
{themes.map((option) => (
|
|
64
|
+
<option key={option.value} value={option.value}>
|
|
65
|
+
{option.label}
|
|
66
|
+
</option>
|
|
67
|
+
))}
|
|
68
|
+
</select>
|
|
69
|
+
</>
|
|
76
70
|
);
|
|
77
|
-
}
|
|
78
71
|
|
|
79
|
-
function PaletteIcon() {
|
|
80
72
|
return (
|
|
81
|
-
<
|
|
82
|
-
className=
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
<div
|
|
74
|
+
className={ClassNames(
|
|
75
|
+
'usx-theme-picker',
|
|
76
|
+
variant !== 'default' && `usx-theme-picker--${variant}`,
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...extraAttributes}
|
|
86
80
|
>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
{variant === 'default' && (
|
|
82
|
+
<>
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
|
|
86
|
+
aria-label={label}
|
|
87
|
+
aria-expanded="false"
|
|
88
|
+
aria-controls={`${selectId}-panel`}
|
|
89
|
+
>
|
|
90
|
+
<Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
|
|
91
|
+
</button>
|
|
92
|
+
<div id={`${selectId}-panel`} className="usx-theme-picker__panel">
|
|
93
|
+
{select()}
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
className="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
97
|
+
aria-label="Confirm theme"
|
|
98
|
+
>
|
|
99
|
+
<Icon name="close" className="usx-theme-picker__icon" />
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
</>
|
|
103
|
+
)}
|
|
104
|
+
{variant === 'swap' && (
|
|
105
|
+
<>
|
|
106
|
+
<Swap
|
|
107
|
+
className="usx-theme-picker__swap usa-button usx-button usx-button--ghost"
|
|
108
|
+
variant="rotate"
|
|
109
|
+
inputProps={{
|
|
110
|
+
checked: selectedValue === themes[1]?.value,
|
|
111
|
+
'aria-label': `${label}: ${selectedLabel}. Switch to ${selectedValue === themes[1]?.value ? themes[0]?.label : themes[1]?.label}`,
|
|
112
|
+
onChange: (event) => {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
choose(themes[event.target.checked ? 1 : 0]?.value ?? '');
|
|
115
|
+
},
|
|
116
|
+
}}
|
|
117
|
+
offContent={<Icon name="sun" source="usx" className="usx-theme-picker__icon" />}
|
|
118
|
+
onContent={<Icon name="moon" source="usx" className="usx-theme-picker__icon" />}
|
|
119
|
+
/>
|
|
120
|
+
<div className="usx-theme-picker__fallback">{select()}</div>
|
|
121
|
+
</>
|
|
122
|
+
)}
|
|
123
|
+
{variant === 'ghost-select' && (
|
|
124
|
+
<div className="usx-theme-picker__ghost">
|
|
125
|
+
<span
|
|
126
|
+
className="usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face"
|
|
127
|
+
aria-hidden="true"
|
|
128
|
+
>
|
|
129
|
+
<Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
|
|
130
|
+
</span>
|
|
131
|
+
{select(true)}
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
92
135
|
);
|
|
93
136
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theme-picker",
|
|
3
3
|
"template": "theme-picker/theme-picker.django.html",
|
|
4
|
-
"version":
|
|
5
|
-
"required": [
|
|
6
|
-
"themes"
|
|
7
|
-
],
|
|
4
|
+
"version": 2,
|
|
5
|
+
"required": ["themes"],
|
|
8
6
|
"default": {
|
|
9
7
|
"id": "theme-picker-1",
|
|
10
8
|
"label": "Theme",
|
|
@@ -99,6 +97,11 @@
|
|
|
99
97
|
"extraAttributes": {
|
|
100
98
|
"type": "object",
|
|
101
99
|
"description": "Additional HTML attributes on the theme picker root."
|
|
100
|
+
},
|
|
101
|
+
"variant": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"default": "default",
|
|
104
|
+
"description": "Picker presentation: default, ghost-select, or swap. Swap uses two themes: first light, second dark."
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{% load usx_components %}
|
|
2
|
+
{% label htmlFor=field_id screenReaderOnly=True only %}{{ label|default:'Theme' }}{% endlabel %}
|
|
3
|
+
<select id="{{ field_id }}" class="usa-select usx-select{% if hidden %} usx-theme-picker__select--hidden{% endif %}"{% if name %} name="{{ name }}"{% endif %}>
|
|
4
|
+
{% for theme in themes %}
|
|
5
|
+
<option value="{{ theme.value }}"{% if theme.value == selected_value %} selected{% endif %}>{{ theme.label }}</option>
|
|
6
|
+
{% endfor %}
|
|
7
|
+
</select>
|
|
@@ -8,21 +8,18 @@
|
|
|
8
8
|
aria-controls="django-theme-picker-1-panel"
|
|
9
9
|
>
|
|
10
10
|
<svg
|
|
11
|
-
class="usa-icon usx-theme-picker__icon"
|
|
11
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
12
12
|
aria-hidden="true"
|
|
13
13
|
focusable="false"
|
|
14
|
-
|
|
14
|
+
role="img"
|
|
15
15
|
>
|
|
16
|
-
<
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
|
|
19
|
-
/>
|
|
16
|
+
<use href="img/usx-sprite.svg#color_palette"></use>
|
|
20
17
|
</svg>
|
|
21
18
|
</button>
|
|
22
19
|
<div id="django-theme-picker-1-panel" class="usx-theme-picker__panel">
|
|
23
20
|
<label class="usa-label usx-label usa-sr-only" for="django-theme-picker-1"> Theme </label>
|
|
24
21
|
|
|
25
|
-
<select class="usa-select usx-select"
|
|
22
|
+
<select id="django-theme-picker-1" class="usa-select usx-select">
|
|
26
23
|
<option value="Default" selected>Default</option>
|
|
27
24
|
|
|
28
25
|
<option value="Forest">Forest</option>
|
|
@@ -45,6 +42,7 @@
|
|
|
45
42
|
|
|
46
43
|
<option value="NASA">NASA</option>
|
|
47
44
|
</select>
|
|
45
|
+
|
|
48
46
|
<button
|
|
49
47
|
type="button"
|
|
50
48
|
class="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
@@ -72,25 +70,23 @@
|
|
|
72
70
|
aria-controls="django-theme-picker-2-panel"
|
|
73
71
|
>
|
|
74
72
|
<svg
|
|
75
|
-
class="usa-icon usx-theme-picker__icon"
|
|
73
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
76
74
|
aria-hidden="true"
|
|
77
75
|
focusable="false"
|
|
78
|
-
|
|
76
|
+
role="img"
|
|
79
77
|
>
|
|
80
|
-
<
|
|
81
|
-
fill="currentColor"
|
|
82
|
-
d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
|
|
83
|
-
/>
|
|
78
|
+
<use href="img/usx-sprite.svg#color_palette"></use>
|
|
84
79
|
</svg>
|
|
85
80
|
</button>
|
|
86
81
|
<div id="django-theme-picker-2-panel" class="usx-theme-picker__panel">
|
|
87
82
|
<label class="usa-label usx-label usa-sr-only" for="django-theme-picker-2"> Theme </label>
|
|
88
83
|
|
|
89
|
-
<select class="usa-select usx-select"
|
|
84
|
+
<select id="django-theme-picker-2" class="usa-select usx-select">
|
|
90
85
|
<option value="Aurora" selected>Light</option>
|
|
91
86
|
|
|
92
87
|
<option value="Borealis">Dark</option>
|
|
93
88
|
</select>
|
|
89
|
+
|
|
94
90
|
<button
|
|
95
91
|
type="button"
|
|
96
92
|
class="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
@@ -108,6 +104,92 @@
|
|
|
108
104
|
</div>
|
|
109
105
|
</div>
|
|
110
106
|
|
|
107
|
+
<h3 class="site-preview-heading">Ghost Select</h3>
|
|
108
|
+
<div class="usx-theme-picker usx-theme-picker--ghost-select">
|
|
109
|
+
<div class="usx-theme-picker__ghost">
|
|
110
|
+
<span
|
|
111
|
+
class="usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face"
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
>
|
|
114
|
+
<svg
|
|
115
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
116
|
+
aria-hidden="true"
|
|
117
|
+
focusable="false"
|
|
118
|
+
role="img"
|
|
119
|
+
>
|
|
120
|
+
<use href="img/usx-sprite.svg#color_palette"></use>
|
|
121
|
+
</svg>
|
|
122
|
+
</span>
|
|
123
|
+
|
|
124
|
+
<label class="usa-label usx-label usa-sr-only" for="django-theme-picker-ghost-select">
|
|
125
|
+
Theme
|
|
126
|
+
</label>
|
|
127
|
+
|
|
128
|
+
<select
|
|
129
|
+
id="django-theme-picker-ghost-select"
|
|
130
|
+
class="usa-select usx-select usx-theme-picker__select--hidden"
|
|
131
|
+
>
|
|
132
|
+
<option value="Default" selected>Default</option>
|
|
133
|
+
|
|
134
|
+
<option value="Forest">Forest</option>
|
|
135
|
+
|
|
136
|
+
<option value="Sunset">Sunset</option>
|
|
137
|
+
|
|
138
|
+
<option value="Ocean">Ocean</option>
|
|
139
|
+
|
|
140
|
+
<option value="Aurora">Aurora</option>
|
|
141
|
+
|
|
142
|
+
<option value="Borealis">Borealis</option>
|
|
143
|
+
|
|
144
|
+
<option value="Midnight">Midnight</option>
|
|
145
|
+
|
|
146
|
+
<option value="Carbon">Carbon</option>
|
|
147
|
+
|
|
148
|
+
<option value="VADS">VADS</option>
|
|
149
|
+
|
|
150
|
+
<option value="GOV.UK">GOV.UK</option>
|
|
151
|
+
|
|
152
|
+
<option value="NASA">NASA</option>
|
|
153
|
+
</select>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<h3 class="site-preview-heading">Swap</h3>
|
|
158
|
+
<div class="usx-theme-picker usx-theme-picker--swap">
|
|
159
|
+
<label
|
|
160
|
+
class="usx-swap usx-swap--rotate usx-theme-picker__swap usa-button usx-button usx-button--ghost"
|
|
161
|
+
>
|
|
162
|
+
<input type="checkbox" autocomplete="off" aria-label="Theme: Light. Switch to Dark" />
|
|
163
|
+
<span class="usx-swap-on">
|
|
164
|
+
<svg
|
|
165
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
166
|
+
aria-hidden="true"
|
|
167
|
+
focusable="false"
|
|
168
|
+
role="img"
|
|
169
|
+
>
|
|
170
|
+
<use href="img/usx-sprite.svg#moon"></use></svg
|
|
171
|
+
></span>
|
|
172
|
+
<span class="usx-swap-off">
|
|
173
|
+
<svg
|
|
174
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
175
|
+
aria-hidden="true"
|
|
176
|
+
focusable="false"
|
|
177
|
+
role="img"
|
|
178
|
+
>
|
|
179
|
+
<use href="img/usx-sprite.svg#sun"></use></svg
|
|
180
|
+
></span>
|
|
181
|
+
</label>
|
|
182
|
+
<div class="usx-theme-picker__fallback">
|
|
183
|
+
<label class="usa-label usx-label usa-sr-only" for="django-theme-picker-swap"> Theme </label>
|
|
184
|
+
|
|
185
|
+
<select id="django-theme-picker-swap" class="usa-select usx-select">
|
|
186
|
+
<option value="Aurora" selected>Light</option>
|
|
187
|
+
|
|
188
|
+
<option value="Borealis">Dark</option>
|
|
189
|
+
</select>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
111
193
|
<h3 class="site-preview-heading">With Value</h3>
|
|
112
194
|
<div class="usx-theme-picker">
|
|
113
195
|
<button
|
|
@@ -118,21 +200,18 @@
|
|
|
118
200
|
aria-controls="django-theme-picker-value-panel"
|
|
119
201
|
>
|
|
120
202
|
<svg
|
|
121
|
-
class="usa-icon usx-theme-picker__icon"
|
|
203
|
+
class="usa-icon usx-icon usx-theme-picker__icon"
|
|
122
204
|
aria-hidden="true"
|
|
123
205
|
focusable="false"
|
|
124
|
-
|
|
206
|
+
role="img"
|
|
125
207
|
>
|
|
126
|
-
<
|
|
127
|
-
fill="currentColor"
|
|
128
|
-
d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
|
|
129
|
-
/>
|
|
208
|
+
<use href="img/usx-sprite.svg#color_palette"></use>
|
|
130
209
|
</svg>
|
|
131
210
|
</button>
|
|
132
211
|
<div id="django-theme-picker-value-panel" class="usx-theme-picker__panel">
|
|
133
212
|
<label class="usa-label usx-label usa-sr-only" for="django-theme-picker-value"> Theme </label>
|
|
134
213
|
|
|
135
|
-
<select class="usa-select usx-select"
|
|
214
|
+
<select id="django-theme-picker-value" class="usa-select usx-select">
|
|
136
215
|
<option value="Default">Default</option>
|
|
137
216
|
|
|
138
217
|
<option value="Forest" selected>Forest</option>
|
|
@@ -155,6 +234,7 @@
|
|
|
155
234
|
|
|
156
235
|
<option value="NASA">NASA</option>
|
|
157
236
|
</select>
|
|
237
|
+
|
|
158
238
|
<button
|
|
159
239
|
type="button"
|
|
160
240
|
class="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
{% load usx_components %}
|
|
2
2
|
{% firstof id "theme-picker" as field_id %}
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
aria-label="{{ label|default:'Theme' }}"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
|
|
3
|
+
{% firstof value defaultValue themes.0.value as selected_value %}
|
|
4
|
+
<div class="usx-theme-picker{% if variant and variant != 'default' %} usx-theme-picker--{{ variant }}{% endif %}{% if className %} {{ className }}{% endif %}"{% if extraAttributes %}{% for attr, attr_value in extraAttributes.items %} {{ attr }}="{% if attr_value is True %}true{% elif attr_value is False %}false{% else %}{{ attr_value }}{% endif %}"{% endfor %}{% endif %}>
|
|
5
|
+
{% if variant == 'swap' %}
|
|
6
|
+
<label class="usx-swap usx-swap--rotate usx-theme-picker__swap usa-button usx-button usx-button--ghost">
|
|
7
|
+
<input type="checkbox" autocomplete="off" aria-label="{{ label|default:'Theme' }}: {% for theme in themes %}{% if theme.value == selected_value %}{{ theme.label }}{% endif %}{% endfor %}. Switch to {% if themes.1.value == selected_value %}{{ themes.0.label }}{% else %}{{ themes.1.label }}{% endif %}"{% if themes.1.value == selected_value %} checked{% endif %}>
|
|
8
|
+
<span class="usx-swap-on">{% icon name="moon" source="usx" className="usx-theme-picker__icon" %}{% endicon %}</span>
|
|
9
|
+
<span class="usx-swap-off">{% icon name="sun" source="usx" className="usx-theme-picker__icon" %}{% endicon %}</span>
|
|
10
|
+
</label>
|
|
11
|
+
<div class="usx-theme-picker__fallback">{% include "theme-picker/theme-picker-select.django.html" %}</div>
|
|
12
|
+
{% elif variant == 'ghost-select' %}
|
|
13
|
+
<div class="usx-theme-picker__ghost">
|
|
14
|
+
<span class="usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face" aria-hidden="true">
|
|
15
|
+
{% icon name="color_palette" source="usx" className="usx-theme-picker__icon" %}{% endicon %}
|
|
16
|
+
</span>
|
|
17
|
+
{% include "theme-picker/theme-picker-select.django.html" with hidden=True %}
|
|
18
|
+
</div>
|
|
19
|
+
{% else %}
|
|
20
|
+
<button type="button" class="usa-button usx-button usx-button--ghost usx-theme-picker__trigger" aria-label="{{ label|default:'Theme' }}" aria-expanded="false" aria-controls="{{ field_id }}-panel">
|
|
21
|
+
{% icon name="color_palette" source="usx" className="usx-theme-picker__icon" %}{% endicon %}
|
|
12
22
|
</button>
|
|
13
23
|
<div id="{{ field_id }}-panel" class="usx-theme-picker__panel">
|
|
14
|
-
{%
|
|
15
|
-
<
|
|
16
|
-
class="usa-select usx-select"
|
|
17
|
-
id="{{ field_id }}"
|
|
18
|
-
{% if name %}name="{{ name }}"{% endif %}
|
|
19
|
-
>
|
|
20
|
-
{% for theme in themes %}
|
|
21
|
-
<option value="{{ theme.value }}" {% if value is not None and theme.value == value or value is None and theme.value == defaultValue %}selected{% endif %}>{{ theme.label }}</option>
|
|
22
|
-
{% endfor %}
|
|
23
|
-
</select>
|
|
24
|
-
<button
|
|
25
|
-
type="button"
|
|
26
|
-
class="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
|
|
27
|
-
aria-label="Confirm theme"
|
|
28
|
-
>
|
|
24
|
+
{% include "theme-picker/theme-picker-select.django.html" %}
|
|
25
|
+
<button type="button" class="usa-button usx-button usa-button--primary usx-theme-picker__toggle" aria-label="Confirm theme">
|
|
29
26
|
{% icon name="close" className="usx-theme-picker__icon" %}{% endicon %}
|
|
30
27
|
</button>
|
|
31
28
|
</div>
|
|
29
|
+
{% endif %}
|
|
32
30
|
</div>
|