Skip to content

Commit

Permalink
fix(resources): hide PDF embed on iOS
Browse files Browse the repository at this point in the history
Because of a bug with Safari iOS that shows only the first page of PDFs
  • Loading branch information
davidsandoz committed May 25, 2024
1 parent 482a52e commit 821f37f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion components/resources/st-resource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
</h2>
<st-resource-details :resource="resource" />

<st-button v-if="resource.file" class="c-resource__download-button" primary :href="href" :download="download">
<st-button
v-if="resource.file"
class="c-resource__download-button"
primary
:href="`${href}?download`"
:download="download"
>
{{ $t('resources.download') }}
</st-button>

Expand Down Expand Up @@ -62,5 +68,14 @@ a.c-resource__link-button {
.c-resource__embed {
height: 80vh;
margin-top: var(--st-length-spacing-s);
border: 1px solid black;
}
/* Hack to target iOS devices only */
@supports (-webkit-touch-callout: none) {
/* We hide the PDF embed on iOS because it shows only the first page */
.c-resource__embed {
display: none;
}
}
</style>
2 changes: 1 addition & 1 deletion mixins/resource.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineComponent({
computed: {
href(): string | undefined {
if (this.resource.file) {
return `${this.$config.cmsURL}/assets/${this.resource.file.id}?download`;
return `${this.$config.cmsURL}/assets/${this.resource.file.id}`;
} else if (this.resource?.link) {
return this.resource.link;
} else {
Expand Down

0 comments on commit 821f37f

Please sign in to comment.