-
Notifications
You must be signed in to change notification settings - Fork 17
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
Showing
12 changed files
with
267 additions
and
32 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
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
131 changes: 131 additions & 0 deletions
131
src/components/Document/DocumentDownloadPopover/DocumentDownloadPopover.vue
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,131 @@ | ||
<script setup> | ||
import { computed } from 'vue' | ||
import { PhosphorIcon } from '@icij/murmur-next' | ||
import { useI18n } from 'vue-i18n' | ||
import DocumentDownloadPopoverSection from './DocumentDownloadPopoverSection' | ||
import DisplayContentType from '@/components/Display/DisplayContentType' | ||
const props = defineProps({ | ||
/** | ||
* The selected document | ||
*/ | ||
document: { | ||
type: Object | ||
}, | ||
/** | ||
* The target element | ||
*/ | ||
target: { | ||
type: Object | ||
}, | ||
/** | ||
* Toggle value when the popover is open | ||
*/ | ||
modelValue: { | ||
type: Boolean | ||
}, | ||
/** | ||
* True if the popover is open manually | ||
*/ | ||
manual: { | ||
type: Boolean | ||
}, | ||
/** | ||
* Disable auto close | ||
*/ | ||
noAutoClose: { | ||
type: Boolean | ||
}, | ||
/** | ||
* The placement of the popover | ||
*/ | ||
placement: { | ||
type: String | ||
} | ||
}) | ||
const { locale, t } = useI18n() | ||
const extensionWarning = computed(() => { | ||
const { standardExtension: extension } = props.document | ||
return t('documentDownloadPopover.extensionWarning', { extension }) | ||
}) | ||
const description = computed(() => { | ||
const descriptions = props.document.contentTypeDescription ?? {} | ||
const description = descriptions[locale.value] || descriptions.en | ||
return props.document.hasStandardExtension ? description : `${description} <strong>${extensionWarning.value}</strong>` | ||
}) | ||
const executionWarning = computed(() => { | ||
const warnings = props.document.contentTypeWarning ?? {} | ||
return warnings[locale.value] || warnings.en | ||
}) | ||
</script> | ||
<template> | ||
<b-popover | ||
teleport-to="body" | ||
:target="target" | ||
:manual="manual" | ||
:model-value="modelValue" | ||
:no-auto-close="noAutoClose" | ||
:placement="placement" | ||
custom-class="document-download-popover" | ||
@update:modelValue="$emit('update:modelValue')" | ||
> | ||
<div class="document-download-popover__body"> | ||
<icon-button icon-left="download-simple" label="Download" class="document-download-popover__body__button" /> | ||
<icon-button | ||
icon-left="download-simple" | ||
label="Download without metadata" | ||
variant="outline-primary" | ||
class="document-download-popover__body__button" | ||
/> | ||
<icon-button | ||
icon-left="download-simple" | ||
label="Download extract text" | ||
variant="outline-primary" | ||
class="document-download-popover__body__button" | ||
/> | ||
<div class="document-download-popover__body__sections pt-3"> | ||
<document-download-popover-section title="What's the document's title?" :value="document.title" /> | ||
<document-download-popover-section title="What's the document's type"> | ||
<phosphor-icon :name="document.contentTypeIcon" class="me-2" /> | ||
<display-content-type :value="document.contentType" /> | ||
</document-download-popover-section> | ||
<document-download-popover-section | ||
v-if="description" | ||
title="Once downloaded, how do I open it ?" | ||
:value="description" | ||
/> | ||
</div> | ||
</div> | ||
</b-popover> | ||
</template> | ||
<style lang="scss"> | ||
.document-download-popover { | ||
width: 100%; | ||
&__body { | ||
display: flex; | ||
flex-direction: column; | ||
gap: $spacer-sm; | ||
&__button { | ||
white-space: nowrap; | ||
align-self: flex-start; | ||
} | ||
&__sections { | ||
margin-top: $spacer; | ||
display: flex; | ||
flex-direction: column; | ||
gap: $spacer-xl; | ||
} | ||
} | ||
} | ||
</style> |
21 changes: 21 additions & 0 deletions
21
src/components/Document/DocumentDownloadPopover/DocumentDownloadPopoverSection.vue
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,21 @@ | ||
<script setup> | ||
defineProps({ | ||
title: { | ||
type: String | ||
}, | ||
value: { | ||
type: String | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<section class="document-download-popover-section"> | ||
<div class="document-download-popover-section__title pb-2 text-tertiary-emphasis fst-italic"> | ||
{{ title }} | ||
</div> | ||
<div class="document-download-popover-section__value text-primary-emphasis"> | ||
<slot><span v-html="value"></span></slot> | ||
</div> | ||
</section> | ||
</template> |
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
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
51 changes: 29 additions & 22 deletions
51
src/stories/components/Document/DocumentActionsGroup/DocumentActionsGroup.stories.js
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 |
---|---|---|
@@ -1,37 +1,44 @@ | ||
import IconButton from '@/components/IconButton' | ||
import { markRaw } from 'vue' | ||
import { PhFilePdf } from '@phosphor-icons/vue' | ||
|
||
import types from '@/utils/types.json' | ||
import DocumentActionsGroup from '@/components/Document/DocumentActionsGroup/DocumentActionsGroup' | ||
|
||
export default { | ||
components: { DocumentActionsGroup }, | ||
title: 'Components/Document/DocumentActionsGroup', | ||
component: IconButton, | ||
component: DocumentActionsGroup, | ||
tags: ['autodocs'], | ||
render: (args) => ({ | ||
components: { | ||
DocumentActionsGroup | ||
}, | ||
setup() { | ||
return { | ||
args | ||
} | ||
}, | ||
template: ` | ||
<document-actions-group v-bind="args" > | ||
</document-actions-group> | ||
` | ||
}) | ||
} | ||
|
||
export const Default = { | ||
args: { | ||
document: { | ||
id: 'test' | ||
id: '5f5b3b3b-7b3b-4b3b-8b3b-3b3b3b3b3b3b', | ||
title: 'Inter IKEA Investment S.à r.l._cover letter 2010-2011 tax returns.pdf', | ||
extractionLevel: 0, | ||
project: 'banana-papers', | ||
creationDate: new Date(), | ||
inlineFullUrl: 'https://i.imgur.com/ns9ThQx.jpeg', | ||
path: '/vault/ns9ThQx.jpeg', | ||
tags: ['foo', 'bar', 'baz'], | ||
language: 'ENGLISH', | ||
contentLength: 23e4, | ||
contentTextLength: 14e3, | ||
isSupportedImage: true, | ||
highlights: [ | ||
'Lorem ispum dolor sit <mark>IKEA</mark> amet.', | ||
'Consectetur <mark>IKEA</mark> adipiscing elit.', | ||
'Sed do eiusmod tempor incididunt ut labore et <mark>IKEA</mark> dolore magna aliqua.' | ||
], | ||
contentType: 'application/pdf', | ||
contentTypeDescription: types['application/pdf'].description, | ||
contentTypeIcon: markRaw(PhFilePdf) | ||
}, | ||
vertical: false, | ||
tooltipPlacement: 'top', | ||
tooltipPlacement: 'bottom', | ||
isStarred: false, | ||
isDownloadAllowed: false, | ||
isDownloadAllowed: true, | ||
selectMode: true, | ||
selected: false | ||
} | ||
} | ||
|
||
export const Default = {} |
58 changes: 58 additions & 0 deletions
58
src/stories/components/Document/DocumentDownloadPopover/DocumentDownloadPopover.stories.js
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,58 @@ | ||
import { markRaw } from 'vue' | ||
import { PhFile, PhFilePdf } from '@phosphor-icons/vue' | ||
|
||
import DocumentDownloadPopover from '@/components/Document/DocumentDownloadPopover/DocumentDownloadPopover' | ||
import types from '@/utils/types.json' | ||
|
||
export default { | ||
component: DocumentDownloadPopover, | ||
title: 'Components/Document/DocumentDownloadPopover/DocumentDownloadPopover', | ||
tags: ['autodocs'], | ||
args: { | ||
document: { | ||
id: 'foo', | ||
title: 'Inter IKEA Investment S.à r.l._cover letter 2010-2011 tax returns.pdf', | ||
standardExtension: 'pdf', | ||
hasStandardExtension: true, | ||
contentType: 'application/pdf', | ||
contentTypeDescription: types['application/pdf'].description, | ||
contentTypeIcon: markRaw(PhFilePdf) | ||
} | ||
}, | ||
render: (args) => ({ | ||
components: { | ||
DocumentDownloadPopover | ||
}, | ||
setup: () => ({ args }), | ||
computed: { | ||
trigger() { | ||
return `btn-${this.$.uid}` | ||
} | ||
}, | ||
template: ` | ||
<div class="p-sm-5 p-3 text-center"> | ||
<button type="button" class="btn btn-outline-secondary" :id="trigger"> | ||
Hover me | ||
</button> | ||
<document-download-popover v-bind="args" :target="trigger" /> | ||
</div> | ||
` | ||
}) | ||
} | ||
|
||
export const Default = {} | ||
|
||
export const WithWarning = { | ||
args: { | ||
document: { | ||
id: 'bar', | ||
title: 'Inter IKEA Investment S.à r.l._cover letter 2010-2011 tax returns.txt', | ||
contentType: 'text/html', | ||
standardExtension: 'html', | ||
hasStandardExtension: false, | ||
contentTypeDescription: types['text/html'].description, | ||
contentTypeWarning: types['text/html'].warning, | ||
contentTypeIcon: markRaw(PhFile) | ||
} | ||
} | ||
} |
Oops, something went wrong.