@solexllc/usx-react 0.9.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.
Files changed (145) hide show
  1. package/README.md +6 -5
  2. package/dist/index.cjs +245 -162
  3. package/dist/index.js +246 -163
  4. package/package.json +4 -4
  5. package/src/components/accordion/Accordion.tsx +4 -1
  6. package/src/components/accordion/accordion.django.html +1 -1
  7. package/src/components/accordion/config.json +1 -0
  8. package/src/components/banner/Banner.tsx +3 -1
  9. package/src/components/banner/banner.django.html +1 -1
  10. package/src/components/banner/config.json +1 -0
  11. package/src/components/carousel/carousel.django-snapshot.html +0 -40
  12. package/src/components/carousel/carousel.react-snapshot.html +0 -38
  13. package/src/components/character-count/CharacterCount.tsx +3 -0
  14. package/src/components/character-count/character-count.django-snapshot.html +43 -0
  15. package/src/components/character-count/character-count.django.html +2 -2
  16. package/src/components/character-count/character-count.react-snapshot.html +37 -0
  17. package/src/components/character-count/config.json +9 -0
  18. package/src/components/checkbox/Checkbox.tsx +16 -17
  19. package/src/components/checkbox/checkbox.django-snapshot.html +18 -0
  20. package/src/components/checkbox/checkbox.django.html +6 -4
  21. package/src/components/checkbox/checkbox.react-snapshot.html +14 -0
  22. package/src/components/checkbox/config.json +4 -4
  23. package/src/components/checkbox-group/checkbox-group.django-snapshot.html +54 -0
  24. package/src/components/checkbox-group/checkbox-group.react-snapshot.html +45 -0
  25. package/src/components/code/code.django-snapshot.html +4 -6
  26. package/src/components/code/code.html +2 -2
  27. package/src/components/code/code.react-snapshot.html +2 -4
  28. package/src/components/combobox/Combobox.tsx +6 -1
  29. package/src/components/combobox/combobox.django-snapshot.html +141 -0
  30. package/src/components/combobox/combobox.django.html +2 -2
  31. package/src/components/combobox/combobox.react-snapshot.html +76 -0
  32. package/src/components/combobox/config.json +9 -0
  33. package/src/components/data-table/DataTable.tsx +4 -1
  34. package/src/components/data-table/config.json +4 -0
  35. package/src/components/data-table/data-table.django.html +1 -1
  36. package/src/components/date-picker/DatePicker.tsx +6 -1
  37. package/src/components/date-picker/config.json +9 -0
  38. package/src/components/date-picker/date-picker.django-snapshot.html +23 -0
  39. package/src/components/date-picker/date-picker.django.html +4 -4
  40. package/src/components/date-picker/date-picker.react-snapshot.html +19 -0
  41. package/src/components/date-range-picker/DateRangePicker.tsx +11 -2
  42. package/src/components/date-range-picker/config.json +14 -0
  43. package/src/components/date-range-picker/date-range-picker.django-snapshot.html +47 -0
  44. package/src/components/date-range-picker/date-range-picker.django.html +5 -5
  45. package/src/components/date-range-picker/date-range-picker.react-snapshot.html +38 -0
  46. package/src/components/drawer/Drawer.tsx +3 -1
  47. package/src/components/drawer/config.json +4 -0
  48. package/src/components/drawer/drawer.django.html +1 -1
  49. package/src/components/file-input/FileInput.tsx +7 -2
  50. package/src/components/file-input/_contents.django.html +2 -1
  51. package/src/components/file-input/config.json +4 -0
  52. package/src/components/header/Header.tsx +15 -9
  53. package/src/components/header/config.json +1 -0
  54. package/src/components/header/header.django-snapshot.html +29 -7
  55. package/src/components/header/header.django.html +8 -4
  56. package/src/components/header/header.html +21 -11
  57. package/src/components/header/header.react-snapshot.html +23 -6
  58. package/src/components/icon-list/IconList.tsx +10 -2
  59. package/src/components/icon-list/config.json +5 -1
  60. package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
  61. package/src/components/icon-list/icon-list.django.html +2 -0
  62. package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
  63. package/src/components/in-page-nav/InPageNav.tsx +3 -0
  64. package/src/components/in-page-nav/config.json +1 -0
  65. package/src/components/in-page-nav/in-page-nav.django.html +1 -1
  66. package/src/components/input/Input.tsx +3 -0
  67. package/src/components/input/config.json +10 -0
  68. package/src/components/input/input.django-snapshot.html +24 -0
  69. package/src/components/input/input.django.html +4 -4
  70. package/src/components/input/input.react-snapshot.html +22 -0
  71. package/src/components/language-selector/LanguageSelector.tsx +10 -5
  72. package/src/components/language-selector/config.json +1 -0
  73. package/src/components/language-selector/language-selector.django.html +2 -2
  74. package/src/components/layout/Layout.tsx +3 -1
  75. package/src/components/layout/config.json +4 -0
  76. package/src/components/layout/layout.django.html +1 -1
  77. package/src/components/list/List.tsx +10 -2
  78. package/src/components/list/config.json +5 -1
  79. package/src/components/list/list.django-snapshot.html +26 -0
  80. package/src/components/list/list.django.html +2 -0
  81. package/src/components/list/list.html +20 -0
  82. package/src/components/list/list.react-snapshot.html +20 -0
  83. package/src/components/memorable-date/MemorableDate.tsx +18 -3
  84. package/src/components/memorable-date/config.json +15 -0
  85. package/src/components/memorable-date/memorable-date.django-snapshot.html +82 -0
  86. package/src/components/memorable-date/memorable-date.django.html +14 -14
  87. package/src/components/memorable-date/memorable-date.react-snapshot.html +70 -0
  88. package/src/components/modal/Modal.tsx +3 -0
  89. package/src/components/modal/config.json +1 -0
  90. package/src/components/modal/modal.django.html +1 -1
  91. package/src/components/page/Page.tsx +16 -0
  92. package/src/components/page/config.json +18 -1
  93. package/src/components/page/page.django-snapshot.html +74 -0
  94. package/src/components/page/page.django.html +8 -0
  95. package/src/components/page/page.html +60 -0
  96. package/src/components/page/page.react-snapshot.html +60 -0
  97. package/src/components/popover/Popover.tsx +3 -0
  98. package/src/components/popover/config.json +4 -0
  99. package/src/components/popover/popover.django-snapshot.html +30 -0
  100. package/src/components/popover/popover.django.html +1 -0
  101. package/src/components/radio-buttons/RadioButtons.tsx +5 -1
  102. package/src/components/radio-buttons/radio-buttons.django-snapshot.html +65 -0
  103. package/src/components/radio-buttons/radio-buttons.django.html +1 -1
  104. package/src/components/radio-buttons/radio-buttons.react-snapshot.html +53 -0
  105. package/src/components/range-slider/RangeSlider.tsx +4 -2
  106. package/src/components/range-slider/config.json +1 -0
  107. package/src/components/range-slider/range-slider.django-snapshot.html +17 -0
  108. package/src/components/range-slider/range-slider.django.html +4 -4
  109. package/src/components/range-slider/range-slider.react-snapshot.html +16 -0
  110. package/src/components/search/Search.tsx +6 -1
  111. package/src/components/search/config.json +5 -0
  112. package/src/components/search/search.django-snapshot.html +683 -563
  113. package/src/components/search/search.django.html +1 -1
  114. package/src/components/search/search.react-snapshot.html +25 -0
  115. package/src/components/select/Select.tsx +3 -1
  116. package/src/components/select/config.json +5 -0
  117. package/src/components/select/select.django-snapshot.html +15 -0
  118. package/src/components/select/select.django.html +2 -2
  119. package/src/components/select/select.react-snapshot.html +11 -0
  120. package/src/components/switch/Switch.tsx +13 -70
  121. package/src/components/switch/config.json +60 -23
  122. package/src/components/switch/switch.django-snapshot.html +507 -56
  123. package/src/components/switch/switch.django.html +23 -26
  124. package/src/components/switch/switch.html +425 -33
  125. package/src/components/switch/switch.react-snapshot.html +447 -58
  126. package/src/components/table/Table.tsx +3 -1
  127. package/src/components/table/config.json +1 -0
  128. package/src/components/table/table.django.html +1 -1
  129. package/src/components/text-area/TextArea.tsx +3 -1
  130. package/src/components/text-area/config.json +5 -0
  131. package/src/components/text-area/text-area.django-snapshot.html +18 -0
  132. package/src/components/text-area/text-area.django.html +4 -4
  133. package/src/components/text-area/text-area.react-snapshot.html +16 -0
  134. package/src/components/theme-picker/ThemePicker.tsx +97 -52
  135. package/src/components/theme-picker/config.json +21 -5
  136. package/src/components/theme-picker/theme-picker-select.django.html +7 -0
  137. package/src/components/theme-picker/theme-picker.django-snapshot.html +158 -14
  138. package/src/components/theme-picker/theme-picker.django.html +22 -24
  139. package/src/components/theme-picker/theme-picker.html +86 -56
  140. package/src/components/theme-picker/theme-picker.react-snapshot.html +120 -12
  141. package/src/components/time-picker/TimePicker.tsx +6 -1
  142. package/src/components/time-picker/config.json +9 -0
  143. package/src/components/time-picker/time-picker.django-snapshot.html +26 -0
  144. package/src/components/time-picker/time-picker.django.html +4 -4
  145. package/src/components/time-picker/time-picker.react-snapshot.html +22 -0
