Merge pull request #44 in YR/star-web-components from feature-component-overlay-fusion to master
* commit 'fd509c8b813483f6312f4163ff467ed1eee26ead': TASK: #110347 处理冲突及样式修改 TASK: #110347 overflowmenu样式修改
This commit is contained in:
commit
ca9334d8a5
|
@ -102,4 +102,10 @@ export default css`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* menubutton */
|
||||||
|
:host(#menuitem) button {
|
||||||
|
font-size: 24px;
|
||||||
|
height: 76px;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import {LitElement, html, TemplateResult, CSSResultArray} from 'lit'
|
import {LitElement, html, TemplateResult, CSSResultArray} from 'lit'
|
||||||
import {customElement, property} from 'lit/decorators.js'
|
import {customElement, property} from 'lit/decorators.js'
|
||||||
import {OverlayOpenDetail} from './overlay-types'
|
import {OverlayOpenDetail} from './overlay-types'
|
||||||
import { sharedStyles } from './overlaystyle'
|
import {sharedStyles} from './overlaystyle'
|
||||||
|
|
||||||
@customElement('star-activeoverlay')
|
@customElement('star-activeoverlay')
|
||||||
export class ActiveOverlay extends LitElement {
|
export class ActiveOverlay extends LitElement {
|
||||||
|
|
||||||
public static override get styles(): CSSResultArray {
|
public static override get styles(): CSSResultArray {
|
||||||
return [sharedStyles]
|
return [sharedStyles]
|
||||||
}
|
}
|
||||||
|
@ -20,9 +19,6 @@ export class ActiveOverlay extends LitElement {
|
||||||
@property({reflect: true})
|
@property({reflect: true})
|
||||||
public placement?: String
|
public placement?: String
|
||||||
|
|
||||||
offset!: number
|
|
||||||
skidding!: number
|
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
@ -37,8 +33,6 @@ export class ActiveOverlay extends LitElement {
|
||||||
this.root = detail.root
|
this.root = detail.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private stealOverlayContent(element: HTMLElement) {}
|
|
||||||
|
|
||||||
// 位置更新函数
|
// 位置更新函数
|
||||||
public updatePosition = () => {
|
public updatePosition = () => {
|
||||||
// 设置最大显示宽度和高度
|
// 设置最大显示宽度和高度
|
||||||
|
@ -57,38 +51,36 @@ export class ActiveOverlay extends LitElement {
|
||||||
const targettop = Number(targetNodePosition?.top)
|
const targettop = Number(targetNodePosition?.top)
|
||||||
const targetbottom = Number(targetNodePosition?.bottom)
|
const targetbottom = Number(targetNodePosition?.bottom)
|
||||||
const targetleft = Number(targetNodePosition?.left)
|
const targetleft = Number(targetNodePosition?.left)
|
||||||
const targetright = Number(targetNodePosition?.right)
|
|
||||||
// 设置样式
|
// 设置样式
|
||||||
this.style.position = 'relative'
|
this.style.position = 'relative'
|
||||||
this.style.zIndex = '10'
|
this.style.zIndex = '10'
|
||||||
this.style.maxWidth = availableWidth + 'px'
|
this.style.maxWidth = availableWidth + 'px'
|
||||||
this.style.maxHeight = availableHeight + 'px'
|
this.style.maxHeight = availableHeight + 'px'
|
||||||
// 边界判断:targetright指被点击的节点右边界,contentwidth表示将要显示的内容的宽度
|
// 边界判断:targetright指被点击的节点右边界,contentwidth表示将要显示的内容的宽度
|
||||||
const rightline = targetright + contentwidth > bodywidth ? true : false // 右侧越界条件
|
const rightline = targetleft + contentwidth > bodywidth ? true : false // 右侧越界条件
|
||||||
const bottomline =
|
const bottomline =
|
||||||
targetbottom + availableHeight > bodyheight ? true : false //下方越界条件
|
targetbottom + availableHeight > bodyheight ? true : false //下方越界条件
|
||||||
|
let left: number
|
||||||
|
let top: number
|
||||||
// 右下角边界
|
// 右下角边界
|
||||||
if (rightline && bottomline) {
|
if (rightline && bottomline) {
|
||||||
this.style.left = targetleft - (contentwidth - targetnode.offsetWidth) + 'px'
|
left = targetleft - (contentwidth - targetnode.offsetWidth)
|
||||||
this.style.top = targettop - contentheight - targetnode.offsetHeight + 'px'
|
top = targettop - contentheight - targetnode.offsetHeight
|
||||||
return
|
|
||||||
} else if (rightline) {
|
} else if (rightline) {
|
||||||
// 右侧边界
|
// 右侧边界
|
||||||
this.style.left =
|
left = targetleft - (contentwidth - targetnode.offsetWidth)
|
||||||
targetleft - (contentwidth - targetnode.offsetWidth) + 'px'
|
top = targettop + targetnode.offsetHeight
|
||||||
this.style.top = targettop + targetnode.offsetHeight + 'px'
|
|
||||||
return
|
|
||||||
} else if (bottomline) {
|
} else if (bottomline) {
|
||||||
// 下侧边界
|
// 下侧边界
|
||||||
this.style.left = targetleft + 'px'
|
left = targetleft
|
||||||
this.style.top = targettop - contentheight - targetnode.offsetHeight + 'px'
|
top = targettop - contentheight - targetnode.offsetHeight
|
||||||
return
|
|
||||||
} else {
|
} else {
|
||||||
// 正常情况
|
// 正常情况
|
||||||
this.style.left = targetleft + 'px'
|
left = targetleft
|
||||||
this.style.top = targettop + targetnode.offsetHeight + 'px'
|
top = targettop + targetnode.offsetHeight
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
this.style.left = left + 'px'
|
||||||
|
this.style.top = top + 'px'
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSlotChange(): void {
|
private onSlotChange(): void {
|
||||||
|
|
|
@ -23,17 +23,17 @@ export class OverlayStack {
|
||||||
activeOverlay.root?.appendChild(placeholderTemplate)
|
activeOverlay.root?.appendChild(placeholderTemplate)
|
||||||
// // 将activeoverlay添加到body底部显示div中
|
// // 将activeoverlay添加到body底部显示div中
|
||||||
let showmenu = document.querySelector('#showmenu') as HTMLElement //后续关联模态时
|
let showmenu = document.querySelector('#showmenu') as HTMLElement //后续关联模态时
|
||||||
if(showmenu==null){
|
if (showmenu == null) {
|
||||||
showmenu = document.createElement('div')
|
showmenu = document.createElement('div')
|
||||||
showmenu.setAttribute('id','showmenu')
|
showmenu.setAttribute('id', 'showmenu')
|
||||||
Object.assign(showmenu.style, {
|
Object.assign(showmenu.style, {
|
||||||
width: '100vw',
|
width: '100vw',
|
||||||
height: '100vh',
|
height: '100vh',
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
backgroundColor: '#00000033',
|
backgroundColor: '#00000033',
|
||||||
justifycontent: 'center',
|
justifycontent: 'center',
|
||||||
});
|
})
|
||||||
}else{
|
} else {
|
||||||
showmenu.style.display = 'fixed'
|
showmenu.style.display = 'fixed'
|
||||||
}
|
}
|
||||||
// 为显示div添加overlay并将div添加到body中
|
// 为显示div添加overlay并将div添加到body中
|
||||||
|
@ -42,9 +42,9 @@ export class OverlayStack {
|
||||||
// 将activeoverlay添加到已打开overlay数组中
|
// 将activeoverlay添加到已打开overlay数组中
|
||||||
this.overlays.push(activeOverlay)
|
this.overlays.push(activeOverlay)
|
||||||
// 为showmenu显示层添加监听
|
// 为showmenu显示层添加监听
|
||||||
showmenu.addEventListener('click',function(e:Event){
|
showmenu.addEventListener('click', function (e: Event) {
|
||||||
console.log(e.target);
|
console.log(e.target)
|
||||||
if(e.target == this){
|
if (e.target == this) {
|
||||||
root!.dispatchEvent(
|
root!.dispatchEvent(
|
||||||
new Event('test', {
|
new Event('test', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
@ -67,7 +67,6 @@ export class OverlayStack {
|
||||||
const placeholder = srcroot?.lastChild as Node
|
const placeholder = srcroot?.lastChild as Node
|
||||||
// 获取overlay中的内容
|
// 获取overlay中的内容
|
||||||
const content = closeactiveoverlay.restoreContent as HTMLElement
|
const content = closeactiveoverlay.restoreContent as HTMLElement
|
||||||
console.log(content.offsetWidth);
|
|
||||||
// 替换子节点
|
// 替换子节点
|
||||||
srcroot?.replaceChild(content, placeholder)
|
srcroot?.replaceChild(content, placeholder)
|
||||||
const showmenu = document.querySelector('#showmenu') as HTMLElement
|
const showmenu = document.querySelector('#showmenu') as HTMLElement
|
||||||
|
|
|
@ -8,6 +8,14 @@ export default css`
|
||||||
max-width: 88vw;
|
max-width: 88vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* menu ul */
|
||||||
|
:host(#iconmenu) {
|
||||||
|
width: 320px;
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -13,6 +13,9 @@ export class PanelActiveOverlay extends LitElement {
|
||||||
public overlayStack = new OverlayStack()
|
public overlayStack = new OverlayStack()
|
||||||
|
|
||||||
public test(e: Event) {
|
public test(e: Event) {
|
||||||
|
this.addEventListener('test', () => {
|
||||||
|
this.overlayStack.closeOverlay()
|
||||||
|
})
|
||||||
if (this.overlayStack.isOpen == false) {
|
if (this.overlayStack.isOpen == false) {
|
||||||
// 获取被点击节点
|
// 获取被点击节点
|
||||||
const targetNode = e.target as HTMLElement
|
const targetNode = e.target as HTMLElement
|
||||||
|
|
|
@ -15,26 +15,24 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
return html`
|
return html`
|
||||||
<star-overflowmenu icon="more">
|
<star-overflowmenu icon="more">
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<star-ul
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
type="onlyheader"
|
|
||||||
title="菜单"
|
|
||||||
id="iconmenu"
|
|
||||||
background="var(--bg-dialog)"
|
|
||||||
>
|
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="info"
|
icon="info"
|
||||||
label="应用详情"
|
label="应用详情"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
label="卸载"
|
label="卸载"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="download-circle"
|
icon="download-circle"
|
||||||
label="固定至Dock"
|
label="固定至Dock"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
|
@ -42,6 +40,7 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="keyboard-circle"
|
icon="keyboard-circle"
|
||||||
label="编辑屏幕"
|
label="编辑屏幕"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,26 +51,24 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
style="position: fixed; top: 50%; left: 50%;"
|
style="position: fixed; top: 50%; left: 50%;"
|
||||||
>
|
>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<star-ul
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
type="onlyheader"
|
|
||||||
title="菜单"
|
|
||||||
id="iconmenu"
|
|
||||||
background="var(--bg-dialog)"
|
|
||||||
>
|
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="info"
|
icon="info"
|
||||||
label="应用详情"
|
label="应用详情"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
label="卸载"
|
label="卸载"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="download-circle"
|
icon="download-circle"
|
||||||
label="固定至Dock"
|
label="固定至Dock"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
|
@ -79,33 +76,35 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="keyboard-circle"
|
icon="keyboard-circle"
|
||||||
label="编辑屏幕"
|
label="编辑屏幕"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
</div>
|
</div>
|
||||||
</star-overflowmenu>
|
</star-overflowmenu>
|
||||||
|
|
||||||
<star-overflowmenu icon="more" style="position: fixed; top: 0; left: 90%;">
|
<star-overflowmenu
|
||||||
|
icon="more"
|
||||||
|
style="position: fixed; top: 0; left: 90%;"
|
||||||
|
>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<star-ul
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
type="onlyheader"
|
|
||||||
title="菜单"
|
|
||||||
id="iconmenu"
|
|
||||||
background="var(--bg-dialog)"
|
|
||||||
>
|
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="info"
|
icon="info"
|
||||||
label="应用详情"
|
label="应用详情"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
label="卸载"
|
label="卸载"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="download-circle"
|
icon="download-circle"
|
||||||
label="固定至Dock"
|
label="固定至Dock"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
|
@ -113,6 +112,7 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="keyboard-circle"
|
icon="keyboard-circle"
|
||||||
label="编辑屏幕"
|
label="编辑屏幕"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -123,26 +123,24 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
style="position: fixed; top: 90%; left: 0;"
|
style="position: fixed; top: 90%; left: 0;"
|
||||||
>
|
>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<star-ul
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
type="onlyheader"
|
|
||||||
title="菜单"
|
|
||||||
id="iconmenu"
|
|
||||||
background="var(--bg-dialog)"
|
|
||||||
>
|
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="info"
|
icon="info"
|
||||||
label="应用详情"
|
label="应用详情"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
label="卸载"
|
label="卸载"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="download-circle"
|
icon="download-circle"
|
||||||
label="固定至Dock"
|
label="固定至Dock"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
|
@ -150,6 +148,7 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="keyboard-circle"
|
icon="keyboard-circle"
|
||||||
label="编辑屏幕"
|
label="编辑屏幕"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -160,26 +159,24 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
style="position: fixed; top: 90%; left: 90%;"
|
style="position: fixed; top: 90%; left: 90%;"
|
||||||
>
|
>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<star-ul
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
type="onlyheader"
|
|
||||||
title="菜单"
|
|
||||||
id="iconmenu"
|
|
||||||
background="var(--bg-dialog)"
|
|
||||||
>
|
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="info"
|
icon="info"
|
||||||
label="应用详情"
|
label="应用详情"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
label="卸载"
|
label="卸载"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
<star-button
|
<star-button
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="download-circle"
|
icon="download-circle"
|
||||||
label="固定至Dock"
|
label="固定至Dock"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
<star-ul type="base" id="iconmenu" background="var(--bg-dialog)">
|
||||||
|
@ -187,6 +184,7 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
type="iconlabel"
|
type="iconlabel"
|
||||||
icon="keyboard-circle"
|
icon="keyboard-circle"
|
||||||
label="编辑屏幕"
|
label="编辑屏幕"
|
||||||
|
id="menuitem"
|
||||||
></star-button>
|
></star-button>
|
||||||
</star-ul>
|
</star-ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -215,6 +213,9 @@ export class PanelOverflowMenu extends LitElement {
|
||||||
star-li span.split {
|
star-li span.split {
|
||||||
color: var(--split-line);
|
color: var(--split-line);
|
||||||
}
|
}
|
||||||
|
::slotted(div) {
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue