-
Notifications
You must be signed in to change notification settings - Fork 273
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): new InputLabel component
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
@xen-orchestra/lite/src/stories/web-core/input/input-label.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,22 @@ | ||
<template> | ||
<ComponentStory | ||
v-slot="{ properties, settings }" | ||
:params="[ | ||
prop('status').enum('normal', 'warning', 'danger').required().preset('normal').widget(), | ||
prop('required').bool().widget(), | ||
prop('href').str().widget(), | ||
slot(), | ||
setting('defaultSlot').widget(text()).preset('Slot content'), | ||
iconProp(), | ||
]" | ||
> | ||
<InputLabel v-bind="properties">{{ settings.defaultSlot }}</InputLabel> | ||
</ComponentStory> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import ComponentStory from '@/components/component-story/ComponentStory.vue' | ||
import { iconProp, prop, setting, slot } from '@/libs/story/story-param' | ||
import { text } from '@/libs/story/story-widget' | ||
import InputLabel from '@core/components/input/InputLabel.vue' | ||
</script> |
74 changes: 74 additions & 0 deletions
74
@xen-orchestra/web-core/lib/components/input/InputLabel.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,74 @@ | ||
<!-- v2.0 --> | ||
<template> | ||
<div :class="status" class="input-label"> | ||
<UiIcon :icon class="left-icon" /> | ||
<span :class="{ required }" class="typo c2-semi-bold label"><slot /></span> | ||
<a v-if="href" :href class="link"> | ||
<span class="typo p3-regular-underline">{{ $t('learn-more') }}</span> | ||
<UiIcon :icon="faUpRightFromSquare" class="link-icon" /> | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import UiIcon from '@core/components/icon/UiIcon.vue' | ||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types' | ||
import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons' | ||
|
||
defineProps<{ | ||
status: 'normal' | 'warning' | 'danger' | ||
icon?: IconDefinition | ||
required?: boolean | ||
href?: string | ||
}>() | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
/* COLOR VARIANTS */ | ||
|
||
.input-label { | ||
&.normal { | ||
--label__color: var(--color-neutral-txt-primary); | ||
} | ||
|
||
&.warning { | ||
--label__color: var(--color-warning-txt-base); | ||
} | ||
|
||
&.danger { | ||
--label__color: var(--color-danger-txt-base); | ||
} | ||
} | ||
|
||
/* IMPLEMENTATION */ | ||
|
||
.input-label { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.left-icon { | ||
margin-right: 0.8rem; | ||
} | ||
|
||
.label { | ||
color: var(--label__color); | ||
|
||
&.required::after { | ||
content: '*'; | ||
margin-left: 0.4rem; | ||
color: var(--color-normal-txt-base); | ||
} | ||
} | ||
|
||
.link { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.8rem; | ||
margin-left: auto; | ||
} | ||
|
||
.link-icon { | ||
font-size: 0.8rem; | ||
} | ||
</style> |