Skip to content

Commit

Permalink
Add file card component to ui package (#456)
Browse files Browse the repository at this point in the history
* feat: add file card component to ui package

* feat: add confirmation action with file card demo

* feat: add custom message demo for file card

* feat: add buttons properties demo for file card

* feat: add visibility detail demo for file card

* chore: sort props alphabetically
  • Loading branch information
KabinKhandThakuri authored Jan 15, 2025
1 parent 4c531f7 commit 1aebec2
Show file tree
Hide file tree
Showing 13 changed files with 959 additions and 1 deletion.
10 changes: 10 additions & 0 deletions apps/demo/src/locales/en/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@
"withSlot": "With slot"
}
},
"file": "File",
"fileCard": {
"title": "File card",
"usage": {
"basic": "Basic",
"buttonProps": "Action button's props",
"messages": "Custom messages",
"visibilityDetail": "With visibility detail"
}
},
"getStarted": "Get started",
"gridContainer": {
"usage": {
Expand Down
10 changes: 10 additions & 0 deletions apps/demo/src/locales/fr/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@
"withSlot": "With slot"
}
},
"file": "File",
"fileCard": {
"title": "File card",
"usage": {
"basic": "Basic",
"buttonProps": "Action button's props",
"messages": "Custom messages",
"visibilityDetail": "With visibility detail"
}
},
"getStarted": "Get started",
"gridContainer": {
"usage": {
Expand Down
6 changes: 6 additions & 0 deletions apps/demo/src/router/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const ConfirmationModal = () =>
const Data = () => import("@/views/UI/data/Index.vue");
const Divider = () => import("@/views/UI/divider/Index.vue");
const Dropdown = () => import("@/views/UI/dropdown/Index.vue");
const FileCard = () => import("@/views/UI/fileCard/Index.vue");
const GridContainer = () => import("@/views/UI/gridContainer/Index.vue");
const LoadingPage = () => import("@/views/UI/loading/Index.vue");
const Message = () => import("@/views/UI/message/Index.vue");
Expand Down Expand Up @@ -70,6 +71,11 @@ const routes = [
name: "data",
path: "data",
},
{
component: FileCard,
name: "fileCard",
path: "file-card",
},
{
component: GridContainer,
name: "gridContainer",
Expand Down
9 changes: 9 additions & 0 deletions apps/demo/src/views/UI/UiPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ const menu = [
},
],
},
{
name: t("ui.file"),
children: [
{
name: t("ui.fileCard.title"),
routeName: "fileCard",
},
],
},
{
name: t("ui.menu"),
children: [
Expand Down
281 changes: 281 additions & 0 deletions apps/demo/src/views/UI/fileCard/Index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
<template>
<UiPage :title="$t('ui.fileCard.title')" class="demo">
<template #toolbar>
<router-link :to="{ name: 'ui' }" class="back">
{{ $t("common.back") }}
</router-link>
</template>

<section>
<h2>{{ $t("ui.fileCard.usage.basic") }}</h2>

<div class="section-content">
<FileCard :file="file" />

<!-- eslint-disable -->
<SshPre language="html-vue">
&lt;template&gt;
&lt;FileCard :file="file" /&gt;
&lt;/template&gt;

&lt;script setup lang="ts"&gt;
import { FileCard } from "@dzangolab/vue3-ui";

import type { IFile } from "@dzangolab/vue3-ui";

const file = {
description: "This is a file",
downloadCount: 0,
id: 1,
lastDownloadedAt: Date.now(),
originalFileName: "file.png",
size: 4,
uploadedBy: { givenName: "Test", lastName: "user" },
uploadedAt: Date.now(),
} as IFile;
&lt;/script&gt;
</SshPre>
<!-- eslint-enable -->
</div>
</section>

<section>
<h2>{{ $t("ui.fileCard.usage.messages") }}</h2>

<div class="section-content">
<FileCard :file="file" :messages="messages" />

<!-- eslint-disable -->
<SshPre language="html-vue">
&lt;template&gt;
&lt;FileCard :file="file" :messages="messages" /&gt;
&lt;/template&gt;

&lt;script setup lang="ts"&gt;
import { FileCard } from "@dzangolab/vue3-ui";

import type { FileMessages, IFile } from "@dzangolab/vue3-ui";

const file = {
...
} as IFile;

const messages = {
archiveAction: "Archive file",
archiveConfirmationHeader: "Confirm archive?",
archiveConfirmationMessage: "Are you sure to archive this file?",
deleteAction: "Delete file",
deleteConfirmationHeader: "Confirm delete?",
deleteConfirmationMessage: "Are you sure to delete this file?",
downloadAction: "Download file",
downloadCountHeader: "Download count:",
lastDownloadedAtHeader: "Last downloaded date:",
shareAction: "Share file",
uploadedAtHeader: "Uploaded date:",
uploadedByHeader: "Uploaded by:",
viewAction: "View file",
} as FileMessages;
&lt;/script&gt;
</SshPre>
<!-- eslint-enable -->
</div>
</section>

<section>
<h2>{{ $t("ui.fileCard.usage.buttonProps") }}</h2>

<div class="section-content">
<FileCard
:archive-button-props="archiveButtonProperties"
:delete-button-props="deleteButtonProperties"
:download-button-props="downloadButtonProperties"
:file="file"
:share-button-props="shareButtonProperties"
:view-button-props="viewButtonProperties"
/>

<!-- eslint-disable -->
<SshPre language="html-vue">
&lt;template&gt;
&lt;FileCard
:archive-button-props="archiveButtonProps"
:delete-button-props="deleteButtonProps"
:download-button-props="downloadButtonProps"
:file="file"
:share-button-props="shareButtonProps"
:view-button-props="viewButtonProps"
/&gt;
&lt;/template&gt;

&lt;script setup lang="ts"&gt;
import { FileCard } from "@dzangolab/vue3-ui";

import type { FileMessages, IFile } from "@dzangolab/vue3-ui";

const archiveButtonProps = {
severity: "warning",
size: "medium",
variant: "outlined",
};

const deleteButtonProps = {
severity: "danger",
size: "medium",
variant: "outlined",
};

const downloadButtonProps = {
severity: "primary",
size: "medium",
variant: "outlined",
};

const file = {
...
} as IFile;

const shareButtonProps = {
severity: "alternate",
size: "medium",
variant: "outlined",
};

const viewButtonProps = {
severity: "secondary",
size: "medium",
variant: "outlined",
};
</SshPre>
<!-- eslint-enable -->
</div>
</section>

<section>
<h2>{{ $t("ui.fileCard.usage.visibilityDetail") }}</h2>

<div class="section-content">
<FileCard
:action-buttons-visibility="{
archive: false,
delete: true,
download: true,
share: false,
view: true,
}"
:file="file"
:visibility-detail="{
actions: true,
description: false,
downloadCount: true,
lastDownloadedAt: false,
originalFileName: true,
size: false,
uploadedAt: true,
uploadedBy: true,
}"
/>

<!-- eslint-disable -->
<SshPre language="html-vue">
&lt;template&gt;
&lt;FileCard
:action-buttons-visibility="{
archive: false,
delete: true,
download: true,
share: false,
view: true,
}"
:file="file"
:visibility-detail="{
actions: true,
description: false,
downloadCount: true,
lastDownloadedAt: false,
originalFileName: true,
size: false,
uploadedAt: true,
uploadedBy: true,
}"
/&gt;
&lt;/template&gt;

