Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xo-6): add panel component #8122

Merged
merged 16 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<ComponentStory
v-slot="{ properties, settings }"
:params="[
prop('error').bool().widget(),
setting('action1').widget(text()).preset('Edit'),
setting('action2').widget(text()).preset('Delete'),
slot(),
slot('header').help('Meant to receive UiButton or other information'),
]"
:presets="{
Normal: {
props: {
error: false,
},
},
Error: {
props: {
error: true,
},
},
}"
>
<UiSidePanel v-bind="properties" :error="properties.error">
<template #header>
<UiButton variant="tertiary" size="medium" accent="info" @click="toggle()">Toggle</UiButton>
<UiButton variant="tertiary" size="medium" accent="info" :left-icon="faEdit"> {{ settings.action1 }}</UiButton>
<UiButton variant="tertiary" size="medium" accent="danger" :left-icon="faTrash">
{{ settings.action2 }}
</UiButton>
</template>
<VtsLoadingHero type="card" :disabled="isReady">
<UiCard v-if="!properties.error">
<div>Content 1</div>
<div>Content 1</div>
<div>Content 1</div>
</UiCard>
</VtsLoadingHero>
</UiSidePanel>
</ComponentStory>
</template>

<script setup lang="ts">
import ComponentStory from '@/components/component-story/ComponentStory.vue'
import { prop, setting, slot } from '@/libs/story/story-param'
import { text } from '@/libs/story/story-widget'
import VtsLoadingHero from '@core/components/state-hero/VtsLoadingHero.vue'
import UiButton from '@core/components/ui/button/UiButton.vue'
import UiCard from '@core/components/ui/card/UiCard.vue'
import UiSidePanel from '@core/components/ui/panel/UiPanel.vue'
import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons'
import { useToggle } from '@vueuse/core'
import { computed } from 'vue'

const [isToggled, toggle] = useToggle()
const isReady = computed(() => isToggled.value)
</script>
57 changes: 57 additions & 0 deletions @xen-orchestra/web-core/lib/components/ui/panel/UiPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!-- wip -->
<template>
<div class="ui-panel" :class="{ error: props.error }">
OlivierFL marked this conversation as resolved.
Show resolved Hide resolved
<div v-if="slots.header" class="header">
<slot name="header" />
</div>
<div class="content">
<slot />
</div>
</div>
</template>

<script setup lang="ts">
const props = defineProps<{
error?: boolean
}>()

const slots = defineSlots<{
default(): any
header?(): any
}>()
</script>

<style scoped lang="postcss">
.ui-panel {
height: 100%;
display: flex;
flex-direction: column;
border: 0.1rem solid var(--color-neutral-border);
background-color: var(--color-neutral-background-secondary);

.header {
border-bottom: 0.1rem solid var(--color-neutral-border);
background-color: var(--color-neutral-background-primary);
display: flex;
justify-content: flex-end;
align-items: center;
gap: 1.6rem;
padding: 0.4rem 1.6rem;
}

.content {
display: flex;
flex-direction: column;
padding: 0.8rem;
gap: 0.8rem;
}

&.error {
background-color: var(--color-danger-background-selected);

.content {
padding-top: 15rem;
}
}
}
</style>
Loading