-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add ability to dock player to top or bottom of page #331
Open
wadebekker
wants to merge
1
commit into
develop
Choose a base branch
from
feature/dock-player-position
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -70,7 +70,8 @@ function Edit( props ) { | |||||
displayExplicitBadge, | ||||||
displaySeasonNumber, | ||||||
displayEpisodeNumber, | ||||||
displayEpisodeType | ||||||
displayEpisodeType, | ||||||
isDocked, | ||||||
} = attributes; | ||||||
|
||||||
const duration = attributes.duration || ''; | ||||||
|
@@ -185,6 +186,53 @@ function Edit( props ) { | |||||
setFeaturedImage(image.id); | ||||||
}; | ||||||
|
||||||
// Docked Player | ||||||
const dockedClass = isDocked !== 'none' ? `docked-${isDocked}` : ''; | ||||||
const [showPodcastMeta, setShowPodcastMeta] = useState(false); | ||||||
const [isDisplayingSettings, setIsDisplayingSettings] = useState(false); | ||||||
|
||||||
const checkDisplaySettings = () => { | ||||||
if (displayDuration || displayShowTitle || | ||||||
// displayEpisodeTitle || | ||||||
// displayArt || | ||||||
Comment on lines
+196
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the commented out code.
Suggested change
|
||||||
displayExplicitBadge || displaySeasonNumber || displayEpisodeNumber || displayEpisodeType) { | ||||||
setIsDisplayingSettings(true); | ||||||
} | ||||||
else { | ||||||
setIsDisplayingSettings(false); | ||||||
} | ||||||
} | ||||||
|
||||||
// If the user changes one of the toggles, the checkDisplaySettings function will be called to check if any of the display settings are enabled. | ||||||
// If at least one of the display settings are enabled, then we want to show the More/Less button. | ||||||
useEffect(() => { | ||||||
checkDisplaySettings(); | ||||||
}, [displayDuration, | ||||||
displayShowTitle, | ||||||
// displayEpisodeTitle, | ||||||
// displayArt, | ||||||
Comment on lines
+212
to
+213
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
displayExplicitBadge, | ||||||
displaySeasonNumber, | ||||||
displayEpisodeNumber, | ||||||
displayEpisodeType]) | ||||||
|
||||||
// Reset the More/Less button when the user docks or undocks the player. | ||||||
useEffect(() => { | ||||||
setShowPodcastMeta(false) | ||||||
}, [isDocked]) | ||||||
|
||||||
useEffect(() => { | ||||||
// Remove any existing classes | ||||||
document.body.classList.remove('has-docked-top', 'has-docked-bottom', 'docked-in-editor'); | ||||||
|
||||||
// Add the appropriate class based on the isDocked value | ||||||
if (isDocked === 'top') { | ||||||
document.body.classList.add('has-docked-top', 'docked-in-editor'); | ||||||
} else if (isDocked === 'bottom') { | ||||||
document.body.classList.add('has-docked-bottom', 'docked-in-editor'); | ||||||
} | ||||||
}, [isDocked]); // Run this effect when isDocked changes | ||||||
|
||||||
return ( | ||||||
<Fragment> | ||||||
{controls} | ||||||
|
@@ -285,7 +333,33 @@ function Edit( props ) { | |||||
'simple-podcasting' | ||||||
)} | ||||||
checked={displayEpisodeType} | ||||||
onChange={() => setAttributes({ displayEpisodeType: !displayEpisodeType})} | ||||||
onChange={() => setAttributes({ displayEpisodeType: !displayEpisodeType })} | ||||||
/> | ||||||
</PanelRow> | ||||||
<PanelRow> | ||||||
<RadioControl | ||||||
label={__('Dock Player', 'simple-podcasting')} | ||||||
selected={isDocked} | ||||||
options={[ | ||||||
{ | ||||||
label: __('None', 'simple-podcasting'), | ||||||
value: 'none', | ||||||
}, | ||||||
{ | ||||||
label: __('Top', 'simple-podcasting'), | ||||||
value: 'top', | ||||||
}, | ||||||
{ | ||||||
label: __( | ||||||
'Bottom', | ||||||
'simple-podcasting' | ||||||
), | ||||||
value: 'bottom', | ||||||
}, | ||||||
]} | ||||||
onChange={(isDocked) => | ||||||
setAttributes({ isDocked }) | ||||||
} | ||||||
/> | ||||||
</PanelRow> | ||||||
<PanelRow> | ||||||
|
@@ -420,7 +494,7 @@ function Edit( props ) { | |||||
</PanelRow> | ||||||
</PanelBody> | ||||||
</InspectorControls> | ||||||
<div className="wp-block-podcasting-podcast-outer"> | ||||||
<div className={`wp-block-podcasting-podcast-outer ${dockedClass}`}> | ||||||
{src ? ( | ||||||
<> | ||||||
<div className="wp-block-podcasting-podcast__container"> | ||||||
|
@@ -448,76 +522,109 @@ function Edit( props ) { | |||||
</h3> | ||||||
)} | ||||||
|
||||||
<div className="wp-block-podcasting-podcast__show-details"> | ||||||
{displayShowTitle && ( | ||||||
<span className="wp-block-podcasting-podcast__title"> | ||||||
{showName} | ||||||
</span> | ||||||
)} | ||||||
{displaySeasonNumber && seasonNumber && ( | ||||||
<span className="wp-block-podcasting-podcast__season"> | ||||||
{__( | ||||||
'Season: ', | ||||||
'simple-podcasting' | ||||||
{(isDocked === 'none' || showPodcastMeta) && ( | ||||||
<> | ||||||
<div className="wp-block-podcasting-podcast__show-details"> | ||||||
{displayShowTitle && ( | ||||||
<span className="wp-block-podcasting-podcast__title"> | ||||||
{showName} | ||||||
</span> | ||||||
)} | ||||||
{seasonNumber} | ||||||
</span> | ||||||
)} | ||||||
{displayEpisodeNumber && episodeNumber && ( | ||||||
<span className="wp-block-podcasting-podcast__episode"> | ||||||
{__('Episode: ', 'simple-podcasting')} | ||||||
{episodeNumber} | ||||||
</span> | ||||||
)} | ||||||
</div> | ||||||
|
||||||
<div className="wp-block-podcasting-podcast__show-details"> | ||||||
{displayDuration && duration && ( | ||||||
<span className="wp-block-podcasting-podcast__duration"> | ||||||
{__('Listen Time: ', 'simple-podcasting')} | ||||||
{duration} | ||||||
</span> | ||||||
)} | ||||||
{displayEpisodeType && (episodeType !== 'none') && ( | ||||||
<span className="wp-block-podcasting-podcast__episode-type"> | ||||||
{__( | ||||||
'Episode type: ', | ||||||
'simple-podcasting' | ||||||
{displaySeasonNumber && seasonNumber && ( | ||||||
<span className="wp-block-podcasting-podcast__season"> | ||||||
{__( | ||||||
'Season: ', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
{seasonNumber} | ||||||
</span> | ||||||
)} | ||||||
{episodeType} | ||||||
</span> | ||||||
)} | ||||||
{displayExplicitBadge && ( | ||||||
<span className="wp-block-podcasting-podcast__explicit-badge"> | ||||||
{__( | ||||||
'Explicit: ', | ||||||
'simple-podcasting' | ||||||
{displayEpisodeNumber && episodeNumber && ( | ||||||
<span className="wp-block-podcasting-podcast__episode"> | ||||||
{__('Episode: ', 'simple-podcasting')} | ||||||
{episodeNumber} | ||||||
</span> | ||||||
)} | ||||||
{explicit} | ||||||
</span> | ||||||
)} | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<div className="wp-block-podcasting-podcast__show-details"> | ||||||
{displayDuration && duration && ( | ||||||
<span className="wp-block-podcasting-podcast__duration"> | ||||||
{__('Listen Time: ', 'simple-podcasting')} | ||||||
{duration} | ||||||
</span> | ||||||
)} | ||||||
{displayEpisodeType && (episodeType !== 'none') && ( | ||||||
<span className="wp-block-podcasting-podcast__episode-type"> | ||||||
{__( | ||||||
'Episode type: ', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
{episodeType} | ||||||
</span> | ||||||
)} | ||||||
{displayExplicitBadge && ( | ||||||
<span className="wp-block-podcasting-podcast__explicit-badge"> | ||||||
{__( | ||||||
'Explicit: ', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
{explicit} | ||||||
</span> | ||||||
)} | ||||||
</div> | ||||||
</> | ||||||
)} | ||||||
|
||||||
{isDocked !== 'none' && isDisplayingSettings && ( | ||||||
<button onClick={() => setShowPodcastMeta(!showPodcastMeta)} id="toggle-details-button"> | ||||||
{showPodcastMeta ? 'Less' : 'More'} | ||||||
</button> | ||||||
)} | ||||||
|
||||||
{isDocked !== 'none' && ( | ||||||
<figure key="audio" className={className}> | ||||||
{((caption && caption.length) || !!isSelected) && ( | ||||||
<RichText | ||||||
tagName="figcaption" | ||||||
placeholder={__( | ||||||
'Write caption…', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
className="wp-block-podcasting-podcast__caption" | ||||||
value={caption} | ||||||
onChange={(value) => | ||||||
setAttributes({ caption: value }) | ||||||
} | ||||||
isSelected={isSelected} | ||||||
/> | ||||||
)} | ||||||
<audio controls="controls" src={src} /> | ||||||
</figure> | ||||||
)} | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<figure key="audio" className={className}> | ||||||
{((caption && caption.length) || !!isSelected) && ( | ||||||
<RichText | ||||||
tagName="figcaption" | ||||||
placeholder={__( | ||||||
'Write caption…', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
className="wp-block-podcasting-podcast__caption" | ||||||
value={caption} | ||||||
onChange={(value) => | ||||||
setAttributes({ caption: value }) | ||||||
} | ||||||
isSelected={isSelected} | ||||||
/> | ||||||
)} | ||||||
<audio controls="controls" src={src} /> | ||||||
</figure> | ||||||
{isDocked === 'none' && ( | ||||||
<figure key="audio" className={className}> | ||||||
{((caption && caption.length) || !!isSelected) && ( | ||||||
<RichText | ||||||
tagName="figcaption" | ||||||
placeholder={__( | ||||||
'Write caption…', | ||||||
'simple-podcasting' | ||||||
)} | ||||||
className="wp-block-podcasting-podcast__caption" | ||||||
value={caption} | ||||||
onChange={(value) => | ||||||
setAttributes({ caption: value }) | ||||||
} | ||||||
isSelected={isSelected} | ||||||
/> | ||||||
)} | ||||||
<audio controls="controls" src={src} /> | ||||||
</figure> | ||||||
)} | ||||||
</> | ||||||
) : ( | ||||||
<MediaPlaceholder | ||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new code in this file uses tabs for intending, whereas the existing code is using spaces. Are you able to switch to spaces for consistency.