Skip to content

Commit

Permalink
Add multiple pages support (#140)
Browse files Browse the repository at this point in the history
* Remove "common" directory from FormEdit; it's inconsistent with the nested component organization structure used throughout the design package.

* Add initial PageMenu component and story.

* Make FormConfig a constructor argument to BlueprintBuilder.

* Use sequence element edit component via the configuration map, rather than the old special-cased createPreviewComponents function.

* Add page pattern, based on the sequence pattern.

* Render fieldset children in edit mode

* in-progress

* Add basic page set story

* Remove edit-component-panel class and autoformat css

* Remove global nav styles

* Add structure to support multiple pages.

* Page set rendering and page navigation functional.

* Trial a more modular pattern directory structure for pages and page-sets.

* Add page edit functionality

* linting

* Fix issues with periodic save functionality.

* Add initial toolbar

* Tests passing with multi-page patterns.

* Store query parameters in state, to ease updating in response to route changes inside patterns.

* Linting

* Story for FormSetEdit

* Add Vitest wrappers for each of the pattern edit components.

* Move PageMenu component into PageSet pattern, and update to use it.

* Wrap some inputs in labels, to satisfy an issue with jsdom.

* Linting

* Remove redundant button

* Minor cleanup
  • Loading branch information
danielnaab authored May 24, 2024
1 parent c7f9aea commit 8f0509d
Show file tree
Hide file tree
Showing 85 changed files with 1,879 additions and 701 deletions.
22 changes: 12 additions & 10 deletions apps/spotlight/src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ const getNavLinkClasses = (url: string) => {
---

<div class="usa-overlay"></div>
<header class="usa-header usa-header--extended bg-base-darkest">
<div class="usa-navbar">
<div class="usa-logo">
<em class="usa-logo__text">
<a href={routes.getHomeUrl()} title="10x Access to Justice">
<img src={logoSvg.src} role="img" alt="10x Logo" />
<span class="text-white">A2J Forms</span>
</a>
</em>
<header class="usa-header usa-header--extended">
<div class="bg-base-darkest">
<div class="usa-navbar">
<div class="usa-logo">
<em class="usa-logo__text">
<a href={routes.getHomeUrl()} title="10x Access to Justice">
<img src={logoSvg.src} role="img" alt="10x Logo" />
<span class="text-white">A2J Forms</span>
</a>
</em>
</div>
<button type="button" class="usa-menu-btn">Menu</button>
</div>
<button type="button" class="usa-menu-btn">Menu</button>
</div>
<nav aria-label="Primary navigation" class="usa-nav">
<div class="usa-nav__inner">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"turbo": "^1.12.3",
"type-fest": "^4.10.2",
"typescript": "^5.3.3",
"vitest": "^0.34.6",
"vitest": "^1.6.0",
"vitest-github-actions-reporter": "^0.11.1",
"vitest-mock-extended": "^1.3.1"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/locales/en/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const en = {
displayName: 'Checkbox input',
errorTextMustContainChar: 'String must contain at least 1 character(s)',
},
page: {
fieldLabel: 'Page title',
},
paragraph: {
fieldLabel: 'Paragraph text',
displayName: 'Lorem ipsum...',
Expand Down
13 changes: 6 additions & 7 deletions packages/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
"clean:styles": "rm -rf static",
"dev": "run-p dev:*",
"dev:lib": "vite",
"dev:storybook": "storybook dev",
"dev:storybook": "storybook dev -p 9009",
"dev:styles": "gulp watch",
"lint": "eslint --ext ts,tsx --report-unused-disable-directives --max-warnings 0 src",
"test:storybook": "test-storybook",
"test:url": "test-storybook --url http://127.0.0.1:9009 --config-dir storybook",
"test:url": "test-storybook --url http://127.0.0.1:9009 --config-dir .storybook",
"test:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"pnpm build:storybook --quiet && npx http-server storybook/public --port 9009 --silent\" \"wait-on tcp:127.0.0.1:9009 && pnpm test:url --maxWorkers=2\""
},
"files": [
Expand All @@ -37,14 +36,14 @@
"@storybook/test": "^7.6.10",
"@storybook/test-runner": "^0.16.0",
"@storybook/types": "^7.6.10",
"@testing-library/react": "^15.0.2",
"@testing-library/react": "^15.0.7",
"@types/deep-equal": "^1.0.4",
"@types/prop-types": "^15.7.12",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@uswds/compile": "1.1.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react": "^4.3.0",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.34.1",
Expand All @@ -54,8 +53,8 @@
"install": "^0.13.0",
"prop-types": "^15.8.1",
"react-dom": "^18.2.0",
"vite": "^5.2.9",
"vite-plugin-dts": "^3.8.3",
"vite": "^5.2.11",
"vite-plugin-dts": "^3.9.1",
"wait-on": "^7.2.0"
},
"dependencies": {
Expand Down
265 changes: 124 additions & 141 deletions packages/design/sass/_uswds-custom-styles.scss
Original file line number Diff line number Diff line change
@@ -1,157 +1,140 @@
@use "uswds-core" as *;
@use 'uswds-core' as *;

html {
scroll-behavior: smooth;
}

h1 {
font-size: units(5);

span {
display: inline-block;
vertical-align: top;
margin-right: units(2.5);
}
}

h2 {
margin-top: units(4);
margin-bottom: units(2);
}

p {
line-height: units(3);
}
scroll-behavior: smooth;
}

.hide {
display: none;
}

.show {
display: block;
}

.usa-app {
display: flex;
min-height: 100vh;
flex-direction: column;
}

main {
flex: 1;
width: 100%;
}

.usa-combo-box__input,
.usa-input,
.usa-input-group,
.usa-range,
.usa-select,
.usa-textarea {
max-width: 40rem;
height: 3rem;
h1 {
font-size: units(5);

span {
display: inline-block;
vertical-align: top;
margin-right: units(2.5);
}

.usa-sidenav{

.usa-sidenav__item {
.usa-current {
color: #54278f;

&:after {
background-color: rebeccapurple;
}
}

h2 {
margin-top: units(4);
margin-bottom: units(2);
}

p {
line-height: units(3);
}

.hide {
display: none;
}

.show {
display: block;
}

.usa-app {
display: flex;
min-height: 100vh;
flex-direction: column;
}

main {
flex: 1;
width: 100%;
}

.usa-combo-box__input,
.usa-input,
.usa-input-group,
.usa-range,
.usa-select,
.usa-textarea {
max-width: 40rem;
height: 3rem;
}

.usa-sidenav {
.usa-sidenav__item {
.usa-current {
color: #54278f;

&:after {
background-color: rebeccapurple;
}
}
}

.usa-section {
padding-top: units(5);
padding-bottom: units(5);
}

.usa-section {
padding-top: units(5);
padding-bottom: units(5);
}

.usa-checkbox {
background: none;
}

.usa-table {
width: 100%;

.column1 {
width: 50%;
}
.usa-checkbox {
background: none;

.column2 {
width: 30%;
}

.usa-table {
width: 100%;

.column1 {
width: 50%;
}

.column2 {
width: 30%;
}

.column3 {
width: 20%;
}

.actionColumn {
span {
margin: 0 30px 0 0;

&:last-child {
margin: 0;
}

.column3 {
width: 20%;
}

.actionColumn {
span {
margin: 0 30px 0 0;

&:last-child {
margin: 0;
}
}
}

.usa-form--large {
max-width: 32rem;
}
}

.usa-legend-wrapper {
word-wrap: break-word;
hyphens: auto;
}

.usa-legend {
width: -webkit-fill-available;
}

nav {
background: #F7F9FD;
padding: 0 units(3);

>ul {
padding-top: units(5);
.usa-form--large {
max-width: 32rem;
}

.usa-legend-wrapper {
word-wrap: break-word;
hyphens: auto;
}

.usa-legend {
width: -webkit-fill-available;
}

[contentEditable='true']:focus,
[href]:focus,
[tabindex]:focus,
iframe:focus {
outline: units(0.5) solid #783cb9;
}

.usa-step-indicator__segment {
max-width: 22rem;

&--current {
.usa-step-indicator__segment-label {
color: #783cb9;
}
}

[contentEditable=true]:focus,
[href]:focus,
[tabindex]:focus,
iframe:focus {
outline: units(0.5) solid #783cb9;
}

.usa-step-indicator__segment {
max-width: 22rem;

&--current {

.usa-step-indicator__segment-label {
color: #783cb9;
}

&::after {
background: #783cb9;
}

&::after {
background: #783cb9;
}
}

.videoWrapper {
position: relative;
padding-bottom: 62.5%;
height: 0;
}

.edit-component-panel {
.usa-fieldset {
margin-top: 0;
}
}
}

.videoWrapper {
position: relative;
padding-bottom: 62.5%;
height: 0;
}
9 changes: 8 additions & 1 deletion packages/design/src/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import type { Meta, StoryObj } from '@storybook/react';

import Form from '.';
import { createTestFormContext, createTestSession } from '../test-form';
import { MemoryRouter } from 'react-router-dom';

const meta: Meta<typeof Form> = {
title: 'Form',
component: Form,
decorators: [(Story, args) => <Story {...args} />],
decorators: [
(Story, args) => (
<MemoryRouter initialEntries={['/']}>
<Story {...args} />
</MemoryRouter>
),
],
args: {
context: createTestFormContext(),
session: createTestSession(),
Expand Down
Loading

0 comments on commit 8f0509d

Please sign in to comment.