Ghost/ghost/admin/app/components/gh-tenor.hbs
Kevin Ansfield a9ae15b1a5 Added responsive column count to gif selector
refs https://github.com/TryGhost/Team/issues/1220

- added resize observer and cut-off widths for number of columns to auto-adjust based on the size of the selector's container
- fixed error when tenor service is unavailable due to missing `retry` action
2021-11-15 14:27:22 +00:00

95 lines
4.9 KiB
Handlebars

{{!-- TODO: switch to {{css-transition}}? --}}
<LiquidWormhole @class="unsplash">
{{!-- TODO: why does this modal background not cover the PSM without style override? --}}
<div class="fullscreen-modal-background" style="z-index: 999" {{on "click" @close}}></div>
<div class="absolute top-8 right-8 bottom-8 left-8 br4 overflow-hidden bg-white z-9999" {{on-key "Escape" this.handleEscape}} {{did-insert this.postInsertSetup}} data-tenor>
{{!-- close button --}}
<button type="button" class="absolute top-6 right-6" {{on "click" @close}}>
{{svg-jar "close" class="w4 stroke-midlightgrey-l2"}}
</button>
<div class="flex flex-column h-100">
{{!-- static header --}}
<header class="flex-shrink-0 flex flex-row-l flex-column justify-between pt6 pr8 pb6 pl8 pt10-l pr20-l pb10-l pl20-l items-center">
<h1 class="flex items-center darkgrey-d2 w-100 nudge-top--4">
<a class="dib w-30 mr2" href="https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit" target="_blank">
{{svg-jar "powered-by-tenor"}}
</a>
</h1>
<span class="gh-input-icon mw88-l flex-auto w-100 mt3 mt0-l">
{{svg-jar "search"}}
<GhTextInput
@class="gh-unsplash-search"
@name="searchKeyword"
@placeholder="Search Tenor"
@tabindex="1"
@shouldFocus={{true}}
@autocorrect="off"
@value={{readonly this.tenor.searchTerm}}
@input={{this.search}}
/>
</span>
</header>
{{!-- content container --}}
<div class="relative h-100 overflow-hidden">
{{!-- scrollable image container --}}
<div class="overflow-auto h-100 w-100 pr8 pl8 pr20-l pl20-l">
{{#if this.tenor.gifs}}
<section class="gh-unsplash-grid">
{{#each this.tenor.columns as |gifs|}}
<div class="gh-unsplash-grid-column">
{{#each gifs as |gif|}}
<GhTenor::Gif
@gif={{gif}}
@zoom={{fn this.zoom gif}}
@select={{fn this.select gif}} />
{{/each}}
</div>
{{/each}}
</section>
{{else if (and this.tenor.searchTerm (not this.tenor.error this.tenor.isLoading))}}
<section class="gh-unsplash-error h-100 flex items-center justify-center pb30">
<div>
<img class="gh-unsplash-error-404" src="assets/img/unsplash-404.png" alt="No photos found" />
<h4>No gifs found for '{{this.tenor.searchTerm}}'</h4>
</div>
</section>
{{/if}}
{{#if this.tenor.error}}
<section class="gh-unsplash-error h-100 flex items-center justify-center pb30">
<div>
<img class="gh-unsplash-error-404" src="assets/img/unsplash-404.png" alt="Network error" />
<h4>{{this.tenor.error}} (<a href="#" {{on "click" this.tenor.retry}}>retry</a>)</h4>
</div>
</section>
{{/if}}
{{#if this.tenor.isLoading}}
<div class="gh-unsplash-loading h-100 flex items-center justify-center pb30">
<div class="gh-loading-spinner"></div>
</div>
{{/if}}
{{#unless this.tenor.isLoading}}
<GhScrollTrigger
@enter={{this.tenor.loadNextPage}}
@triggerOffset={{1000}} />
{{/unless}}
</div>
{{!-- zoomed image overlay --}}
{{#if this.zoomedGif}}
<div class="absolute flex justify-center top-0 right-0 bottom-0 left-0 pr20 pb10 pl20 bg-white overflow-hidden" {{on "click" this.closeZoom}}>
<GhTenor::Gif
@gif={{this.zoomedGif}}
@zoomed={{true}}
@zoom={{this.closeZoom}}
@select={{fn this.select this.zoomedGif}} />
</div>
{{/if}}
</div>
</div>
</div>
</LiquidWormhole>