Skip to content

Commit

Permalink
fix: improved the design of layer header name and buttons. Show toolt…
Browse files Browse the repository at this point in the history
…ip to describe what they are.
  • Loading branch information
JinIgarashi committed Dec 29, 2023
1 parent db13edb commit 730fb29
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-worms-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"geohub": patch
---

fix: improved the design of layer header name and buttons. Show tooltip to describe what they are.
50 changes: 31 additions & 19 deletions sites/geohub/src/components/pages/map/layers/LayerTemplate.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<script lang="ts">
import { AccessLevel } from '$lib/config/AppConfig';
import { clean, getAccessLevelIcon, getLayerStyle, handleEnterKey, initTippy } from '$lib/helper';
import {
clean,
getAccessLevelIcon,
getLayerStyle,
handleEnterKey,
initTippy,
initTooltipTippy
} from '$lib/helper';
import type { Layer, RasterTileMetadata, VectorTileMetadata } from '$lib/types';
import {
EDITING_LAYER_STORE_CONTEXT_KEY,
Expand Down Expand Up @@ -63,6 +70,8 @@
});
let tooltipContent: HTMLElement;
const tippyTooltip = initTooltipTippy();
const handleZoomToLayer = () => {
clickMenuButton();
let bounds: LngLatBoundsLike;
Expand Down Expand Up @@ -170,22 +179,35 @@
</div>
{/if}

<i class="fa-solid fa-lock fa-lg px-2 access-icon {accessIcon ? 'show' : ''}" />

<span class="layer-name has-text-weight-bold is-size-6 pl-1">
<span
class="layer-name is-size-5 has-text-grey-dark"
use:tippyTooltip={{ content: layer.name }}
>
{clean(layer.name)}
</span>
</div>

<div class="is-flex is-align-items-center">
{#if accessIcon}
<button
class="button menu-button p-0 px-3"
use:tippyTooltip={{ content: 'This dataset has limited data accesibility' }}
>
<span class="icon is-small">
<i class="fa-solid fa-circle-exclamation fa-lg has-text-grey-dark"></i>
</span>
</button>
{/if}

{#if showEditButton}
<button
class="button menu-button hidden-mobile"
class="button menu-button hidden-mobile p-0 px-3"
on:click={handleEditLayer}
disabled={($editingLayerStore && $editingLayerStore.id !== layer.id) ?? false}
use:tippyTooltip={{ content: 'Edit the settings on how the layer is visualised.' }}
>
<span class="icon is-small">
<i class="fa-solid fa-palette fa-lg"></i>
<i class="fa-solid fa-sliders fa-lg has-text-grey-dark"></i>
</span>
</button>
{/if}
Expand All @@ -194,11 +216,11 @@

<div class="dropdown-trigger">
<button
class="button menu-button menu-button-{layer.id}"
class="button menu-button menu-button-{layer.id} p-0 px-3"
use:tippy={{ content: tooltipContent }}
>
<span class="icon is-small">
<i class="fas fa-ellipsis fa-lg" aria-hidden="true"></i>
<i class="fas fa-ellipsis fa-lg has-text-grey-dark" aria-hidden="true"></i>
</span>
</button>
</div>
Expand Down Expand Up @@ -290,14 +312,6 @@
.header {
max-height: 60px;
.access-icon {
visibility: hidden;
&.show {
visibility: visible;
}
}
.layer-header {
cursor: default;
Expand All @@ -310,12 +324,10 @@
}
.layer-name {
align-items: center;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
-webkit-line-clamp: 1;
}
:global(.tippy-box[data-theme='transparent']) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { initTooltipTippy } from '$lib/helper';
import type { Layer } from '$lib/types';
import {
LAYERLISTSTORE_CONTEXT_KEY,
Expand All @@ -12,6 +13,8 @@
const map: MapStore = getContext(MAPSTORE_CONTEXT_KEY);
const layerListStore: LayerListStore = getContext(LAYERLISTSTORE_CONTEXT_KEY);
const tippyTooltip = initTooltipTippy();
export let layer: Layer;
const layerId = layer.id;
Expand Down Expand Up @@ -50,9 +53,17 @@
});
</script>

<button class="button menu-button" on:click={toggleVisibility}>
<button
class="button menu-button p-0 px-3"
on:click={toggleVisibility}
use:tippyTooltip={{ content: 'Change the layer visibility' }}
>
<span class="icon is-small">
<i class="fa-solid {visibility === 'visible' ? 'fa-eye' : 'fa-eye-slash'} fa-lg" />
<i
class="fa-solid {visibility === 'visible'
? 'fa-eye'
: 'fa-eye-slash'} fa-lg has-text-grey-dark"
/>
</span>
</button>

Expand Down
20 changes: 20 additions & 0 deletions sites/geohub/src/lib/helper/initTippy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ export const initTippy = (options?: TippyProps) => {
const tippy = createTippy(props);
return tippy;
};

/**
* Create tippy object for tooltip purpose
* @param options TippyProps
* @returns Tippy object
*/
export const initTooltipTippy = (options?: TippyProps) => {
let props: TippyProps = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
trigger: 'mouseenter focus'
};

if (options) {
props = Object.assign(props, options);
}

const tippy = createTippy(props);
return tippy;
};

0 comments on commit 730fb29

Please sign in to comment.