Skip to content

Commit

Permalink
Merge pull request #897 from dpc-sdp/task/sdpap-8247-update-twitter-icon
Browse files Browse the repository at this point in the history
[SDPAP-8247] Replace Twitter with X
  • Loading branch information
waitingallday authored Oct 18, 2023
2 parents a9b4d7b + 37a902b commit bac37ad
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 20 deletions.
5 changes: 4 additions & 1 deletion packages/nuxt-ripple/components/TideSidebarContactUs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const getSocialMediaIconByType = (type: string): string => {
if (type === 'youtube_channel') {
return 'icon-youtube'
}
if (['twitter', 'facebook', 'linkedin', 'instagram'].includes(type)) {
if (type === 'twitter') {
return 'icon-x'
}
if (['x', 'facebook', 'linkedin', 'instagram'].includes(type)) {
return `icon-${type}`
} else {
return 'icon-browser'
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt-ripple/composables/use-tide-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const useTideSite = async (id?: number): Promise<TideSiteData> => {

return data.value
}

return siteData.value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('sidebarSocialShareMapping', () => {
it('should return the default list of networks when social share display is switched on', () => {
expect(sidebarSocialShareMapping(parsedData)).toEqual([
'Facebook',
'Twitter',
'X',
'LinkedIn'
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const map = (src: TideApiResponse): string[] => {
return []
}

return ['Facebook', 'Twitter', 'LinkedIn']
return ['Facebook', 'X', 'LinkedIn']
}

export const includes = []
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ describe('getIconForUrl', () => {
expect(getIconForUrl('https://linkedin.com/')).toBe('icon-linkedin')
})

it('returns icon-twitter when passed twitter.com link', () => {
expect(getIconForUrl('https://www.twitter.com/')).toBe('icon-twitter')
expect(getIconForUrl('https://twitter.com/')).toBe('icon-twitter')
it('returns icon-x when passed twitter.com link', () => {
expect(getIconForUrl('https://www.twitter.com/')).toBe('icon-x')
expect(getIconForUrl('https://twitter.com/')).toBe('icon-x')
})

it('returns icon-x when passed x.com link', () => {
expect(getIconForUrl('https://www.x.com/')).toBe('icon-x')
expect(getIconForUrl('https://x.com/')).toBe('icon-x')
})

it('returns icon-youtube when passed youtube.com link', () => {
Expand Down Expand Up @@ -122,7 +127,7 @@ describe('processSiteSocialLinks', () => {
id: 'social_link-5',
text: 'Twitter',
url: 'https://www.twitter.com/',
icon: 'icon-twitter',
icon: 'icon-x',
iconColour: 'currentColor'
},
{
Expand Down
3 changes: 2 additions & 1 deletion packages/nuxt-ripple/mapping/utils/processSiteSocialLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const getIconForUrl = (urlString: string) => {
case 'linkedin.com':
return 'icon-linkedin'
case 'twitter.com':
return 'icon-twitter'
case 'x.com':
return 'icon-x'
case 'youtube.com':
return 'icon-youtube'
default:
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { setup, type Preview } from '@storybook/vue3'

// @ts-ignore-next-line: Missing declaration
import { registerRplFormPlugin } from '@dpc-sdp/ripple-ui-forms'
// Note: rebuild ripple-ui-core after generating sprite to update in storybook
// @ts-ignore-next-line: Vue SFC
import { RplIconSprite, RplLink, RplImg } from '@dpc-sdp/ripple-ui-core/vue'
import '@dpc-sdp/ripple-ui-core/style'
Expand Down
3 changes: 3 additions & 0 deletions packages/ripple-ui-core/src/assets/icons/core/icon-x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/ripple-ui-core/src/assets/icons/sprite.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ripple-ui-core/src/assets/icons/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export const SingleTemplate = (args) => ({
icon: 'icon-facebook'
},
{
text: '@twitterhandle',
url: 'https:/t',
icon: 'icon-twitter'
text: '@xhandle',
url: 'https:/x',
icon: 'icon-x'
},
{
text: '@linkedinhandle',
Expand All @@ -72,6 +72,11 @@ export const SingleTemplate = (args) => ({
url: 'https://i',
icon: 'icon-instagram'
},
{
text: '@legacytwitterhandle',
url: 'https:/t',
icon: 'icon-twitter'
},
{
text: '',
url: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { IRplListItemArray } from '../list/constants'
import { computed } from 'vue'
import RplList from '../list/RplList.vue'
import {
useRippleEvent,
Expand Down Expand Up @@ -40,6 +41,13 @@ const handleClick = (event) => {
{ global: true }
)
}
// Replace icon-twitter with icon-x
const socialLinks = computed(() =>
props.items.map((i) =>
i.icon === 'icon-twitter' ? { ...i, icon: 'icon-x' } : i
)
)
</script>

<template>
Expand All @@ -59,7 +67,7 @@ const handleClick = (event) => {
</p>
</div>
<RplList
:items="items"
:items="socialLinks"
class="rpl-type-p"
@item-click="handleClick"
></RplList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ export const RplFooterLinks = [
{
text: 'DFFH Twitter',
url: '#',
icon: 'icon-twitter'
icon: 'icon-x'
},
{
text: 'DH Twitter',
url: '#',
icon: 'icon-twitter'
icon: 'icon-x'
},
{
text: 'DFFH LinkedIn',
Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-ui-core/src/components/icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const RplIconGroups = {
'icon-instagram',
'icon-linkedin',
'icon-spotify',
'icon-twitter',
'icon-wechat',
'icon-youtube'
'icon-youtube',
'icon-x'
],
standard: [
'icon-accessible',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ const handleClick = () => {
@click.prevent="handleClick"
>
<RplIcon class="rpl-social-share__icon" :name="`icon-${key}`"></RplIcon>
<span>{{ network }}</span>
<span>{{ network === 'X' ? 'X (formerly Twitter)' : network }}</span>
</RplTextLink>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const RplSocialShareNetworks = {
Facebook: 'https://www.facebook.com/sharer/sharer.php?u=$u&title=$t',
LinkedIn: 'https://www.linkedin.com/shareArticle?url=$u',
Twitter: 'https://twitter.com/intent/tweet?text=$t&url=$u'
X: 'https://twitter.com/intent/tweet?text=$t&url=$u'
}

0 comments on commit bac37ad

Please sign in to comment.