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

View file

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

View file

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