@solexllc/usx-react 0.1.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/README.md +45 -0
- package/dist/index.cjs +6017 -0
- package/dist/index.js +6015 -0
- package/package.json +48 -0
- package/src/components/accordion/Accordion.jsx +170 -0
- package/src/components/accordion/accordion.django.html +47 -0
- package/src/components/accordion/accordion.html +304 -0
- package/src/components/accordion/config.json +31 -0
- package/src/components/alert/Alert.tsx +88 -0
- package/src/components/alert/alert.django.html +45 -0
- package/src/components/alert/alert.html +192 -0
- package/src/components/alert/config.json +70 -0
- package/src/components/attribution/Attribution.tsx +40 -0
- package/src/components/attribution/attribution.django.html +21 -0
- package/src/components/attribution/attribution.html +26 -0
- package/src/components/attribution/config.json +32 -0
- package/src/components/avatar/Avatar.tsx +85 -0
- package/src/components/avatar/avatar.django.html +27 -0
- package/src/components/avatar/avatar.html +101 -0
- package/src/components/avatar/config.json +59 -0
- package/src/components/avatar-group/AvatarGroup.tsx +43 -0
- package/src/components/avatar-group/avatar-group.django.html +8 -0
- package/src/components/avatar-group/avatar-group.html +208 -0
- package/src/components/avatar-group/config.json +60 -0
- package/src/components/back-to-top/BackToTop.tsx +60 -0
- package/src/components/back-to-top/back-to-top.django.html +38 -0
- package/src/components/back-to-top/back-to-top.html +107 -0
- package/src/components/back-to-top/config.json +44 -0
- package/src/components/banner/Banner.tsx +111 -0
- package/src/components/banner/banner.django.html +80 -0
- package/src/components/banner/banner.html +411 -0
- package/src/components/banner/config.json +47 -0
- package/src/components/block/Block.tsx +78 -0
- package/src/components/block/block.django.html +26 -0
- package/src/components/block/block.html +162 -0
- package/src/components/block/config.json +88 -0
- package/src/components/breadcrumb/Breadcrumb.tsx +83 -0
- package/src/components/breadcrumb/breadcrumb.django.html +24 -0
- package/src/components/breadcrumb/breadcrumb.html +108 -0
- package/src/components/breadcrumb/config.json +74 -0
- package/src/components/button/Button.tsx +121 -0
- package/src/components/button/button.django.html +58 -0
- package/src/components/button/button.html +363 -0
- package/src/components/button/config.json +103 -0
- package/src/components/button-group/ButtonGroup.tsx +33 -0
- package/src/components/button-group/button-group.django.html +9 -0
- package/src/components/button-group/button-group.html +159 -0
- package/src/components/button-group/config.json +25 -0
- package/src/components/calendar-date/CalendarDate.tsx +40 -0
- package/src/components/calendar-date/calendar-date.django.html +8 -0
- package/src/components/calendar-date/calendar-date.html +17 -0
- package/src/components/calendar-date/config.json +17 -0
- package/src/components/card/Card.tsx +137 -0
- package/src/components/card/card.django.html +40 -0
- package/src/components/card/card.html +67 -0
- package/src/components/card/config.json +115 -0
- package/src/components/card-group/CardGroup.tsx +23 -0
- package/src/components/card-group/card-group.django.html +6 -0
- package/src/components/card-group/card-group.html +164 -0
- package/src/components/card-group/config.json +21 -0
- package/src/components/carousel/Carousel.tsx +101 -0
- package/src/components/carousel/carousel.django.html +41 -0
- package/src/components/carousel/carousel.html +64 -0
- package/src/components/carousel/config.json +38 -0
- package/src/components/character-count/CharacterCount.tsx +77 -0
- package/src/components/character-count/character-count.django.html +19 -0
- package/src/components/character-count/character-count.html +110 -0
- package/src/components/character-count/config.json +78 -0
- package/src/components/checkbox/Checkbox.tsx +90 -0
- package/src/components/checkbox/checkbox.django.html +16 -0
- package/src/components/checkbox/checkbox.html +266 -0
- package/src/components/checkbox/config.json +71 -0
- package/src/components/checkbox-group/CheckboxGroup.tsx +67 -0
- package/src/components/checkbox-group/checkbox-group.django.html +12 -0
- package/src/components/checkbox-group/checkbox-group.html +36 -0
- package/src/components/checkbox-group/config.json +50 -0
- package/src/components/clickable/Clickable.tsx +78 -0
- package/src/components/clickable/clickable.django.html +5 -0
- package/src/components/clickable/clickable.html +133 -0
- package/src/components/clickable/config.json +26 -0
- package/src/components/code/Code.tsx +60 -0
- package/src/components/code/code.django.html +21 -0
- package/src/components/code/code.html +71 -0
- package/src/components/code/config.json +40 -0
- package/src/components/collection/Collection.tsx +99 -0
- package/src/components/collection/collection.django.html +48 -0
- package/src/components/collection/collection.html +384 -0
- package/src/components/collection/config.json +60 -0
- package/src/components/combobox/Combobox.tsx +114 -0
- package/src/components/combobox/combobox.django.html +61 -0
- package/src/components/combobox/combobox.html +509 -0
- package/src/components/combobox/config.json +80 -0
- package/src/components/copy-to-clipboard/CopyToClipboard.tsx +48 -0
- package/src/components/copy-to-clipboard/config.json +30 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +16 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.html +68 -0
- package/src/components/date-picker/DatePicker.jsx +83 -0
- package/src/components/date-picker/config.json +71 -0
- package/src/components/date-picker/date-picker.django.html +67 -0
- package/src/components/date-picker/date-picker.html +104 -0
- package/src/components/date-range-picker/DateRangePicker.jsx +113 -0
- package/src/components/date-range-picker/config.json +92 -0
- package/src/components/date-range-picker/date-range-picker.django.html +66 -0
- package/src/components/date-range-picker/date-range-picker.html +190 -0
- package/src/components/error-message/ErrorMessage.tsx +23 -0
- package/src/components/error-message/config.json +19 -0
- package/src/components/error-message/error-message.django.html +2 -0
- package/src/components/error-message/error-message.html +2 -0
- package/src/components/eyebrow/Eyebrow.tsx +15 -0
- package/src/components/eyebrow/config.json +15 -0
- package/src/components/eyebrow/eyebrow.django.html +4 -0
- package/src/components/eyebrow/eyebrow.html +4 -0
- package/src/components/fieldset/Fieldset.tsx +54 -0
- package/src/components/fieldset/config.json +47 -0
- package/src/components/fieldset/fieldset.django.html +22 -0
- package/src/components/fieldset/fieldset.html +17 -0
- package/src/components/file-input/FileInput.jsx +174 -0
- package/src/components/file-input/config.json +80 -0
- package/src/components/file-input/file-input.django.html +57 -0
- package/src/components/file-input/file-input.html +258 -0
- package/src/components/file-list/FileList.jsx +105 -0
- package/src/components/file-list/config.json +43 -0
- package/src/components/file-list/file-list.django.html +30 -0
- package/src/components/file-list/file-list.html +61 -0
- package/src/components/footer/Footer.tsx +365 -0
- package/src/components/footer/config.json +83 -0
- package/src/components/footer/footer.django.html +260 -0
- package/src/components/footer/footer.html +392 -0
- package/src/components/form-group/FormGroup.tsx +26 -0
- package/src/components/form-group/config.json +22 -0
- package/src/components/form-group/form-group.django.html +4 -0
- package/src/components/form-group/form-group.html +17 -0
- package/src/components/header/Branding.tsx +101 -0
- package/src/components/header/Header.tsx +229 -0
- package/src/components/header/HeaderBranding.jsx +4 -0
- package/src/components/header/config.json +58 -0
- package/src/components/header/header.django.html +194 -0
- package/src/components/header/header.html +823 -0
- package/src/components/hero/Hero.tsx +64 -0
- package/src/components/hero/config.json +70 -0
- package/src/components/hero/hero.django.html +22 -0
- package/src/components/hero/hero.html +75 -0
- package/src/components/hint/Hint.tsx +23 -0
- package/src/components/hint/config.json +19 -0
- package/src/components/hint/hint.django.html +2 -0
- package/src/components/hint/hint.html +2 -0
- package/src/components/icon/Icon.tsx +46 -0
- package/src/components/icon/config.json +60 -0
- package/src/components/icon/icon.django.html +26 -0
- package/src/components/icon/icon.html +289 -0
- package/src/components/icon/icons_list.json +247 -0
- package/src/components/icon-list/IconList.tsx +59 -0
- package/src/components/icon-list/config.json +86 -0
- package/src/components/icon-list/icon-list.django.html +17 -0
- package/src/components/icon-list/icon-list.html +227 -0
- package/src/components/identifier/Identifier.tsx +193 -0
- package/src/components/identifier/config.json +133 -0
- package/src/components/identifier/identifier.django.html +99 -0
- package/src/components/identifier/identifier.html +737 -0
- package/src/components/image/Image.tsx +106 -0
- package/src/components/image/config.json +64 -0
- package/src/components/image/image.django.html +62 -0
- package/src/components/image/image.html +53 -0
- package/src/components/in-page-nav/InPageNav.jsx +76 -0
- package/src/components/in-page-nav/config.json +69 -0
- package/src/components/in-page-nav/in-page-nav.django.html +28 -0
- package/src/components/in-page-nav/in-page-nav.html +183 -0
- package/src/components/indicator/Indicator.tsx +32 -0
- package/src/components/indicator/README.md +1 -0
- package/src/components/indicator/config.json +19 -0
- package/src/components/indicator/indicator.django.html +10 -0
- package/src/components/indicator/indicator.html +42 -0
- package/src/components/input/Input.tsx +85 -0
- package/src/components/input/config.json +73 -0
- package/src/components/input/input.django.html +55 -0
- package/src/components/input/input.html +59 -0
- package/src/components/label/Label.tsx +42 -0
- package/src/components/label/config.json +39 -0
- package/src/components/label/label.django.html +23 -0
- package/src/components/label/label.html +23 -0
- package/src/components/language-selector/LanguageSelector.jsx +224 -0
- package/src/components/language-selector/config.json +107 -0
- package/src/components/language-selector/language-selector.django.html +40 -0
- package/src/components/language-selector/language-selector.html +85 -0
- package/src/components/layout/Layout.tsx +131 -0
- package/src/components/layout/config.json +36 -0
- package/src/components/layout/layout.django.html +28 -0
- package/src/components/layout/layout.html +29 -0
- package/src/components/legend/Legend.tsx +34 -0
- package/src/components/legend/config.json +27 -0
- package/src/components/legend/legend.django.html +11 -0
- package/src/components/legend/legend.html +12 -0
- package/src/components/link/Link.tsx +45 -0
- package/src/components/link/config.json +39 -0
- package/src/components/link/link.django.html +8 -0
- package/src/components/link/link.html +47 -0
- package/src/components/list/List.tsx +82 -0
- package/src/components/list/_list-items.django.html +17 -0
- package/src/components/list/config.json +25 -0
- package/src/components/list/list.django.html +11 -0
- package/src/components/list/list.html +26 -0
- package/src/components/memorable-date/MemorableDate.jsx +167 -0
- package/src/components/memorable-date/config.json +104 -0
- package/src/components/memorable-date/memorable-date.django.html +86 -0
- package/src/components/memorable-date/memorable-date.html +275 -0
- package/src/components/misc-banner/MiscBanner.tsx +112 -0
- package/src/components/misc-banner/config.json +57 -0
- package/src/components/misc-banner/misc-banner.django.html +63 -0
- package/src/components/misc-banner/misc-banner.html +191 -0
- package/src/components/modal/Modal.tsx +71 -0
- package/src/components/modal/config.json +57 -0
- package/src/components/modal/modal.django.html +43 -0
- package/src/components/modal/modal.html +222 -0
- package/src/components/page/Page.jsx +34 -0
- package/src/components/page/config.json +34 -0
- package/src/components/page/page.django.html +5 -0
- package/src/components/page/page.html +23 -0
- package/src/components/pagination/Pagination.tsx +112 -0
- package/src/components/pagination/config.json +135 -0
- package/src/components/pagination/container/PaginationContainer.tsx +38 -0
- package/src/components/pagination/navigation/PaginationNavigation.tsx +219 -0
- package/src/components/pagination/navigation/pagination-navigation.django.html +64 -0
- package/src/components/pagination/pagination.django.html +48 -0
- package/src/components/pagination/pagination.html +613 -0
- package/src/components/pagination/step-options/PaginationStepOptions.tsx +43 -0
- package/src/components/pagination/step-options/pagination-step-options.django.html +7 -0
- package/src/components/pagination/summary/PaginationSummary.tsx +33 -0
- package/src/components/pagination/summary/pagination-summary.django.html +12 -0
- package/src/components/process-list/ProcessList.tsx +52 -0
- package/src/components/process-list/config.json +15 -0
- package/src/components/process-list/process-list.django.html +15 -0
- package/src/components/process-list/process-list.html +90 -0
- package/src/components/prose/Prose.tsx +32 -0
- package/src/components/prose/config.json +28 -0
- package/src/components/prose/prose.django.html +35 -0
- package/src/components/prose/prose.html +91 -0
- package/src/components/radio-buttons/RadioButtons.tsx +82 -0
- package/src/components/radio-buttons/config.json +57 -0
- package/src/components/radio-buttons/radio-buttons.django.html +28 -0
- package/src/components/radio-buttons/radio-buttons.html +189 -0
- package/src/components/range-slider/RangeSlider.jsx +84 -0
- package/src/components/range-slider/config.json +89 -0
- package/src/components/range-slider/range-slider.django.html +65 -0
- package/src/components/range-slider/range-slider.html +106 -0
- package/src/components/required/Required.tsx +25 -0
- package/src/components/required/config.json +20 -0
- package/src/components/required/required.django.html +2 -0
- package/src/components/required/required.html +6 -0
- package/src/components/search/Search.tsx +92 -0
- package/src/components/search/config.json +69 -0
- package/src/components/search/search.django.html +59 -0
- package/src/components/search/search.html +76 -0
- package/src/components/section/Section.tsx +28 -0
- package/src/components/section/config.json +27 -0
- package/src/components/section/section.django.html +5 -0
- package/src/components/section/section.html +16 -0
- package/src/components/select/Select.tsx +107 -0
- package/src/components/select/config.json +80 -0
- package/src/components/select/select.django.html +64 -0
- package/src/components/select/select.html +62 -0
- package/src/components/sidenav/SideNav.tsx +74 -0
- package/src/components/sidenav/config.json +45 -0
- package/src/components/sidenav/sidenav.django.html +29 -0
- package/src/components/sidenav/sidenav.html +84 -0
- package/src/components/site-alert/SiteAlert.tsx +101 -0
- package/src/components/site-alert/config.json +62 -0
- package/src/components/site-alert/site-alert.django.html +34 -0
- package/src/components/site-alert/site-alert.html +312 -0
- package/src/components/skipnav/Skipnav.tsx +41 -0
- package/src/components/skipnav/config.json +29 -0
- package/src/components/skipnav/skipnav.django.html +11 -0
- package/src/components/skipnav/skipnav.html +1 -0
- package/src/components/spinner/Spinner.tsx +46 -0
- package/src/components/spinner/config.json +44 -0
- package/src/components/spinner/spinner.django.html +8 -0
- package/src/components/spinner/spinner.html +219 -0
- package/src/components/status/Status.tsx +28 -0
- package/src/components/status/config.json +47 -0
- package/src/components/status/status.django.html +2 -0
- package/src/components/status/status.html +31 -0
- package/src/components/step-indicator/StepIndicator.tsx +80 -0
- package/src/components/step-indicator/config.json +54 -0
- package/src/components/step-indicator/step-indicator.django.html +29 -0
- package/src/components/step-indicator/step-indicator.html +243 -0
- package/src/components/summary-box/SummaryBox.tsx +41 -0
- package/src/components/summary-box/config.json +30 -0
- package/src/components/summary-box/summary-box.django.html +19 -0
- package/src/components/summary-box/summary-box.html +210 -0
- package/src/components/swap/Swap.tsx +47 -0
- package/src/components/swap/config.json +61 -0
- package/src/components/swap/swap.django.html +14 -0
- package/src/components/swap/swap.html +163 -0
- package/src/components/switch/Switch.tsx +73 -0
- package/src/components/switch/config.json +55 -0
- package/src/components/switch/switch.django.html +28 -0
- package/src/components/switch/switch.html +56 -0
- package/src/components/table/Table.tsx +334 -0
- package/src/components/table/TableBody.tsx +253 -0
- package/src/components/table/TableCell.tsx +37 -0
- package/src/components/table/TableContext.tsx +87 -0
- package/src/components/table/TableFoot.tsx +68 -0
- package/src/components/table/TableGroup.tsx +69 -0
- package/src/components/table/TableHead.tsx +139 -0
- package/src/components/table/TableRow.tsx +56 -0
- package/src/components/table/__pycache__/table_helper.cpython-312.pyc +0 -0
- package/src/components/table/config.json +297 -0
- package/src/components/table/hooks/useRowDetails.ts +34 -0
- package/src/components/table/hooks/useTableGroups.ts +61 -0
- package/src/components/table/hooks/useTableSelect.ts +82 -0
- package/src/components/table/hooks/useTableSort.ts +60 -0
- package/src/components/table/table-body.django.html +68 -0
- package/src/components/table/table-detail-row.django.html +14 -0
- package/src/components/table/table-foot.django.html +31 -0
- package/src/components/table/table-group.django.html +40 -0
- package/src/components/table/table-head.django.html +85 -0
- package/src/components/table/table-row.django.html +98 -0
- package/src/components/table/table.django.html +60 -0
- package/src/components/table/table.html +1186 -0
- package/src/components/table/table_helper.py +298 -0
- package/src/components/table/types.ts +68 -0
- package/src/components/tag/Tag.tsx +75 -0
- package/src/components/tag/config.json +54 -0
- package/src/components/tag/tag.django.html +39 -0
- package/src/components/tag/tag.html +45 -0
- package/src/components/tag-group/TagGroup.tsx +35 -0
- package/src/components/tag-group/config.json +24 -0
- package/src/components/tag-group/tag-group.django.html +11 -0
- package/src/components/tag-group/tag-group.html +36 -0
- package/src/components/task-list/TaskList.tsx +40 -0
- package/src/components/task-list/config.json +41 -0
- package/src/components/task-list/task-list.django.html +21 -0
- package/src/components/task-list/task-list.html +24 -0
- package/src/components/text-area/TextArea.tsx +78 -0
- package/src/components/text-area/config.json +78 -0
- package/src/components/text-area/text-area.django.html +53 -0
- package/src/components/text-area/text-area.html +59 -0
- package/src/components/theme-picker/ThemePicker.tsx +106 -0
- package/src/components/theme-picker/config.json +39 -0
- package/src/components/theme-picker/theme-picker.django.html +32 -0
- package/src/components/theme-picker/theme-picker.html +67 -0
- package/src/components/time-picker/TimePicker.jsx +87 -0
- package/src/components/time-picker/config.json +76 -0
- package/src/components/time-picker/time-picker.django.html +67 -0
- package/src/components/time-picker/time-picker.html +123 -0
- package/src/components/toggle/Toggle.tsx +80 -0
- package/src/components/toggle/config.json +69 -0
- package/src/components/toggle/toggle.django.html +19 -0
- package/src/components/toggle/toggle.html +85 -0
- package/src/components/tooltip/Tooltip.tsx +33 -0
- package/src/components/tooltip/config.json +33 -0
- package/src/components/tooltip/tooltip.django.html +5 -0
- package/src/components/tooltip/tooltip.html +57 -0
- package/src/components/villain/Villain.tsx +47 -0
- package/src/components/villain/config.json +44 -0
- package/src/components/villain/villain.django.html +19 -0
- package/src/components/villain/villain.html +39 -0
- package/src/declarations.d.ts +1 -0
- package/src/index.js +82 -0
- package/src/styles/core.scss +12 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders a single language link/submenu-item's accessible label.
|
|
7
|
+
* Real USWDS wraps the native-language name in <strong> and appends an
|
|
8
|
+
* English gloss in parens (e.g. <strong>Español</strong> (Spanish)); the
|
|
9
|
+
* whole thing carries `lang`/`xml:lang` so assistive tech announces it in
|
|
10
|
+
* the correct language (WCAG H58).
|
|
11
|
+
*/
|
|
12
|
+
function LanguageLabel({ code, label, description }) {
|
|
13
|
+
if (!code) {
|
|
14
|
+
return <>{label}</>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<span lang={code} xmlLang={code}>
|
|
19
|
+
<strong>{label}</strong>
|
|
20
|
+
{description ? ` (${description})` : null}
|
|
21
|
+
</span>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
LanguageLabel.propTypes = {
|
|
26
|
+
code: PropTypes.string,
|
|
27
|
+
label: PropTypes.node.isRequired,
|
|
28
|
+
description: PropTypes.string,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function TwoLanguageSelector({ target, onSelect, className, navAriaLabel }) {
|
|
32
|
+
const handleClick = (e) => {
|
|
33
|
+
if (onSelect) onSelect(target, e);
|
|
34
|
+
if (!target.href) e.preventDefault();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Tag = target.href ? 'a' : 'button';
|
|
38
|
+
const tagProps = target.href
|
|
39
|
+
? { href: target.href }
|
|
40
|
+
: { type: 'button' };
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<nav aria-label={navAriaLabel} className={className}>
|
|
44
|
+
<div className="usa-language-container">
|
|
45
|
+
<Tag className="usa-button usx-button usa-button--primary" onClick={handleClick} {...tagProps}>
|
|
46
|
+
<LanguageLabel code={target.code} label={target.label} />
|
|
47
|
+
</Tag>
|
|
48
|
+
</div>
|
|
49
|
+
</nav>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
TwoLanguageSelector.propTypes = {
|
|
54
|
+
target: PropTypes.shape({
|
|
55
|
+
code: PropTypes.string,
|
|
56
|
+
label: PropTypes.node,
|
|
57
|
+
href: PropTypes.string,
|
|
58
|
+
}).isRequired,
|
|
59
|
+
onSelect: PropTypes.func,
|
|
60
|
+
className: PropTypes.string,
|
|
61
|
+
navAriaLabel: PropTypes.string,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function MenuLanguageSelector({
|
|
65
|
+
languages,
|
|
66
|
+
unstyled,
|
|
67
|
+
small,
|
|
68
|
+
label,
|
|
69
|
+
id,
|
|
70
|
+
onSelect,
|
|
71
|
+
className,
|
|
72
|
+
navAriaLabel,
|
|
73
|
+
}) {
|
|
74
|
+
// Open/close (aria-expanded, hidden, outside-click, Escape, focusout) is
|
|
75
|
+
// driven by USWDS's own JS, initialized via a decorator in the story/host
|
|
76
|
+
// app — this component only renders the static USWDS markup.
|
|
77
|
+
const containerClasses = classnames(
|
|
78
|
+
'usa-language-container',
|
|
79
|
+
small && 'usa-language--small'
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const buttonClasses = classnames(
|
|
83
|
+
'usa-button',
|
|
84
|
+
'usx-button',
|
|
85
|
+
unstyled ? 'usa-button--unstyled' : 'usa-button--primary',
|
|
86
|
+
'usa-language__link'
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<nav aria-label={navAriaLabel} className={className}>
|
|
91
|
+
<div className={containerClasses}>
|
|
92
|
+
<ul className="usa-language__primary usa-accordion">
|
|
93
|
+
<li className="usa-language__primary-item">
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
className={buttonClasses}
|
|
97
|
+
aria-expanded="false"
|
|
98
|
+
aria-controls={id}
|
|
99
|
+
>
|
|
100
|
+
{label}
|
|
101
|
+
</button>
|
|
102
|
+
<ul id={id} className="usa-language__submenu" hidden>
|
|
103
|
+
{languages.map((lang, idx) => (
|
|
104
|
+
<li className="usa-language__submenu-item" key={lang.code || lang.label || idx}>
|
|
105
|
+
<a
|
|
106
|
+
href={lang.href || 'javascript:void(0);'}
|
|
107
|
+
aria-current={lang.current ? 'true' : undefined}
|
|
108
|
+
onClick={(e) => {
|
|
109
|
+
if (onSelect) onSelect(lang, e);
|
|
110
|
+
if (!lang.href) e.preventDefault();
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{lang.plain ? (
|
|
114
|
+
lang.label
|
|
115
|
+
) : (
|
|
116
|
+
<LanguageLabel code={lang.code} label={lang.label} description={lang.description} />
|
|
117
|
+
)}
|
|
118
|
+
</a>
|
|
119
|
+
</li>
|
|
120
|
+
))}
|
|
121
|
+
</ul>
|
|
122
|
+
</li>
|
|
123
|
+
</ul>
|
|
124
|
+
</div>
|
|
125
|
+
</nav>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
MenuLanguageSelector.propTypes = {
|
|
130
|
+
languages: PropTypes.arrayOf(
|
|
131
|
+
PropTypes.shape({
|
|
132
|
+
code: PropTypes.string,
|
|
133
|
+
label: PropTypes.node,
|
|
134
|
+
description: PropTypes.string,
|
|
135
|
+
href: PropTypes.string,
|
|
136
|
+
current: PropTypes.bool,
|
|
137
|
+
plain: PropTypes.bool,
|
|
138
|
+
})
|
|
139
|
+
).isRequired,
|
|
140
|
+
unstyled: PropTypes.bool,
|
|
141
|
+
small: PropTypes.bool,
|
|
142
|
+
label: PropTypes.string,
|
|
143
|
+
id: PropTypes.string,
|
|
144
|
+
onSelect: PropTypes.func,
|
|
145
|
+
className: PropTypes.string,
|
|
146
|
+
navAriaLabel: PropTypes.string,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* LanguageSelector — USWDS `usa-language-selector` with the USX treatment.
|
|
151
|
+
*
|
|
152
|
+
* Renders either the two-language button (`variant="two"`) or the
|
|
153
|
+
* three-or-more-language dropdown menu (`variant="menu"`, optionally
|
|
154
|
+
* `unstyled`), auto-inferring the variant from `languages.length` when not
|
|
155
|
+
* given explicitly. Always exposed as a `<nav>` landmark for discoverability
|
|
156
|
+
* by assistive tech, per gov.uk/VA.gov prior art.
|
|
157
|
+
*/
|
|
158
|
+
export default function LanguageSelector({
|
|
159
|
+
languages = [],
|
|
160
|
+
variant = null,
|
|
161
|
+
unstyled = false,
|
|
162
|
+
small = false,
|
|
163
|
+
label = 'Languages',
|
|
164
|
+
id = 'language-options',
|
|
165
|
+
navAriaLabel = 'Language selection',
|
|
166
|
+
className = '',
|
|
167
|
+
onSelect = null,
|
|
168
|
+
...props
|
|
169
|
+
}) {
|
|
170
|
+
const resolvedVariant = variant || (languages.length > 2 ? 'menu' : 'two');
|
|
171
|
+
const classes = classnames('usx-language-selector', className);
|
|
172
|
+
|
|
173
|
+
if (!languages || languages.length === 0) {
|
|
174
|
+
return <div className={classes}>{'LanguageSelector'}</div>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (resolvedVariant === 'two') {
|
|
178
|
+
const target = languages.find((lang) => !lang.current) || languages[1] || languages[0];
|
|
179
|
+
return (
|
|
180
|
+
<TwoLanguageSelector
|
|
181
|
+
target={target}
|
|
182
|
+
onSelect={onSelect}
|
|
183
|
+
className={classes}
|
|
184
|
+
navAriaLabel={navAriaLabel}
|
|
185
|
+
{...props}
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<MenuLanguageSelector
|
|
192
|
+
languages={languages}
|
|
193
|
+
unstyled={unstyled}
|
|
194
|
+
small={small}
|
|
195
|
+
label={label}
|
|
196
|
+
id={id}
|
|
197
|
+
onSelect={onSelect}
|
|
198
|
+
className={classes}
|
|
199
|
+
navAriaLabel={navAriaLabel}
|
|
200
|
+
{...props}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
LanguageSelector.propTypes = {
|
|
206
|
+
languages: PropTypes.arrayOf(
|
|
207
|
+
PropTypes.shape({
|
|
208
|
+
code: PropTypes.string,
|
|
209
|
+
label: PropTypes.node,
|
|
210
|
+
description: PropTypes.string,
|
|
211
|
+
href: PropTypes.string,
|
|
212
|
+
current: PropTypes.bool,
|
|
213
|
+
plain: PropTypes.bool,
|
|
214
|
+
})
|
|
215
|
+
),
|
|
216
|
+
variant: PropTypes.oneOf(['two', 'menu']),
|
|
217
|
+
unstyled: PropTypes.bool,
|
|
218
|
+
small: PropTypes.bool,
|
|
219
|
+
label: PropTypes.string,
|
|
220
|
+
id: PropTypes.string,
|
|
221
|
+
navAriaLabel: PropTypes.string,
|
|
222
|
+
className: PropTypes.string,
|
|
223
|
+
onSelect: PropTypes.func,
|
|
224
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "language-selector",
|
|
3
|
+
"template": "language-selector/language-selector.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"default": {
|
|
6
|
+
"variant": "menu",
|
|
7
|
+
"languages": [
|
|
8
|
+
{
|
|
9
|
+
"code": "en",
|
|
10
|
+
"label": "English",
|
|
11
|
+
"current": true
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"code": "es",
|
|
15
|
+
"label": "Español",
|
|
16
|
+
"description": "Spanish"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"code": "vi",
|
|
20
|
+
"label": "Tiếng Việt",
|
|
21
|
+
"description": "Vietnamese"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"code": "zh",
|
|
25
|
+
"label": "简体字",
|
|
26
|
+
"description": "Chinese – Simplified"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "Selected content in additional languages",
|
|
30
|
+
"plain": true
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"props": {
|
|
35
|
+
"languages": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"description": "Array of language options",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"description": "Language option.",
|
|
41
|
+
"properties": {
|
|
42
|
+
"code": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "ISO language code, used for the lang/xml:lang attribute"
|
|
45
|
+
},
|
|
46
|
+
"label": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Native-language name of the language (e.g. Español)"
|
|
49
|
+
},
|
|
50
|
+
"description": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "English gloss shown in parens (e.g. Spanish); omit for English itself"
|
|
53
|
+
},
|
|
54
|
+
"href": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "URL for this language's version of the page"
|
|
57
|
+
},
|
|
58
|
+
"current": {
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"description": "Whether this is the page's current language"
|
|
61
|
+
},
|
|
62
|
+
"plain": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"description": "Render as a plain link with no lang span (e.g. \"Selected content in additional languages\")"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"variant": {
|
|
70
|
+
"type": "select",
|
|
71
|
+
"options": [
|
|
72
|
+
"two",
|
|
73
|
+
"menu"
|
|
74
|
+
],
|
|
75
|
+
"description": "Two-language button vs. three-or-more-language dropdown menu. Auto-inferred from languages.length when omitted."
|
|
76
|
+
},
|
|
77
|
+
"unstyled": {
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"default": false,
|
|
80
|
+
"description": "Render the menu variant's trigger as an unstyled button (usa-button--unstyled)"
|
|
81
|
+
},
|
|
82
|
+
"small": {
|
|
83
|
+
"type": "boolean",
|
|
84
|
+
"default": false,
|
|
85
|
+
"description": "Compact sizing for the menu variant (usa-language--small), e.g. inside a header"
|
|
86
|
+
},
|
|
87
|
+
"label": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"default": "Languages",
|
|
90
|
+
"description": "Menu variant trigger button text"
|
|
91
|
+
},
|
|
92
|
+
"id": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"default": "language-options",
|
|
95
|
+
"description": "id of the submenu, referenced by the trigger's aria-controls"
|
|
96
|
+
},
|
|
97
|
+
"navAriaLabel": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"default": "Language selection",
|
|
100
|
+
"description": "aria-label for the wrapping <nav> landmark"
|
|
101
|
+
},
|
|
102
|
+
"className": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "Additional classes to apply"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{# Django template for LanguageSelector #}
|
|
2
|
+
{# Props: languages (array of {code,label,description,href,current,plain}), variant ('two'|'menu'), unstyled (bool), small (bool), label (string), id (string), navAriaLabel (string), className (string) #}
|
|
3
|
+
{# For variant="two", mark exactly one language `current: true` — the other renders as the switch target. #}
|
|
4
|
+
<nav aria-label="{{ navAriaLabel|default:'Language selection' }}"{% if className %} class="{{ className }}"{% endif %}>
|
|
5
|
+
{% if variant == 'menu' %}
|
|
6
|
+
<div class="usa-language-container usx-language-selector{% if small %} usa-language--small{% endif %}">
|
|
7
|
+
<ul class="usa-language__primary usa-accordion">
|
|
8
|
+
<li class="usa-language__primary-item">
|
|
9
|
+
<button
|
|
10
|
+
type="button"
|
|
11
|
+
class="usa-button usx-button{% if unstyled %} usa-button--unstyled{% else %} usa-button--primary{% endif %} usa-language__link"
|
|
12
|
+
aria-expanded="false"
|
|
13
|
+
aria-controls="{{ id|default:'language-options' }}"
|
|
14
|
+
>
|
|
15
|
+
{{ label|default:'Languages' }}
|
|
16
|
+
</button>
|
|
17
|
+
<ul id="{{ id|default:'language-options' }}" class="usa-language__submenu" hidden>
|
|
18
|
+
{% for lang in languages %}
|
|
19
|
+
<li class="usa-language__submenu-item">
|
|
20
|
+
<a href="{{ lang.href|default:'javascript:void(0);' }}"{% if lang.current %} aria-current="true"{% endif %}>
|
|
21
|
+
{% if lang.plain %}{{ lang.label }}{% else %}<span lang="{{ lang.code }}" xml:lang="{{ lang.code }}"><strong>{{ lang.label }}</strong>{% if lang.description %} ({{ lang.description }}){% endif %}</span>{% endif %}
|
|
22
|
+
</a>
|
|
23
|
+
</li>
|
|
24
|
+
{% endfor %}
|
|
25
|
+
</ul>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
</div>
|
|
29
|
+
{% else %}
|
|
30
|
+
<div class="usa-language-container usx-language-selector">
|
|
31
|
+
{% for lang in languages %}{% if not lang.current %}
|
|
32
|
+
{% if lang.href %}
|
|
33
|
+
<a href="{{ lang.href }}" class="usa-button usx-button usa-button--primary"><span lang="{{ lang.code }}" xml:lang="{{ lang.code }}"><strong>{{ lang.label }}</strong></span></a>
|
|
34
|
+
{% else %}
|
|
35
|
+
<button type="button" class="usa-button usx-button usa-button--primary"><span lang="{{ lang.code }}" xml:lang="{{ lang.code }}"><strong>{{ lang.label }}</strong></span></button>
|
|
36
|
+
{% endif %}
|
|
37
|
+
{% endif %}{% endfor %}
|
|
38
|
+
</div>
|
|
39
|
+
{% endif %}
|
|
40
|
+
</nav>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<h3 class="site-preview-heading">Two languages</h3>
|
|
2
|
+
<nav aria-label="Language selection">
|
|
3
|
+
<div class="usa-language-container usx-language-selector">
|
|
4
|
+
<button type="button" class="usa-button usx-button usa-button--primary">
|
|
5
|
+
<span lang="es" xml:lang="es"><strong>Español</strong></span>
|
|
6
|
+
</button>
|
|
7
|
+
</div>
|
|
8
|
+
</nav>
|
|
9
|
+
|
|
10
|
+
<h3 class="site-preview-heading">Three or more languages</h3>
|
|
11
|
+
<nav aria-label="Language selection">
|
|
12
|
+
<div class="usa-language-container usx-language-selector">
|
|
13
|
+
<ul class="usa-language__primary usa-accordion">
|
|
14
|
+
<li class="usa-language__primary-item">
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
class="usa-button usx-button usa-button--primary usa-language__link"
|
|
18
|
+
aria-expanded="false"
|
|
19
|
+
aria-controls="language-options"
|
|
20
|
+
>
|
|
21
|
+
Languages
|
|
22
|
+
</button>
|
|
23
|
+
<ul id="language-options" class="usa-language__submenu" hidden>
|
|
24
|
+
<li class="usa-language__submenu-item">
|
|
25
|
+
<a href="javascript:void(0);"><span lang="en" xml:lang="en"><strong>English</strong></span></a>
|
|
26
|
+
</li>
|
|
27
|
+
<li class="usa-language__submenu-item">
|
|
28
|
+
<a href="javascript:void(0);"
|
|
29
|
+
><span lang="es" xml:lang="es"
|
|
30
|
+
><strong>Español</strong> (Spanish)</span
|
|
31
|
+
></a
|
|
32
|
+
>
|
|
33
|
+
</li>
|
|
34
|
+
<li class="usa-language__submenu-item">
|
|
35
|
+
<a href="javascript:void(0);"
|
|
36
|
+
><span lang="vi" xml:lang="vi"
|
|
37
|
+
><strong>Tiếng Việt</strong> (Vietnamese)</span
|
|
38
|
+
></a
|
|
39
|
+
>
|
|
40
|
+
</li>
|
|
41
|
+
<li class="usa-language__submenu-item">
|
|
42
|
+
<a href="javascript:void(0);"
|
|
43
|
+
><span lang="zh" xml:lang="zh"
|
|
44
|
+
><strong>简体字</strong> (Chinese – Simplified)</span
|
|
45
|
+
></a
|
|
46
|
+
>
|
|
47
|
+
</li>
|
|
48
|
+
<li class="usa-language__submenu-item">
|
|
49
|
+
<a href="javascript:void(0);">Selected content in additional languages</a>
|
|
50
|
+
</li>
|
|
51
|
+
</ul>
|
|
52
|
+
</li>
|
|
53
|
+
</ul>
|
|
54
|
+
</div>
|
|
55
|
+
</nav>
|
|
56
|
+
|
|
57
|
+
<h3 class="site-preview-heading">Unstyled</h3>
|
|
58
|
+
<nav aria-label="Language selection">
|
|
59
|
+
<div class="usa-language-container usx-language-selector">
|
|
60
|
+
<ul class="usa-language__primary usa-accordion">
|
|
61
|
+
<li class="usa-language__primary-item">
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
class="usa-button usx-button usa-button--unstyled usa-language__link"
|
|
65
|
+
aria-expanded="false"
|
|
66
|
+
aria-controls="language-options-unstyled"
|
|
67
|
+
>
|
|
68
|
+
Languages
|
|
69
|
+
</button>
|
|
70
|
+
<ul id="language-options-unstyled" class="usa-language__submenu" hidden>
|
|
71
|
+
<li class="usa-language__submenu-item">
|
|
72
|
+
<a href="javascript:void(0);"><span lang="en" xml:lang="en"><strong>English</strong></span></a>
|
|
73
|
+
</li>
|
|
74
|
+
<li class="usa-language__submenu-item">
|
|
75
|
+
<a href="javascript:void(0);"
|
|
76
|
+
><span lang="es" xml:lang="es"
|
|
77
|
+
><strong>Español</strong> (Spanish)</span
|
|
78
|
+
></a
|
|
79
|
+
>
|
|
80
|
+
</li>
|
|
81
|
+
</ul>
|
|
82
|
+
</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</div>
|
|
85
|
+
</nav>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import ClassNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
// ── Sub-components ──────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export interface SingleColumnLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function SingleColumnLayout({ children, className = '', ...props }: SingleColumnLayoutProps) {
|
|
12
|
+
const classes = ['usx-layout__single-column', className].filter(Boolean).join(' ');
|
|
13
|
+
return (
|
|
14
|
+
<div className={classes} {...props}>
|
|
15
|
+
{children}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type GridLayoutProps = {
|
|
21
|
+
leftSidebar?: ReactNode;
|
|
22
|
+
rightSidebar?: ReactNode;
|
|
23
|
+
expandLeftSidebar?: boolean;
|
|
24
|
+
expandRightSidebar?: boolean;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
28
|
+
|
|
29
|
+
export function GridLayout({
|
|
30
|
+
leftSidebar,
|
|
31
|
+
rightSidebar,
|
|
32
|
+
expandLeftSidebar,
|
|
33
|
+
expandRightSidebar,
|
|
34
|
+
children,
|
|
35
|
+
className = '',
|
|
36
|
+
...props
|
|
37
|
+
}: GridLayoutProps) {
|
|
38
|
+
const contentModifier = (
|
|
39
|
+
rightSidebar && !leftSidebar ? 'left'
|
|
40
|
+
: leftSidebar && !rightSidebar ? 'right'
|
|
41
|
+
: null
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const contentClasses = ClassNames(
|
|
45
|
+
'usx-layout__content',
|
|
46
|
+
{
|
|
47
|
+
'usx-layout__content--left': contentModifier === 'left',
|
|
48
|
+
'usx-layout__content--right': contentModifier === 'right',
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
const containerClasses = ClassNames(
|
|
52
|
+
'usx-layout__grid-container',
|
|
53
|
+
className,
|
|
54
|
+
);
|
|
55
|
+
const leftSidebarClasses = ClassNames(
|
|
56
|
+
'usx-layout__sidebar--left',
|
|
57
|
+
{
|
|
58
|
+
'usx-layout__sidebar--expanded': expandLeftSidebar,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const rightSidebarClasses = ClassNames(
|
|
62
|
+
'usx-layout__sidebar--right',
|
|
63
|
+
{
|
|
64
|
+
'usx-layout__sidebar--expanded': expandRightSidebar,
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className={containerClasses} {...props}>
|
|
70
|
+
{leftSidebar && (
|
|
71
|
+
<aside className={leftSidebarClasses}>{leftSidebar}</aside>
|
|
72
|
+
)}
|
|
73
|
+
<main className={contentClasses}>{children}</main>
|
|
74
|
+
{rightSidebar && (
|
|
75
|
+
<aside className={rightSidebarClasses}>{rightSidebar}</aside>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
// ── Main Layout ─────────────────────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
export type LayoutProps = {
|
|
85
|
+
variant?: 'single-column' | 'grid';
|
|
86
|
+
children?: ReactNode;
|
|
87
|
+
content?: ReactNode;
|
|
88
|
+
leftSidebar?: ReactNode;
|
|
89
|
+
rightSidebar?: ReactNode;
|
|
90
|
+
expandLeftSidebar?: boolean;
|
|
91
|
+
expandRightSidebar?: boolean;
|
|
92
|
+
className?: string;
|
|
93
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
94
|
+
|
|
95
|
+
export default function Layout({
|
|
96
|
+
variant = 'single-column',
|
|
97
|
+
children,
|
|
98
|
+
content,
|
|
99
|
+
leftSidebar,
|
|
100
|
+
rightSidebar,
|
|
101
|
+
expandLeftSidebar,
|
|
102
|
+
expandRightSidebar,
|
|
103
|
+
className = '',
|
|
104
|
+
...props
|
|
105
|
+
}: LayoutProps) {
|
|
106
|
+
const classes = ClassNames(
|
|
107
|
+
'usx-layout',
|
|
108
|
+
className,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className={classes} {...props}>
|
|
113
|
+
{variant === 'single-column' ? (
|
|
114
|
+
<SingleColumnLayout>
|
|
115
|
+
{children || content}
|
|
116
|
+
</SingleColumnLayout>
|
|
117
|
+
) : variant === 'grid' ? (
|
|
118
|
+
<GridLayout
|
|
119
|
+
leftSidebar={leftSidebar}
|
|
120
|
+
rightSidebar={rightSidebar}
|
|
121
|
+
expandLeftSidebar={expandLeftSidebar}
|
|
122
|
+
expandRightSidebar={expandRightSidebar}
|
|
123
|
+
>
|
|
124
|
+
{children || content}
|
|
125
|
+
</GridLayout>
|
|
126
|
+
) : (
|
|
127
|
+
children || content
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "layout",
|
|
3
|
+
"template": "layout/layout.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"props": {
|
|
6
|
+
"variant": {
|
|
7
|
+
"type": "select",
|
|
8
|
+
"options": [
|
|
9
|
+
"single-column",
|
|
10
|
+
"grid"
|
|
11
|
+
],
|
|
12
|
+
"default": "single-column",
|
|
13
|
+
"description": "Layout variant: single-column centers content, grid supports sidebars"
|
|
14
|
+
},
|
|
15
|
+
"children": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Inner HTML or text content (for single-column)"
|
|
18
|
+
},
|
|
19
|
+
"content": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Main content for grid layout"
|
|
22
|
+
},
|
|
23
|
+
"leftSidebar": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Left sidebar content (grid variant only)"
|
|
26
|
+
},
|
|
27
|
+
"rightSidebar": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Right sidebar content (grid variant only)"
|
|
30
|
+
},
|
|
31
|
+
"className": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Additional CSS classes"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{# Django template for Layout #}
|
|
2
|
+
{# Supports variant: 'single-column' (default), 'grid' #}
|
|
3
|
+
{# For grid: content, leftSidebar, rightSidebar #}
|
|
4
|
+
<div class="usx-layout{% if className %} {{ className }}{% endif %}">
|
|
5
|
+
{% if variant == 'single-column' %}
|
|
6
|
+
<div class="usx-layout__single-column">
|
|
7
|
+
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
8
|
+
</div>
|
|
9
|
+
{% elif variant == 'grid' %}
|
|
10
|
+
<div class="usx-layout__grid-container">
|
|
11
|
+
{% if leftSidebar %}
|
|
12
|
+
<aside class="usx-layout__sidebar--left">
|
|
13
|
+
{{ leftSidebar|safe }}
|
|
14
|
+
</aside>
|
|
15
|
+
{% endif %}
|
|
16
|
+
<main class="usx-layout__content{% if rightSidebar and not leftSidebar %} usx-layout__content--left{% elif leftSidebar and not rightSidebar %} usx-layout__content--right{% endif %}">
|
|
17
|
+
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
18
|
+
</main>
|
|
19
|
+
{% if rightSidebar %}
|
|
20
|
+
<aside class="usx-layout__sidebar--right">
|
|
21
|
+
{{ rightSidebar|safe }}
|
|
22
|
+
</aside>
|
|
23
|
+
{% endif %}
|
|
24
|
+
</div>
|
|
25
|
+
{% else %}
|
|
26
|
+
{% if children %}{{ children|safe }}{% else %}{{ content|safe }}{% endif %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Single Column Layout Example -->
|
|
2
|
+
<div class="usx-layout">
|
|
3
|
+
<div class="usx-layout__single-column">
|
|
4
|
+
<h1>Page Title</h1>
|
|
5
|
+
<p>Main content goes here, centered with responsive gutters.</p>
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<!-- Grid Layout Example -->
|
|
10
|
+
<div class="usx-layout">
|
|
11
|
+
<div class="usx-layout__grid-container">
|
|
12
|
+
<aside class="usx-layout__sidebar--left">
|
|
13
|
+
<nav aria-label="Side navigation">
|
|
14
|
+
<ul class="usa-sidenav">
|
|
15
|
+
<li class="usa-sidenav__item">
|
|
16
|
+
<a href="#" class="usa-current">Current Page</a>
|
|
17
|
+
</li>
|
|
18
|
+
<li class="usa-sidenav__item">
|
|
19
|
+
<a href="#">Menu Item</a>
|
|
20
|
+
</li>
|
|
21
|
+
</ul>
|
|
22
|
+
</nav>
|
|
23
|
+
</aside>
|
|
24
|
+
<main class="usx-layout__content usx-layout__content--right">
|
|
25
|
+
<h1>Page Title</h1>
|
|
26
|
+
<p>Main content with left sidebar. On desktop, content adjusts to account for sidebar width.</p>
|
|
27
|
+
</main>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|