@@ -106,3 +106,19 @@
106
106
  disabled=""
107
107
  ></textarea>
108
108
  </div>
109
+
110
+ <h3 class="site-preview-heading">Value</h3>
111
+ <div class="usa-form-group usx-form-group">
112
+ <label class="usa-label usx-label" for="react-text-area-value">Current value</label
113
+ ><textarea id="react-text-area-value" class="usa-textarea usx-textarea" placeholder="">
114
+ Current text</textarea
115
+ >
116
+ </div>
117
+
118
+ <h3 class="site-preview-heading">Default Value</h3>
119
+ <div class="usa-form-group usx-form-group">
120
+ <label class="usa-label usx-label" for="react-text-area-default-value">Initial value</label
121
+ ><textarea id="react-text-area-default-value" class="usa-textarea usx-textarea" placeholder="">
122
+ Editable initial text</textarea
123
+ >
124
+ </div>
@@ -1,23 +1,28 @@
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;
20
24
  className?: string;
25
+ extraAttributes?: Record<string, unknown>;
21
26
  }
22
27
 
23
28
  export default function ThemePicker({
@@ -25,67 +30,107 @@ export default function ThemePicker({
25
30
  name,
26
31
  label = 'Theme',
27
32
  themes = [],
33
+ variant = 'default',
28
34
  value,
29
35
  defaultValue,
30
36
  onChange,
31
37
  className = '',
38
+ extraAttributes,
32
39
  }: ThemePickerProps) {
33
40
  const selectId = id || 'theme-picker';
34
- const selection =
35
- value !== undefined ? { value } : { defaultValue: defaultValue ?? themes[0]?.value };
36
-
37
- return (
38
- <div className={ClassNames('usx-theme-picker', className)}>
39
- <button
40
- type="button"
41
- className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
42
- aria-label={label}
43
- aria-expanded="false"
44
- aria-controls={`${selectId}-panel`}
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)}
45
62
  >
46
- <PaletteIcon />
47
- </button>
48
- <div id={`${selectId}-panel`} className="usx-theme-picker__panel">
49
- <Label htmlFor={selectId} screenReaderOnly>
50
- {label}
51
- </Label>
52
- <select
53
- id={selectId}
54
- name={name}
55
- className="usa-select usx-select"
56
- {...selection}
57
- onChange={(event) => onChange?.(event.target.value)}
58
- >
59
- {themes.map((option) => (
60
- <option key={option.value} value={option.value}>
61
- {option.label}
62
- </option>
63
- ))}
64
- </select>
65
- <button
66
- type="button"
67
- className="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
68
- aria-label="Confirm theme"
69
- >
70
- <Icon name="close" className="usx-theme-picker__icon" />
71
- </button>
72
- </div>
73
- </div>
63
+ {themes.map((option) => (
64
+ <option key={option.value} value={option.value}>
65
+ {option.label}
66
+ </option>
67
+ ))}
68
+ </select>
69
+ </>
74
70
  );
75
- }
76
71
 
