Skip to content

chore(dropzone): full fidelity#6446

Open
cdransf wants to merge 14 commits into
cdransf/s2-dropzone-migrationfrom
cdransf/s2-dropzone-migration-full-fidelity
Open

chore(dropzone): full fidelity#6446
cdransf wants to merge 14 commits into
cdransf/s2-dropzone-migrationfrom
cdransf/s2-dropzone-migration-full-fidelity

Conversation

@cdransf

@cdransf cdransf commented Jun 23, 2026

Copy link
Copy Markdown
Member

Description

Phase 5 (CSS migration and stories) of the swc-dropzone Spectrum 2 migration. This PR is stacked on top of the file-structure PR and should be merged after that PR lands.

Changes in this PR:

  • Dropzone.types.ts — Added DropzoneSize type and DROPZONE_VALID_SIZES constant ('s' | 'm' | 'l'); added DropzoneEventDetail type alias for consumers who imported it from the 1st-gen package
  • Dropzone.base.ts — Applied SizedMixin with validSizes: DROPZONE_VALID_SIZES to expose the size attribute on the base class; size is new in 2nd-gen (not in 1st-gen)
  • Dropzone.ts — Updated render() to emit a .swc-Dropzone wrapper and a swc-Dropzone-status visually-hidden live region; added @cssprop JSDoc for all five exposed custom properties; fixed @param name mismatch in _onDragStateChange JSDoc
  • dropzone.css — Full S2 token-based stylesheet: CSS-only dashed/solid border, size-variant padding overrides, dragged and filled state selectors, --swc-illustrated-message-illustration-color cascade for accent-colored illustration in dragged state, and @media (forced-colors: active) block
  • dropzone.stories.ts — New stories file with Playground, Overview, Anatomy, Sizes (options), and States stories; Behaviors and Accessibility stubs deferred to Phase 7
  • preview.ts — Added 'Migration plan' to the Dropzone reference doc list in the Storybook sidebar

Motivation and context

This is Phase 5 of the Dropzone Spectrum 2 migration. The CSS migration replaces the 1st-gen Spectrum CSS dependency with 2nd-gen S2 tokens (token() calls), introduces size variants (new in 2nd-gen), and ensures the component renders correctly in both default and dragged/filled states.

Key design decisions resolved during this phase:

  • CSS-only border — decided to use CSS border (dashed/solid toggling) rather than an SVG stroke, matching the current spectrum-css main branch approach; SVG stroke can be revisited if the Figma or CSS spec diverges
  • Illustrated-message accent color--swc-illustrated-message-illustration-color is set on :host([dragged]) and cascades through the DOM into swc-illustrated-message's shadow via normal CSS custom property inheritance; no ::slotted() selector needed for color

Related issue(s)

  • SWC-2149

Screenshots (if appropriate)

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes. (Phase 6 — deferred to a follow-up PR)
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it. (Migration plan and status table updated)

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Default state renders correctly

    1. Open Storybook → Drop Zone → Docs
    2. Confirm the zone shows a dashed gray border, transparent background, and correct padding for size m
    3. No console errors
  • Dragged state applies correctly

    1. Open Storybook → Drop Zone → States
    2. The "dragged" instance should show a solid accent-colored border, an accent-tinted background, and the illustrated message SVG should be accent-colored
    3. Toggle dragged in the Playground controls; confirm the transition is immediate
  • Filled state hides the illustrated message

    1. In the States story, the "filled" instance should show content (uploaded file name) with the illustrated message hidden
    2. The filled+dragged instance should show the dragged visual treatment without the illustrated message
  • Size variants change padding only

    1. In the Sizes story, compare s, m, and l instances
    2. Only padding should differ; border and corner radius should be identical across sizes
  • Forced-colors / high-contrast mode

    1. Enable forced-colors in browser DevTools (Rendering panel → Emulate CSS media feature)
    2. Default: border uses ButtonText; dragged: background Canvas, border Highlight

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

Required: Complete each applicable item and document your testing steps.

  • Keyboard (required — document steps below)

    1. Open Storybook → Drop Zone → Playground
    2. Tab into the drop zone; confirm role="group" is announced and the accessible name is read
    3. Tab to the "Browse files" button inside; confirm it receives focus and can be activated with Enter or Space
    4. Confirm no focus is trapped inside the drop zone region itself
  • Screen reader (required — document steps below)

    1. Open Storybook → Drop Zone → States
    2. Navigate to the "Dragged" instance; confirm the status live region (aria-live="polite") announces the state change when dragged is toggled programmatically
    3. Navigate to the "Filled" instance; confirm the illustrated message is hidden from the accessibility tree (it has display: none when [filled]) and only the uploaded-content region is announced
    4. Confirm the group label and structure are coherent with VoiceOver (macOS) and NVDA (Windows)

