menu: menu alignment options

This commit is contained in:
bordun 2020-05-09 18:12:53 +02:00
parent 4701850924
commit 8f388e974e
2 changed files with 31 additions and 13 deletions

View file

@ -22,7 +22,8 @@ class Menu extends MenuBase {
'- If `layout` is `circular`: diameter (in px)',
'- Else: square size or `[width, height]` array',
]},
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
alignV: {type: 'string', value: 'center', choices: ['center', 'top', 'bottom'], help: 'Set to `top` or `bottom` to change menu alignment (otherwise center)'},
alignH: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change menu alignment (otherwise center)'},
layout: {type: 'string', value: 'circular', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [
'Defines whether the menu\'s layout should be rendered in a circle or in a box'
]},
@ -36,7 +37,8 @@ class Menu extends MenuBase {
weights: {type: 'array', value: '', help: [
'`Array` of `number` defining the weights of each value in `values`',
'Ignored when `mode` is `grid`'
]}
]},
textAlign: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
})
@ -52,8 +54,9 @@ class Menu extends MenuBase {
`})
if (this.getProp('align') === 'left') this.widget.classList.add('left')
if (this.getProp('align') === 'right') this.widget.classList.add('right')
this.widget.classList.add('text-align-' + this.getProp('textAlign'))
this.widget.classList.add('menu-align-h-' + this.getProp('alignH'))
this.widget.classList.add('menu-align-v-' + this.getProp('alignV'))
this.menu = html`<menu></menu>`
this.text = DOM.get(this.widget, '.text')[0]
@ -270,6 +273,9 @@ class Menu extends MenuBase {
parent = parent.parent
}
scrollX += parent.widget.scrollLeft
scrollY += parent.widget.scrollTop
this.container.style.setProperty('--parent-scroll-x', scrollX + 'px')
this.container.style.setProperty('--parent-scroll-y', scrollY + 'px')

View file

@ -149,16 +149,32 @@
position: relative;
@include pseudo-stroke();
&.right .text {
&.text-align-right .text {
justify-content: flex-end;
}
&.left .text{
&.text-align-left .text{
justify-content: flex-start;
}
&.menu-align-h-right {
justify-content: flex-end;
}
&.menu-align-h-left{
justify-content: flex-start;
}
&.menu-align-v-top {
align-items: flex-start;
}
&.menu-align-v-bottom{
align-items: flex-end;
}
}
.text {
flex: 1;
height: 100%;
text-align: center;
display: flex;
justify-content: center;
@ -190,10 +206,11 @@
menu {
// animation: menu-widget-fade .1s forwards;
position: fixed;
z-index: 999999999;
margin-left: calc(-1 * var(--parent-scroll-x));
margin-top: calc(-1 * var(--parent-scroll-y));
overflow: hidden;
@ -223,8 +240,7 @@
border-radius: 100%;
width:var(--size);
height:var(--size);
margin-left: calc(-1 * var(--parent-scroll-x));
margin-top: calc(-1 * var(--parent-scroll-y));
&:after {
content:"";
@ -298,10 +314,6 @@
width:var(--size-box-w);
height:var(--size-box-h);
margin-left: calc(var(--x) - var(--size-box-w) / 2);
margin-top: calc(var(--y) - var(--size-box-h) / 2);
// top:var(--size-box-h);
// margin-top: 0;
display: flex;