77
- function PaletteIcon() {
78
72
  return (
79
- <svg
80
- className="usa-icon usx-theme-picker__icon"
81
- aria-hidden="true"
82
- focusable="false"
83
- viewBox="0 0 24 24"
73
+ <div
74
+ className={ClassNames(
75
+ 'usx-theme-picker',
76
+ variant !== 'default' && `usx-theme-picker--${variant}`,
77
+ className
78
+ )}
79
+ {...extraAttributes}
84
80
  >
85
- <path
86
- fill="currentColor"
87
- 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"
88
- />
89
- </svg>
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>
90
135
  );
91
136
  }
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "theme-picker",
3
3
  "template": "theme-picker/theme-picker.django.html",
4
- "version": 1,
5
- "required": [
6
- "themes"
7
- ],
4
+ "version": 2,
5
+ "required": ["themes"],
8
6
  "default": {
9
7
  "id": "theme-picker-1",
10
8
  "label": "Theme",
@@ -78,14 +76,32 @@
78
76
  "type": "string",
79
77
  "description": "Initial selected value for uncontrolled usage"
80
78
  },
79
+ "value": {
80
+ "type": "string",
81
+ "default": null,
82
+ "description": "Current theme selection. Takes precedence over defaultValue."
83
+ },
81
84
  "onChange": {
82
85
  "type": "function",
83
86
  "description": "React callback for a selected theme. Django consumers can listen for the select's native change event; applying the theme remains the application's responsibility.",
84
- "renderers": { "django": { "supported": false } }
87
+ "renderers": {
88
+ "django": {
89
+ "supported": false
90
+ }
91
+ }
85
92
  },
