-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2ee5cf
commit f896522
Showing
5 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<template> | ||
<div | ||
class="k-default-file-preview k-pdf-file-preview" | ||
:data-supported="supported" | ||
> | ||
<object | ||
:data="url" | ||
type="application/pdf" | ||
class="k-pdf-file-preview-object" | ||
> | ||
<k-file-preview-frame> | ||
<a :href="url"> | ||
<k-icon | ||
:color="$helper.color(image.color)" | ||
:type="image.icon" | ||
class="k-item-icon" | ||
/> | ||
</a> | ||
</k-file-preview-frame> | ||
</object> | ||
|
||
<k-file-preview-details :details="details" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
/** | ||
* File view preview for PDF documents | ||
* @since 5.0.0 | ||
*/ | ||
export default { | ||
props: { | ||
details: Array, | ||
image: { | ||
default: () => ({}), | ||
type: Object | ||
}, | ||
url: String | ||
}, | ||
computed: { | ||
supported() { | ||
return window.navigator.pdfViewerEnabled; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
.k-pdf-file-preview[data-supported="true"] { | ||
grid-template-columns: 1fr; | ||
} | ||
.k-pdf-file-preview .k-pdf-file-preview-object { | ||
width: 100%; | ||
} | ||
.k-pdf-file-preview[data-supported="true"] .k-pdf-file-preview-object { | ||
aspect-ratio: 1/1; | ||
} | ||
@container (min-width: 36rem) { | ||
.k-pdf-file-preview[data-supported="true"] .k-pdf-file-preview-object { | ||
aspect-ratio: 3/2; | ||
} | ||
} | ||
@container (min-width: 60rem) { | ||
.k-pdf-file-preview[data-supported="true"] { | ||
grid-template-columns: 70% auto; | ||
} | ||
.k-pdf-file-preview[data-supported="true"] .k-pdf-file-preview-object { | ||
aspect-ratio: 5/3; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Kirby\Panel\Ui\FilePreviews; | ||
|
||
use Kirby\Cms\File; | ||
use Kirby\Panel\Ui\FilePreview; | ||
|
||
/** | ||
* @package Kirby Panel | ||
* @author Nico Hoffmann <[email protected]> | ||
* @link https://getkirby.com | ||
* @copyright Bastian Allgeier | ||
* @license https://getkirby.com/license | ||
* @since 5.0.0 | ||
* @internal | ||
*/ | ||
class PdfFilePreview extends FilePreview | ||
{ | ||
public function __construct( | ||
public File $file, | ||
public string $component = 'k-pdf-file-preview' | ||
) { | ||
} | ||
|
||
public static function accepts(File $file): bool | ||
{ | ||
return $file->extension() === 'pdf'; | ||
} | ||
} |