Skip to content

Commit cb3ac16

Browse files
committed
feat(PostSharing): implement post sharing component with copy link and 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.
1 parent 84f9bad commit cb3ac16

12 files changed

Lines changed: 380 additions & 59 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Post sharing actions (copy link / native share).
4+
*
5+
* @var array $args {
6+
* @type string $url Post permalink.
7+
* @type string $title Post title.
8+
* }
9+
*/
10+
11+
use function BEA\Theme\Framework\Helpers\Svg\the_icon;
12+
13+
$url = (string) ( $args['url'] ?? '' );
14+
$post_title = (string) ( $args['title'] ?? '' );
15+
16+
if ( '' === $url ) {
17+
return;
18+
}
19+
?>
20+
21+
<div
22+
class="post-sharing"
23+
data-url="<?php echo esc_url( $url ); ?>"
24+
data-title="<?php echo esc_attr( $post_title ); ?>"
25+
data-copied-label="<?php echo esc_attr__( 'Link copied!', 'beapi-frontend-framework' ); ?>"
26+
data-error-copy="<?php echo esc_attr__( 'Unable to copy the link', 'beapi-frontend-framework' ); ?>"
27+
data-error-share="<?php echo esc_attr__( 'Unable to share', 'beapi-frontend-framework' ); ?>"
28+
>
29+
<div class="post-sharing__actions">
30+
<button type="button" class="post-sharing__button post-sharing__button--copy" data-action="copy">
31+
<?php the_icon( 'link', [ 'post-sharing__icon', 'post-sharing__icon--copy' ] ); ?>
32+
<?php the_icon( 'check-circle', [ 'post-sharing__icon', 'post-sharing__icon--check' ] ); ?>
33+
<span class="post-sharing__label"><?php echo esc_html__( 'Copy link', 'beapi-frontend-framework' ); ?></span>
34+
</button>
35+
<button type="button" class="post-sharing__button post-sharing__button--share" data-action="share">
36+
<?php the_icon( 'share', [ 'post-sharing__icon', 'post-sharing__icon--share' ] ); ?>
37+
<span class="post-sharing__label"><?php echo esc_html__( 'Share', 'beapi-frontend-framework' ); ?></span>
38+
</button>
39+
</div>
40+
<p class="post-sharing__status" role="status" aria-live="polite" hidden></p>
41+
</div>

‎languages/beapi-frontend-framework.pot‎

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgstr ""
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2026-05-07T14:30:39+00:00\n"
12+
"POT-Creation-Date: 2026-09-18T09:57:30+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.12.0\n"
1515
"X-Domain: beapi-frontend-framework\n"
@@ -39,6 +39,26 @@ msgstr ""
3939
msgid "Breadcrumb"
4040
msgstr ""
4141

42+
#: components/parts/common/post-sharing.php:25
43+
msgid "Link copied!"
44+
msgstr ""
45+
46+
#: components/parts/common/post-sharing.php:26
47+
msgid "Unable to copy the link"
48+
msgstr ""
49+
50+
#: components/parts/common/post-sharing.php:27
51+
msgid "Unable to share"
52+
msgstr ""
53+
54+
#: components/parts/common/post-sharing.php:33
55+
msgid "Copy link"
56+
msgstr ""
57+
58+
#: components/parts/common/post-sharing.php:37
59+
msgid "Share"
60+
msgstr ""
61+
4262
#: footer.php:2
4363
msgid "Footer"
4464
msgstr ""
@@ -92,6 +112,10 @@ msgstr ""
92112
msgid "Close menu"
93113
msgstr ""
94114

115+
#: inc/Helpers/Formatting/Datetime.php:53
116+
msgid "Published on"
117+
msgstr ""
118+
95119
#: inc/Helpers/Formatting/Link.php:144
96120
msgid "New window"
97121
msgstr ""
@@ -120,46 +144,28 @@ msgstr ""
120144
msgid "Share by email"
121145
msgstr ""
122146