&lt;script setup lang="ts"&gt;
import { FileCard } from "@dzangolab/vue3-ui";

import type { IFile } from "@dzangolab/vue3-ui";

const file = {
...
} as IFile;
</SshPre>
<!-- eslint-enable -->
</div>
</section>
</UiPage>
</template>

<script setup lang="ts">
import { FileCard } from "@dzangolab/vue3-ui";
import UiPage from "../UiPage.vue";
import type { FileMessages, IFile } from "@dzangolab/vue3-ui";
const archiveButtonProperties = {
severity: "warning",
size: "medium",
variant: "outlined",
};
const deleteButtonProperties = {
severity: "danger",
size: "medium",
variant: "outlined",
};
const downloadButtonProperties = {
severity: "primary",
size: "medium",
variant: "outlined",
};
const file = {
description: "This is a file",
downloadCount: 0,
id: 1,
lastDownloadedAt: Date.now(),
originalFileName: "file.png",
size: 4,
uploadedBy: { givenName: "Test", lastName: "user" },
uploadedAt: Date.now(),
} as IFile;
const messages = {
archiveAction: "Archive file",
archiveConfirmationHeader: "Confirm archive?",
archiveConfirmationMessage: "Are you sure to archive this file?",
deleteAction: "Delete file",
deleteConfirmationHeader: "Confirm delete?",
deleteConfirmationMessage: "Are you sure to delete this file?",
downloadAction: "Download file",
downloadCountHeader: "Download count:",
lastDownloadedAtHeader: "Last downloaded date:",
shareAction: "Share file",
uploadedAtHeader: "Uploaded date:",
uploadedByHeader: "Uploaded by:",
viewAction: "View file",
} as FileMessages;
const shareButtonProperties = {
severity: "alternate",
size: "medium",
variant: "outlined",
};
const viewButtonProperties = {
severity: "secondary",
size: "medium",
variant: "outlined",
};
</script>
Loading

0 comments on commit 1aebec2

Please sign in to comment.