Skip to content

Commit

Permalink
Use nested component to configure context menu position (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
tar-g authored Jan 21, 2020
1 parent b898d8e commit 6483f26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ContextMenu from 'devextreme-react/context-menu';
import ContextMenu, { Position } from 'devextreme-react/context-menu';
import List from 'devextreme-react/list';
import './user-panel.scss';

Expand All @@ -21,9 +21,10 @@ export default class UserPanel extends React.Component {
target={'.user-button'}
showEvent={'dxclick'}
width={170}
position={{ my: 'top center', at: 'bottom center' }}
cssClass={'user-menu'}
/>
>
<Position my={'top center'} at={'bottom center'} />
</ContextMenu>
)}
{menuMode === 'list' && (
<List className={'dx-toolbar-menu-action'} items={menuItems} />
Expand Down
16 changes: 5 additions & 11 deletions templates/vue/application/src/components/user-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
target=".user-button"
:items="menuItems"
:width="170"
:position="menuPositionConfig"
show-event="dxclick"
css-class="user-menu"
/>
>
<dx-position my="top center" at="bottom center" />
</dx-context-menu>

<dx-list
v-if="menuMode === 'list'"
Expand All @@ -26,24 +27,17 @@
</template>

<script>
import DxContextMenu from "devextreme-vue/context-menu";
import DxContextMenu, { DxPosition } from "devextreme-vue/context-menu";
import DxList from "devextreme-vue/list";
export default {
props: {
menuMode: String,
menuItems: Array
},
data() {
return {
menuPositionConfig: {
my: "top center",
at: "bottom center"
}
};
},
components: {
DxContextMenu,
DxPosition,
DxList
}
};
Expand Down

0 comments on commit 6483f26

Please sign in to comment.