Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Added iconUrl to oc-file element #678

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/678
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Added iconUrl to oc-file element

The oc-file element now supports passing an arbitrary URL to be displayed as a file thumbnail.
It will fall back to the icon name in case the thumbnail could not be loaded.

https://github.com/owncloud/owncloud-design-system/pull/678

Binary file added src/assets/examples/lorem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions src/elements/OcFile.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<span class="oc-file" @click="onClick" role="button">
<oc-icon :name="icon" variation="file-type" class="uk-position-center-left" />
<oc-icon :name="icon" :url="iconUrl" variation="file-type" class="uk-position-center-left" />
<span class="oc-file-name" v-text="name" /><span v-if="extension" class="oc-file-extension"
>.{{ extension }}</span
>
Expand All @@ -16,13 +16,24 @@ export default {
release: "1.0.0",
props: {
/**
* The icon to be used.
* The icon name to be used.
*/
icon: {
type: String,
required: false,
default: "folder",
},
/**
* Icon URL.
*
* Has higher priority than icon name.
* In case of failure it will fall back to the icon name if set.
*/
iconUrl: {
type: String,
required: false
},

/**
* The name of a file.
* Please note that the name shall not hold the extension
Expand Down Expand Up @@ -78,6 +89,17 @@ export default {
<li>
</li>
</ul>
<h3 class="uk-heading-divider">
Icon URL examples
</h3>
<ul class="uk-list">
<li>
<oc-file icon="image" iconUrl="examples/lorem.png" name="file with preview" extension="jpg" />
</li>
<li>
<oc-file icon="image" iconUrl="examples/notfound.png" name="file with preview that failed to load" extension="jpg" />
</li>
</ul>
<h3 class="uk-heading-divider">
Interactions
</h3>
Expand Down