Skip to content

feat(Toggle): rename SwitchField → ToggleField, ToggleField → ButtonToggle#112

Merged
pglevy merged 3 commits into
pglevy:mainfrom
govind-gs:feat/rename-switch-toggle
May 28, 2026
Merged

feat(Toggle): rename SwitchField → ToggleField, ToggleField → ButtonToggle#112
pglevy merged 3 commits into
pglevy:mainfrom
govind-gs:feat/rename-switch-toggle

Conversation

@govind-gs

Copy link
Copy Markdown
Contributor

Summary

Closes #99

Renames components to align with Appian SAIL's a!toggleField() and avoid naming collisions:

  • SwitchFieldToggleField (switch/toggle for boolean input)
  • ToggleFieldButtonToggle (button-style on/off toggle for toolbars/filters)

Changes

Before After Purpose
src/components/Switch/SwitchField.tsx src/components/Toggle/ToggleField.tsx Aligns with a!toggleField()
src/components/Toggle/ToggleField.tsx src/components/ButtonToggle/ButtonToggle.tsx Avoids collision, groups with buttons
switchLabelPosition prop toggleLabelPosition prop Matches new component name

Files modified

  • src/components/Toggle/ToggleField.tsx — switch-based implementation (formerly SwitchField)
  • src/components/Toggle/Toggle.stories.tsx — updated stories
  • src/components/Toggle/index.ts — exports
  • src/components/ButtonToggle/ButtonToggle.tsx — button-style toggle (formerly ToggleField)
  • src/components/ButtonToggle/ButtonToggle.stories.tsx — updated stories
  • src/components/ButtonToggle/index.ts — exports
  • src/components/index.ts — updated barrel exports
  • src/components/ApplicationHeader/ApplicationHeader.tsx — updated imports/usages
  • AGENTS.md — added quick reference patterns for both components

Files deleted

  • src/components/Switch/SwitchField.tsx
  • src/components/Switch/Switch.stories.tsx
  • src/components/Switch/index.ts

…oggle

- Rename SwitchField to ToggleField to align with SAIL's a!toggleField()
- Rename ToggleField (button-style toggle) to ButtonToggle
- Delete src/components/Switch/ directory
- Create src/components/ButtonToggle/ with renamed component
- Update src/components/Toggle/ to contain the switch-based implementation
- Update ApplicationHeader imports and usages
- Update src/components/index.ts exports
- Update AGENTS.md with new component quick reference patterns
- Rename switchLabelPosition prop to toggleLabelPosition

Closes pglevy#99

@pglevy pglevy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hey Govind! Looks good overall. Just had a few tweaks to the props. I realize this wasn't in the Issue, but let's use opportunity to align the props with the SAIL counterpart (since this was created before it existed). I think I caught them all (with help from AI) but feel free to double check.

Comment thread src/components/Toggle/ToggleField.tsx Outdated
*/
export interface ToggleFieldProps {
/** Text to display as the field label */
label?: string

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

now choiceLabel

Comment thread src/components/Toggle/ToggleField.tsx Outdated
/** Position of icon relative to text */
iconPosition?: "START" | "END"
/** Position of the inline label relative to the switch control: LEFT or RIGHT */
toggleLabelPosition?: "LEFT" | "RIGHT"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

now choicePosition with START/END

Comment thread src/components/Toggle/ToggleField.tsx Outdated
validationGroup: _validationGroup,
requiredMessage,
labelPosition = "ABOVE",
labelPosition: _labelPosition = "ABOVE",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No longer used

Comment thread src/components/Toggle/ToggleField.tsx Outdated
@@ -205,43 +158,88 @@ export const ToggleField: React.FC<ToggleFieldProps> = ({
// Show required message
const showRequiredMessage = required && !value && requiredMessage

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe incorporate default required message if it doesn't complicate things too much: Enable the toggle to continue from docs

govind-gs added 2 commits May 21, 2026 02:50
- Rename label → choiceLabel (matches SAIL parameter name)
- Rename toggleLabelPosition → choicePosition with START/END values
- Remove unused labelPosition and instructions props
- Add default required message: "Enable the toggle to continue"
- Update stories to use new prop names and add required message stories
- Update ApplicationHeader usage
- Update AGENTS.md quick reference
- Remove size prop (no other SAIL field component has it)
- Remove color prop (same reasoning)
- Fixed at STANDARD size and ACCENT (blue) color, matching Appian product
- Remove all size/color maps and palette color resolution logic
- Remove unused imports (SAILSize, SAILColorInput, isPaletteColor, paletteColorMap)
- Remove size and color stories from Storybook
- Update AGENTS.md quick reference
@govind-gs

Copy link
Copy Markdown
Contributor Author

Also removed size and color props from ToggleField. This reduces functionality but brings it in line with the actual SAIL a!toggleField() — which has neither parameter. The toggle now uses fixed STANDARD size and ACCENT blue, matching the Appian product behaviour.

@pglevy pglevy merged commit 893f25d into pglevy:main May 28, 2026
3 checks passed
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.

Rename SwitchField → ToggleField, ToggleField → ButtonToggle

2 participants