Browse Source

Responsive map component

master
David Larlet 8 months ago
parent
commit
9671ceba98
Signed by: David Larlet <david@larlet.fr> GPG Key ID: 3E2953A359E7E7BD

+ 22
- 2
david/2024/03/26/index.html View File

this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement('div') const mapContainer = document.createElement('div')
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 22
- 2
david/2024/_sources/2024-03-26 - GPX Viewer.html View File

this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement('div') const mapContainer = document.createElement('div')
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 22
- 2
david/2024/apprentissage/index.html View File

this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement('div') const mapContainer = document.createElement('div')
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 22
- 2
david/2024/technique/index.html View File

this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement('div') const mapContainer = document.createElement('div')
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 22
- 2
david/2024/web/index.html View File

this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement('div') const mapContainer = document.createElement('div')
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 23
- 3
david/log/index.xml View File

<link href="https://larlet.fr/david/" rel="alternate" type="text/html" /> <link href="https://larlet.fr/david/" rel="alternate" type="text/html" />
<link href="https://larlet.fr/david/log/" rel="self" /> <link href="https://larlet.fr/david/log/" rel="self" />
<id>https://larlet.fr/david/</id> <id>https://larlet.fr/david/</id>
<updated>2024-03-26T12:00:00+01:00</updated>
<updated>2024-03-27T12:00:00+01:00</updated>
<author> <author>
<name>David Larlet</name> <name>David Larlet</name>
<uri>https://larlet.fr/david/</uri> <uri>https://larlet.fr/david/</uri>
this.shadowRoot.appendChild(linkElement) this.shadowRoot.appendChild(linkElement)
} }


#computeDimensions(mapContainer) {
// There has to be a better way but I feel lazy tonight.
let height = this.dataset.height
let width = this.dataset.width
// Size is in px so we strip these chars and convert to int.
const heightValue = Number(height.slice(0, -2))
const widthValue = Number(width.slice(0, -2))
const mediaQueryMiddle = window.matchMedia(`(max-width: ${widthValue}px)`)
const mediaQuerySmall = window.matchMedia(`(max-width: ${widthValue / 2}px)`)
if (mediaQueryMiddle.matches) {
height = `${heightValue / 2}px`
width = `${widthValue / 2}px`
}
if (mediaQuerySmall.matches) {
height = `${heightValue / 3}px`
width = `${widthValue / 3}px`
}
mapContainer.style.height = height
mapContainer.style.width = width
}

#createMapContainer() { #createMapContainer() {
const mapContainer = document.createElement(&#x27;div&#x27;) const mapContainer = document.createElement(&#x27;div&#x27;)
mapContainer.style.height = this.dataset.height
mapContainer.style.width = this.dataset.width
this.#computeDimensions(mapContainer)
this.shadowRoot.appendChild(mapContainer) this.shadowRoot.appendChild(mapContainer)
return mapContainer return mapContainer
} }

+ 2
- 2
david/recherche/index.html
File diff suppressed because it is too large
View File


Loading…
Cancel
Save