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 edit form focus and UI styles #228

Merged
merged 3 commits into from
Jun 27, 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
4 changes: 2 additions & 2 deletions packages/design/src/Form/components/Fieldset/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { type PatternComponent } from '../../../Form';

const Fieldset: PatternComponent<FieldsetProps> = props => {
return (
<fieldset className="usa-fieldset width-full margin-top-2">
<fieldset className="usa-fieldset width-full padding-top-2">
{props.legend !== '' && props.legend !== undefined && (
<legend className="usa-legend text-bold text-uppercase line-height-body-4 margin-top-2 margin-bottom-1">
<legend className="usa-legend text-bold text-uppercase line-height-body-4 width-full margin-top-0 padding-top-3 padding-bottom-1">
{props.legend}
</legend>
)}
Expand Down
4 changes: 2 additions & 2 deletions packages/design/src/Form/components/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { type PatternComponent } from '../../../Form';
export const RadioGroupPattern: PatternComponent<RadioGroupProps> = props => {
const { register } = useFormContext();
return (
<div className="usa-fieldset">
<legend className="usa-legend text-bold">{props.legend}</legend>
<div className="usa-fieldset padding-top-2">
<legend className="usa-legend text-bold margin-top-0 padding-top-3">{props.legend}</legend>
{props.options.map((option, index) => {
return (
<div key={index} className="usa-radio">
Expand Down
2 changes: 1 addition & 1 deletion packages/design/src/Form/components/TextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TextInput: PatternComponent<TextInputProps> = props => {
return (
<div className="usa-form-group-wrapper" key={props.inputId}>
<div
className={classNames('usa-form-group', {
className={classNames('usa-form-group margin-top-2', {
'usa-form-group--error': props.error,
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const CheckboxPatternEdit: PatternEditComponent<CheckboxProps> = ({
editComponent={<CheckboxEditComponent pattern={focus.pattern} />}
></PatternEditForm>
) : (
<Checkbox {...previewProps} />
<div className="padding-left-3 padding-bottom-3 padding-right-3">
<Checkbox {...previewProps} />
</div>
)}
</>
);
Expand All @@ -37,7 +39,7 @@ const CheckboxEditComponent = ({ pattern }: { pattern: CheckboxPattern }) => {
const label = getFieldState('label');

return (
<div className="grid-row grid-gap">
<div className="grid-row grid-gap padding-3">
<div className="tablet:grid-col-6 mobile-lg:grid-col-12">
<label
className={classnames('usa-label', {
Expand All @@ -58,6 +60,7 @@ const CheckboxEditComponent = ({ pattern }: { pattern: CheckboxPattern }) => {
defaultValue={pattern.data.label}
{...register('label')}
type="text"
autoFocus
></input>
</div>
<div className="tablet:grid-col-6 mobile-lg:grid-col-12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PatternEditForm } from './common/PatternEditForm';
import { usePatternEditFormContext } from './common/hooks';
import { FieldsetPattern } from '@atj/forms/src/patterns/fieldset';
import classNames from 'classnames';
import styles from '../formEditStyles.module.css';

const FieldsetEdit: PatternEditComponent<FieldsetProps> = ({
focus,
Expand Down Expand Up @@ -39,8 +40,8 @@ const FieldsetPreview: PatternComponent<FieldsetProps> = props => {
<>
<Fieldset {...(props as FieldsetProps)}>
{pattern && pattern.data.patterns.length === 0 && (
<div className="usa-alert usa-alert--warning usa-alert--no-icon margin-bottom-3">
<div className="usa-alert__body">
<div className={`${styles.usaAlert} usa-alert usa-alert--warning usa-alert--no-icon margin-left-3 margin-right-3 margin-bottom-3`}>
<div className={`${styles.usaAlertBody} usa-alert__body`}>
<p className="usa-alert__text">
<span className="alert-text display-inline-block text-top margin-right-2">
Empty sections will not display.
Expand Down Expand Up @@ -100,6 +101,7 @@ const EditComponent = ({ patternId }: { patternId: PatternId }) => {
defaultValue={pattern.data.legend}
{...register('legend')}
type="text"
autoFocus
></input>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const FormSummaryEdit: PatternEditComponent<FormSummaryProps> = ({
editComponent={<EditComponent pattern={focus.pattern} />}
></PatternEditForm>
) : (
<FormSummary {...previewProps} />
<div className="padding-left-3 padding-bottom-3 padding-right-3">
<FormSummary {...previewProps} />
</div>
)}
</>
);
Expand Down Expand Up @@ -57,6 +59,7 @@ const EditComponent = ({ pattern }: { pattern: Pattern }) => {
{...register('title')}
defaultValue={pattern.data.title}
type="text"
autoFocus
></input>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const InputPatternEdit: PatternEditComponent<TextInputProps> = ({
editComponent={<EditComponent patternId={focus.pattern.id} />}
></PatternEditForm>
) : (
<TextInput {...previewProps} />
<div className="padding-left-3 padding-bottom-3 padding-right-3">
<TextInput {...previewProps} />
</div>
)}
</>
);
Expand Down Expand Up @@ -72,6 +74,7 @@ const EditComponent = ({ patternId }: { patternId: PatternId }) => {
defaultValue={pattern.data.label}
{...register('label')}
type="text"
autoFocus
></input>
</label>
</div>
Expand Down
12 changes: 11 additions & 1 deletion packages/design/src/FormManager/FormEdit/components/PageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import { PatternPreviewSequence } from './PreviewSequencePattern';
import styles from '../formEditStyles.module.css';

export const PageEdit: PatternEditComponent<PageProps> = props => {
const handleParentClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
if (event.target === event.currentTarget) {
// Trigger focus or any other action you want when the parent div is clicked
event.currentTarget.focus();
}
};

return (
<>
{props.focus ? (
Expand All @@ -24,6 +31,8 @@ export const PageEdit: PatternEditComponent<PageProps> = props => {
) : (
<div
className={`${styles.titleArea} display-flex flex-justify flex-align-center position-relative margin-bottom-205`}
onClick={handleParentClick}
tabIndex={0} // Make the div focusable
>
<span
className={`${styles.titleText} padding-right-1 text-uppercase text-ls-1 text-base-darkest bg-primary-lighter`}
Expand Down Expand Up @@ -81,11 +90,12 @@ const PageEditComponent = ({ pattern }: { pattern: PagePattern }) => {
id={fieldId('title')}
defaultValue={pattern.data.title}
{...register('title')}
autoFocus
></input>
</div>
<div className="grid-col-12">
<PatternEditActions />
</div>
</div>
);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const ParagraphPatternEdit: PatternEditComponent<ParagraphProps> = ({
editComponent={<EditComponent patternId={focus.pattern.id} />}
></PatternEditForm>
) : (
<Paragraph {...previewProps} />
<div className="padding-left-3 padding-bottom-3 padding-right-3">
<Paragraph {...previewProps} />
</div>
)}
</>
);
Expand Down Expand Up @@ -62,6 +64,7 @@ const EditComponent = ({ patternId }: { patternId: PatternId }) => {
rows={4}
{...register('text')}
defaultValue={pattern.data.text}
autoFocus
></textarea>
</div>
<PatternEditActions />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ const SortableItem = ({

return (
<div
className={`${styles.draggableListWrapper} draggable-list-item-wrapper bg-white margin-bottom-3 padding-3`}
className={`${styles.draggableListWrapper} draggable-list-item-wrapper bg-white margin-bottom-3`}
ref={setNodeRef}
style={{
transform: CSS.Transform.toString(transform),
transition,
}}
>
<div className="grid-row grid-gap draggable-list-item cursor-pointer">
<div className="grid-row draggable-list-item cursor-pointer">
<div
className="grid-col-12 width-full draggable-list-button cursor-grab margin-top-2 margin-bottom-2"
className="grid-col-12 width-full draggable-list-button cursor-grab padding-2"
{...listeners}
{...attributes}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PatternEditActions } from './common/PatternEditActions';
import { PatternEditForm } from './common/PatternEditForm';
import { usePatternEditFormContext } from './common/hooks';
import { en as message } from '@atj/common/src/locales/en/app';
import styles from '../formEditStyles.module.css';

const RadioGroupPatternEdit: PatternEditComponent<RadioGroupProps> = ({
focus,
Expand All @@ -24,7 +25,9 @@ const RadioGroupPatternEdit: PatternEditComponent<RadioGroupProps> = ({
editComponent={<EditComponent pattern={focus.pattern} />}
></PatternEditForm>
) : (
<RadioGroup {...previewProps} />
<div className={`${styles.radioFormPattern} padding-left-3 padding-bottom-3 padding-right-3`}>
<RadioGroup {...previewProps} />
</div>
)}
</>
);
Expand All @@ -38,7 +41,7 @@ const EditComponent = ({ pattern }: { pattern: RadioGroupPattern }) => {

return (
<div className="grid-row grid-gap">
<div className="tablet:grid-col-6 mobile-lg:grid-col-12">
<div className="tablet:grid-col-6 mobile-lg:grid-col-12 margin-bottom-2">
<label
className={classnames('usa-label', {
'usa-label--error': label.error,
Expand All @@ -56,6 +59,7 @@ const EditComponent = ({ pattern }: { pattern: RadioGroupPattern }) => {
defaultValue={pattern.data.label}
{...register('label')}
type="text"
autoFocus
></input>
</label>
</div>
Expand All @@ -75,7 +79,7 @@ const EditComponent = ({ pattern }: { pattern: RadioGroupPattern }) => {
{optionLabel.error.message}
</span>
) : null}
<div className="display-flex">
<div className="display-flex margin-bottom-2">
<input
className={classnames('hide', 'usa-input', {
'usa-label--error': label.error,
Expand All @@ -97,7 +101,7 @@ const EditComponent = ({ pattern }: { pattern: RadioGroupPattern }) => {
);
})}
<button
className="usa-button usa-button--outline"
className="usa-button usa-button--outline margin-top-1"
type="button"
onClick={event => {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const PatternEditForm = ({
}
})}
>
<div className="border-1 radius-md border-primary-light padding-1">
<div className="border-05 radius-md border-primary-light padding-3">
{editComponent}
</div>
</form>
Expand Down
17 changes: 17 additions & 0 deletions packages/design/src/FormManager/FormEdit/formEditStyles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,28 @@
background-color: #fff;
}

.draggableListWrapper legend {
padding-left: 1.5rem;
}

.draggableListWrapper .radioFormPattern legend {
padding-left: 0;
}

/* Configure and Publish Pages */
.progressPage {
min-height: 60vh;
}

/* Fieldset */
.usaAlert .usaAlertBody {
margin-left: 0;
}

.usaAlert span {
background: none;
}

@media (max-width: 40em) {
.dropdownMenu {
bottom: 4.5rem;
Expand Down
Loading