Skip to content

Conversation

@twjeffery
Copy link
Collaborator

Summary

Updates the Form Item component to support V2 design system styling while
maintaining full backward compatibility with V1. Introduces compact size
variant, input-type-aware message spacing, and refined error message
structure.

Changes

New Props

  • version ("1" | "2", default "1"): Controls V1 vs V2 styling
    • Optional prop that helps form-item apply the right spacing for different input types. If not set, has a middle default.
    • Future Enhancement: Inputs could auto-report their type via existing relay messaging, eliminating the need for manual inputType configuration.
  • inputType ("" | "text-input" | "textarea" | "checkbox-list" | "radio-group", default ""): Enables input-type-specific message spacing in V2

New Size Variant

  • labelsize now accepts "compact" in addition to "regular" and
    "large"
  • Compact size (V2 only):
    • Label: 14px/20px semibold, 9px bottom spacing
    • Messages: 8px top spacing (text inputs), 12px (selection controls)
    • Error icon: xsmall (16px) instead of small (18px)
    • Message gaps: 3px icon-to-text, 4px message stack

V2 Styling Updates

Label Typography & Spacing

  • Large: Bold 28px/34px with -0.5px spacing, 22px bottom padding
  • Regular: Semibold 16px/22px with 0 spacing, 10px bottom padding
  • Compact (V2 only): Semibold 14px/20px with 0 spacing, 9px bottom
    padding

Message Container

  • Wraps both error and helper messages for proper spacing control
  • Size-specific spacing from input to messages
  • Input-type-aware spacing (selection controls have larger gaps)

Message Spacing from Input:

Label Size Text Inputs Selection Controls
Large 16px 20px
Regular 12px 16px
Compact 8px 12px

Error Message Structure

  • Error icon and text wrapped in flex container
  • Icon size varies by form item size (compact: 16px, regular/large: 18px)
  • Icon-to-text gap: 4px (3px compact)

Message Stack

  • When both error and helper messages present:
    • 8px gap between messages (4px compact)

Technical Implementation

Input-Type Awareness

  • inputType prop enables CSS to apply different spacing based on control
    type
  • Cascading fallback pattern: input-type-specific → size-specific → V1
    default
  • Example: .large.checkbox-list .messages-container uses larger spacing
    than .large.text-input

V2 CSS Scoping

  • All V2-specific styles use .v2 class selector
  • Compact size styles are V2-only (.v2.compact)
  • V1 behavior preserved exactly as-is

Messages Container Pattern

  • Wraps error and helper messages for unified spacing control
  • Replaces individual message margin-top with container-level spacing
  • Enables consistent gap between stacked messages

Related

@twjeffery twjeffery changed the title feat(#3134): update Text Input component for V2 feat(#3134): update Form item component for V2 Oct 23, 2025
@twjeffery twjeffery linked an issue Oct 23, 2025 that may be closed by this pull request
@twjeffery twjeffery marked this pull request as ready for review October 23, 2025 20:00
Copy link
Collaborator

@bdfranck bdfranck left a comment

Choose a reason for hiding this comment

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

Looks good! I'm not sure about the addition of the inputType property. 🤔

type RequirementType = (typeof REQUIREMENT_TYPES)[number];
type LabelSizeType = (typeof LABEL_SIZE_TYPES)[number];
type VersionType = (typeof Version)[number];
type InputTypeType = (typeof INPUT_TYPES)[number];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type InputTypeType = (typeof INPUT_TYPES)[number];
type InputType = (typeof INPUT_TYPES)[number];

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can call this InputType like we do elsewhere:

export type GoabInputType =
| "text"

export let requirement: RequirementType = "";
export let maxwidth: string = "none";
export let version: VersionType = "1";
export let inputType: InputTypeType = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export let inputType: InputTypeType = "";
export let type: InputType = "";

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious of how many teams will properly apply this input type property. I suspect it will be low for the following reasons:

  • It requires a dev to know that the property exists and should be applied correctly. "I added a radio group to this form item so I need to set this to radio group."
  • The difference is subltle and easy for a dev to overlook

I think a better approach would be to detect the type of the slotted input then add a class accordingly.

<!-- HTML -->
<div
  class:radio-group={hasRadioGroup}
  class:checkbox-list={hasCheckboxList}
  class:v2={version === "2"}

But that feels like an enhancement beyond the scope of our immediate work.

<!-- HTML -->
<div
class:v2={version === "2"}
class={`${labelsize}${inputType ? ' ' + inputType : ''}`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
class={`${labelsize}${inputType ? ' ' + inputType : ''}`}
class={`${labelsize}${type ? ' ' + type : ''}`}

validateRequirementType(requirement);
validateLabelSize(labelsize);
validateVersion(version);
validateInputType(inputType);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
validateInputType(inputType);
validateType(type);

false,
);
const [Version, validateVersion] = typeValidator("Version", ["1", "2"]);
const [INPUT_TYPES, validateInputType] = typeValidator(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const [INPUT_TYPES, validateInputType] = typeValidator(
const [INPUT_TYPES, validateType] = typeValidator(

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Form item 2.0 Update

3 participants