123-
#: inc/Services/Editor.php:144
147+
#: inc/Services/Editor.php:168
124148
msgid "Small"
125149
msgstr ""
126150

127-
#: inc/Services/Editor.php:152
151+
#: inc/Services/Editor.php:176
128152
msgid "Large"
129153
msgstr ""
130154

131-
#: inc/Services/Editor.php:160
155+
#: inc/Services/Editor.php:184
132156
msgid "Huge"
133157
msgstr ""
134158

135159
#. translators: %s: heading number
136-
#: inc/Services/Editor.php:168
160+
#: inc/Services/Editor.php:192
137161
#, php-format
138162
msgid "Style H%s"
139163
msgstr ""
140164

141-
#: inc/Services/Editor_Patterns.php:40
165+
#: inc/Services/Editor_Patterns.php:45
142166
msgid "Common"
143167
msgstr ""
144168

145-
#. translators: %s: file name.
146-
#: inc/Services/Editor_Patterns.php:125
147-
#, php-format
148-
msgid "Could not register file \"%s\" as a block pattern (\"Slug\" field missing)"
149-
msgstr ""
150-
151-
#. translators: %1s: file name; %2s: slug value found.
152-
#: inc/Services/Editor_Patterns.php:138
153-
#, php-format
154-
msgid "Could not register file \"%1$s\" as a block pattern (invalid slug \"%2$s\")"
155-
msgstr ""
156-
157-
#. translators: %1s: file name; %2s: slug value found.
158-
#: inc/Services/Editor_Patterns.php:155
159-
#, php-format
160-
msgid "Could not register file \"%s\" as a block pattern (\"Title\" field missing)"
161-
msgstr ""
162-
163169
#: inc/Services/Menu.php:37
164170
msgid "Main menu"
165171
msgstr ""

‎languages/fr_FR.mo‎

-289 Bytes
Binary file not shown.

‎languages/fr_FR.po‎

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ msgstr ""
55
"Project-Id-Version: Be API Frontend Framework 1.0.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/theme/beapi-frontend-"
77
"framework\n"
8-
"POT-Creation-Date: 2026-05-07T14:30:39+00:00\n"
9-
"PO-Revision-Date: 2026-05-07 16:41+0200\n"
8+
"POT-Creation-Date: 2026-09-18T09:57:30+00:00\n"
9+
"PO-Revision-Date: 2026-09-18 12:00+0200\n"
1010
"Last-Translator: \n"
1111
"Language-Team: \n"
1212
"Language: fr\n"
@@ -42,6 +42,26 @@ msgstr ""
4242
msgid "Breadcrumb"
4343
msgstr "Fil d’ariane"
4444

45+
#: components/parts/common/post-sharing.php:25
46+
msgid "Link copied!"
47+
msgstr "Lien copié !"
48+
49+
#: components/parts/common/post-sharing.php:26
50+
msgid "Unable to copy the link"
51+
msgstr "Impossible de copier le lien"
52+
53+
#: components/parts/common/post-sharing.php:27
54+
msgid "Unable to share"
55+
msgstr "Impossible de partager"
56+
57+
#: components/parts/common/post-sharing.php:33
58+
msgid "Copy link"
59+
msgstr "Copier le lien"
60+
61+
#: components/parts/common/post-sharing.php:37
62+
msgid "Share"
63+
msgstr "Partager"
64+
4565
#: footer.php:2
4666
msgid "Footer"
4767
msgstr "Pied de Page"
@@ -94,6 +114,10 @@ msgstr "Ouvrir le menu"
94114
msgid "Close menu"
95115
msgstr "Fermer le menu"
96116

117+
#: inc/Helpers/Formatting/Datetime.php:53
118+
msgid "Published on"
119+
msgstr "Publié le"
120+
97121
#: inc/Helpers/Formatting/Link.php:144
98122
msgid "New window"
99123
msgstr "Nouvelle fenêtre"
@@ -122,55 +146,28 @@ msgstr "Partager sur Bluesky"
122146
msgid "Share by email"
123147
msgstr "Partager par email"
124148

125-
#: inc/Services/Editor.php:144
149+
#: inc/Services/Editor.php:168
126150
msgid "Small"
127151
msgstr "Petit"
128152

129-
#: inc/Services/Editor.php:152
153+
#: inc/Services/Editor.php:176
130154
msgid "Large"
131155
msgstr "Grand"
132156

133-
#: inc/Services/Editor.php:160
157+
#: inc/Services/Editor.php:184
134158
msgid "Huge"
135159
msgstr "Très grand"
136160

137161
#. translators: %s: heading number
138-
#: inc/Services/Editor.php:168
162+
#: inc/Services/Editor.php:192
139163
#, php-format
140164
msgid "Style H%s"
141165
msgstr ""
142166

143-
#: inc/Services/Editor_Patterns.php:40
167+
#: inc/Services/Editor_Patterns.php:45
144168
msgid "Common"
145169
msgstr "Général"
146170

147-
#. translators: %s: file name.
148-
#: inc/Services/Editor_Patterns.php:125
149-
#, php-format
150-
msgid ""
151-
"Could not register file \"%s\" as a block pattern (\"Slug\" field missing)"
152-
msgstr ""
153-
"Impossible de déclarer la composition de blocs à partir du fichier \"%s\" "
154-
"(Le champ \"Slug\" est manquant)"
155-
156-
#. translators: %1s: file name; %2s: slug value found.
157-
#: inc/Services/Editor_Patterns.php:138
158-
#, php-format
159-
msgid ""
160-
"Could not register file \"%1$s\" as a block pattern (invalid slug \"%2$s\")"
161-
msgstr ""
162-
"Impossible de déclarer la composition de blocs à partir du fichier \"%1$s\" "
163-
"(Le slug \"%2$s\" n'est pas valide)"
164-
165-
#. translators: %1s: file name; %2s: slug value found.
166-
#: inc/Services/Editor_Patterns.php:155
167-
#, php-format
168-
msgid ""
169-
"Could not register file \"%s\" as a block pattern (\"Title\" field missing)"
170-
msgstr ""
171-
"Impossible de déclarer la composition de blocs à partir du fichier \"%s\" "
172-
"(Le champ \"Title\" est manquant)"
173-
174171
#: inc/Services/Menu.php:37
175172
msgid "Main menu"
176173
msgstr "Menu principal"
@@ -264,6 +261,29 @@ msgctxt "Space size name"
264261
msgid "lg (64px)"
265262
msgstr ""
266263

264+
#, php-format
265+
#~ msgid ""
266+
#~ "Could not register file \"%s\" as a block pattern (\"Slug\" field missing)"
267+
#~ msgstr ""
268+
#~ "Impossible de déclarer la composition de blocs à partir du fichier \"%s\" "
269+
#~ "(Le champ \"Slug\" est manquant)"
270+
271+
#, php-format
272+
#~ msgid ""
273+
#~ "Could not register file \"%1$s\" as a block pattern (invalid slug "
274+
#~ "\"%2$s\")"
275+
#~ msgstr ""
276+
#~ "Impossible de déclarer la composition de blocs à partir du fichier "
277+
#~ "\"%1$s\" (Le slug \"%2$s\" n'est pas valide)"
278+
279+
#, php-format
280+
#~ msgid ""
281+
#~ "Could not register file \"%s\" as a block pattern (\"Title\" field "
282+
#~ "missing)"
283+
#~ msgstr ""
284+
#~ "Impossible de déclarer la composition de blocs à partir du fichier \"%s\" "
285+
#~ "(Le champ \"Title\" est manquant)"
286+
267287
#~ msgid "Dark"
268288
#~ msgstr "Sombre"
269289

Lines changed: 1 addition & 0 deletions
Loading

‎src/img/icons/sprite/link.svg‎

Lines changed: 1 addition & 0 deletions
Loading

‎src/img/icons/sprite/logo-beapi.svg‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/img/icons/sprite/share.svg‎

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)