Skip to content

Form layout—Components (HDS-4885) #2898

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

Open
wants to merge 117 commits into
base: main
Choose a base branch
from

Conversation

KristinLBradley
Copy link
Contributor

@KristinLBradley KristinLBradley commented May 22, 2025

📌 Summary

If merged, this PR adds Form layout components to HDS.

👉 Showcase: https://hds-showcase-git-kristin-hds-4885-form-layout-d00037-hashicorp.vercel.app/components/form/layout

Related:

🛠️ Detailed description

Changes:

  • Reorganized Showcase links on home page to create new "section" for Form-related components: https://hds-showcase-git-kristin-hds-4885-form-layout-d00037-hashicorp.vercel.app/
    • Please let me know your opinions on this change.
  • Created Form component with @tag prop.
  • Created FormHeader component with @hasMaxWidth prop
  • Created FormHeaderTitle component with @tag & @size props
  • Created FormHeaderDescription component.
  • Created FormSection component with @hasMaxWidth & @hasBorder props
  • Created FormSectionHeader component
  • Created FormSectionHeaderTitle component with @tag & @size props
  • Created FormSectionHeaderDescription component.
  • Created FormSectionFieldGroup component based off Layout::Flex component which exposes @direction prop & includes responsive behavior to stack Fields at screen width below 768px
  • Created FormSeparator component with @hasMaxWidth prop
  • Created Showcase page for Form layout components
Component structure in use:
  • Form
    • FormHeader
      • FormHeaderTitle
      • FormHeaderDescription
    • FormSection
      • FormSectionHeader
        • FormSectionHeaderTitle
        • FormSectionHeaderDescription
      • Form Fields such as TextInput::Field (pre-existing)
      • FieldGroup (lay out related groups of inputs in a row or stacked)
        • Form Fields such as TextInput::Field (pre-existing)
    • FormSeparator (extra visual separation between Sections)
    • ButtonSet (pre-existing, can be wrapped in Section to control max-width)
How widths work:

For Form Sections & similar:

  • If @isFullWidth="false" (the default) FormSection will expand to a max of 700px
  • If @isFullWidth="true" FormSection & similar will expand to 100% of available width
  • It will be possible for consumers to set a custom max-width value if they write their own CSS style. (The components don't directly support this on their own.)

For Field Groups:

  • For non-wrappping rows/groups, inputs will be laid out in equal width columns by default (halves, thirds, etc.)
  • Custom widths can be set specifically for each input element using an optional Item container.
  • Inputs/Fields will stack when screen width is below 768px (the "md" breakpoint)

🔗 External links


👀 Component checklist

💬 Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented May 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Jun 20, 2025 10:31pm
hds-website ✅ Ready (Inspect) Visit Preview Jun 20, 2025 10:31pm

@KristinLBradley KristinLBradley force-pushed the kristin/hds-4885-form-layout-components branch from f52c81e to 1cc5dd1 Compare May 27, 2025 15:59
@KristinLBradley KristinLBradley force-pushed the kristin/hds-4885-form-layout-components branch from c4ccb5d to dcc2031 Compare May 28, 2025 17:00
@alex-ju
Copy link
Member

alex-ju commented Jun 19, 2025

@KristinLBradley This PR seems close to being merged to main, but I suggest we hold from merging it while conducting product testing as we may discover something (and also until we release a fix for the recently surfaced Modal issue).

@alex-ju alex-ju added this to the [email protected] milestone Jun 19, 2025
@KristinLBradley KristinLBradley changed the title Form layout components (HDS-4885) Form layout—Components (HDS-4885) Jun 19, 2025
didoo
didoo previously approved these changes Jun 20, 2025
shleewhite
shleewhite previously approved these changes Jun 20, 2025
Copy link
Contributor

@shleewhite shleewhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking! Just a few small comments.

* SPDX-License-Identifier: MPL-2.0
*/

import type { TemplateOnlyComponent } from '@ember/component/template-only';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: not sure if this is out of scope, but could any of these more "real" examples have validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems likely a bit out of scope as these are meant to demonstrate layouts.

const MockAppMainGenericFormPartialsActions: TemplateOnlyComponent<MockAppMainGenericFormPartialsActionsSignature> =
<template>
{{#if @extraText}}
<HdsLayoutFlex @gap="24" @align="center" ...attributes>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should this use the Hds::Form::Footer component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@didoo what do you think? This example seemed too custom to me, so I left it as is when I was adding the Form::Footer.

form: 'custom width / form',
'header+section': 'custom width / header+section',
section: 'custom width / section',
// TODO!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done? or is it for a follow up ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@didoo What do you think? We don't have a real option for a custom width applied to just a single Form::Section.

Custom width set via local CSS class only at section level (not at header/separator)
{{else if (eq this.customWidthMode "section")}}
Custom width set via local CSS class only at section level (not at header/separator)
{{! TODO! }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Theres still a couple todos in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@didoo Do you think these TODOs here are really necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants