2024-12-27 01:53:26 +01:00
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
property,
|
|
|
|
|
html,
|
|
|
|
|
customElement,
|
|
|
|
|
type TemplateResult,
|
|
|
|
|
cssManager,
|
|
|
|
|
css,
|
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
import * as domtools from '@design.estate/dees-domtools';
|
|
|
|
|
|
|
|
|
|
import { SioCombox } from './sio-combox.js';
|
2025-07-14 14:54:54 +00:00
|
|
|
import { SioIcon } from './sio-icon.js';
|
2025-07-14 15:30:16 +00:00
|
|
|
import { state } from '@design.estate/dees-element';
|
2024-12-27 01:53:26 +01:00
|
|
|
SioCombox;
|
2025-07-14 14:54:54 +00:00
|
|
|
SioIcon;
|
|
|
|
|
|
|
|
|
|
// Import design tokens
|
|
|
|
|
import { colors, bdTheme } from './00colors.js';
|
|
|
|
|
import { spacing, radius, shadows, transitions, sizes } from './00tokens.js';
|
|
|
|
|
import { fontFamilies, typography } from './00fonts.js';
|
2024-12-27 01:53:26 +01:00
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
|
'sio-fab': SioFab;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@customElement('sio-fab')
|
|
|
|
|
export class SioFab extends DeesElement {
|
2025-07-14 14:54:54 +00:00
|
|
|
@property({ type: Boolean })
|
2024-12-27 01:53:26 +01:00
|
|
|
public showCombox = false;
|
|
|
|
|
|
2025-07-14 15:30:16 +00:00
|
|
|
@state()
|
|
|
|
|
private hasShownOnce = false;
|
|
|
|
|
|
2024-12-27 01:53:26 +01:00
|
|
|
public static demo = () => html` <sio-fab .showCombox=${true}></sio-fab> `;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
domtools.DomTools.setupDomTools();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
|
|
|
|
${domtools.elementBasic.styles}
|
|
|
|
|
<style>
|
|
|
|
|
:host {
|
|
|
|
|
will-change: transform;
|
|
|
|
|
position: absolute;
|
|
|
|
|
display: block;
|
|
|
|
|
bottom: 20px;
|
|
|
|
|
right: 20px;
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox {
|
2025-07-14 14:54:54 +00:00
|
|
|
transition: ${transitions.all};
|
2024-12-27 01:53:26 +01:00
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0px;
|
|
|
|
|
right: 0px;
|
2025-07-14 14:54:54 +00:00
|
|
|
height: 56px;
|
|
|
|
|
width: 56px;
|
|
|
|
|
box-shadow: ${cssManager.bdTheme(shadows.md, shadows.lg)};
|
|
|
|
|
line-height: 56px;
|
2024-12-27 01:53:26 +01:00
|
|
|
text-align: center;
|
|
|
|
|
cursor: pointer;
|
2025-07-14 14:54:54 +00:00
|
|
|
background: ${bdTheme('primary')};
|
|
|
|
|
color: ${bdTheme('primaryForeground')};
|
|
|
|
|
border-radius: ${radius.full};
|
2024-12-27 01:53:26 +01:00
|
|
|
user-select: none;
|
2025-07-14 14:54:54 +00:00
|
|
|
border: 1px solid ${bdTheme('border')};
|
2025-07-14 15:11:47 +00:00
|
|
|
animation: fabEntrance 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes fabEntrance {
|
|
|
|
|
from {
|
|
|
|
|
transform: scale(0) rotate(-180deg);
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
to {
|
|
|
|
|
transform: scale(1) rotate(0deg);
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox:hover {
|
2025-07-14 14:54:54 +00:00
|
|
|
box-shadow: ${cssManager.bdTheme(shadows.lg, shadows.xl)};
|
2025-07-14 15:11:47 +00:00
|
|
|
transform: translateY(-2px) scale(1.05);
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox:active {
|
2025-07-14 15:11:47 +00:00
|
|
|
transform: translateY(0) scale(0.98);
|
2025-07-14 14:54:54 +00:00
|
|
|
box-shadow: ${cssManager.bdTheme(shadows.sm, shadows.md)};
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox .icon {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0px;
|
|
|
|
|
left: 0px;
|
|
|
|
|
will-change: transform;
|
2025-07-14 15:11:47 +00:00
|
|
|
transform: ${this.showCombox ? 'rotate(180deg)' : 'rotate(0deg)'};
|
|
|
|
|
transition: transform 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
2024-12-27 01:53:26 +01:00
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
-webkit-user-drag: none;
|
|
|
|
|
-khtml-user-drag: none;
|
|
|
|
|
-moz-user-drag: none;
|
|
|
|
|
-o-user-drag: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox .icon img {
|
2025-07-14 14:54:54 +00:00
|
|
|
filter: ${cssManager.bdTheme('brightness(0) invert(1)', 'brightness(1)')};
|
2024-12-27 01:53:26 +01:00
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
top: 0px;
|
|
|
|
|
left: 0px;
|
|
|
|
|
will-change: transform;
|
|
|
|
|
transform: scale(0.2, 0.2) translateY(-5px);
|
|
|
|
|
}
|
|
|
|
|
#mainbox .icon.open:hover img {
|
2025-07-14 14:54:54 +00:00
|
|
|
filter: ${cssManager.bdTheme('brightness(0) invert(1)', 'brightness(1.2)')};
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox .icon.open {
|
|
|
|
|
opacity: ${this.showCombox ? '0' : '1'};
|
|
|
|
|
pointer-events: ${this.showCombox ? 'none' : 'all'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#mainbox .icon.close {
|
|
|
|
|
opacity: ${this.showCombox ? '1' : '0'};
|
|
|
|
|
pointer-events: ${this.showCombox ? 'all' : 'none'};
|
|
|
|
|
}
|
2025-07-14 14:54:54 +00:00
|
|
|
#mainbox .icon.close:hover sio-icon {
|
|
|
|
|
color: ${bdTheme('primaryForeground')};
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
2025-07-14 14:54:54 +00:00
|
|
|
#mainbox .icon.open sio-icon {
|
2024-12-27 01:53:26 +01:00
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-07-14 14:54:54 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
color: ${bdTheme('primaryForeground')};
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
2025-07-14 14:54:54 +00:00
|
|
|
#mainbox .icon.close sio-icon {
|
2024-12-27 01:53:26 +01:00
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-07-14 14:54:54 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
color: ${bdTheme('primaryForeground')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#comboxContainer {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
pointer-events: none;
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#comboxContainer sio-combox {
|
2025-07-14 14:54:54 +00:00
|
|
|
position: absolute;
|
2025-07-14 15:11:47 +00:00
|
|
|
bottom: calc(56px + ${spacing["4"]});
|
2025-07-14 14:54:54 +00:00
|
|
|
right: 0;
|
|
|
|
|
transition: ${transitions.all};
|
2024-12-27 01:53:26 +01:00
|
|
|
will-change: transform;
|
2025-07-14 15:11:47 +00:00
|
|
|
transform: translateY(${spacing["5"]});
|
2024-12-27 01:53:26 +01:00
|
|
|
opacity: 0;
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-14 14:54:54 +00:00
|
|
|
#comboxContainer.show {
|
|
|
|
|
pointer-events: all;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-27 01:53:26 +01:00
|
|
|
#comboxContainer.show sio-combox {
|
|
|
|
|
transform: translateY(0px);
|
|
|
|
|
opacity: 1;
|
|
|
|
|
pointer-events: all;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<div id="mainbox" @click=${this.toggleCombox}>
|
|
|
|
|
<div class="icon open">
|
2025-07-14 14:54:54 +00:00
|
|
|
<sio-icon icon="message-square" size="28"></sio-icon>
|
2024-12-27 01:53:26 +01:00
|
|
|
<img src="https://assetbroker.lossless.one/brandfiles/00general/favicon_socialio.svg" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="icon close">
|
2025-07-14 14:54:54 +00:00
|
|
|
<sio-icon icon="x" size="22"></sio-icon>
|
2024-12-27 01:53:26 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-07-14 15:30:16 +00:00
|
|
|
<div id="comboxContainer" class="${this.showCombox ? 'show' : ''}">
|
|
|
|
|
${this.showCombox || this.hasShownOnce ? html`
|
|
|
|
|
<sio-combox @close=${() => this.showCombox = false}></sio-combox>
|
|
|
|
|
` : ''}
|
2024-12-27 01:53:26 +01:00
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* toggles the combox
|
|
|
|
|
*/
|
|
|
|
|
public async toggleCombox() {
|
|
|
|
|
console.log('toggle combox');
|
|
|
|
|
this.showCombox = !this.showCombox;
|
2025-07-14 15:30:16 +00:00
|
|
|
if (this.showCombox) {
|
|
|
|
|
this.hasShownOnce = true;
|
|
|
|
|
}
|
2024-12-27 01:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async firstUpdated(args) {
|
|
|
|
|
super.firstUpdated(args);
|
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
|
const sioCombox: SioCombox = this.shadowRoot.querySelector('sio-combox');
|
|
|
|
|
const mainBox: HTMLElement = this.shadowRoot.querySelector('#mainbox');
|
|
|
|
|
sioCombox.referenceObject = mainBox;
|
|
|
|
|
|
|
|
|
|
domtools.keyboard
|
|
|
|
|
.on([domtools.keyboard.keyEnum.Ctrl, domtools.keyboard.keyEnum.S])
|
|
|
|
|
.subscribe((event) => {
|
2025-07-14 15:30:16 +00:00
|
|
|
this.toggleCombox();
|
2024-12-27 01:53:26 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|