86
93
  "className": {
87
94
  "type": "string",
88
95
  "description": "Additional CSS classes"
96
+ },
97
+ "extraAttributes": {
98
+ "type": "object",
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."
89
105
  }
90
106
  }
91
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
- viewBox="0 0 24 24"
14
+ role="img"
15
15
  >
16
- <path
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" id="django-theme-picker-1">
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,171 @@
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
- viewBox="0 0 24 24"
76
+ role="img"
79
77
  >
80
- <path
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" id="django-theme-picker-2">
84
+ <select id="django-theme-picker-2" class="usa-select usx-select">
85
+ <option value="Aurora" selected>Light</option>
86
+
87
+ <option value="Borealis">Dark</option>
88
+ </select>
89
+
90
+ <button
91
+ type="button"
92
+ class="usa-button usx-button usa-button--primary usx-theme-picker__toggle"
93
+ aria-label="Confirm theme"
94
+ >
95
+ <svg
96
+ class="usa-icon usx-icon usx-theme-picker__icon"
97
+ aria-hidden="true"
98
+ focusable="false"
99
+ role="img"
100
+ >
101
+ <use href="img/sprite.svg#close"></use>
102
+ </svg>
103
+ </button>
104
+ </div>
105
+ </div>
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">
90
186
  <option value="Aurora" selected>Light</option>
91
187
 
92
188
  <option value="Borealis">Dark</option>
93
189
  </select>
190
+ </div>
191
+ </div>
192
+
193
+ <h3 class="site-preview-heading">With Value</h3>
194
+ <div class="usx-theme-picker">
195
+ <button
196
+ type="button"
197
+ class="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
198
+ aria-label="Theme"
199
+ aria-expanded="false"
200
+ aria-controls="django-theme-picker-value-panel"
201
+ >
202
+ <svg
203
+ class="usa-icon usx-icon usx-theme-picker__icon"
204
+ aria-hidden="true"
205
+ focusable="false"
206
+ role="img"
207
+ >
208
+ <use href="img/usx-sprite.svg#color_palette"></use>
209
+ </svg>
210
+ </button>
211
+ <div id="django-theme-picker-value-panel" class="usx-theme-picker__panel">
212
+ <label class="usa-label usx-label usa-sr-only" for="django-theme-picker-value"> Theme </label>
213
+
214
+ <select id="django-theme-picker-value" class="usa-select usx-select">
215
+ <option value="Default">Default</option>
216
+
217
+ <option value="Forest" selected>Forest</option>
218
+
219
+ <option value="Sunset">Sunset</option>
220
+
221
+ <option value="Ocean">Ocean</option>
222
+
223
+ <option value="Aurora">Aurora</option>
224
+
225
+ <option value="Borealis">Borealis</option>
226
+
227
+ <option value="Midnight">Midnight</option>
228
+
229
+ <option value="Carbon">Carbon</option>
230
+
231
+ <option value="VADS">VADS</option>
232
+
233
+ <option value="GOV.UK">GOV.UK</option>
234
+
235
+ <option value="NASA">NASA</option>
236
+ </select>
237
+
94
238
  <button
95
239
  type="button"
96
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
- <div class="usx-theme-picker{% if className %} {{ className }}{% endif %}">
4
- <button
5
- type="button"
6
- class="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
7
- aria-label="{{ label|default:'Theme' }}"
8
- aria-expanded="false"
9
- aria-controls="{{ field_id }}-panel"
10
- >
11
- <svg class="usa-icon usx-theme-picker__icon" aria-hidden="true" focusable="false" viewBox="0 0 24 24"><path fill="currentColor" 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"/></svg>
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
- {% label htmlFor=field_id screenReaderOnly=True only %}{{ label|default:'Theme' }}{% endlabel %}
15
- <select
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 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>