Skip to content

Commit

Permalink
Update: Use Carbon.FileLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Feb 13, 2024
1 parent 870ee4d commit 90cdbbe
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 110 deletions.
29 changes: 29 additions & 0 deletions Resources/Private/Fusion/Helper/Assets.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
prototype(Jonnitto.PrettyEmbed:Assets) < prototype(Neos.Fusion:Component) {
@propTypes {
player = ${PropTypes.oneOf(['YouTube', 'Vimeo', 'Video', 'Audio']).isRequired}
gdprHandling = ${PropTypes.oneOf([true, false, 'popup'])}
includeAlpineJsCheck = ${PropTypes.boolean}
inBackend = ${PropTypes.boolean}
}

debug = ${Configuration.setting('Jonnitto.PrettyEmbed.debug')}
includeAssets = ${Configuration.setting('Jonnitto.PrettyEmbed.includeAssets')}
includeAlpineJsCheck = ${Configuration.setting('Jonnitto.PrettyEmbed.includeAlpineJsCheck')}
inBackend = ${node.context.inBackend && node.context.currentRenderingMode.edit}

// This decides which file to load
player = null

renderer = Carbon.FileLoader:Component {
package = 'Jonnitto.PrettyEmbedHelper'
css = ${props.includeAssets.css ? 'Main.css' : null}
js = ${[props.inBackend ? 'Backend.js' : null, props.debug ? 'Debug.js' : null]}
mjs = Neos.Fusion:DataStructure {
gdprPlugin = ${props.gdprHandling == true ? 'Consent.js' : null}
magicPlugin = ${props.player == 'Video' || props.player == 'Audio' || props.gdprHandling != 'Popup' ? 'Methods.js' : null}
popupPlugin = ${props.gdprHandling ? 'Popup.js' : null}
pluginBasedOnPlayer = ${props.player == 'Video' || props.player == 'Audio' ? 'Media.js' : (props.player + '.js')}
alpineJsCheck= ${props.includeAlpineJsCheck ? 'AlpineCheck.js' : null}
}
}
}
57 changes: 0 additions & 57 deletions Resources/Private/Fusion/Helper/Assets/Assets.fusion

This file was deleted.

14 changes: 0 additions & 14 deletions Resources/Private/Fusion/Helper/Assets/Fragment/Module.fusion

This file was deleted.

20 changes: 0 additions & 20 deletions Resources/Private/Fusion/Helper/Assets/Fragment/Script.fusion

This file was deleted.

12 changes: 0 additions & 12 deletions Resources/Private/Fusion/Helper/Assets/Fragment/Style.fusion

This file was deleted.

11 changes: 10 additions & 1 deletion Resources/Private/Fusion/Presentation/Audio.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Audio) < prototype(Neos.Fusion:Compo

@if.checkAudio = ${this.content}

// @internal Move to @private if minimal Neos requirement is 8.3 or higher
_fileLoader = ${{debug: this.debug}}
[email protected] = Jonnitto.PrettyEmbed:Assets {
player = 'Audio'
debug = ${value.debug}
}
_fileLoaderAsAttributes = ${!Type.isString(this._fileLoader)}

renderer = afx`
<Jonnitto.PrettyEmbed:Presenation.Wrapper wrapper={props.wrapper}>
<div
Expand All @@ -31,8 +39,9 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Audio) < prototype(Neos.Fusion:Compo
aria-label={props.label}
id={props.id}
class={Carbon.String.merge(props.class, BEM.modifier('jonnitto-prettyembed', 'audio'))}
{...(props._fileLoaderAsAttributes ? props._fileLoader : {})}
>
<Jonnitto.PrettyEmbed:Assets player="Audio" debug={props.debug} />
{props._fileLoaderAsAttributes ? '' : props._fileLoader}
{props.customControls}
<audio
x-prettyembedmedia:media
Expand Down
16 changes: 11 additions & 5 deletions Resources/Private/Fusion/Presentation/Components/Iframe.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Iframe) < prototype(Neos.Fusion:Comp
checkYouTube = ${this.player == 'YouTube' ? (this.videoID && this.href && this.embedHref) : true}
checkPreviewImage = ${this.poster || this.preview}
}

// @internal Move to @private if minimal Neos requirement is 8.3 or higher
_alwaysOpenInPopup = ${this.gdprHandling == 'popup'}
_fileLoader = ${{debug: this.debug, player: this.player, gdprHandling: this.gdprHandling}}
[email protected] = Jonnitto.PrettyEmbed:Assets {
player = ${value.player}
gdprHandling = ${value.gdprHandling}
debug = ${value.debug}
}
_fileLoaderAsAttributes = ${!Type.isString(this._fileLoader)}

renderer = afx`
<Jonnitto.PrettyEmbed:Presenation.Wrapper wrapper={props.wrapper}>
Expand Down Expand Up @@ -78,12 +87,9 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Iframe) < prototype(Neos.Fusion:Comp
id={props.id}
class={Carbon.String.merge(props.class, BEM.modifier('jonnitto-prettyembed', String.toLowerCase(props.player)), props.setAspectRatioClass && 'jonnitto-prettyembed-ratio')}
style={props.aspectRatio ? '--aspect-ratio:' + props.aspectRatio : null}
{...(props._fileLoaderAsAttributes ? props._fileLoader : {})}
>
<Jonnitto.PrettyEmbed:Assets
player={props.player}
gdprHandling={props.gdprHandling}
debug={props.debug}
/>
{props._fileLoaderAsAttributes ? '' : props._fileLoader}
<Jonnitto.PrettyEmbed:Presentation.Button.Play
@if={!props._alwaysOpenInPopup}
show={props.controls ? "!loaded" : "!playing"}
Expand Down
12 changes: 11 additions & 1 deletion Resources/Private/Fusion/Presentation/Video.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Video) < prototype(Neos.Fusion:Compo
{props.streaming ? '' : props.content}
</video>
`

// @internal Move to @private if minimal Neos requirement is 8.3 or higher
_fileLoader = Jonnitto.PrettyEmbed:Assets {
player = 'Video'
debug = ${props.debug}
}
_fileLoaderAsAttributes = ${!Type.isString(this._fileLoader)}


renderer = afx`
<Jonnitto.PrettyEmbed:Presenation.Wrapper wrapper={props.wrapper}>
<div
Expand All @@ -73,8 +82,9 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Video) < prototype(Neos.Fusion:Compo
aria-label={props.label}
id={props.id}
class={Carbon.String.merge(props.class, BEM.modifier('jonnitto-prettyembed', 'video'))}
{...(props._fileLoaderAsAttributes ? props._fileLoader : {})}
>
<Jonnitto.PrettyEmbed:Assets player="Video" debug={props.debug} />
{props._fileLoaderAsAttributes ? '' : props._fileLoader}
<Jonnitto.PrettyEmbed:Presentation.Preview
show={props.lightbox ? null : '!loaded'}
content={props.preview}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"neos/neos": "^7.3 || ^8.0",
"neos/fusion-afx": "^7.3 || ^8.0",
"sitegeist/slipstream": "^2.1.6",
"carbon/fileloader": "^0.1",
"carbon/notification": "^2.4",
"carbon/eel": "^2.8"
},
Expand Down

0 comments on commit 90cdbbe

Please sign in to comment.