Skip to content

feat(admin): WYSIWYG shortcode generator tab#70

Merged
techtimo merged 3 commits intomainfrom
feat/shortcode-generator-admin-tab
Apr 29, 2026
Merged

feat(admin): WYSIWYG shortcode generator tab#70
techtimo merged 3 commits intomainfrom
feat/shortcode-generator-admin-tab

Conversation

@techtimo
Copy link
Copy Markdown
Owner

Summary

  • Adds a Shortcode Generator tab to the Spotmap admin settings page β€” a WYSIWYG editor that lets users configure a [spotmap] map visually and copy the resulting shortcode string without needing to know any parameters
  • Live map preview auto-updates (500 ms debounce) as settings change, matching the block editor experience
  • Full toolbar: Feeds (with per-feed color/split-lines styling), Maps, Time filter, GPX tracks (full media library + upload via the shared GpxManagerModal), and a Settings dropdown (height, zoom-to, toggles for all map options)

Shared components extracted

Several pieces that were duplicated or block-editor-only are now properly shared:

New file Used by
src/spotmap/constants.js block editor, shortcode tab
src/spotmap/icons.jsx block editor, shortcode tab
src/spotmap/components/NavigationButtonsControl.jsx block editor, shortcode tab
src/spotmap/components/GpxManagerModal.jsx block editor, shortcode tab
src/spotmap-admin/components/FeedsToolbarGroup.jsx Edit Points tab, shortcode tab
src/spotmap-admin/mapDefaults.js Edit Points tab, shortcode tab

GpxManagerModal now uses wp.media instead of MediaUpload from @wordpress/block-editor, making it work in admin pages without a block editor store context.

Other fixes

  • TimeToolbarGroup: isPressed now reflects whether the modal is open, not whether a filter is active β€” consistent with all other toolbar buttons
  • Admin map CSS: build/spotmap-map.css (bundled leaflet-fullscreen + easybutton styles) is now enqueued in admin, fixing missing fullscreen icon and undersized navigate-to buttons in the Edit Points and Shortcode Generator maps

Test plan

  • Build passes (npm run build)
  • All JS tests pass (npm run test:js)
  • Visit WP Admin β†’ Settings β†’ Spotmap β†’ Shortcode Generator
  • Toggle feeds/maps/time/GPX/settings β€” confirm live map preview updates
  • Confirm shortcode string updates on every control change
  • Click Copy β€” paste shortcode into a post, confirm rendered map matches preview
  • Open GPX modal β€” confirm Upload and Media Library buttons both work
  • Confirm time filter toolbar button is no longer dark when a filter is active but modal is closed
  • Confirm fullscreen icon and navigation buttons render correctly in Edit Points map

πŸ€– Generated with Claude Code

Some themes apply `svg { max-width: 100%; height: auto; }` globally.
Leaflet's renderer pane <div> is position:absolute with no explicit
width, so 100% resolves to 0 β€” wiping out the width/height attributes
Leaflet sets on the renderer SVG. Circle markers (L.circleMarker) are
clipped to nothing, while polylines remain visible because they overflow
their SVG differently.

Fix: add `max-width: none !important` to `.leaflet-pane > svg` in
custom.css so the SVG can expand to its Leaflet-set intrinsic width.

Also move the circle-dot renderer from markerPane to a dedicated
spotmapCirclePane (z-index 450) so circle markers render above
polylines and avoid any pane-specific theme overrides.
Adds a new "Shortcode Generator" tab to the Spotmap admin page that
lets users configure a map visually and copy the resulting [spotmap]
shortcode β€” no manual parameter lookup required.

Key changes:
- New ShortcodeTab with live map preview (500 ms debounced), full
  toolbar (feeds, maps, time filter, GPX, settings), and one-click
  copy of the generated shortcode string
- Extracted shared components: NavigationButtonsControl, GpxManagerModal,
  FeedsToolbarGroup, COLORS constant, SATELLITE_ICON, getDefaultMaps β€”
  all reused between the block editor, Edit Points tab, and Shortcode tab
- GpxManagerModal now uses wp.media instead of MediaUpload, so it works
  in both block editor and admin contexts
- Fix TimeToolbarGroup: isPressed reflects modal-open state, not
  filter-active state
- Fix admin enqueue: load build/spotmap-map.css so fullscreen icon and
  easybutton styles appear in admin map previews
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

@techtimo techtimo merged commit 6ce8048 into main Apr 29, 2026
5 checks passed
@techtimo techtimo deleted the feat/shortcode-generator-admin-tab branch April 29, 2026 13:03
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.

1 participant