-
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
14 changed files
with
387 additions
and
0 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,69 @@ | ||
<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')" | ||
> | ||
<entity-popover-tabs v-bind="mentionTabsProps" /> | ||
</b-popover> | ||
</template> | ||
<script setup> | ||
import { computed } from 'vue' | ||
import EntityPopoverTabs from '@/components/EntityPopover/EntityPopoverTabs' | ||
const props = defineProps({ | ||
/** | ||
* 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 | ||
}, | ||
mention: { type: String }, | ||
excerpt: { type: String }, | ||
projects: { type: Array, default: () => [] }, | ||
nbMentions: { type: Number }, | ||
language: { type: String }, | ||
model: { type: String } | ||
}) | ||
const mentionTabsProps = computed(() => { | ||
return { | ||
mention: props.mention, | ||
excerpt: props.excerpt, | ||
projects: props.projects, | ||
nbMentions: props.nbMentions, | ||
language: props.language, | ||
model: props.model | ||
} | ||
}) | ||
</script> |
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,33 @@ | ||
<script setup> | ||
import { useI18n } from 'vue-i18n' | ||
const props = defineProps({ | ||
language: { type: String }, | ||
model: { type: String } | ||
}) | ||
const { t } = useI18n() | ||
const content = t('entityPopoverInfo.content') | ||
const propertyHtml = (property) => { | ||
return `<span class="font-monospace border border-tertiary rounded-1 p-1 cursor-pointer">${property}</span>` | ||
} | ||
const modelLabel = t('entityPopoverInfo.model', { model: propertyHtml(props.model) }) | ||
const languageLabel = t('entityPopoverInfo.language', { language: propertyHtml(props.language) }) | ||
const sentence = `${modelLabel} ${languageLabel}` | ||
</script> | ||
|
||
<template> | ||
<div class="entity-popover-info"> | ||
<p class="text-secondary-emphasis"> | ||
{{ content }} | ||
</p> | ||
|
||
<span v-html="sentence" /> | ||
</div> | ||
</template> | ||
<style scoped lang="scss"> | ||
.entity-popover-info { | ||
&__property { | ||
font-family: $font-family-monospace; | ||
} | ||
} | ||
</style> |
32 changes: 32 additions & 0 deletions
32
src/components/EntityPopover/EntityPopoverMentionExcerpt.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,32 @@ | ||
<script setup> | ||
import { computed } from 'vue' | ||
const props = defineProps({ | ||
mention: { | ||
type: String | ||
}, | ||
excerpt: { | ||
type: String | ||
} | ||
}) | ||
const replacement = `<span class="entity-popover-mention-excerpt__mark">${props.mention}</span>` | ||
const content = computed(() => { | ||
return props.excerpt.replace(new RegExp(props.mention, 'g'), replacement) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<p class="entity-popover-mention-excerpt text-center m-0" v-html="content" /> | ||
</template> | ||
|
||
<style lang="scss"> | ||
.entity-popover-mention-excerpt { | ||
&::before, | ||
&::after { | ||
content: '...'; | ||
} | ||
&__mark { | ||
font-weight: $font-weight-bold; | ||
} | ||
} | ||
</style> |
33 changes: 33 additions & 0 deletions
33
src/components/EntityPopover/EntityPopoverMentionOccurrences.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,33 @@ | ||
<script setup> | ||
import { useI18n } from 'vue-i18n' | ||
import ProjectLink from '@/components/Project/ProjectLink' | ||
const props = defineProps({ | ||
nbMentions: { | ||
type: Number | ||
}, | ||
projects: { | ||
type: Array, | ||
default: () => [] | ||
} | ||
}) | ||
const { t, n } = useI18n() | ||
const nbProjects = props.projects?.length ?? 0 | ||
const occurrences = t('entityPopoverMentionOccurrences.occurrences', { | ||
n: props.nbMentions, | ||
nbMentions: n(props.nbMentions) | ||
}) | ||
const projectList = t('entityPopoverMentionOccurrences.projectList', { n: nbProjects }) | ||
</script> | ||
<template> | ||
<div class="entity-popover-mention-occurrences"> | ||
<p>{{ `${occurrences} ${projectList}` }}</p> | ||
<div class="d-flex gap-2"> | ||
<project-link v-for="(project, index) in projects" :key="index" :project="project" /> | ||
</div> | ||
</div> | ||
</template> | ||
<style scoped lang="scss"></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup> | ||
import { TinyPagination } from '@icij/murmur-next' | ||
import EntityPopoverMentionOccurrences from '@/components/EntityPopover/EntityPopoverMentionOccurrences' | ||
import EntityPopoverMentionExcerpt from '@/components/EntityPopover/EntityPopoverMentionExcerpt' | ||
const mentionIndex = defineModel({ type: Number }) | ||
defineProps({ | ||
mention: { type: String }, | ||
excerpt: { type: String }, | ||
projects: { type: Array, default: () => [] }, | ||
nbMentions: { type: Number } | ||
}) | ||
</script> | ||
<template> | ||
<div class="d-flex flex-column align-items-center gap-3"> | ||
<entity-popover-mention-excerpt :mention="mention" :excerpt="excerpt" /> | ||
<tiny-pagination v-model="mentionIndex" :per-page="1" :total-rows="nbMentions" compact /> | ||
<entity-popover-mention-occurrences | ||
:nb-mentions="nbMentions" | ||
:projects="projects" | ||
class="text-secondary-emphasis" | ||
/> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<template> | ||
<b-tabs | ||
class="entity-popover-tabs" | ||
active-nav-item-class="border-bottom border-primary " | ||
nav-item-class="text-action-emphasis d-inline-flex align-items-center gap-2 bg-action-subtle" | ||
active-tab-class="my-4" | ||
> | ||
<b-tab> | ||
<template #title | ||
><phosphor-icon name="list-magnifying-glass" />{{ mentionsLabel }} | ||
<b-badge pill variant="tertiary">{{ props.nbMentions }}</b-badge> | ||
</template> | ||
<entity-popover-mentions v-bind="mentionsProps" /> | ||
</b-tab> | ||
<b-tab> | ||
<template #title><phosphor-icon name="info" /> {{ infoLabel }}</template> | ||
<entity-popover-info v-bind="infoProps" /> | ||
</b-tab> | ||
</b-tabs> | ||
</template> | ||
<script setup> | ||
import { computed } from 'vue' | ||
import { PhosphorIcon } from '@icij/murmur-next' | ||
import { useI18n } from 'vue-i18n' | ||
import EntityPopoverMentions from '@/components/EntityPopover/EntityPopoverMentions' | ||
import EntityPopoverInfo from '@/components/EntityPopover/EntityPopoverInfo' | ||
const props = defineProps({ | ||
mention: { type: String }, | ||
excerpt: { type: String }, | ||
projects: { type: Array, default: () => [] }, | ||
nbMentions: { type: Number }, | ||
language: { type: String }, | ||
model: { type: String } | ||
}) | ||
const mentionsProps = computed(() => { | ||
return { | ||
mention: props.mention, | ||
excerpt: props.excerpt, | ||
projects: props.projects, | ||
nbMentions: props.nbMentions | ||
} | ||
}) | ||
const infoProps = computed(() => { | ||
return { | ||
language: props.language, | ||
model: props.model | ||
} | ||
}) | ||
const { t } = useI18n() | ||
const infoLabel = t('entityPopoverTabs.info') | ||
const mentionsLabel = t('entityPopoverTabs.mentions') | ||
</script> |
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
38 changes: 38 additions & 0 deletions
38
src/stories/components/EntityPopover/EntityPopover.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,38 @@ | ||
import EntityPopover from '@/components/EntityPopover/EntityPopover' | ||
|
||
export default { | ||
title: 'Components/EntityPopover/EntityPopover', | ||
component: EntityPopover, | ||
tags: ['autodocs'], | ||
args: { | ||
language: 'English', | ||
model: 'CoreNLP', | ||
mention: 'Bruno Mars', | ||
excerpt: 'Lorem ipsum Bruno Mars dolor ipset', | ||
nbMentions: 5033, | ||
projects: ['banana papers', 'citrus confidential'] | ||
}, | ||
render: (args) => ({ | ||
components: { | ||
EntityPopover | ||
}, | ||
setup: () => ({ args }), | ||
computed: { | ||
trigger() { | ||
return `btn-${this.$.uid}` | ||
}, | ||
title() { | ||
return args.document.title | ||
} | ||
}, | ||
template: ` | ||
<div class="p-sm-5 p-3 text-center"> | ||
<button type="button" class="btn btn-outline-primary" :id="trigger"> | ||
Mentions of <var class="text-decoration-underline">{{ args.mention }}</var> | ||
</button> | ||
<entity-popover v-bind="args" :target="trigger" /> | ||
</div> | ||
` | ||
}) | ||
} | ||
export const Default = {} |
12 changes: 12 additions & 0 deletions
12
src/stories/components/EntityPopover/EntityPopoverInfo.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,12 @@ | ||
import EntityPopoverInfo from '@/components/EntityPopover/EntityPopoverInfo' | ||
|
||
export default { | ||
title: 'Components/EntityPopover/EntityPopoverInfo', | ||
component: EntityPopoverInfo, | ||
tags: ['autodocs'], | ||
args: { | ||
language: 'english', | ||
model: 'CoreNLP' | ||
} | ||
} | ||
export const Default = {} |
12 changes: 12 additions & 0 deletions
12
src/stories/components/EntityPopover/EntityPopoverMentionExcerpt.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,12 @@ | ||
import EntityPopoverMentionExcerpt from '@/components/EntityPopover/EntityPopoverMentionExcerpt' | ||
|
||
export default { | ||
title: 'Components/EntityPopover/EntityPopoverMentionExcerpt', | ||
component: EntityPopoverMentionExcerpt, | ||
tags: ['autodocs'], | ||
args: { | ||
mention: 'Bruno Mars', | ||
excerpt: 'Lorem ipsum Bruno Mars dolor ipset ' | ||
} | ||
} | ||
export const Default = {} |
12 changes: 12 additions & 0 deletions
12
src/stories/components/EntityPopover/EntityPopoverMentionOccurrences.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,12 @@ | ||
import EntityPopoverMentionOccurrences from '@/components/EntityPopover/EntityPopoverMentionOccurrences' | ||
|
||
export default { | ||
title: 'Components/EntityPopover/EntityPopoverMentionOccurrences', | ||
component: EntityPopoverMentionOccurrences, | ||
tags: ['autodocs'], | ||
args: { | ||
nbMentions: 5033, | ||
projects: ['banana papers', 'citrus confidential'] | ||
} | ||
} | ||
export const Default = {} |
33 changes: 33 additions & 0 deletions
33
src/stories/components/EntityPopover/EntityPopoverMentions.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,33 @@ | ||
import { computed, ref } from 'vue' | ||
|
||
import EntityPopoverMentions from '@/components/EntityPopover/EntityPopoverMentions' | ||
const excerpt = 'Lorem ipsum Bruno Mars dolor ipset' | ||
const excerpts = [excerpt, 'Lorem ipsum dolor ipset Bruno Mars', 'Bruno Mars Lorem ipsum dolor ipset'] | ||
export default { | ||
title: 'Components/EntityPopover/EntityPopoverMentions', | ||
component: EntityPopoverMentions, | ||
tags: ['autodocs'], | ||
args: { | ||
mention: 'Bruno Mars', | ||
projects: ['banana papers', 'citrus confidential'], | ||
nbMentions: excerpts.length, | ||
excerpt, | ||
excerpts | ||
}, | ||
render: (args) => ({ | ||
components: { | ||
EntityPopoverMentions | ||
}, | ||
setup: () => { | ||
const index = ref(1) | ||
const current = computed(() => excerpts[index.value - 1]) | ||
return { args, index, current } | ||
}, | ||
|
||
template: ` | ||
<entity-popover-mentions v-bind="args" :excerpt="current" v-model="index" /> | ||
` | ||
}) | ||
} | ||
export const Default = {} |
Oops, something went wrong.