-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lite/component): created UiResources + UiResource (#6932)
- Loading branch information
Showing
6 changed files
with
179 additions
and
2 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
50 changes: 50 additions & 0 deletions
50
@xen-orchestra/lite/src/components/ui/resources/UiResource.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,50 @@ | ||
<template> | ||
<li class="ui-resource"> | ||
<UiIcon :icon="icon" class="icon" /> | ||
<div class="separator" /> | ||
<div class="label">{{ label }}</div> | ||
<div class="count">{{ count }}</div> | ||
</li> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import UiIcon from "@/components/ui/icon/UiIcon.vue"; | ||
import type { IconDefinition } from "@fortawesome/fontawesome-common-types"; | ||
defineProps<{ | ||
icon: IconDefinition; | ||
label: string; | ||
count: string | number; | ||
}>(); | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
.ui-resource { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.icon { | ||
color: var(--color-extra-blue-base); | ||
font-size: 3.2rem; | ||
} | ||
.separator { | ||
height: 4.5rem; | ||
width: 0; | ||
border-left: 0.1rem solid var(--color-extra-blue-base); | ||
background-color: var(--color-extra-blue-base); | ||
margin: 0 1.5rem; | ||
} | ||
.label { | ||
font-size: 1.6rem; | ||
font-weight: 700; | ||
} | ||
.count { | ||
font-size: 1.4rem; | ||
font-weight: 400; | ||
margin-left: 2rem; | ||
} | ||
</style> |
13 changes: 13 additions & 0 deletions
13
@xen-orchestra/lite/src/components/ui/resources/UiResources.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,13 @@ | ||
<template> | ||
<ul class="ui-resources"> | ||
<slot /> | ||
</ul> | ||
</template> | ||
|
||
<style lang="postcss" scoped> | ||
.ui-resources { | ||
display: flex; | ||
gap: 1rem 5.4rem; | ||
flex-wrap: wrap; | ||
} | ||
</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,70 @@ | ||
<template> | ||
<ComponentStory | ||
v-slot="{ properties }" | ||
:params="[ | ||
iconProp().preset(faRocket), | ||
prop('label').required().str().widget().preset('Rockets'), | ||
prop('count') | ||
.required() | ||
.type('string | number') | ||
.widget(text()) | ||
.preset('175'), | ||
]" | ||
:presets="presets" | ||
> | ||
<UiResource v-bind="properties" /> | ||
</ComponentStory> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import ComponentStory from "@/components/component-story/ComponentStory.vue"; | ||
import UiResource from "@/components/ui/resources/UiResource.vue"; | ||
import { iconProp, prop } from "@/libs/story/story-param"; | ||
import { text } from "@/libs/story/story-widget"; | ||
import { | ||
faDatabase, | ||
faDisplay, | ||
faMemory, | ||
faMicrochip, | ||
faNetworkWired, | ||
faRocket, | ||
} from "@fortawesome/free-solid-svg-icons"; | ||
const presets = { | ||
VMs: { | ||
props: { | ||
icon: faDisplay, | ||
count: 1, | ||
label: "VMs", | ||
}, | ||
}, | ||
vCPUs: { | ||
props: { | ||
icon: faMicrochip, | ||
count: 4, | ||
label: "vCPUs", | ||
}, | ||
}, | ||
RAM: { | ||
props: { | ||
icon: faMemory, | ||
count: 2, | ||
label: "RAM", | ||
}, | ||
}, | ||
SR: { | ||
props: { | ||
icon: faDatabase, | ||
count: 1, | ||
label: "SR", | ||
}, | ||
}, | ||
Interfaces: { | ||
props: { | ||
icon: faNetworkWired, | ||
count: 2, | ||
label: "Interfaces", | ||
}, | ||
}, | ||
}; | ||
</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,11 @@ | ||
# Example | ||
|
||
```vue-template | ||
<UiResources> | ||
<UiResource :icon="faDisplay" count="1" label="VMs" /> | ||
<UiResource :icon="faMicrochip" count="4" label="vCPUs" /> | ||
<UiResource :icon="faMemory" count="2" label="RAM" /> | ||
<UiResource :icon="faDatabase" count="1" label="SR" /> | ||
<UiResource :icon="faNetworkWired" count="2" label="Interfaces" /> | ||
</UiResources> | ||
``` |
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,28 @@ | ||
<template> | ||
<ComponentStory | ||
:params="[slot().help('One or multiple `UiResource`')]" | ||
full-width-component | ||
> | ||
<UiResources> | ||
<UiResource :icon="faDisplay" count="1" label="VMs" /> | ||
<UiResource :icon="faMicrochip" count="4" label="vCPUs" /> | ||
<UiResource :icon="faMemory" count="2" label="RAM" /> | ||
<UiResource :icon="faDatabase" count="1" label="SR" /> | ||
<UiResource :icon="faNetworkWired" count="2" label="Interfaces" /> | ||
</UiResources> | ||
</ComponentStory> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import ComponentStory from "@/components/component-story/ComponentStory.vue"; | ||
import UiResource from "@/components/ui/resources/UiResource.vue"; | ||
import UiResources from "@/components/ui/resources/UiResources.vue"; | ||
import { slot } from "@/libs/story/story-param"; | ||
import { | ||
faDatabase, | ||
faDisplay, | ||
faMemory, | ||
faMicrochip, | ||
faNetworkWired, | ||
} from "@fortawesome/free-solid-svg-icons"; | ||
</script> |