-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-core): added UiTopBottomTable component and some trad (#8055)
- Loading branch information
Showing
5 changed files
with
118 additions
and
4 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
48 changes: 48 additions & 0 deletions
48
@xen-orchestra/lite/src/stories/web-core/ui/top-bottom-table/ui-top-bottom-table.story.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,48 @@ | ||
<template> | ||
<ComponentStory | ||
v-slot="{ properties }" | ||
:params="[ | ||
prop('selected-items').required().num(), | ||
prop('total-items').required().num(), | ||
event('toggleSelectAll').args({ value: 'boolean' }), | ||
]" | ||
> | ||
<UiTopBottomTable | ||
v-bind="properties" | ||
:selected-items="selectedItems" | ||
:total-items="totalItems.length" | ||
@toggle-select-all="toggleSelect" | ||
/> | ||
<div v-for="(item, index) in totalItems" :key="index"> | ||
<input v-model="item.selected" type="checkbox" /> {{ item.name }} | ||
</div> | ||
</ComponentStory> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import ComponentStory from '@/components/component-story/ComponentStory.vue' | ||
import { event, prop } from '@/libs/story/story-param' | ||
import UiTopBottomTable from '@core/components/ui/top-bottom-table/UiTopBottomTable.vue' | ||
import { computed, ref } from 'vue' | ||
const totalItems = ref([ | ||
{ name: 'Item 1', selected: false }, | ||
{ name: 'Item 2', selected: false }, | ||
{ name: 'Item 3', selected: false }, | ||
{ name: 'Item 4', selected: false }, | ||
{ name: 'Item 5', selected: false }, | ||
{ name: 'Item 6', selected: false }, | ||
{ name: 'Item 7', selected: false }, | ||
{ name: 'Item 8', selected: false }, | ||
{ name: 'Item 9', selected: false }, | ||
{ name: 'Item 10', selected: false }, | ||
]) | ||
const toggleSelect = (isSelected: boolean) => { | ||
totalItems.value.forEach(item => { | ||
item.selected = isSelected | ||
}) | ||
} | ||
const selectedItems = computed(() => totalItems.value.filter(item => item.selected).length) | ||
</script> |
64 changes: 64 additions & 0 deletions
64
@xen-orchestra/web-core/lib/components/ui/top-bottom-table/UiTopBottomTable.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,64 @@ | ||
<!-- v2 --> | ||
<template> | ||
<div class="ui-top-bottom-table"> | ||
<div class="content"> | ||
<span class="typo p3-regular label"> | ||
{{ $t('core.select.n-selected-of', { count: selectedItems, total: totalItems }) }} | ||
</span> | ||
|
||
<UiButton | ||
:disabled="selectedItems === totalItems" | ||
accent="info" | ||
size="small" | ||
variant="tertiary" | ||
@click="emit('toggleSelectAll', true)" | ||
> | ||
{{ $t('core.select.all') }} | ||
</UiButton> | ||
<UiButton | ||
:disabled="selectedItems === 0" | ||
accent="info" | ||
size="small" | ||
variant="tertiary" | ||
@click="emit('toggleSelectAll', false)" | ||
> | ||
{{ $t('core.select.unselect') }} | ||
</UiButton> | ||
</div> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import UiButton from '@core/components/ui/button/UiButton.vue' | ||
defineProps<{ | ||
selectedItems: number | ||
totalItems: number | ||
}>() | ||
const emit = defineEmits<{ | ||
toggleSelectAll: [value: boolean] | ||
}>() | ||
defineSlots<{ | ||
default(): any | ||
}>() | ||
</script> | ||
|
||
<style scoped lang="postcss"> | ||
.ui-top-bottom-table { | ||
display: flex; | ||
justify-content: space-between; | ||
.content { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.8rem; | ||
} | ||
.label { | ||
color: var(--color-neutral-txt-secondary); | ||
} | ||
} | ||
</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
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