@cdransf cdransf self-assigned this Jun 23, 2026
@cdransf cdransf requested a review from a team as a code owner June 23, 2026 18:18
@cdransf cdransf added Component:Dropzone Spectrum 2 Issues related to Spectrum 2 labels Jun 23, 2026
@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 261364c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 1b2b242 to 607abae Compare June 23, 2026 19:41
@cdransf cdransf added the Status:Ready for review PR ready for review or re-review. label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6446

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Base automatically changed from cdransf/s2-dropzone-migration-file-structure to cdransf/s2-dropzone-migration June 24, 2026 15:57
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration branch from 94ac3a6 to 2aab51e Compare June 24, 2026 15:58
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 607abae to 26dc7e5 Compare June 24, 2026 15:58
@cdransf cdransf mentioned this pull request Jun 24, 2026
21 tasks
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration branch from 2aab51e to 42b0387 Compare June 24, 2026 20:45
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 26dc7e5 to 87928fd Compare June 24, 2026 20:45

@5t3ph 5t3ph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocking to assess a functional change of possibly adding a filled-content slot.

Comment thread 2nd-gen/packages/swc/components/dropzone/Dropzone.ts
Comment thread 2nd-gen/packages/swc/components/dropzone/stories/dropzone.stories.ts Outdated
Comment thread 2nd-gen/packages/swc/components/dropzone/dropzone.css Outdated
Comment thread 2nd-gen/packages/swc/components/dropzone/dropzone.css Outdated
Comment thread 2nd-gen/packages/swc/components/dropzone/stories/dropzone.stories.ts Outdated
Comment thread 2nd-gen/packages/swc/components/dropzone/dropzone.css
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 420a581 to 40b81e4 Compare June 25, 2026 17:37
@cdransf cdransf added the Status:Blocked PR is blocked for some reason label Jun 25, 2026
@cdransf cdransf requested a review from 5t3ph June 25, 2026 18:32
@cdransf cdransf removed the Status:Ready for review PR ready for review or re-review. label Jun 25, 2026
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration branch from 42b0387 to fce646e Compare June 25, 2026 21:14
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 15ada21 to 972adaa Compare June 25, 2026 21:15
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration branch from fce646e to 2acf4ea Compare June 26, 2026 17:07
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 972adaa to a32b450 Compare June 26, 2026 17:07

@5t3ph 5t3ph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you mind creating a ticket to investigate if we'd want to add something akin to React's FileTrigger (embedded in their DropZone demo, no separate docs) to help facilitate more of the upload operation? It's still feeling odd to me that we turn over so much to consumers to have to handle for the logic.

S1 showed a very rudimentary way to open a hidden file input, which we might want to demo at minimum. Could be done in the docs phase.

} as const satisfies Record<DropzoneSize, string>;

const DROPZONE_SVG = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 103" slot="" aria-hidden="true">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should clarify from design if we should at all build in a default for this, but design and React have different ones.

Design Figma:
Image

React:
Image

<div class="swc-Dropzone">
<div role="status" aria-live="polite" class="swc-Dropzone-status"></div>
<slot @slotchange=${this.handleDefaultSlotChange}></slot>
<slot name="filled-content"></slot>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update to swap between the default slot and filled-content slot based on whether the element has the filled property, otherwise there's not value in having the filled-content slot.

Also please update stories that include the filled presentation to still include default slot content to prove/demo this swap.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated! 021b884

${unsafeHTML(DROPZONE_SVG)}
<h2 slot="heading">${headingText}</h2>
</swc-illustrated-message>
<swc-button variant="accent" size=${size}>Browse files</swc-button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Commenting as a reminder / for visibility of the need to update the buttons in these templates to move into the illustrated message new actions slot 🙌

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated in 65c7ab4

───────────────────────────────────── */

/* Mirror the dragged border when the browse control receives keyboard focus. */
:host(:focus-within) .swc-Dropzone {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could combine this selector with the dragged one, excluding the background, since border properties are the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oohh thank you! Updated bc44c85

align-items: center;
justify-content: center;
padding: var(--swc-dropzone-padding, token("spacing-400"));
background: var(--swc-dropzone-background-color, transparent);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still a bit of mixed use on the custom properties exposure and overrides - we can huddle after break if you need clarity on this beyond the docs examples!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gotcha! I ran through the docs and updated here 261364c. We can chat after the break too ✨

@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from e8780f7 to 5096f04 Compare June 26, 2026 21:57
@cdransf cdransf force-pushed the cdransf/s2-dropzone-migration-full-fidelity branch from 5096f04 to 65c7ab4 Compare June 26, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component:Dropzone Spectrum 2 Issues related to Spectrum 2 Status:Blocked PR is blocked for some reason

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants