Skip to content

Commit 0366b61

Browse files
committed
fix(federatedfilessharing): Use social media icons from core rather than inline SVGs
* Use correct facebook icon provided by Meta The legal terms require to exactly use the facebook logo as provided by Meta. * Add correct X logo as provided by X Corp. * Use social media icons from core rather than inline SVGs * Make copy logic more resilient and use Typescript * Add aria label to include the `X` in `X (formerly Twitter)` button. * Use valid mastodon URL for sharing Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent ce3e92f commit 0366b61

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Files: core/img/apps/richdocumentscode.svg
203203
Copyright: 2016-2024 Collabora Ltd.
204204
License: LicenseRef-CollaboraTrademarks
205205

206-
Files: core/img/twitter.svg core/img/actions/twitter.svg apps/federatedfilesharing/img/social-twitter.svg
206+
Files: core/img/x.svg core/img/twitter.svg core/img/actions/twitter.svg apps/federatedfilesharing/img/social-twitter.svg
207207
Copyright: X Corp.
208208
License: LicenseRef-XTrademarks
209209

apps/federatedfilesharing/src/components/PersonalSettings.vue

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
:title="copyLinkTooltip"
1414
:aria-label="copyLinkTooltip"
1515
class="clipboard"
16-
type="tertiary-no-background"
16+
type="tertiary"
1717
@click.prevent="copyCloudId">
1818
<template #icon>
1919
<Clipboard :size="20" />
@@ -26,22 +26,20 @@
2626
<NcButton @click="goTo(shareFacebookUrl)">
2727
{{ t('federatedfilesharing', 'Facebook') }}
2828
<template #icon>
29-
<Facebook :size="20" />
29+
<img class="social-button__icon social-button__icon--bright" :src="urlFacebookIcon">
3030
</template>
3131
</NcButton>
32-
<NcButton @click="goTo(shareXUrl)">
32+
<NcButton :aria-label="t('federatedfilesharing', 'X (formerly Twitter)')"
33+
@click="goTo(shareXUrl)">
3334
{{ t('federatedfilesharing', 'formerly Twitter') }}
3435
<template #icon>
35-
<svg width="20"
36-
height="20"
37-
viewBox="0 0 15 15"
38-
xmlns="http://www.w3.org/2000/svg"><path fill="black" d="m 3.384891,2.6 c -0.3882,0 -0.61495,0.4362184 -0.39375,0.7558594 L 6.5841098,8.4900156 2.9770785,12.707422 C 2.7436785,12.979821 2.9370285,13.4 3.2958285,13.4 H 3.694266 c 0.176,0 0.3430313,-0.07714 0.4570313,-0.210938 L 7.294266,9.5065156 9.6602817,12.887891 C 9.8762817,13.208984 10.25229,13.4 10.743485,13.4 h 1.900391 c 0.3882,0 0.61575,-0.436688 0.39375,-0.754688 L 9.2466097,7.2195156 12.682547,3.1941408 C 12.881744,2.9601408 12.715528,2.6 12.407473,2.6 h -0.506566 c -0.175,0 -0.34186,0.076453 -0.45586,0.2197656 L 8.5405785,6.2058438 6.3790317,3.1132812 C 6.1568442,2.7913687 5.6965004,2.6 5.3958285,2.6 Z" /></svg>
36+
<img class="social-button__icon" :src="urlXIcon">
3937
</template>
4038
</NcButton>
4139
<NcButton @click="goTo(shareMastodonUrl)">
4240
{{ t('federatedfilesharing', 'Mastodon') }}
4341
<template #icon>
44-
<Mastodon :size="20" />
42+
<img class="social-button__icon" :src="urlMastodonIcon">
4543
</template>
4644
</NcButton>
4745
<NcButton class="social-button__website-button"
@@ -73,13 +71,13 @@
7371
</NcSettingsSection>
7472
</template>
7573

76-
<script>
77-
import { showError, showSuccess } from '@nextcloud/dialogs'
74+
<script lang="ts">
75+
import { showSuccess } from '@nextcloud/dialogs'
7876
import { loadState } from '@nextcloud/initial-state'
77+
import { t } from '@nextcloud/l10n'
78+
import { imagePath } from '@nextcloud/router'
7979
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
8080
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
81-
import Mastodon from 'vue-material-design-icons/Mastodon.vue'
82-
import Facebook from 'vue-material-design-icons/Facebook.vue'
8381
import Web from 'vue-material-design-icons/Web.vue'
8482
import Clipboard from 'vue-material-design-icons/ContentCopy.vue'
8583
@@ -88,18 +86,25 @@ export default {
8886
components: {
8987
NcButton,
9088
NcSettingsSection,
91-
Mastodon,
92-
Facebook,
9389
Web,
9490
Clipboard,
9591
},
92+
setup() {
93+
return {
94+
t,
95+
96+
cloudId: loadState<string>('federatedfilesharing', 'cloudId'),
97+
reference: loadState<string>('federatedfilesharing', 'reference'),
98+
urlFacebookIcon: imagePath('core', 'facebook'),
99+
urlMastodonIcon: imagePath('core', 'mastodon'),
100+
urlXIcon: imagePath('core', 'x'),
101+
}
102+
},
96103
data() {
97104
return {
98105
color: loadState('federatedfilesharing', 'color'),
99106
textColor: loadState('federatedfilesharing', 'textColor'),
100107
logoPath: loadState('federatedfilesharing', 'logoPath'),
101-
reference: loadState('federatedfilesharing', 'reference'),
102-
cloudId: loadState('federatedfilesharing', 'cloudId'),
103108
docUrlFederated: loadState('federatedfilesharing', 'docUrlFederated'),
104109
showHtml: false,
105110
isCopied: false,
@@ -113,7 +118,7 @@ export default {
113118
return t('federatedfilesharing', 'Share with me through my #Nextcloud Federated Cloud ID')
114119
},
115120
shareMastodonUrl() {
116-
return `https://https://mastodon.xyz/?text=${encodeURIComponent(this.messageWithoutURL)}&url=${encodeURIComponent(this.reference)}`
121+
return `https://mastodon.social/?text=${encodeURIComponent(this.messageWithoutURL)}&url=${encodeURIComponent(this.reference)}`
117122
},
118123
shareXUrl() {
119124
return `https://x.com/intent/tweet?text=${encodeURIComponent(this.messageWithURL)}`
@@ -141,18 +146,18 @@ export default {
141146
},
142147
},
143148
methods: {
144-
async copyCloudId() {
145-
if (!navigator.clipboard) {
146-
// Clipboard API not available
147-
showError(t('federatedfilesharing', 'Clipboard is not available'))
148-
return
149+
async copyCloudId(): Promise<void> {
150+
try {
151+
await navigator.clipboard.writeText(this.cloudId)
152+
showSuccess(t('federatedfilesharing', 'Cloud ID copied to the clipboard'))
153+
} catch (e) {
154+
// no secure context or really old browser - need a fallback
155+
window.prompt(t('federatedfilesharing', 'Clipboard not available. Please copy the cloud ID manually.'), this.reference)
149156
}
150-
await navigator.clipboard.writeText(this.cloudId)
151157
this.isCopied = true
152-
showSuccess(t('federatedfilesharing', 'Copied!'))
153-
this.$refs.clipboard.$el.focus()
154158
},
155-
goTo(url) {
159+
160+
goTo(url: string): void {
156161
window.location.href = url
157162
},
158163
},
@@ -162,14 +167,27 @@ export default {
162167
<style lang="scss" scoped>
163168
.social-button {
164169
margin-top: 0.5rem;
170+
165171
button {
166172
display: inline-flex;
167173
margin-left: 0.5rem;
168174
margin-top: 1rem;
169175
}
176+
170177
&__website-button {
171178
width: min(100%, 400px) !important;
172179
}
180+
181+
&__icon {
182+
height: 20px;
183+
width: 20px;
184+
filter: var(--background-invert-if-dark);
185+
186+
&--bright {
187+
// Some logos like the Facebook logo have bright color schema
188+
filter: var(--background-invert-if-bright);
189+
}
190+
}
173191
}
174192
.cloud-id-text {
175193
display: flex;

core/img/facebook.svg

Lines changed: 1 addition & 1 deletion
Loading

core/img/mastodon.svg

Lines changed: 1 addition & 1 deletion
Loading

core/img/x.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)