-
Notifications
You must be signed in to change notification settings - Fork 266
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(web-core): added UiDropdownButton component #8076
Open
J0ris-K
wants to merge
6
commits into
master
Choose a base branch
from
xo6/dropdown-button
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+112
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b5d2f9
feat(web-core): added UiDropdownButton component
J0ris-K a901bee
feat(web-core): added UiDropdownButton component
J0ris-K 240392d
review feedback
J0ris-K 5a13d46
review feedback
J0ris-K c9c020a
review feedback
J0ris-K ae13401
review feedback
J0ris-K File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
@xen-orchestra/lite/src/stories/web-core/dropdown-button/ui-dropdown-button.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,31 @@ | ||
<template> | ||
<ComponentStory | ||
v-slot="{ properties, settings }" | ||
:params="[ | ||
prop('icon') | ||
.type('IconDefinition') | ||
.widget( | ||
choice( | ||
{ label: 'Ship', value: faShip }, | ||
{ label: 'Rocket', value: faRocket }, | ||
{ label: 'Floppy', value: faFloppyDisk }, | ||
{ label: 'Filter', value: faFilter } | ||
) | ||
), | ||
prop('selected').bool().widget(), | ||
prop('disabled').bool().widget().ctx(), | ||
slot(), | ||
setting('defaultSlotContent').preset('Dropdown title').widget(text()).help('Content for default slot'), | ||
]" | ||
> | ||
<UiDropdownButton v-bind="properties">{{ settings.defaultSlotContent }}</UiDropdownButton> | ||
</ComponentStory> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import ComponentStory from '@/components/component-story/ComponentStory.vue' | ||
import { prop, setting, slot } from '@/libs/story/story-param' | ||
import { choice, text } from '@/libs/story/story-widget' | ||
import UiDropdownButton from '@core/components/ui/dropdown-button/UiDropdownButton.vue' | ||
import { faFloppyDisk, faRocket, faShip, faFilter } from '@fortawesome/free-solid-svg-icons' | ||
</script> |
81 changes: 81 additions & 0 deletions
81
@xen-orchestra/web-core/lib/components/ui/dropdown-button/UiDropdownButton.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,81 @@ | ||
<!-- v3 --> | ||
<template> | ||
<button type="button" class="ui-dropdown-item" :class="{ selected }" :disabled="isDisabled"> | ||
<VtsIcon :icon accent="current" class="left-icon" fixed-width /> | ||
<span class="typo p1-regular label"> | ||
<slot /> | ||
</span> | ||
<VtsIcon :icon="faAngleDown" accent="current" class="right-icon" fixed-width /> | ||
</button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import VtsIcon from '@core/components/icon/VtsIcon.vue' | ||
import { useContext } from '@core/composables/context.composable' | ||
import { DisabledContext } from '@core/context' | ||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types' | ||
import { faAngleDown } from '@fortawesome/free-solid-svg-icons' | ||
|
||
const props = withDefaults( | ||
defineProps<{ | ||
disabled?: boolean | ||
selected?: boolean | ||
icon?: IconDefinition | ||
}>(), | ||
{ disabled: undefined } | ||
) | ||
|
||
const isDisabled = useContext(DisabledContext, () => props.disabled) | ||
</script> | ||
|
||
<style scoped lang="postcss"> | ||
.ui-dropdown-item { | ||
display: inline-flex; | ||
align-items: center; | ||
padding-block: 0.4rem; | ||
padding-inline: 1.6rem; | ||
gap: 0.8rem; | ||
background: var(--color-neutral-background-primary); | ||
border: 0.1rem solid var(--color-info-txt-base); | ||
border-radius: 9rem; | ||
cursor: pointer; | ||
position: relative; | ||
color: var(--color-info-txt-base); | ||
|
||
&:hover { | ||
border-color: var(--color-info-txt-hover); | ||
background-color: var(--color-info-background-hover); | ||
color: var(--color-info-txt-hover); | ||
} | ||
|
||
&:active { | ||
border-color: var(--color-info-txt-active); | ||
background-color: var(--color-info-background-active); | ||
color: var(--color-info-txt-active); | ||
} | ||
|
||
&.selected:not(:disabled) { | ||
border: 0.2rem solid var(--color-info-txt-base); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with just changing the border width is that it creates a shift of the button when selected. Padding should be adjusted as well. |
||
background-color: var(--color-info-background-selected); | ||
} | ||
|
||
&:focus-visible { | ||
outline: none; | ||
|
||
&::before { | ||
content: ''; | ||
position: absolute; | ||
inset: -0.5rem; | ||
border: 0.2rem solid var(--color-info-txt-base); | ||
border-radius: 0.4rem; | ||
} | ||
} | ||
|
||
&:disabled { | ||
cursor: not-allowed; | ||
border-color: var(--color-neutral-txt-secondary); | ||
background-color: var(--color-neutral-background-disabled); | ||
color: var(--color-neutral-txt-secondary); | ||
} | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't noticed on the first review, but shouldn't this story be in the
web-core/ui
folder?