Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/41' into feat/41
Browse files Browse the repository at this point in the history
# Conflicts:
#	components/Map/MapBase.vue
#	components/Map/MapPois.vue
#	components/PoisDetails/Route/RouteMap.vue
#	lib/markerLayerFactory.ts
  • Loading branch information
joselegitan committed Nov 23, 2023
2 parents 61169c5 + 12817a8 commit efe4adb
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 18 deletions.
2 changes: 1 addition & 1 deletion components/Layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:logo-url="theme && theme.logo_url"
/>

<div class="tw-flex tw-justify-end">
<div class="tw-flex tw-justify-end print:tw-hidden">
<slot></slot>
<NavMenu :entries="navMenuEntries" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/Layout/PoiLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div v-if="icon" class="tw-flex tw-justify-center">
<TeritorioIconBadge :color-fill="colorFill" size="2xl" :picto="icon" />
</div>
<h1>{{ name }}</h1>
<h1 class="print:tw-pb-4">{{ name }}</h1>
<slot name="actions"></slot>
<slot name="body"></slot>
<Footer :attributions="settings.attributions">
Expand Down
4 changes: 2 additions & 2 deletions components/Map/MapBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default defineNuxtComponent({
features: MapPoi[],
clusterPropertiesValues: string[],
clusterPropertiesKeyExpression: maplibregl.ExpressionSpecification,
noCluster?: boolean
cluster?: boolean
) {
if (this.map.getLayer(POI_LAYER)) {
this.map.removeLayer(POI_LAYER)
Expand Down Expand Up @@ -256,7 +256,7 @@ export default defineNuxtComponent({
this.map.addSource(POI_SOURCE, {
type: 'geojson',
cluster: !noCluster,
cluster: cluster,
clusterRadius: 32,
clusterProperties: clusterProps,
clusterMaxZoom: 15,
Expand Down
6 changes: 3 additions & 3 deletions components/Map/MapPois.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export default defineNuxtComponent({
type: Boolean,
default: false,
},
noCluster: {
cluster: {
type: Boolean,
default: false,
default: true,
},
},
setup() {
Expand Down Expand Up @@ -148,7 +148,7 @@ export default defineNuxtComponent({
['get', 'color_fill', ['get', 'display']],
'#000000',
],
this.noCluster
this.cluster
)
if (this.featureIds) {
Expand Down
14 changes: 14 additions & 0 deletions components/PoisCard/PoiCardContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"
class="tw-ml-6 tw-px-3 tw-py-1.5 tw-text-xs tw-text-zinc-800 tw-bg-zinc-100 hover:tw-bg-zinc-200 focus:tw-bg-zinc-200 tw-transition tw-transition-colors tw-rounded-md"
:to="websiteDetails"
:style="
'background:' +
colorLine +
';color:' +
pickTextColorBasedOnBgColor(colorLine, 'white')
"
rel="noopener noreferrer"
@click.stop="trackingPopupEvent('details')"
>
Expand All @@ -26,6 +32,12 @@
v-else
class="tw-ml-6 tw-px-3 tw-py-1.5 tw-text-xs tw-text-zinc-800 tw-bg-zinc-100 hover:tw-bg-zinc-200 focus:tw-bg-zinc-200 tw-transition tw-transition-colors tw-rounded-md"
:href="websiteDetails"
:style="
'background:' +
colorLine +
';color:' +
pickTextColorBasedOnBgColor(colorLine, 'white')
"
rel="noopener noreferrer"
@click.stop="trackingPopupEvent('details')"
>
Expand Down Expand Up @@ -143,6 +155,7 @@ import Fields from '~/components/PoisCard/Fields.vue'
import FavoriteIcon from '~/components/UI/FavoriteIcon.vue'
import TeritorioIcon from '~/components/UI/TeritorioIcon.vue'
import { ApiPoi, ApiPoiId } from '~/lib/apiPois'
import { pickTextColorBasedOnBgColor } from '~/lib/colorDefiner'
import { coordinatesHref } from '~/lib/coordinates'
import { favoritesStore } from '~/stores/favorite'
import { mapStore } from '~/stores/map'
Expand Down Expand Up @@ -255,6 +268,7 @@ export default defineNuxtComponent({
},
methods: {
pickTextColorBasedOnBgColor,
onZoomClick() {
this.trackingPopupEvent('zoom')
this.$emit('zoom-click', this.poi)
Expand Down
2 changes: 1 addition & 1 deletion components/PoisCard/PoisDeck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:poi="item"
:position="(index + 1).toString()"
:class="[
'tw-grow-1',
'tw-grow-1 poi-deck',
!isFavorite(item.properties.metadata.id) &&
'tw-bg-zinc-200 tw-opacity-70',
]"
Expand Down
2 changes: 1 addition & 1 deletion components/PoisDetails/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<v-carousel
:show-arrows="false"
:hide-delimiter-background="true"
class="mb-14"
class="tw-mb-14 print:tw-mb-6"
:height="smallScreen ? 300 : 500"
>
<v-carousel-item v-for="(image, i) in images" :key="i">
Expand Down
8 changes: 7 additions & 1 deletion components/PoisDetails/FieldsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
field.group !== undefined &&
!isListEmpty(field.fields, properties, geom)
"
class="block"
class="block print:tw-mb-2"
>
<div v-if="field.display_mode === 'standard'">
<FieldsHeader
Expand All @@ -28,6 +28,7 @@
v-else-if="field.display_mode === 'card'"
:color-fill="colorFill"
:icon="field.icon"
class="print:tw-hidden"
>
<FieldsHeader
v-if="fieldTranslateK(field.group)"
Expand Down Expand Up @@ -153,4 +154,9 @@ export default defineNuxtComponent({
.block {
margin-bottom: 3rem;
}
@media print {
.block {
margin-bottom: 0.5rem !important;
}
}
</style>
3 changes: 2 additions & 1 deletion components/PoisDetails/PoiDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</template>
<template #actions>
<Share
class="print:tw-hidden"
:title="poi.properties.name"
:href="
poi.properties.editorial &&
Expand Down Expand Up @@ -68,7 +69,7 @@
:extra-attributions="settings.attributions"
:feature-ids="[id]"
:features="[poi]"
class="tw-relative"
class="tw-relative poi-map"
:off-map-attribution="true"
/>
</template>
Expand Down
6 changes: 1 addition & 5 deletions components/PoisDetails/Route/RouteMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:feature-ids="[poiId]"
:fullscreen-control="true"
:off-map-attribution="true"
:no-cluster="noCluster"
:cluster="false"
/>
<div class="detail-wrapper">
<div v-if="points.length > 0" class="detail-left">
Expand Down Expand Up @@ -83,10 +83,6 @@ export default defineNuxtComponent({
type: Boolean,
required: true,
},
noCluster: {
type: Boolean,
required: false,
},
},
data(): {
Expand Down
20 changes: 20 additions & 0 deletions lib/colorDefiner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export function pickTextColorBasedOnBgColor(
bgColor: string,
lightColor?: string,
darkColor?: string
) {
const color = bgColor.charAt(0) === '#' ? bgColor.substring(1, 7) : bgColor
const r = parseInt(color.substring(0, 2), 16) // hexToR
const g = parseInt(color.substring(2, 4), 16) // hexToG
const b = parseInt(color.substring(4, 6), 16) // hexToB
const uiColors = [r / 255, g / 255, b / 255]
const c = uiColors.map((col) => {
if (col <= 0.03928) {
return col / 12.92
}
return Math.pow((col + 0.055) / 1.055, 2.4)
})
const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]

return L > 0.179 ? darkColor : lightColor
}
4 changes: 2 additions & 2 deletions lib/markerLayerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function makerHtmlFactory(
icon: string,
thumbnail: string | undefined,
size: string | null = null,
waypoint?: number
text?: string
): ITMarker {
// Marker
const el: HTMLElement = document.createElement('div')
Expand All @@ -101,7 +101,7 @@ export function makerHtmlFactory(
picto: icon,
image: thumbnail,
size,
text: waypoint,
text: text,
}).mount(el)

return marker
Expand Down
17 changes: 17 additions & 0 deletions pages/poi/[id]/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,20 @@ export default defineNuxtComponent({
@extend .font-light;
}
</style>

<style>
body,
#__nuxt,
#__layout {
-webkit-print-color-adjust: exact;
}
img,
.poi-deck,
.poi-map,
#route-map {
page-break-before: auto;
page-break-after: auto;
page-break-inside: avoid;
}
</style>
3 changes: 3 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = {
flexBasis: {
max: 'max-content',
},
screens: {
print: { raw: 'print' },
},
},
},
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
Expand Down

0 comments on commit efe4adb

Please sign in to comment.