Skip to content

Partage d’article — copie du lien & partage natif - #509

Open
cedric07 wants to merge 2 commits into
masterfrom
feat/social-share
Open

cedric07 wants to merge 2 commits into
masterfrom
feat/social-share

Conversation

@cedric07

@cedric07 cedric07 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Résumé

Ajout d’un composant de partage d’article moderne, sans dépendre des réseaux sociaux tiers :

  • Desktop : bouton « Copier le lien » (Clipboard API)
  • Mobile : bouton « Partager » via la Web Share API native
  • Fallback : si navigator.share est indisponible, le bouton copie reste affiché sur mobile

Fichiers principaux

Fichier Rôle
components/parts/common/post-sharing.php Markup + i18n PHP (data-* pour les messages JS)
src/js/classes/PostSharing.js Comportement copie / partage
src/scss/05-components/_post-sharing.scss Styles + bascule desktop/mobile
src/img/icons/sprite/{link,share,check-circle}.svg Icônes du composant
languages/* Chaînes FR + pot à jour

Utilisation

get_template_part( 'components/parts/common/post-sharing', null, [
	'url'   => get_permalink(),
	'title' => get_the_title(),
] );

i18n

Pas de traduction JS : les libellés dynamiques (succès / erreurs) sont passés en data-* depuis le PHP (esc_attr__), comme url et title. Les labels visibles utilisent esc_html__.

Accessibilité

  • Boutons natifs type="button"
  • Feedback annoncé via role="status" + aria-live="polite" (sr-only)
  • Annulation du sheet natif (AbortError) non traitée comme une erreur
  • État « copié » : label + icône check, puis retour à l’état initial

Plan de test

  • Desktop : clic « Copier le lien » → label « Lien copié ! » + icône check, reset après ~3s
  • Desktop : le bouton « Partager » est masqué
  • Mobile (navigateur avec Web Share) : bouton « Partager » visible, sheet natif OK
  • Mobile sans Web Share (ou desktop DevTools sans API) : fallback copie visible
  • Lecteur d’écran : annonce du message de succès / d’erreur
  • Contexte non sécurisé (HTTP) : message d’erreur copie si Clipboard API indisponible
  • Chaînes FR présentes dans languages/fr_FR.po

Note

Low Risk
Front-end-only sharing UI using clipboard and Web Share APIs; no server-side or security-sensitive logic.

Overview
Adds a post sharing UI that avoids third-party social widgets: copy link on larger viewports (Clipboard API) and native share on small screens (Web Share API), with copy shown on mobile when navigator.share is missing.

The PHP partial outputs buttons, icons, and passes translated success/error strings via data-* attributes for PostSharing.js, which handles copy feedback (label/icon swap, ~3s reset), share via navigator.share, and role="status" announcements. Styles control desktop/mobile button visibility and the --no-native-share fallback.

Also adds link, share, and check-circle sprite icons, wires the component into the main JS/SCSS bundles, and refreshes POT / fr_FR strings (including unrelated catalog line updates). logo-beapi.svg is removed from the sprite set.

Reviewed by Cursor Bugbot for commit 9923ea3. Bugbot is set up for automated code reviews on this repo. Configure here.

…d native share functionality

- Added a new `post-sharing.php` template for displaying sharing options.
- Created `PostSharing.js` class to handle copy and share actions, including user feedback.
- Introduced SCSS styles for the post sharing buttons and their states.
- Updated language files to include new strings for sharing actions.
- Added SVG icons for copy and share actions.
- Integrated the new component into the main JavaScript and SCSS files.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cb3ac16. Configure here.

Comment thread src/js/classes/PostSharing.js
Remove the hidden attribute so aria-live can announce feedback; rely on sr-only for visual hiding.
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