0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Converted <GhSiteIframe> to a glimmer component

no issue

- updated to class syntax and glimmer component behaviour
- tidied up and standardised usage of the component
This commit is contained in:
Kevin Ansfield 2021-05-18 16:08:03 +01:00
parent 11be983d99
commit b4a6eb594d
4 changed files with 23 additions and 24 deletions

View file

@ -1 +1,8 @@
<iframe id="site-frame" class="site-frame {{this.classNames}}" src={{this.srcUrl}} frameborder="0" allowtransparency="true" ...attributes></iframe>
<iframe
class="site-frame"
src={{this.srcUrl}}
frameborder="0"
allowtransparency="true"
{{did-update this.resetSrcAttribute @guid}}
...attributes
></iframe>

View file

@ -1,26 +1,23 @@
import Component from '@ember/component';
import {computed} from '@ember/object';
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default Component.extend({
config: service(),
export default class GhSiteIframeComponent extends Component {
@service config;
tagName: '',
get srcUrl() {
return this.args.src || `${this.config.get('blogUrl')}/`;
}
srcUrl: computed('src', function () {
return this.src || `${this.config.get('blogUrl')}/`;
}),
didReceiveAttrs() {
@action
resetSrcAttribute(iframe) {
// reset the src attribute each time the guid changes - allows for
// a click on the navigation item to reset back to the homepage
if ((this.guid !== this._lastGuid) || (this.src !== this._lastSrc)) {
let iframe = document.querySelector('#site-frame');
if (this.args.guid !== this._lastGuid) {
if (iframe) {
iframe.src = this.src || `${this.config.get('blogUrl')}/`;
iframe.src = this.srcUrl;
}
}
this._lastGuid = this.guid;
this._lastSrc = this.src;
this._lastGuid = this.args.guid;
}
}
});

View file

@ -242,10 +242,8 @@
<div class="gh-portal-preview-container {{if this.showLinksPage "hide"}}">
<div class="gh-portal-site-frame-cover"> </div>
<GhSiteIframe
@guid="portal-preview-site"
@src={{this.portalPreviewUrl}}
@classNames="gh-portal-siteiframe {{if this.hidePreviewFrame "invisible"}}"
></GhSiteIframe>
class="gh-portal-siteiframe {{if this.hidePreviewFrame "invisible"}}" />
</div>
</div>

View file

@ -51,10 +51,7 @@
{{#if (eq this.settings.membersSignupAccess 'none')}}
PORTAL DISABLED
{{else}}
<GhSiteIframe
@src={{this.portalPreviewUrl}}
@classNames="{{if this.hidePreviewFrame "invisible"}}"
></GhSiteIframe>
<GhSiteIframe @src={{this.portalPreviewUrl}} />
{{/if}}
</div>
</div>