-
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
9 changed files
with
197 additions
and
1 deletion.
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,7 @@ | ||
<template> | ||
<div class="widget-entities d-flex flex-wrap gap-4"> | ||
<slot></slot> | ||
</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,31 @@ | ||
<template> | ||
<b-card | ||
tag="a" | ||
:href="to" | ||
class="widget-entity" | ||
body-class="d-flex flex-column align-items-center gap-1" | ||
:border-variant="variant" | ||
> | ||
<phosphor-icon :variant="variant" :name="icon" :weight="ICON_WEIGHT.BOLD" /> | ||
<span class="widget-entity__value fw-bold" | ||
><slot>{{ humanValue }}</slot></span | ||
> | ||
<span class="widget-entity__label text-secondary-emphasis">{{ label }}</span> | ||
</b-card> | ||
</template> | ||
|
||
<script setup> | ||
import { PhosphorIcon } from '@icij/murmur-next' | ||
import humanNumber from '@/utils/humanNumber' | ||
import { ICON_WEIGHT } from '@/enums/iconWeights' | ||
import { variantValidator } from '@/enums/variants' | ||
const props = defineProps({ | ||
icon: { type: String }, | ||
value: { type: [Number, String] }, | ||
label: { type: String }, | ||
to: { type: String, default: '#' }, | ||
variant: { type: String, validator: variantValidator } | ||
}) | ||
const humanValue = typeof props.value === 'number' ? humanNumber(props.value) : props.value | ||
</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,18 @@ | ||
<template> | ||
<widget-barometer-entry :icon="icon" :label="label" :to="to">{{ value }}</widget-barometer-entry> | ||
</template> | ||
|
||
<script setup> | ||
import { useI18n } from 'vue-i18n' | ||
import WidgetBarometerEntry from '@/components/Widget/WidgetBarometerEntry' | ||
import humanSize from '@/utils/humanSize' | ||
const props = defineProps({ | ||
size: { type: Number, default: null } | ||
}) | ||
const { t } = useI18n() | ||
const icon = 'floppy-disk' | ||
const to = `#` | ||
const label = t('widget.diskUsage.details') | ||
const value = humanSize(props.size) | ||
</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,20 @@ | ||
<template> | ||
<widget-barometer-entry :icon="icon" :label="label" :to="to">{{ value }}</widget-barometer-entry> | ||
</template> | ||
|
||
<script setup> | ||
import { useI18n } from 'vue-i18n' | ||
import WidgetBarometerEntry from '@/components/Widget/WidgetBarometerEntry' | ||
import humanNumber from '@/utils/humanNumber' | ||
const props = defineProps({ | ||
nbDocuments: { type: Number }, | ||
nbDocumentsOnDisks: { type: Number } | ||
}) | ||
const { t } = useI18n() | ||
const icon = 'files' | ||
const to = `#` | ||
const label = `${t('widget.barometer.amongWhich')} ${props.nbDocumentsOnDisks} ${t('widget.barometer.onDisk')}` | ||
const humanNbDocs = humanNumber(props.nbDocuments) | ||
const value = t('widget.barometer.document', { n: props.nbDocuments, value: humanNbDocs }) | ||
</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
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,72 @@ | ||
import { variantsArgType } from '~storybook/utils' | ||
import { getCategoryIcon } from '@/utils/namedEntity' | ||
import { ENTITY_CATEGORY } from '@/enums/entityCategories' | ||
import { VARIANT } from '@/enums/variants' | ||
import WidgetBarometer from '@/components/Widget/WidgetBarometer' | ||
import WidgetBarometerEntry from '@/components/Widget/WidgetBarometerEntry' | ||
import WidgetBarometerEntryDocuments from '@/components/Widget/WidgetBarometerEntryDocuments' | ||
import WidgetBarometerEntryDiskUsage from '@/components/Widget/WidgetBarometerEntryDiskUsage' | ||
const documents = { | ||
nbDocuments: 43, | ||
nbDocumentsOnDisks: 123 | ||
} | ||
const diskUsage = { | ||
size: 300050005050 | ||
} | ||
const persons = { | ||
icon: getCategoryIcon(ENTITY_CATEGORY.PERSON), | ||
label: 'Persons', | ||
value: 9000, | ||
variant: VARIANT.CATEGORY_PERSON | ||
} | ||
const organizations = { | ||
icon: getCategoryIcon(ENTITY_CATEGORY.ORGANIZATION), | ||
label: 'Organizations', | ||
value: 9000, | ||
variant: VARIANT.CATEGORY_ORGANIZATION | ||
} | ||
const locations = { | ||
icon: getCategoryIcon(ENTITY_CATEGORY.LOCATION), | ||
label: 'Locations', | ||
value: 9000, | ||
variant: VARIANT.CATEGORY_LOCATION | ||
} | ||
const emails = { | ||
icon: getCategoryIcon(ENTITY_CATEGORY.EMAIL), | ||
label: 'Emails', | ||
value: 9000, | ||
variant: VARIANT.CATEGORY_EMAIL | ||
} | ||
const args = { documents, diskUsage, persons, organizations, locations, emails } | ||
|
||
export default { | ||
title: 'Components/Widget/WidgetBarometer', | ||
component: WidgetBarometer, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
variant: variantsArgType | ||
}, | ||
args, | ||
render: (args) => ({ | ||
components: { | ||
WidgetBarometer, | ||
WidgetBarometerEntry, | ||
WidgetBarometerEntryDocuments, | ||
WidgetBarometerEntryDiskUsage | ||
}, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<widget-barometer> | ||
<WidgetBarometerEntryDocuments v-bind="args.documents"/> | ||
<WidgetBarometerEntryDiskUsage v-bind="args.diskUsage"/> | ||
<WidgetBarometerEntry v-bind="args.persons"/> | ||
<WidgetBarometerEntry v-bind="args.organizations"/> | ||
<WidgetBarometerEntry v-bind="args.locations"/> | ||
<WidgetBarometerEntry v-bind="args.emails"/> | ||
</widget-barometer> | ||
` | ||
}) | ||
} | ||
export const Default = {} |
18 changes: 18 additions & 0 deletions
18
src/stories/components/Widget/WidgetBarometerEntry.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,18 @@ | ||
import WidgetBarometerEntry from '@/components/Widget/WidgetBarometerEntry' | ||
import { variantsArgType } from '~storybook/utils' | ||
|
||
export default { | ||
title: 'Components/Widget/WidgetBarometerEntry', | ||
component: WidgetBarometerEntry, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
variant: variantsArgType | ||
}, | ||
args: { | ||
icon: 'floppy-disk', | ||
label: 'records', | ||
value: '30000', | ||
variant: 'action' | ||
} | ||
} | ||
export const Default = {} |