@solexllc/usx-react 0.5.0 → 0.6.1

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 CHANGED
@@ -165,6 +165,105 @@ at the repo root for the full, up-to-date list of implemented components.
165
165
 
166
166
  ## Token usage
167
167
 
168
+ ### Generic Container
169
+
170
+ `Container` groups arbitrary content in one element. Its default `div` has only
171
+ the passive `usx-container` hook: no padding, width, display override, or child
172
+ wrappers. `children` takes precedence over `content` unless null or undefined;
173
+ empty children and zero are preserved. It is available in React, Django, the
174
+ CMS contract, and the React/Django/HTML Storybook catalogs.
175
+
176
+ ```jsx
177
+ import { Container, Button } from '@solexllc/usx-react';
178
+
179
+ <Container
180
+ display="flex"
181
+ direction="column"
182
+ gap="2"
183
+ responsive={{ tablet: { direction: 'row', wrap: 'wrap', align: 'center' } }}
184
+ >
185
+ <Button>Save changes</Button>
186
+ <Button variant="secondary">Cancel</Button>
187
+ </Container>
188
+ ```
189
+
190
+ Top-level layout props apply at every width. `responsive` overrides individual
191
+ fields at `mobileLg` (30em), `tablet` (40em), and `desktop` (64em), continuing
192
+ upward until overridden again. At a 16px browser default these are 480, 640,
193
+ and 1024px. Missing fields inherit the smaller-screen setting; use an explicit
194
+ value to reset it, such as `gap: '0'`, `offset: 'none'`, or `direction: 'row'`.
195
+ Keys are processed in breakpoint order, regardless of JSON insertion order.
196
+ `mobileLg` emits the USWDS `mobile-lg:` class prefix.
197
+ Values are string tokens; unsupported tokens and breakpoint names are ignored.
198
+
199
+ | Control | Purpose |
200
+ | --- | --- |
201
+ | `display` | Normal flow, flex, inline flex, hidden, or `flow-root` for containing floats. |
202
+ | `direction`, `wrap`, `justify`, `align` | Arrange children of a flex container. Set `display="flex"` or `"inline-flex"` to enable flex layout. |
203
+ | `alignSelf`, `flex` | Control this container as a child of a flex parent. Use `column` instead of `flex` for USWDS grid columns. |
204
+ | `gap` | Space between flex children. Spacing tokens include `0`, `2px`, `05`, and `1`–`6`; `2` is 1rem. |
205
+ | `column`, `offset` | USWDS column width (`1`–`12`, `auto`, `fill`) and offset (`none`, `1`–`12`). |
206
+ | `gutters` | Horizontal USWDS grid gutters, including `sm`, `md`, `lg`, and spacing tokens. Requires `gridRow`. |
207
+ | `float` | Float this container within surrounding text. Has no effect on a flex child. |
208
+
209
+ These controls all accept breakpoint overrides. `gridContainer` and `gridRow`
210
+ are structural options set on the container itself:
211
+
212
+ ```jsx
213
+ <Container gridContainer="default">
214
+ <Container gridRow gutters="2" responsive={{ desktop: { gutters: '4' } }}>
215
+ <Container column="12" responsive={{ tablet: { column: '4' } }}>
216
+ Sidebar content
217
+ </Container>
218
+ <Container column="12" responsive={{ tablet: { column: '8' } }}>
219
+ Main content
220
+ </Container>
221
+ </Container>
222
+ </Container>
223
+ ```
224
+
225
+ Nest columns directly inside rows. Use `gutters` for rows and `gap` for ordinary
226
+ flex groups: adding CSS gap to percentage-width grid columns can cause unwanted
227
+ wrapping. Gutters add child padding and negative row margins, so nest the row
228
+ inside a padded parent, usually `gridContainer`. Keep page containers, rows, and
229
+ columns as separate nested elements when combining their behaviors. Widths and
230
+ gutters remain opt-in; children are never cloned, wrapped, or reordered.
231
+
232
+ `gridContainer="default"` uses the existing USX-themed `grid-container` width
233
+ and side padding. Named sizes, such as `gridContainer="widescreen"`, use the
234
+ corresponding USWDS class. Load precompiled USWDS CSS followed by USX styles.
235
+ Container supplies its own flex/display/gap/float classes because upstream
236
+ precompiled CSS omits some responsive variants. Its breakpoints deliberately
237
+ match the upstream grid, independently of USX page-layout theme settings.
238
+
239
+ Django uses the same props and nesting:
240
+
241
+ ```django
242
+ {% load components %}
243
+ {% container display="flex" direction="column" gap="2" responsive=layout_overrides %}
244
+ {% button %}Save changes{% endbutton %}
245
+ {% button variant="secondary" %}Cancel{% endbutton %}
246
+ {% endcontainer %}
247
+ ```
248
+
249
+ Here `layout_overrides` is a context dictionary such as
250
+ `{"tablet": {"direction": "row", "wrap": "wrap"}}`. CMS integrations discover
251
+ all options in `container/config.json`; responsive objects reference the same
252
+ contract with non-layout fields omitted.
253
+
254
+ Use `element` for semantic roots (`section`, `article`, `aside`, `nav`, `ul`,
255
+ `ol`, or `li`), with `id`, `role`, `ariaLabel`, or `ariaLabelledby` as needed.
256
+ The ARIA props render as `aria-label` and `aria-labelledby` in both frameworks.
257
+ React and Django use the same explicit prop contract; Container does not forward
258
+ arbitrary HTML props or inline styles. Use `className` for additional styling.
259
+ The Django renderer uses the existing component tags and a reusable template
260
+ fragment for layout classes; it has no Container-specific Python helper.
261
+ Native element styling still applies; for example, lists retain their browser
262
+ spacing unless explicitly reset. Reverse directions affect visual order only,
263
+ so preserve a sensible reading and keyboard order in the source. Responsive
264
+ `display: 'none'` also hides content from assistive technology.
265
+ Use `className` for application-specific decoration, spacing, or other layouts.
266
+
168
267
  ### Responsive Layout
169
268
 
170
269
  `.usx-layout` owns the responsive outer padding: 12px (1.5 units)