Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the focus on the drag list and UI updates #248

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_terraform-plan-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 8
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ The platform is made up of the following high-level terms.

## Development

This project uses the version of Node.js defined in [.nvmrc](./nvmrc). To ensure you're using the correct node version, you may use the [Node Version Manager (NVM)](https://github.com/nvm-sh/nvm):

```bash
nvm install
```

This project uses [pnpm workspaces](https://pnpm.io/workspaces). To work with this project, [install pnpm](https://pnpm.io/installation) and then the project dependencies:

```bash
Expand Down
20 changes: 10 additions & 10 deletions packages/design/src/FormManager/FormEdit/AddPatternDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,22 @@ export const FieldsetAddPatternButton = ({
isOpen={isOpen}
patternSelected={patternSelected}
>
<svg
className="usa-icon text-base"
width="24"
height="24"
aria-hidden="true"
focusable="false"
role="img"
>
<use xlinkHref={`${uswdsRoot}img/sprite.svg#add_circle`}></use>
</svg>{' '}
<button
className={classNames(
'bg-white text-base padding-0 border-0 cursor-pointer'
)}
onClick={() => setIsOpen(!isOpen)}
>
<svg
className="usa-icon text-base"
width="24"
height="24"
aria-hidden="true"
focusable="false"
role="img"
>
<use xlinkHref={`${uswdsRoot}img/sprite.svg#add_circle`}></use>
</svg>{' '}
<span className="display-inline-block text-ttop tablet:width-auto text-center">
<span className="display-inline-block text-ttop margin-right-1">
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PageProps } from '@atj/forms';
import { en as message } from '@atj/common/src/locales/en/app';
import { PagePattern } from '@atj/forms/src/patterns/page/config';

import { useRouteParams } from '../../../FormRouter/hooks';
import { PatternEditComponent } from '../types';

import { PatternEditActions } from './common/PatternEditActions';
Expand All @@ -23,6 +24,10 @@ export const PageEdit: PatternEditComponent<PageProps> = props => {
}
};

const { routeParams } = useRouteParams();
const params = new URLSearchParams(routeParams?.toString());
const pageNumberText = Number(params.get('page')) + 1;

return (
<>
{props.focus ? (
Expand All @@ -45,7 +50,7 @@ export const PageEdit: PatternEditComponent<PageProps> = props => {
<span
className={`${styles.pageNumber} padding-left-1 text-base-darkest bg-primary-lighter`}
>
Page X
Page {pageNumberText}
</span>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export default storyConfig;
export const Basic: StoryObj<typeof PageSetEdit> = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const pagesetHeaderElement = await canvas.findByText(/Page 1/);
await testUpdateFormFieldOnSubmitByElement(
canvasElement,
await canvas.findByText('Page X'),
pagesetHeaderElement,
'Page title',
'Page 1 updated'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ const SortableItemOverlay = ({ children }: { children: React.ReactNode }) => {
style={{
boxShadow: '0 16px 24px rgba(0, 0, 0, 0.4)',
cursor: 'grabbing',
outline: '0.25rem solid #783cb9',
}}
>
<div className="grid-row draggable-list-item">
<div
className="grid-col-12 width-full draggable-list-button padding-2"
style={{ outline: '.25rem solid #783cb9' }}
className={`${styles.draggableListButton} grid-col-12 width-full draggable-list-button padding-2`}
style={{
background: '#f0f0f0',
}}
>
<svg
className="usa-icon margin-x-auto display-block"
Expand Down Expand Up @@ -152,21 +155,24 @@ const SortableItem = ({

return (
<div
className={`${styles.draggableListWrapper} draggable-list-item-wrapper bg-white margin-bottom-3`}
className={`${styles.draggableListWrapper} draggable-list-item-wrapper bg-white margin-bottom-3 cursor-pointer`}
ref={setNodeRef}
style={{
transform: CSS.Translate.toString(transform),
transition,
opacity: isOver ? 0.4 : 1,
opacity: isOver ? 0.5 : 1,
border: isOver ? '1px dashed #8168B3' : 'none',
outline: isOver ? 'none' : '',
}}
>
<div className="grid-row draggable-list-item cursor-pointer">
<div className="grid-row draggable-list-item">
<div
className="grid-col-12 width-full draggable-list-button cursor-grab padding-2"
className={`${styles.draggableListButton} grid-col-12 width-full draggable-list-button padding-2`}
{...listeners}
{...attributes}
style={{ outline: isActive ? 'none' : '' }}
style={{
outline: isActive ? 'none' : '',
}}
>
<svg
className="usa-icon margin-x-auto display-block"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
padding-left: 0;
}

.draggableListWrapper button {
cursor: pointer;
}

.draggableListWrapper:focus-within,
.draggableListWrapper button:not([disabled]):focus {
outline: 0.25rem solid #783cb9;
}

.draggableListWrapper [tabindex]:focus,
.draggableListWrapper:has(input:focus),
.draggableListWrapper:has(button:focus),
.draggableListWrapper:has(textarea:focus) {
outline: none;
}

.draggableListWrapper .dropdownMenu {
margin-top: 5px;
}

/* Configure and Publish Pages */
.progressPage {
min-height: 60vh;
Expand Down Expand Up @@ -89,5 +109,12 @@
content: '';
flex: 1;
border-bottom: 1px dotted #71767a; /* TODO: $theme-color-base */
margin: 0 1em;
}

.dottedLine::before {
margin: 0 1em 0 0;
}

.dottedLine::after {
margin: 0 0 0 1em;
}
4 changes: 2 additions & 2 deletions packages/design/src/test-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ export const createTwoPageTwoPatternTestForm = () => {
type: 'page',
id: 'page-1',
data: {
title: 'Page 1',
title: 'First page',
patterns: ['element-1', 'element-2'],
},
} satisfies PagePattern,
{
type: 'page',
id: 'page-2',
data: {
title: 'Page 2',
title: 'Second page',
patterns: [],
},
} satisfies PagePattern,
Expand Down
Loading