Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide podcast app launchers on desktop #414

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions __tests__/__snapshots__/snapshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ exports[`@financial-times/x-podcast-launchers renders a default Example x-podcas
<ul
className="PodcastLaunchers_podcastAppLinksWrapper__7W6dn"
>
<li>
<li
className=""
>
<a
className="PodcastLaunchers_podcastAppLink__69RMR"
data-trackable="apple-podcasts"
Expand All @@ -603,7 +605,9 @@ exports[`@financial-times/x-podcast-launchers renders a default Example x-podcas
Apple Podcasts
</a>
</li>
<li>
<li
className=""
>
<a
className="PodcastLaunchers_podcastAppLink__69RMR"
data-trackable="overcast"
Expand All @@ -612,7 +616,9 @@ exports[`@financial-times/x-podcast-launchers renders a default Example x-podcas
Overcast
</a>
</li>
<li>
<li
className=""
>
<a
className="PodcastLaunchers_podcastAppLink__69RMR"
data-trackable="pocket-casts"
Expand All @@ -621,7 +627,9 @@ exports[`@financial-times/x-podcast-launchers renders a default Example x-podcas
Pocket Casts
</a>
</li>
<li>
<li
className=""
>
<a
className="PodcastLaunchers_podcastAppLink__69RMR"
data-trackable="podcast-addict"
Expand All @@ -630,7 +638,9 @@ exports[`@financial-times/x-podcast-launchers renders a default Example x-podcas
Podcast Addict
</a>
</li>
<li>
<li
className=""
>
<a
className="PodcastLaunchers_podcastAppLink__69RMR"
data-trackable="acast"
Expand Down
1 change: 1 addition & 0 deletions components/x-podcast-launchers/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "dist/PodcastLaunchers.es5.js",
"private": true,
"dependencies": {
"o-grid": "^5.0.2",
"o-typography": "^6.0.1",
"o-forms": "^8.0.0",
"o-buttons": "^6.0.2"
Expand Down
11 changes: 6 additions & 5 deletions components/x-podcast-launchers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ All `x-` components are designed to be compatible with a variety of runtimes, no

### Properties

Feature | Type | Required | Notes
----------------------|----------|----------|------------------
`acastRSSHost` | String | Yes | e.g. 'https://acast.access.com'
`conceptId` | String | Yes |
`renderFollowButton` | Function | No | Optional render prop for the follow button
Feature | Type | Required | Notes
----------------------------|----------|----------|------------------
`acastRSSHost` | String | Yes | e.g. 'https://acast.access.com'
`conceptId` | String | Yes |
`renderFollowButton` | Function | No | Optional render prop for the follow button
`showLinksOnAllBreakpoints` | Boolean | No | Defaults to true. Used to hide podcast app launchers on wide screen + desktop where the links do nothing because there is no app to launch.

Additional props such as the `conceptName` may be required by x-follow-button. Documentation for these is available over in the component's readme.
53 changes: 26 additions & 27 deletions components/x-podcast-launchers/src/PodcastLaunchers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,38 @@ class PodcastLaunchers extends Component {

render() {
const { rssUrl } = this.state;
const { conceptId, conceptName, csrfToken, isFollowed, renderFollowButton } = this.props
const { conceptId, conceptName, csrfToken, isFollowed, renderFollowButton, showLinksOnAllBreakpoints } = this.props
Copy link
Contributor

Choose a reason for hiding this comment

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

As per IRL chat, default showLinksOnAllBreakpoints to true

const followButton = typeof renderFollowButton === 'function' ? renderFollowButton : defaultFollowButtonRender;

return rssUrl && (
<div className={styles.container} data-trackable='podcast-launchers'>
<h2 className={styles.headingChooseApp}>Subscribe via your installed podcast app</h2>
<ul className={styles.podcastAppLinksWrapper}>
{generateAppLinks(rssUrl).map(({ name, url, trackingId }) => (
<li key={name}>
<a
href={url}
className={styles.podcastAppLink}
data-trackable={trackingId}>
{name}
</a>
</li>
))}

<li key='Rss Url' className={styles.rssUrlWrapper}>
<span className={rssUrlWrapperInner}>
<input value={rssUrl} type='text' readOnly/>
<button
className={styles.rssUrlCopyButton}
onClick={copyToClipboard}
data-url={rssUrl}
data-trackable='copy-rss'
type='button'>
Copy RSS
</button>
</span>
</li>
</ul>
<ul className={styles.podcastAppLinksWrapper}>
{generateAppLinks(rssUrl).map(({ name, url, trackingId }) => (
<li key={name} className={showLinksOnAllBreakpoints ? "" : styles.hidePodcastLinkAtWide}>
alicebartlett marked this conversation as resolved.
Show resolved Hide resolved
<a
href={url}
className={styles.podcastAppLink}
data-trackable={trackingId}>
{name}
</a>
</li>
))}

<li key='Rss Url' className={styles.rssUrlWrapper}>
<span className={rssUrlWrapperInner}>
<input value={rssUrl} type='text' readOnly/>
<button
className={styles.rssUrlCopyButton}
onClick={copyToClipboard}
data-url={rssUrl}
data-trackable='copy-rss'
type='button'>
Copy RSS
</button>
</span>
</li>
</ul>
<div className={noAppWrapperStyles}>
<h2 className={styles.headingNoApp}>Can’t see your podcast app?</h2>
<p className={styles.textNoApp}>Get updates for new episodes</p>
Expand Down
15 changes: 15 additions & 0 deletions components/x-podcast-launchers/src/PodcastLaunchers.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$o-typography-is-silent: true;
$o-grid-is-silent: true;
@import 'o-typography/main';
@import 'o-grid/main';

$o-forms-is-silent: true;
@import 'o-forms/main';
Expand Down Expand Up @@ -53,11 +55,24 @@ $o-buttons-is-silent: true;
margin: 0 0 24px;
}


/*
Hide podcast links at a wide screen width. We only do this when the running application
isn't the App so that on any native device you'll always be able to launch a podcast app
*/
.hidePodcastLinkAtWide {
@include oGridRespondTo(L) {
alicebartlett marked this conversation as resolved.
Show resolved Hide resolved
display: none;
}
}

.podcastAppLink {

@include oButtonsContent($opts: (
'type': 'primary',
'size': 'big',
));

width: 100%;
margin-top: 8px;
}
Expand Down
3 changes: 2 additions & 1 deletion components/x-podcast-launchers/stories/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ exports.data = {
isFollowed: false,
csrfToken: 'token',
acastRSSHost: 'https://access.acast.com',
acastAccessToken: 'abc-123'
acastAccessToken: 'abc-123',
showLinksOnAllBreakpoints: true,
};

// This reference is only required for hot module loading in development
Expand Down