@solexllc/usx-react 0.3.0 → 0.4.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 (43) hide show
  1. package/README.md +156 -5
  2. package/dist/index.cjs +181 -182
  3. package/dist/index.js +181 -182
  4. package/package.json +6 -5
  5. package/src/assets.ts +16 -0
  6. package/src/components/alert/Alert.tsx +4 -3
  7. package/src/components/alert/alert.django.html +2 -3
  8. package/src/components/alert/config.json +15 -4
  9. package/src/components/banner/Banner.tsx +8 -6
  10. package/src/components/banner/banner.django.html +4 -5
  11. package/src/components/banner/config.json +5 -1
  12. package/src/components/button/Button.tsx +1 -1
  13. package/src/components/button/button.django.html +2 -2
  14. package/src/components/button/config.json +14 -6
  15. package/src/components/code/Code.tsx +4 -27
  16. package/src/components/code/code.django.html +3 -9
  17. package/src/components/code/config.json +4 -0
  18. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +35 -24
  19. package/src/components/copy-to-clipboard/config.json +14 -7
  20. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +14 -14
  21. package/src/components/footer/Footer.tsx +26 -6
  22. package/src/components/footer/config.json +4 -0
  23. package/src/components/footer/footer.django.html +10 -9
  24. package/src/components/header/Branding.tsx +9 -6
  25. package/src/components/header/Header.tsx +3 -1
  26. package/src/components/header/config.json +4 -0
  27. package/src/components/header/header.django.html +5 -26
  28. package/src/components/header/header.html +10 -10
  29. package/src/components/icon/Icon.tsx +6 -3
  30. package/src/components/icon/config.json +12 -6
  31. package/src/components/icon/icon.django.html +6 -4
  32. package/src/components/image/Image.tsx +8 -4
  33. package/src/components/image/config.json +10 -2
  34. package/src/components/image/image.django.html +8 -6
  35. package/src/components/layout/config.json +9 -9
  36. package/src/components/layout/layout.django.html +1 -1
  37. package/src/components/spinner/Spinner.tsx +18 -25
  38. package/src/components/spinner/config.json +4 -0
  39. package/src/components/spinner/spinner.django.html +4 -6
  40. package/src/components/tooltip/Tooltip.tsx +4 -2
  41. package/src/components/tooltip/config.json +7 -2
  42. package/src/components/tooltip/tooltip.django.html +1 -1
  43. package/src/styles/core.scss +1 -2
@@ -3,6 +3,10 @@
3
3
  "template": "spinner/spinner.django.html",
4
4
  "version": 1,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional asset base for this component. A non-empty value overrides window.usxBaseUrl in React or STATIC_URL in Django; otherwise the global base or / is used. Asset filenames remain separate."
9
+ },
6
10
  "size": {
7
11
  "type": "select",
8
12
  "options": [
@@ -1,9 +1,7 @@
1
- {% load static %}
1
+ {% load components %}
2
2
  {# Django template for Spinner #}
3
3
  <span role="status" aria-live="polite" class="usx-spinner{% if className %} {{ className }}{% endif %}">
4
- <svg class="usa-icon {% if size == 1 %}usx-spinner--size-1{% else %}usa-icon--size-{{ size|default:3 }}{% endif %}{% if color %} text-{{ color }}{% endif %}" aria-hidden="true" focusable="false">
5
- <use href="{% static 'img/usx-sprite.svg' %}#spinner"></use>
6
- </svg>
7
- {% if screenReaderLabel %}<span class="usa-sr-only">{{ screenReaderLabel }}</span>{% endif %}
8
- {% if label %}<span class="usa-label usx-label">{{ label }}</span>{% endif %}
4
+ {% icon name="spinner" source="usx" size=size|default:3 color=color staticBaseUrl=staticBaseUrl staticUrlPrefix=staticUrlPrefix %}{% endicon %}
5
+ {% if screenReaderLabel %}{% label screenReaderOnly=True %}{{ screenReaderLabel }}{% endlabel %}{% endif %}
6
+ {% if label %}{% label %}{{ label }}{% endlabel %}{% endif %}
9
7
  </span>
@@ -2,10 +2,11 @@ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
 
4
4
  export interface TooltipProps extends React.HTMLAttributes<HTMLSpanElement> {
5
- label: string;
5
+ label: React.ReactNode;
6
6
  position?: 'top' | 'bottom' | 'left' | 'right';
7
7
  children?: React.ReactNode;
8
8
  className?: string;
9
+ bodyClassName?: string;
9
10
  }
10
11
 
11
12
  const Tooltip: React.FC<TooltipProps> = ({
@@ -13,6 +14,7 @@ const Tooltip: React.FC<TooltipProps> = ({
13
14
  position = 'top',
14
15
  children,
15
16
  className = '',
17
+ bodyClassName = '',
16
18
  ...props
17
19
  }) => {
18
20
  const validPositions = ['top', 'bottom', 'left', 'right'] as const;
@@ -21,7 +23,7 @@ const Tooltip: React.FC<TooltipProps> = ({
21
23
  <span className={classNames('usx-tooltip', className)} {...props}>
22
24
  {children}
23
25
  <span
24
- className={`usa-tooltip__body usa-tooltip__body--${normalizedPosition}`}
26
+ className={classNames('usa-tooltip__body', `usa-tooltip__body--${normalizedPosition}`, bodyClassName)}
25
27
  role="tooltip"
26
28
  >
27
29
  {label}
@@ -4,9 +4,9 @@
4
4
  "version": 1,
5
5
  "props": {
6
6
  "label": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "default": "Tooltip text",
9
- "description": "The text content displayed inside the tooltip body."
9
+ "description": "Content displayed inside the tooltip body. Accepts text or composed content, such as React nodes or a Django template fragment."
10
10
  },
11
11
  "position": {
12
12
  "type": "select",
@@ -28,6 +28,11 @@
28
28
  "type": "string",
29
29
  "default": "",
30
30
  "description": "Additional CSS classes to apply to the tooltip wrapper."
31
+ },
32
+ "bodyClassName": {
33
+ "type": "string",
34
+ "default": "",
35
+ "description": "Additional CSS classes to apply to the tooltip body."
31
36
  }
32
37
  }
33
38
  }
@@ -1,5 +1,5 @@
1
1
  {# Django template for Tooltip #}
2
2
  <span class="usx-tooltip{% if className %} {{ className }}{% endif %}">
3
3
  {% if children %}{{ children|safe }}{% endif %}
4
- <span class="usa-tooltip__body usa-tooltip__body--{{ position|default:'top' }}" role="tooltip">{{ label|default:"Tooltip text" }}</span>
4
+ <span class="usa-tooltip__body usa-tooltip__body--{{ position|default:'top' }}{% if bodyClassName %} {{ bodyClassName }}{% endif %}" role="tooltip">{{ label|default:"Tooltip text" }}</span>
5
5
  </span>
@@ -1,6 +1,5 @@
1
- // Sass entry for the core package: theme variables, the themed USX component
1
+ // Sass entry for the core package: the themed USX component
2
2
  // styles and the USWDS fix-ups. Component styles live in packages/usx.
3
- @use 'pkg:@solexllc/usx-theme/variables' as *;
4
3
 
5
4
  // Themed entry = runtime theming opt-in (loads usx-theme's hooks before the
6
5
  // component styles). Swap to 'pkg:@solexllc/usx' for a fully static build.