@solexllc/usx-react 0.10.0 → 0.12.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 (208) hide show
  1. package/README.md +16 -0
  2. package/dist/Popover-BzDCTuQM.cjs +984 -0
  3. package/dist/Popover-LToVWsWc.js +985 -0
  4. package/dist/chat.cjs +1391 -0
  5. package/dist/chat.js +1391 -0
  6. package/dist/index.cjs +4426 -5231
  7. package/dist/index.js +168 -970
  8. package/package.json +9 -5
  9. package/src/chat.js +15 -0
  10. package/src/components/avatar/Avatar.tsx +54 -16
  11. package/src/components/avatar/avatar.django-snapshot.html +112 -0
  12. package/src/components/avatar/avatar.django.html +2 -2
  13. package/src/components/avatar/avatar.html +25 -0
  14. package/src/components/avatar/avatar.react-snapshot.html +104 -0
  15. package/src/components/avatar/config.json +13 -15
  16. package/src/components/avatar-group/AvatarGroup.tsx +17 -15
  17. package/src/components/avatar-group/avatar-group.django-snapshot.html +22 -0
  18. package/src/components/avatar-group/avatar-group.django.html +1 -1
  19. package/src/components/avatar-group/avatar-group.react-snapshot.html +20 -0
  20. package/src/components/avatar-group/config.json +2 -2
  21. package/src/components/back-to-top/BackToTop.tsx +21 -57
  22. package/src/components/back-to-top/back-to-top.django-snapshot.html +101 -202
  23. package/src/components/back-to-top/back-to-top.django.html +11 -38
  24. package/src/components/back-to-top/back-to-top.html +22 -106
  25. package/src/components/back-to-top/back-to-top.react-snapshot.html +94 -148
  26. package/src/components/back-to-top/config.json +41 -10
  27. package/src/components/button/Button.tsx +12 -3
  28. package/src/components/button/button.django-snapshot.html +18 -0
  29. package/src/components/button/button.django.html +3 -2
  30. package/src/components/button/button.react-snapshot.html +16 -0
  31. package/src/components/button/config.json +11 -2
  32. package/src/components/callout/callout.django.html +1 -1
  33. package/src/components/callout/config.json +7 -16
  34. package/src/components/character-count/CharacterCount.tsx +2 -0
  35. package/src/components/character-count/character-count.react-snapshot.html +7 -0
  36. package/src/components/chat/Chat.tsx +575 -0
  37. package/src/components/chat/README.md +174 -0
  38. package/src/components/chat/avatarProps.ts +32 -0
  39. package/src/components/chat/chat.django-snapshot.html +23515 -0
  40. package/src/components/chat/chat.django.html +75 -0
  41. package/src/components/chat/chat.html +116 -0
  42. package/src/components/chat/chat.react-snapshot.html +16895 -0
  43. package/src/components/chat/config.json +1241 -0
  44. package/src/components/chat-attachment/ChatAttachment.tsx +39 -0
  45. package/src/components/chat-attachment/chat-attachment.django.html +24 -0
  46. package/src/components/chat-attachment/chat-attachment.html +10 -0
  47. package/src/components/chat-attachment/config.json +27 -0
  48. package/src/components/chat-attachments/ChatAttachments.tsx +17 -0
  49. package/src/components/chat-attachments/chat-attachments.django-snapshot.html +58 -0
  50. package/src/components/chat-attachments/chat-attachments.django.html +10 -0
  51. package/src/components/chat-attachments/chat-attachments.html +14 -0
  52. package/src/components/chat-attachments/chat-attachments.react-snapshot.html +46 -0
  53. package/src/components/chat-attachments/config.json +25 -0
  54. package/src/components/chat-bubble/ChatBubble.tsx +39 -0
  55. package/src/components/chat-bubble/ChatFormattedText.tsx +138 -0
  56. package/src/components/chat-bubble/chat-bubble.django-snapshot.html +128 -0
  57. package/src/components/chat-bubble/chat-bubble.django.html +19 -0
  58. package/src/components/chat-bubble/chat-bubble.html +1 -0
  59. package/src/components/chat-bubble/chat-bubble.react-snapshot.html +118 -0
  60. package/src/components/chat-bubble/config.json +70 -0
  61. package/src/components/chat-composer/ChatComposer.tsx +210 -0
  62. package/src/components/chat-composer/README.md +15 -0
  63. package/src/components/chat-composer/chat-composer.django-snapshot.html +575 -0
  64. package/src/components/chat-composer/chat-composer.django.html +77 -0
  65. package/src/components/chat-composer/chat-composer.html +44 -0
  66. package/src/components/chat-composer/chat-composer.react-snapshot.html +519 -0
  67. package/src/components/chat-composer/chat-formatting.django.html +59 -0
  68. package/src/components/chat-composer/config.json +137 -0
  69. package/src/components/chat-context/ChatContext.tsx +46 -0
  70. package/src/components/chat-context/chat-context.django-snapshot.html +35 -0
  71. package/src/components/chat-context/chat-context.django.html +20 -0
  72. package/src/components/chat-context/chat-context.html +9 -0
  73. package/src/components/chat-context/chat-context.react-snapshot.html +30 -0
  74. package/src/components/chat-context/config.json +36 -0
  75. package/src/components/chat-controls/ChatControls.tsx +67 -0
  76. package/src/components/chat-controls/chat-controls.django-snapshot.html +114 -0
  77. package/src/components/chat-controls/chat-controls.django.html +36 -0
  78. package/src/components/chat-controls/chat-controls.html +11 -0
  79. package/src/components/chat-controls/chat-controls.react-snapshot.html +107 -0
  80. package/src/components/chat-controls/config.json +67 -0
  81. package/src/components/chat-directory/ChatDirectory.tsx +168 -0
  82. package/src/components/chat-directory/chat-directory.django-snapshot.html +546 -0
  83. package/src/components/chat-directory/chat-directory.django.html +14 -0
  84. package/src/components/chat-directory/chat-directory.html +4 -0
  85. package/src/components/chat-directory/chat-directory.react-snapshot.html +471 -0
  86. package/src/components/chat-directory/config.json +242 -0
  87. package/src/components/chat-directory-item/ChatDirectoryItem.tsx +150 -0
  88. package/src/components/chat-directory-item/chat-directory-item.django-snapshot.html +281 -0
  89. package/src/components/chat-directory-item/chat-directory-item.django.html +38 -0
  90. package/src/components/chat-directory-item/chat-directory-item.html +9 -0
  91. package/src/components/chat-directory-item/chat-directory-item.react-snapshot.html +249 -0
  92. package/src/components/chat-directory-item/config.json +103 -0
  93. package/src/components/chat-history/ChatHistory.tsx +30 -0
  94. package/src/components/chat-history/chat-history.django-snapshot.html +113 -0
  95. package/src/components/chat-history/chat-history.django.html +20 -0
  96. package/src/components/chat-history/chat-history.html +9 -0
  97. package/src/components/chat-history/chat-history.react-snapshot.html +111 -0
  98. package/src/components/chat-history/config.json +24 -0
  99. package/src/components/chat-message/ChatMessage.tsx +148 -0
  100. package/src/components/chat-message/chat-message.django-snapshot.html +758 -0
  101. package/src/components/chat-message/chat-message.django.html +56 -0
  102. package/src/components/chat-message/chat-message.html +12 -0
  103. package/src/components/chat-message/chat-message.react-snapshot.html +627 -0
  104. package/src/components/chat-message/config.json +278 -0
  105. package/src/components/chat-message-actions/ChatMessageActions.tsx +133 -0
  106. package/src/components/chat-message-actions/chat-message-actions.django-snapshot.html +345 -0
  107. package/src/components/chat-message-actions/chat-message-actions.django.html +29 -0
  108. package/src/components/chat-message-actions/chat-message-actions.html +53 -0
  109. package/src/components/chat-message-actions/chat-message-actions.react-snapshot.html +295 -0
  110. package/src/components/chat-message-actions/config.json +121 -0
  111. package/src/components/chat-window/ChatWindow.tsx +133 -0
  112. package/src/components/chat-window/chat-window.django-snapshot.html +448 -0
  113. package/src/components/chat-window/chat-window.django.html +39 -0
  114. package/src/components/chat-window/chat-window.html +26 -0
  115. package/src/components/chat-window/chat-window.react-snapshot.html +286 -0
  116. package/src/components/chat-window/config.json +123 -0
  117. package/src/components/clickable/Clickable.tsx +19 -5
  118. package/src/components/clickable/clickable.django-snapshot.html +11 -2
  119. package/src/components/clickable/clickable.django.html +2 -0
  120. package/src/components/clickable/clickable.react-snapshot.html +10 -2
  121. package/src/components/clickable/config.json +4 -0
  122. package/src/components/code/code.django-snapshot.html +27 -22
  123. package/src/components/code/code.html +2 -2
  124. package/src/components/code/code.react-snapshot.html +43 -8
  125. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +2 -7
  126. package/src/components/copy-to-clipboard/copy-to-clipboard.django-snapshot.html +6 -4
  127. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +3 -2
  128. package/src/components/copy-to-clipboard/copy-to-clipboard.react-snapshot.html +14 -2
  129. package/src/components/file-list/FileList.tsx +3 -2
  130. package/src/components/file-list/config.json +5 -0
  131. package/src/components/file-list/file-list.django-snapshot.html +63 -0
  132. package/src/components/file-list/file-list.django.html +1 -1
  133. package/src/components/file-list/file-list.react-snapshot.html +53 -0
  134. package/src/components/footer/footer.django-snapshot.html +0 -3
  135. package/src/components/header/header.django-snapshot.html +5 -167
  136. package/src/components/header/header.django.html +2 -2
  137. package/src/components/header/header.html +1 -11
  138. package/src/components/header/header.react-snapshot.html +3 -6
  139. package/src/components/hero/hero.django-snapshot.html +0 -20
  140. package/src/components/hero/hero.django.html +3 -3
  141. package/src/components/icon-list/IconList.tsx +10 -2
  142. package/src/components/icon-list/config.json +5 -1
  143. package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
  144. package/src/components/icon-list/icon-list.django.html +2 -0
  145. package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
  146. package/src/components/image/image.django.html +4 -4
  147. package/src/components/input/Input.tsx +1 -1
  148. package/src/components/input/config.json +2 -3
  149. package/src/components/input/input.django-snapshot.html +4 -21
  150. package/src/components/input/input.django.html +2 -2
  151. package/src/components/link/Link.tsx +7 -4
  152. package/src/components/link/config.json +2 -3
  153. package/src/components/link/link.django-snapshot.html +8 -0
  154. package/src/components/link/link.django.html +2 -2
  155. package/src/components/link/link.html +4 -1
  156. package/src/components/link/link.react-snapshot.html +8 -0
  157. package/src/components/list/List.tsx +10 -2
  158. package/src/components/list/config.json +5 -1
  159. package/src/components/list/list.django-snapshot.html +26 -0
  160. package/src/components/list/list.django.html +2 -0
  161. package/src/components/list/list.html +20 -0
  162. package/src/components/list/list.react-snapshot.html +20 -0
  163. package/src/components/memorable-date/memorable-date.django-snapshot.html +0 -8
  164. package/src/components/memorable-date/memorable-date.django.html +2 -2
  165. package/src/components/misc-banner/misc-banner.django-snapshot.html +12 -12
  166. package/src/components/misc-banner/misc-banner.django.html +4 -2
  167. package/src/components/page/Page.tsx +16 -0
  168. package/src/components/page/config.json +18 -1
  169. package/src/components/page/page.django-snapshot.html +74 -0
  170. package/src/components/page/page.django.html +8 -0
  171. package/src/components/page/page.html +60 -0
  172. package/src/components/page/page.react-snapshot.html +60 -0
  173. package/src/components/popover/Popover.tsx +60 -9
  174. package/src/components/popover/PopoverMenu.tsx +33 -15
  175. package/src/components/popover/config.json +88 -14
  176. package/src/components/popover/popover-menu.django.html +13 -2
  177. package/src/components/popover/popover.django-snapshot.html +229 -7
  178. package/src/components/popover/popover.django.html +3 -2
  179. package/src/components/popover/popover.react-snapshot.html +127 -4
  180. package/src/components/process-list/config.json +41 -3
  181. package/src/components/quote/Quote.tsx +9 -2
  182. package/src/components/search/Search.tsx +1 -1
  183. package/src/components/search/config.json +3 -4
  184. package/src/components/search/search.django-snapshot.html +262 -1684
  185. package/src/components/search/search.django.html +1 -20
  186. package/src/components/select/select.django-snapshot.html +7 -7
  187. package/src/components/select/select.react-snapshot.html +7 -7
  188. package/src/components/summary/Summary.tsx +4 -2
  189. package/src/components/summary/config.json +4 -0
  190. package/src/components/summary/summary.django.html +4 -4
  191. package/src/components/table/Table.tsx +58 -25
  192. package/src/components/table/config.json +61 -13
  193. package/src/components/tag/Tag.tsx +40 -7
  194. package/src/components/tag/config.json +18 -2
  195. package/src/components/tag/tag.django-snapshot.html +16 -1
  196. package/src/components/tag/tag.django.html +12 -6
  197. package/src/components/tag/tag.html +4 -0
  198. package/src/components/tag/tag.react-snapshot.html +16 -1
  199. package/src/components/tag-group/TagGroup.tsx +6 -9
  200. package/src/components/tag-group/config.json +4 -0
  201. package/src/components/tag-group/tag-group.django.html +1 -1
  202. package/src/components/theme-picker/ThemePicker.tsx +95 -52
  203. package/src/components/theme-picker/config.json +7 -4
  204. package/src/components/theme-picker/theme-picker-select.django.html +7 -0
  205. package/src/components/theme-picker/theme-picker.django-snapshot.html +101 -21
  206. package/src/components/theme-picker/theme-picker.django.html +22 -24
  207. package/src/components/theme-picker/theme-picker.html +86 -56
  208. package/src/components/theme-picker/theme-picker.react-snapshot.html +74 -18
@@ -6,27 +6,24 @@ export interface TagGroupProps extends React.HTMLAttributes<HTMLDivElement> {
6
6
  tagProps?: TagProps[] | null;
7
7
  children?: React.ReactNode;
8
8
  className?: string;
9
+ extraAttributes?: Record<string, unknown>;
9
10
  }
10
11
 
11
12
  const TagGroup: React.FC<TagGroupProps> = ({
12
13
  tagProps = null,
13
14
  children = null,
14
15
  className = '',
16
+ extraAttributes = {},
15
17
  ...props
16
18
  }) => {
17
- const classes = classNames(
18
- 'usx-tag-group',
19
- className
20
- );
19
+ const classes = classNames('usx-tag-group', className);
21
20
  const content = children
22
21
  ? children
23
22
  : Array.isArray(tagProps)
24
- ? tagProps.map((t, i) => (
25
- <Tag key={t.id || t.value || i} {...t} />
26
- ))
27
- : null;
23
+ ? tagProps.map((t, i) => <Tag key={t.id || t.value || i} {...t} />)
24
+ : null;
28
25
  return (
29
- <div className={classes} {...props}>
26
+ <div {...props} {...extraAttributes} className={classes}>
30
27
  {content}
31
28
  </div>
32
29
  );
@@ -43,6 +43,10 @@
43
43
  "className": {
44
44
  "type": "string",
45
45
  "description": "Additional classes"
46
+ },
47
+ "extraAttributes": {
48
+ "type": "object",
49
+ "description": "Additional HTML attributes on the group container, such as role and aria-label."
46
50
  }
47
51
  }
48
52
  }
@@ -1,6 +1,6 @@
1
1
  {% load usx_components %}
2
2
 
3
- <div class="usx-tag-group{% if className %} {{ className }}{% endif %}">
3
+ <div class="usx-tag-group{% if className %} {{ className }}{% endif %}"{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}>
4
4
  {% if children %}
5
5
  {{ children|safe }}
6
6
  {% elif tagProps %}
@@ -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 selection =
37
- value !== undefined ? { value } : { defaultValue: defaultValue ?? themes[0]?.value };
38
-
39
- return (
40
- <div className={ClassNames('usx-theme-picker', className)} {...extraAttributes}>
41
- <button
42
- type="button"
43
- className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
44
- aria-label={label}
45
- aria-expanded="false"
46
- 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)}
47
62
  >
48
- <PaletteIcon />
49
- </button>
50
- <div id={`${selectId}-panel`} className="usx-theme-picker__panel">
51
- <Label htmlFor={selectId} screenReaderOnly>
52
- {label}
53
- </Label>
54
- <select
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
- <svg
82
- className="usa-icon usx-theme-picker__icon"
83
- aria-hidden="true"
84
- focusable="false"
85
- 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}
86
80
  >
87
- <path
88
- fill="currentColor"
89
- 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"
90
- />
91
- </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>
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": 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",
@@ -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
- 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,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
- 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">
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
- viewBox="0 0 24 24"
206
+ role="img"
125
207
  >
126
- <path
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" id="django-theme-picker-value">
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
- <div class="usx-theme-picker{% if className %} {{ className }}{% endif %}"{% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% 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 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>