Skip to content

Commit bd3fdc7

Browse files
authored
[C-2972] Fix feed, trending track-page seo (#3907)
1 parent 45279fe commit bd3fdc7

26 files changed

+169
-326
lines changed

packages/web/src/components/link/Link.module.css

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.root {
2+
display: inline-flex;
3+
align-items: center;
24
transition: color var(--expressive);
35
}
46

packages/web/src/components/link/Link.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useCallback, MouseEvent } from 'react'
2+
13
import cn from 'classnames'
24
import { Link as LinkBase, LinkProps as LinkBaseProps } from 'react-router-dom'
35

@@ -9,8 +11,22 @@ import styles from './Link.module.css'
911
type LinkProps = LinkBaseProps<'a'> & TextProps<'a'>
1012

1113
export const Link = (props: LinkProps) => {
12-
const { className, ...other } = props
14+
const { className, onClick, ...other } = props
15+
16+
const handleClick = useCallback(
17+
(e: MouseEvent<HTMLAnchorElement>) => {
18+
onClick?.(e)
19+
e.stopPropagation()
20+
},
21+
[onClick]
22+
)
23+
1324
return (
14-
<Text as={LinkBase} className={cn(styles.root, className)} {...other} />
25+
<Text
26+
as={LinkBase}
27+
className={cn(styles.root, className)}
28+
onClick={handleClick}
29+
{...other}
30+
/>
1531
)
1632
}

packages/web/src/components/track/GiantTrackTile.module.css

+3-11
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,11 @@
9595
display: inline;
9696
}
9797

98-
.artistWrapper .artist {
98+
.artist {
9999
display: inline-flex;
100-
color: var(--secondary);
101-
font-size: var(--font-l);
102-
font-weight: var(--font-medium);
103100
padding-left: var(--unit-1);
104-
align-items: center;
105-
}
106-
107-
.artistWrapper .artist:hover {
108-
color: var(--primary);
109-
cursor: pointer;
110-
text-decoration: underline;
101+
text-decoration: inherit;
102+
color: inherit;
111103
}
112104

113105
.playSection {

packages/web/src/components/track/GiantTrackTile.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { ReactComponent as IconRobot } from 'assets/img/robot.svg'
3434
import { ArtistPopover } from 'components/artist/ArtistPopover'
3535
import DownloadButtons from 'components/download-buttons/DownloadButtons'
3636
import { EntityActionButton } from 'components/entity-page/EntityActionButton'
37+
import { Link } from 'components/link'
3738
import LoadingSpinner from 'components/loading-spinner/LoadingSpinner'
3839
import Menu from 'components/menu/Menu'
3940
import RepostFavoritesStats from 'components/repost-favorites-stats/RepostFavoritesStats'
@@ -43,9 +44,11 @@ import { Tile } from 'components/tile'
4344
import Toast from 'components/toast/Toast'
4445
import Tooltip from 'components/tooltip/Tooltip'
4546
import { ComponentPlacement } from 'components/types'
47+
import { Text } from 'components/typography'
4648
import UserBadges from 'components/user-badges/UserBadges'
4749
import { getFeatureEnabled } from 'services/remote-config/featureFlagHelpers'
4850
import { moodMap } from 'utils/Moods'
51+
import { profilePage } from 'utils/route'
4952

5053
import { AiTrackSection } from './AiTrackSection'
5154
import Badge from './Badge'
@@ -105,7 +108,6 @@ export type GiantTrackTileProps = {
105108
listenCount: number
106109
loading: boolean
107110
mood: string
108-
onClickArtistName: () => void
109111
onClickFavorites: () => void
110112
onClickReposts: () => void
111113
onDownload: (trackId: ID, category?: string, parentTrackId?: ID) => void
@@ -154,7 +156,6 @@ export const GiantTrackTile = ({
154156
listenCount,
155157
loading,
156158
mood,
157-
onClickArtistName,
158159
onClickFavorites,
159160
onClickReposts,
160161
onDownload,
@@ -523,16 +524,23 @@ export const GiantTrackTile = ({
523524
</div>
524525
<div className={styles.artistWrapper}>
525526
<div className={cn(fadeIn)}>
526-
<span>By</span>
527+
<span>By </span>
527528
<ArtistPopover handle={artistHandle}>
528-
<h2 className={styles.artist} onClick={onClickArtistName}>
529-
{artistName}
529+
<Link
530+
to={profilePage(artistHandle)}
531+
color='secondary'
532+
variant='body'
533+
size='large'
534+
>
535+
<Text as='h2' variant='inherit'>
536+
{artistName}
537+
</Text>
530538
<UserBadges
531539
className={styles.verified}
532540
badgeSize={18}
533541
userId={userId}
534542
/>
535-
</h2>
543+
</Link>
536544
</ArtistPopover>
537545
</div>
538546
{isLoading && (

packages/web/src/components/track/desktop/ConnectedPlaylistTile.module.css

-13
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@
4343
margin-right: 4px;
4444
}
4545

46-
.name {
47-
font-weight: var(--font-medium);
48-
font-size: var(--font-m);
49-
color: var(--neutral);
50-
}
51-
5246
.userName {
5347
display: inline-flex;
5448
align-items: baseline;
@@ -68,13 +62,6 @@
6862
margin-right: 4px;
6963
}
7064

71-
.name.artistNameLink:hover {
72-
cursor: pointer;
73-
color: var(--primary);
74-
text-decoration: underline;
75-
text-decoration-color: var(--primary-light-2);
76-
}
77-
7865
.iconVerified {
7966
margin-left: 4px;
8067
position: relative;

packages/web/src/components/track/desktop/ConnectedPlaylistTile.tsx

+9-17
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
useEffect,
77
useCallback,
88
ReactChildren,
9-
useRef,
10-
MouseEventHandler
9+
useRef
1110
} from 'react'
1211

1312
import {
@@ -36,6 +35,7 @@ import { ReactComponent as IconKebabHorizontal } from 'assets/img/iconKebabHoriz
3635
import { TrackEvent, make } from 'common/store/analytics/actions'
3736
import { ArtistPopover } from 'components/artist/ArtistPopover'
3837
import { Draggable } from 'components/dragndrop'
38+
import { Link } from 'components/link'
3939
import { OwnProps as CollectionkMenuProps } from 'components/menu/CollectionMenu'
4040
import Menu from 'components/menu/Menu'
4141
import { CollectionArtwork } from 'components/track/Artwork'
@@ -78,6 +78,10 @@ const {
7878
const { getCollection, getTracksFromCollection } = cacheCollectionsSelectors
7979
const getUserHandle = accountSelectors.getUserHandle
8080

81+
const messages = {
82+
createdBy: 'Created by'
83+
}
84+
8185
type OwnProps = {
8286
uid: UID
8387
ordered: boolean
@@ -309,27 +313,15 @@ const ConnectedPlaylistTile = ({
309313
</Menu>
310314
)
311315
}
312-
const onClickArtistName: MouseEventHandler = useCallback(
313-
(e) => {
314-
e.stopPropagation()
315-
if (goToRoute) goToRoute(profilePage(handle))
316-
},
317-
[handle, goToRoute]
318-
)
319316

320317
const renderUserName = () => {
321318
return (
322319
<div className={styles.userName}>
323-
<span className={styles.createdBy}>{'Created by'}</span>
320+
<span className={styles.createdBy}>{messages.createdBy}</span>
324321
<ArtistPopover handle={handle}>
325-
<span
326-
className={cn(styles.name, {
327-
[styles.artistNameLink]: onClickArtistName
328-
})}
329-
onClick={onClickArtistName}
330-
>
322+
<Link to={profilePage(handle)} className={styles.name}>
331323
{name}
332-
</span>
324+
</Link>
333325
</ArtistPopover>
334326
<UserBadges
335327
userId={user?.user_id ?? 0}

packages/web/src/components/track/desktop/ConnectedTrackTile.module.css

+1-28
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,8 @@
4848
opacity: 0.75;
4949
}
5050

51-
.name,
52-
.name:hover,
53-
.name:active {
54-
color: inherit;
55-
text-decoration: inherit;
56-
}
57-
58-
.userName {
59-
display: inline-flex;
60-
font-weight: var(--font-medium);
61-
align-items: center;
62-
/**
63-
* Some webkit browsers (safari) have some trouble rendering this specific
64-
* font style within this particular context (due to floating point math being wonky
65-
* and the text getting accidentally wrapped). This is a temporary fix.
66-
* https://bugs.webkit.org/show_bug.cgi?id=217136
67-
*/
68-
letter-spacing: 0.000001px;
69-
}
70-
71-
.active .userName {
72-
color: var(--primary);
73-
}
74-
75-
.artistNameLink:hover {
76-
cursor: pointer;
51+
.active .name {
7752
color: var(--primary);
78-
text-decoration: underline !important;
79-
text-decoration-color: var(--primary-light-2);
8053
}
8154

8255
.socialInfo {

packages/web/src/components/track/desktop/ConnectedTrackTile.tsx

+13-42
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {
44
useCallback,
55
useEffect,
66
MouseEvent,
7-
useRef,
8-
MouseEventHandler
7+
useRef
98
} from 'react'
109

1110
import {
@@ -25,14 +24,14 @@ import {
2524
Genre
2625
} from '@audius/common'
2726
import cn from 'classnames'
28-
import { push as pushRoute } from 'connected-react-router'
2927
import { connect, useDispatch } from 'react-redux'
3028
import { Dispatch } from 'redux'
3129

3230
import { ReactComponent as IconKebabHorizontal } from 'assets/img/iconKebabHorizontal.svg'
3331
import { useModalState } from 'common/hooks/useModalState'
3432
import { ArtistPopover } from 'components/artist/ArtistPopover'
3533
import { Draggable } from 'components/dragndrop'
34+
import { Link } from 'components/link'
3635
import Menu from 'components/menu/Menu'
3736
import { OwnProps as TrackMenuProps } from 'components/menu/TrackMenu'
3837
import { TrackArtwork } from 'components/track/Artwork'
@@ -94,7 +93,6 @@ const ConnectedTrackTile = ({
9493
user,
9594
ordered,
9695
showArtistPick,
97-
goToRoute,
9896
togglePlay,
9997
isBuffering,
10098
isPlaying,
@@ -241,44 +239,19 @@ const ConnectedTrackTile = ({
241239
)
242240
}
243241

244-
const onClickArtistName: MouseEventHandler = useCallback(
245-
(e) => {
246-
e.preventDefault()
247-
e.stopPropagation()
248-
if (goToRoute) goToRoute(profilePage(handle))
249-
},
250-
[handle, goToRoute]
251-
)
252-
253-
const onClickTitle: MouseEventHandler = useCallback(
254-
(e) => {
255-
e.preventDefault()
256-
e.stopPropagation()
257-
if (goToRoute) goToRoute(permalink)
258-
},
259-
[goToRoute, permalink]
260-
)
261-
262242
const renderUserName = () => {
263243
return (
264-
<div className={styles.userName}>
265-
<ArtistPopover handle={handle}>
266-
<a
267-
className={cn(styles.name, {
268-
[styles.artistNameLink]: onClickArtistName
269-
})}
270-
onClick={onClickArtistName}
271-
href={profilePage(handle)}
272-
>
273-
{name}
274-
</a>
275-
</ArtistPopover>
276-
<UserBadges
277-
userId={user?.user_id ?? 0}
278-
badgeSize={14}
279-
className={styles.badgeWrapper}
280-
/>
281-
</div>
244+
<ArtistPopover handle={handle}>
245+
<Link to={profilePage(handle)} className={styles.name}>
246+
{name}
247+
248+
<UserBadges
249+
userId={user?.user_id ?? 0}
250+
badgeSize={14}
251+
className={styles.badgeWrapper}
252+
/>
253+
</Link>
254+
</ArtistPopover>
282255
)
283256
}
284257

@@ -405,7 +378,6 @@ const ConnectedTrackTile = ({
405378
[styles.loading]: loading,
406379
[styles.active]: isActive
407380
})}
408-
onClickTitle={onClickTitle}
409381
onClickRepost={onClickRepost}
410382
onClickFavorite={onClickFavorite}
411383
onClickShare={onClickShare}
@@ -449,7 +421,6 @@ function mapStateToProps(state: AppState, ownProps: OwnProps) {
449421

450422
function mapDispatchToProps(dispatch: Dispatch) {
451423
return {
452-
goToRoute: (route: string) => dispatch(pushRoute(route)),
453424
shareTrack: (trackId: ID) =>
454425
dispatch(
455426
requestOpenShareModal({

packages/web/src/components/track/desktop/PlaylistTile.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const PlaylistTile = ({
109109
bottomBar={bottomBar}
110110
showIconButtons={showIconButtons}
111111
containerClassName={tileClassName}
112-
onClickTitle={onClickTitle}
113112
onClickRepost={onClickRepost}
114113
onClickFavorite={onClickFavorite}
115114
onClickShare={onClickShare}

packages/web/src/components/track/desktop/TrackTile.module.css

+2-14
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@
148148
inset var(--unit-1) var(--unit-1) var(--unit-2) rgba(255, 255, 255, 0.2);
149149
}
150150

151-
.title {
152-
color: var(--neutral);
153-
}
154-
155151
.volumeIcon {
156152
margin-left: 6px;
157153
}
@@ -212,19 +208,11 @@
212208
color: var(--primary);
213209
}
214210

215-
.title:hover,
216-
.creatorRow .name.artistNameLink:hover {
217-
cursor: pointer;
218-
color: var(--primary);
219-
text-decoration: underline !important;
220-
text-decoration-color: var(--primary-light-2);
221-
}
222-
223211
.isDisabled .title:hover,
224-
.isDisabled .creatorRow .name.artistNameLink:hover {
212+
.isDisabled .creatorRow:hover {
225213
cursor: default;
226214
color: inherit;
227-
text-decoration: none;
215+
text-decoration: none !important;
228216
}
229217

230218
.isHidden {

0 commit comments

Comments
 (0)