Skip to content

Create the Success snackbar component #12509

Description

@benbowler

Feature Description

Create the component only for the Success snack bar for the PDF generation feature.

Image

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • A new Success PDF snackbar component is added for dashboard usage only (component scope, no integration/wiring in this issue).
  • The component copy and visually matches the Figma design
  • The retry link does not invoke anything yet.
  • The close "X" triggers a dismissal.
  • The component supports auto-dismiss behavior with a default of 10 seconds and notifies parent code via callback when auto-dismiss occurs.
  • The component is accessible

Implementation Brief

  • Extend assets/js/components/Notice/DismissButton.js with optional mode (if not implemented as part of Create the Error snackbar component #12510):
    • variant: 'text' | 'icon' (default 'text')
    • icon (React node, required when variant='icon')
    • ariaLabel (required when variant='icon')
  • Update assets/js/components/Notice/index.js to pass through new dismiss props and keep current behavior as default.
    • Use existing Button component for icon dismiss rendering in DismissButton.
    • Add scoped notice styles for icon dismiss button alignment only if needed, in _googlesitekit-notice.scss, backward-compatible.
  • Create component at assets/js/components/pdf-export/PDFReportSuccessSnackbar.js.
    • Reuse Notice (assets/js/components/Notice/index.js) as the base surface with type={ Notice.TYPES.SUCCESS } and className="googlesitekit-notice-snackbar--bottom-right googlesitekit-pdf-report-success-snackbar".
    • Use Notice built-in success icon for the left icon.
    • Render description text with inline retry link via createInterpolateElement + Link, and map retry click to onRetryDownload.
    • Use existing Button component for icon dismiss rendering in DismissButton.
      • Use for eq: dismissButton={{ variant: 'icon', icon: <CloseIcon />, ariaLabel: 'Dismiss', onClick: onDismiss }}
    • Implement auto-dismiss in component with useEffect, default autoDismissMS=10000, cleared on unmount; call onAutoDismiss when timer elapses.
    • Keep component presentational: no datastore selectors, no notification API registration, no export blob handling.
  • Add scoped Sass partial at assets/sass/components/pdf-export/_googlesitekit-pdf-report-success-snackbar.scss.
    • Import Sass partial in assets/sass/admin.scss
    • Keep all style overrides scoped to .googlesitekit-pdf-report-success-snackbar so existing Notice/Toast components remain unaffected.

Test Coverage

  • Add assets/js/components/pdf-export/PDFReportSuccessSnackbar.test.js.
    • Verify default title/description/retry label render.
    • Verify onRetryDownload is called when retry link is clicked.
    • Verify onDismiss is called when close icon button is clicked.
    • Verify auto-dismiss fires at 10s by default and calls onAutoDismiss.
    • Verify disableAutoDismiss prevents timer dismissal.
  • Add Storybook stories at assets/js/components/pdf-export/PDFReportSuccessSnackbar.stories.js.
    • Include story for default state. (Only this scenario can be added to VRT)
    • Include story for long-copy wrapping behavior.

QA Brief

  • Verify that the new component (Storybook URL once the PR is open, e.g. https://storage.googleapis.com/site-kit-github-artifacts/storybook/pull/<PR>/index.html?path=/story/components-pdfexport-pdfreportsuccesssnackbar--default) matches the referenced Figma.

Changelog entry

  • N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueGood first issue for new engineersP1Medium priorityTeam SIssues for Squad 1Type: EnhancementImprovement of an existing feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions