Update StatesBar (Safari fix)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
Alexander Platov 2022-02-11 20:41:16 +07:00
parent aca81cedb0
commit 2307ab5eb5
3 changed files with 97 additions and 81 deletions

View File

@ -200,3 +200,66 @@
} }
} }
.ac-column__list-item + .ac-column__list-item { margin-top: .75rem; } .ac-column__list-item + .ac-column__list-item { margin-top: .75rem; }
/* StatesBar */
.antiStatesBar {
overflow-x: auto;
display: flex;
align-items: center;
flex: 1 0;
padding: 0.125rem 0;
min-width: 0;
// width: auto;
&::-webkit-scrollbar:horizontal { height: 0.125rem; }
&::-webkit-scrollbar-track { margin: 0.25rem; }
&::-webkit-scrollbar-thumb { background-color: var(--theme-bg-accent-color); }
&.mask-none { mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 1); }
&.mask-left { mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 1) 1rem); }
&.mask-right { mask-image: linear-gradient(to left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 1) 1rem); }
&.mask-both {
mask-image: linear-gradient(
to right,
rgba(0, 0, 0, 0) 0,
rgba(0, 0, 0, 1) 1rem,
rgba(0, 0, 0, 1) calc(100% - 1rem),
rgba(0, 0, 0, 0) 100%
);
}
.asb-bar {
flex: 1 0 auto;
position: relative;
display: flex;
min-width: 0;
// max-width: 100%;
width: auto;
// height: auto;
&__back {
width: auto;
height: 2.25rem;
}
&__element {
fill: var(--theme-button-bg-enabled);
stroke: var(--theme-bg-accent-color);
stroke-linecap: round;
stroke-linejoin: round;
}
&__selected { fill: red; }
.asb-label__container {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 1rem;
right: 1rem;
min-width: 0;
width: calc(100% - 2rem);
height: 100%;
}
}
}

View File

@ -33,7 +33,7 @@
let maskLeft: boolean = false let maskLeft: boolean = false
let maskRight: boolean = false let maskRight: boolean = false
let mask: 'left' | 'right' | 'both' | 'none' = 'none' let mask: 'left' | 'right' | 'both' | 'none' = 'none'
let stepStyle = (gap === 'small') ? 'step-lr25' : 'step-lr75' let stepStyle = (gap === 'small') ? 'safari-gap-1' : 'safari-gap-2'
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -87,9 +87,12 @@
} }
}) })
onDestroy(() => { if (div) div.removeEventListener('scroll', checkMask) }) onDestroy(() => { if (div) div.removeEventListener('scroll', checkMask) })
afterUpdate(() => {
console.log('!!!!!!!!!!!!!!!!!!!!!!! UPDATED')
})
</script> </script>
<div bind:this={div} class="flex-row-center statusesbar-container mask-{mask} {stepStyle}"> <div bind:this={div} class="antiStatesBar mask-{mask} {stepStyle}">
{#each states as item, i (item._id)} {#each states as item, i (item._id)}
<StatesBarElement <StatesBarElement
label={item.title} label={item.title}
@ -102,40 +105,3 @@
/> />
{/each} {/each}
</div> </div>
<style lang="scss">
.statusesbar-container {
overflow-x: auto;
padding: 0.125rem 0;
width: auto;
&::-webkit-scrollbar:horizontal {
height: 0.125rem;
}
&::-webkit-scrollbar-track {
margin: 0.25rem;
}
&::-webkit-scrollbar-thumb {
background-color: var(--theme-bg-accent-color);
}
}
.mask-left {
mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 1) 1rem);
}
.mask-right {
mask-image: linear-gradient(to left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 1) 1rem);
}
.mask-both {
mask-image: linear-gradient(
to right,
rgba(0, 0, 0, 0) 0,
rgba(0, 0, 0, 1) 1rem,
rgba(0, 0, 0, 1) calc(100% - 1rem),
rgba(0, 0, 0, 0) 100%
);
}
.mask-none {
mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 1);
}
</style>

View File

@ -25,79 +25,66 @@
let lenght: number = 0 let lenght: number = 0
let text: HTMLElement let text: HTMLElement
let divBar: HTMLElement
let svgBack: SVGElement
// $: if (text) lenght = (text.clientWidth + 20 > 300) ? 300 : text.clientWidth + 20
// $: if (lenght) {
// if (position === 'start') d = `M0,8c0-4.4,3.6-8,8-8h2h${lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16c-0.3,0.8-1,1.3-1.9,1.3L${lenght + 10},36H10 l-2,0c-4.4,0-8-3.6-8-8V8z`
// else if (position === 'middle') d = `M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h${lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16 c-0.3,0.8-1,1.3-1.9,1.3H${lenght + 10}H10H1c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z`
// else if (position === 'end') d = `M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h${lenght}h2c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H1 c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z`
// else d = `M0,8c0-4.4,3.6-8,8-8l2,0h${lenght}l2,0c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H8c-4.4,0-8-3.6-8-8V8z`
// }
afterUpdate(() => { afterUpdate(() => {
if (text) lenght = (text.clientWidth + 20 > 300) ? 300 : text.clientWidth + 20 if (text) lenght = (text.clientWidth + 20 > 300) ? 300 : text.clientWidth + 20
if (divBar) divBar.style.width = lenght + 20 + 'px'
if (svgBack) svgBack.style.width = lenght + 20 + 'px'
}) })
</script> </script>
<div class="hidden-text" bind:this={text}>{label}</div> <div class="hidden-text" bind:this={text}>{label}</div>
{#if lenght > 0} {#if lenght > 0}
<div <div
class="statuses-bar" bind:this={divBar}
class="asb-bar"
class:cursor-pointer={!selected} class:cursor-pointer={!selected}
class:cursor-default={selected} class:cursor-default={selected}
on:click|stopPropagation on:click|stopPropagation
> >
<div class="label-container"><div class="overflow-label">{label}</div></div> <svg
<svg class="statuses-bar__back" viewBox="0 0 {lenght + 20} 36" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> bind:this={svgBack}
{#if position === 'start'} class="asb-bar__back"
viewBox="0 0 {lenght + 20} 36"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
{#if (position === 'start') }
<path <path
class="statuses-bar__{selected ? 'selected' : 'element'}" class="asb-bar__{selected ? 'selected' : 'element'}"
style={selected ? `fill: ${color};` : ''} style={selected ? `fill: ${color};` : ''}
d="M0,8c0-4.4,3.6-8,8-8h2h{lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16c-0.3,0.8-1,1.3-1.9,1.3L{lenght + 10},36H10 l-2,0c-4.4,0-8-3.6-8-8V8z" d="M0,8c0-4.4,3.6-8,8-8h2h{lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16c-0.3,0.8-1,1.3-1.9,1.3L{lenght + 10},36H10 l-2,0c-4.4,0-8-3.6-8-8V8z"
/> />
{:else if position === 'middle'} {:else if (position === 'middle') }
<path <path
class="statuses-bar__{selected ? 'selected' : 'element'}" class="asb-bar__{selected ? 'selected' : 'element'}"
style={selected ? `fill: ${color};` : ''} style={selected ? `fill: ${color};` : ''}
d="M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h{lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16 c-0.3,0.8-1,1.3-1.9,1.3H{lenght + 10}H10H1c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z" d="M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h{lenght}h1.8c0.8,0,1.6,0.5,1.9,1.3l6.1,16c0.2,0.5,0.2,1,0,1.4l-6.1,16 c-0.3,0.8-1,1.3-1.9,1.3H{lenght + 10}H10H1c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z"
/> />
{:else if position === 'end'} {:else if (position === 'end') }
<path <path
class="statuses-bar__{selected ? 'selected' : 'element'}" class="asb-bar__{selected ? 'selected' : 'element'}"
style={selected ? `fill: ${color};` : ''} style={selected ? `fill: ${color};` : ''}
d="M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h{lenght}h2c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H1 c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z" d="M6.1,17.3l-6-15.9C-0.2,0.7,0.3,0,1,0h9h{lenght}h2c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H1 c-0.7,0-1.2-0.7-0.9-1.4l6-15.9C6.3,18.3,6.3,17.7,6.1,17.3z"
/> />
{:else} {:else}
<path <path
class="statuses-bar__{selected ? 'selected' : 'element'}" class="asb-bar__{selected ? 'selected' : 'element'}"
style={selected ? `fill: ${color};` : ''} style={selected ? `fill: ${color};` : ''}
d="M0,8c0-4.4,3.6-8,8-8l2,0h{lenght}l2,0c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H8c-4.4,0-8-3.6-8-8V8z" d="M0,8c0-4.4,3.6-8,8-8l2,0h{lenght}l2,0c4.4,0,8,3.6,8,8v20c0,4.4-3.6,8-8,8h-2H10H8c-4.4,0-8-3.6-8-8V8z"
/> />
{/if} {/if}
</svg> </svg>
<div class="asb-label__container"><div class="overflow-label">{label}</div></div>
</div> </div>
{/if} {/if}
<style lang="scss">
.statuses-bar {
position: relative;
max-width: 100%;
height: min-content;
&__back {
height: 2.25rem;
}
&__element {
fill: var(--theme-button-bg-enabled);
stroke: var(--theme-bg-accent-color);
stroke-linecap: round;
stroke-linejoin: round;
}
&__selected { fill: red; }
.label-container {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 1rem;
right: 1rem;
min-width: 0;
width: calc(100% - 2rem);
height: 100%;
}
}
</style>