-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-menu): add
<SActionMenu>
(#426)
Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
- Loading branch information
Showing
14 changed files
with
718 additions
and
538 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { type DropdownSection, useManualDropdownPosition } from '../composables/Dropdown' | ||
import { useFlyout } from '../composables/Flyout' | ||
import SButton, { type Mode, type Size, type Tooltip, type Type } from './SButton.vue' | ||
import SDropdown from './SDropdown.vue' | ||
export type { Mode, Size, Tooltip, Type } | ||
const props = defineProps<{ | ||
tag?: string | ||
size?: Size | ||
type?: Type | ||
mode?: Mode | ||
icon?: any | ||
iconMode?: Mode | ||
label?: string | ||
labelMode?: Mode | ||
rounded?: boolean | ||
block?: boolean | ||
loading?: boolean | ||
disabled?: boolean | ||
tooltip?: Tooltip | ||
options: DropdownSection[] | ||
}>() | ||
const container = ref<any>(null) | ||
const { isOpen, toggle } = useFlyout(container) | ||
const { position, update: updatePosition } = useManualDropdownPosition(container) | ||
async function onOpen() { | ||
if (!props.disabled) { | ||
updatePosition() | ||
toggle() | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="SActionMenu" :class="[block]" ref="container"> | ||
<div class="button"> | ||
<SButton | ||
:tag="tag" | ||
:size="size" | ||
:type="type" | ||
:mode="mode" | ||
:icon="icon" | ||
:icon-mode="iconMode" | ||
:label="label" | ||
:label-mode="labelMode" | ||
:rounded="rounded" | ||
:block="block" | ||
:loading="loading" | ||
:disabled="disabled" | ||
:tooltip="tooltip" | ||
@click="onOpen" | ||
/> | ||
</div> | ||
<div v-if="isOpen" class="dropdown" :class="position"> | ||
<SDropdown :sections="options" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="postcss"> | ||
.SActionMenu { | ||
position: relative; | ||
display: inline-block; | ||
} | ||
.dropdown { | ||
position: absolute; | ||
left: 0; | ||
z-index: var(--z-index-dropdown); | ||
&.top { bottom: calc(100% + 8px); } | ||
&.bottom { top: calc(100% + 8px); } | ||
} | ||
.SActionMenu.block { | ||
display: block; | ||
} | ||
</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,43 @@ | ||
<script setup lang="ts"> | ||
import { useControlSize } from '../composables/Control' | ||
import { type DropdownSection } from '../composables/Dropdown' | ||
import SActionMenu, { type Mode, type Tooltip, type Type } from './SActionMenu.vue' | ||
defineProps<{ | ||
tag?: string | ||
type?: Type | ||
mode?: Mode | ||
icon?: any | ||
iconMode?: Mode | ||
label?: string | ||
labelMode?: Mode | ||
href?: string | ||
loading?: boolean | ||
disabled?: boolean | ||
tooltip?: Tooltip | ||
options: DropdownSection[] | ||
}>() | ||
const size = useControlSize() | ||
</script> | ||
|
||
<template> | ||
<div class="SControlActionMenu"> | ||
<SActionMenu | ||
:tag="tag" | ||
:size="size" | ||
:type="type" | ||
:mode="mode" | ||
:icon="icon" | ||
:icon-mode="iconMode" | ||
:label="label" | ||
:label-mode="labelMode" | ||
:href="href" | ||
:tooltip="tooltip" | ||
:options="options" | ||
block | ||
:loading="loading" | ||
:disabled="disabled" | ||
/> | ||
</div> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,20 @@ | ||
<script setup lang="ts"> | ||
import { type DropdownSectionMenuOption } from '../composables/Dropdown' | ||
import SActionList, { type ActionList } from './SActionList.vue' | ||
defineProps<{ | ||
options: DropdownSectionMenuOption[] | ||
options: ActionList | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<ul class="SDropdownSectionMenu"> | ||
<li v-for="option in options" :key="option.label" class="item"> | ||
<button | ||
class="button" | ||
@click="option.onClick" | ||
:disabled="option.disabled" | ||
> | ||
{{ option.label }} | ||
</button> | ||
</li> | ||
</ul> | ||
<div class="SDropdownSectionMenu"> | ||
<SActionList :list="options" /> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="postcss"> | ||
.SDropdownSectionMenu { | ||
padding: 8px; | ||
background-color: var(--c-bg-elv-3); | ||
} | ||
.button { | ||
display: block; | ||
border-radius: 6px; | ||
padding: 0 8px; | ||
width: 100%; | ||
text-align: left; | ||
line-height: 32px; | ||
font-size: 14px; | ||
font-weight: 400; | ||
transition: color 0.25s, background-color 0.25s; | ||
&:hover:not(:disabled) { | ||
background-color: var(--c-bg-mute-1); | ||
} | ||
&:disabled { | ||
color: var(--c-text-3); | ||
cursor: not-allowed; | ||
} | ||
} | ||
</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
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
Oops, something went wrong.