Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
feat: added context menu and context button components
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianKienle committed Jun 29, 2019
1 parent b78ce9f commit 1aaf128
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/ContextButton/ContextButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
import FdButton from "./../Button/Button.vue";
export default {
name: "FdContextButton",
extends: FdButton,
props: {
styling: {
default: "light"
},
icon: {
default: "overflow"
}
}
};
</script>
4 changes: 4 additions & 0 deletions src/components/ContextButton/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ContextButton from "./ContextButton.vue";
import { pluginify } from "./../../util";
export default pluginify(ContextButton);
export { ContextButton };
29 changes: 29 additions & 0 deletions src/components/ContextMenu/ContextMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<fd-menu-popover placement="bottom-start" with-arrow :flips="false">
<template #control="popoverProps">
<slot name="button" v-bind="controlProps(popoverProps)">
<fd-context-button @click="popoverProps.toggle" />
</slot>
</template>
<template #default>
<slot />
</template>
</fd-menu-popover>
</template>

<script>
import FdMenuPopover from "./../MenuPopover/MenuPopover.vue";
import FdContextButton from "./../ContextButton/ContextButton.vue";
export default {
name: "FdContextMenu",
components: { FdMenuPopover, FdContextButton },
methods: {
controlProps(controlProps) {
return {
...controlProps,
toggleContextMenu: controlProps.toggle
};
}
}
};
</script>
4 changes: 4 additions & 0 deletions src/components/ContextMenu/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ContextMenu from "./ContextMenu.vue";
import { pluginify } from "./../../util";
export default pluginify(ContextMenu);
export { ContextMenu };
4 changes: 4 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Button from "./Button";
import ButtonGroup from "./ButtonGroup";
import Calendar from "./Calendar";
import Combobox from "./Combobox";
import ContextMenu from "./ContextMenu";
import ContextButton from "./ContextButton";
import ComboboxMenu from "./ComboboxMenu";
import Counter from "./Counter";
import DatePicker from "./DatePicker";
Expand Down Expand Up @@ -64,6 +66,8 @@ const plugin = {
Combobox,
ComboboxMenu,
Counter,
ContextMenu,
ContextButton,
DatePicker,
DatePickerCalendar,
DatePickerInput,
Expand Down
14 changes: 14 additions & 0 deletions src/docs/api/_baseline.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"components": {
"FdContextMenu": {
"slots": {},
"props": {},
"events": {},
"mixins": [],
"componentName": "FdContextMenu"
},
"FdContextButton": {
"slots": {},
"props": {},
"events": {},
"mixins": [],
"componentName": "FdContextButton"
},
"FdVirtualizedList": {
"slots": {},
"props": {},
Expand Down
12 changes: 12 additions & 0 deletions src/docs/pages/Context Menu/0-context-menu-default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<title>Default Context Menu</title>

<template>
<fd-context-menu>
<fd-menu-list>
<fd-menu-item>New File</fd-menu-item>
<fd-menu-item>New Window</fd-menu-item>
<fd-menu-item>About Fundamental Vue</fd-menu-item>
<fd-menu-item>Check for Updates…</fd-menu-item>
</fd-menu-list>
</fd-context-menu>
</template>
24 changes: 24 additions & 0 deletions src/docs/pages/Context Menu/1-context-menu-custom-button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<title>Context Menu with custom Button</title>

<docs>
Use the `button`-slot in order to provide a custom `fd-context-button`.
</docs>

<template>
<fd-context-menu>
<template #button="{toggleContextMenu}">
<fd-context-button
styling="emphasized"
:icon="null"
@click="toggleContextMenu"
>More…</fd-context-button
>
</template>
<fd-menu-list>
<fd-menu-item>New File</fd-menu-item>
<fd-menu-item>New Window</fd-menu-item>
<fd-menu-item>About Fundamental Vue</fd-menu-item>
<fd-menu-item>Check for Updates…</fd-menu-item>
</fd-menu-list>
</fd-context-menu>
</template>
9 changes: 9 additions & 0 deletions src/docs/pages/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
"FdCalendar"
]
},
{
"id": "./Context Menu/index.ts",
"status": "experimental",
"slug": "context-menu",
"key": "./Context Menu/index.ts",
"title": "Context Menu",
"icon": "overflow",
"related": ["FdContextMenu"]
},
{
"id": "./Colors/index.ts",
"status": "inprogress",
Expand Down

0 comments on commit 1aaf128

Please sign in to comment.