-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: implement expandable row details * feat: implement expandable row for data table * fix: improve examples, fix new demo errors * fix(data-table): rollback cell slot bind change * feat(data-table): added row-data to expandable slot bind * docs(data-table): improve docs demo * docs(data-table): chore change colors --------- Co-authored-by: Maksim Nedoshev <m0ksem1337@gmail.com>
- Loading branch information
1 parent
d750959
commit 9a7b7ad
Showing
7 changed files
with
259 additions
and
99 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
114 changes: 114 additions & 0 deletions
114
packages/docs/page-config/ui-elements/data-table/examples/ExpandableRow.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,114 @@ | ||
<template> | ||
<va-data-table | ||
:items="items" | ||
:columns="columns" | ||
> | ||
<template #cell(actions)="{ row, isExpanded }"> | ||
<va-button | ||
@click="row.toggleRowDetails()" | ||
:icon="row.isExpanded ? 'va-arrow-up': 'va-arrow-down'" | ||
preset="secondary" | ||
class="w-full" | ||
> | ||
{{ isExpanded ? 'Hide': 'More info' }} | ||
</va-button> | ||
</template> | ||
|
||
<template #expandableRow="{ rowData }"> | ||
<div class="flex gap-2"> | ||
<va-avatar :src="`https://randomuser.me/api/portraits/men/${rowData.id}.jpg`"/> | ||
<div class="pl-2"> | ||
<div class="flex gap-1"> | ||
<span>{{ rowData.name }}</span> | ||
<span class="va-link">@{{ rowData.username }}</span> | ||
</div> | ||
<div class="flex items-center"> | ||
<va-icon size="small" name="phone" color="secondary" class="mr-2" /> | ||
<span>{{ rowData.phone }}</span> | ||
</div> | ||
<div class="flex items-center"> | ||
<va-icon size="small" name="email" color="secondary" class="mr-2" /> | ||
<span>{{ rowData.email }}</span> | ||
</div> | ||
<div class="flex items-center"> | ||
<va-icon size="small" name="language" color="secondary" class="mr-2" /> | ||
<span class="va-link">{{ rowData.website }}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
</va-data-table> | ||
</template> | ||
|
||
<style> | ||
.va-data-table__table-tr--expanded td { | ||
background: var(--va-background-border); | ||
} | ||
.va-data-table__table-expanded-content td { | ||
background-color: var(--va-background-element); | ||
} | ||
</style> | ||
|
||
<script> | ||
import { defineComponent } from "vue"; | ||
export default defineComponent({ | ||
data() { | ||
const users = [ | ||
{ | ||
id: 1, | ||
name: "Leanne Graham", | ||
username: "Bret", | ||
email: "Sincere@april.biz", | ||
phone: "1-770-736-8031", | ||
website: "hildegard.org", | ||
}, | ||
{ | ||
id: 2, | ||
name: "Ervin Howell", | ||
username: "Antonette", | ||
email: "Shanna@melissa.tv", | ||
phone: "010-692-6593", | ||
website: "anastasia.net", | ||
}, | ||
{ | ||
id: 3, | ||
name: "Clementine Bauch", | ||
username: "Samantha", | ||
email: "Nathan@yesenia.net", | ||
phone: "1-463-123-4447", | ||
website: "ramiro.info", | ||
}, | ||
{ | ||
id: 4, | ||
name: "Patricia Lebsack", | ||
username: "Karianne", | ||
email: "Julianne.OConner@kory.org", | ||
phone: "493-170-9623", | ||
website: "kale.biz", | ||
}, | ||
{ | ||
id: 5, | ||
name: "Chelsey Dietrich", | ||
username: "Kamren", | ||
email: "Lucio_Hettinger@annie.ca", | ||
phone: "(254)954-1289", | ||
website: "demarco.info", | ||
}, | ||
]; | ||
const columns = [ | ||
{ key: "name" }, | ||
{ key: "username" }, | ||
{ key: "email" }, | ||
{ key: "actions", width: 80 }, | ||
]; | ||
return { | ||
items: users, | ||
columns | ||
}; | ||
}, | ||
}); | ||
</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
Oops, something went wrong.