Skip to content

Commit

Permalink
Refactor/use css class style (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
azarz authored Oct 7, 2024
1 parent d2667b0 commit 26eeb76
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 179 deletions.
5 changes: 4 additions & 1 deletion src/css/directions-results.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
color: white;
}

/* INFO l'affichage est programmatique */
#directionsListDetails {
display: none;
position: relative;
Expand All @@ -127,6 +126,10 @@
font-family: "Open Sans";
}

#directionsResults:has(#directionsShowDetail:checked) #directionsListDetails {
display: flex;
}

.divDirectionsDetailsItem {
display: flex;
flex-direction: row;
Expand Down
8 changes: 8 additions & 0 deletions src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ body {
overflow-x: clip;
}

body.scrollable {
overflow-y: scroll;
}

body:has(action-sheet:not(.d-none)) {
overflow-y: hidden;
}
Expand Down Expand Up @@ -93,6 +97,10 @@ input, textarea, select {
animation: fadeIn 0.15s;
}

#whiteScreen.falseWhite {
background-color: var(--false-white);
}

.hidden {
max-height: 0 !important;
overflow: hidden !important;
Expand Down
29 changes: 29 additions & 0 deletions src/css/map-buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
transition: transform 0.5s ease-in-out;
}

#bottomButtons.routeDraw {
bottom: calc(72px + 112px + max(calc(var(--safe-area-inset-bottom) - 10px - var(--nav-bar-height)), 20px));
}

#bottomButtons.compare {
bottom: calc(42px + var(--safe-area-inset-bottom));
}

#layerManagerBtn {
background-image: url("assets/map-buttons/layers.svg");
position: absolute;
Expand Down Expand Up @@ -414,6 +422,16 @@ button.maplibregl-ctrl-shrink {
z-index: 2500;
}

#bottomButtons.routeDraw {
left: min(50vw, calc(100vh + var(--safe-area-inset-left) + 42px));
width: auto;
bottom: calc(112px + var(--safe-area-inset-bottom));
}

#bottomButtons.compareWidth {
width: calc(100vw - var(--safe-area-inset-left) - var(--safe-area-inset-right));
}

#interactivityBtn {
left: calc(85px + var(--safe-area-inset-left));
}
Expand Down Expand Up @@ -456,4 +474,15 @@ button.maplibregl-ctrl-shrink {
width: min(50vw, calc(100vh + var(--safe-area-inset-left) + 42px));
border-top-right-radius: 8px;
}

#sideBySideLeftLayer.compareLayers {
left: calc(min(50vw, 100vh + var(--safe-area-inset-left) + 42px) + 15px);
}

#sideBySideFadeSlider.compareLayers {
left: calc(min(50vw, 100vh + var(--safe-area-inset-left) + 42px) + 78px);
transform: unset;
width: calc(100vw - 144px - var(--safe-area-inset-left) - var(--safe-area-inset-right) - min(50vw, 100vh + var(--safe-area-inset-left) + 42px) - 15px);
}

}
12 changes: 12 additions & 0 deletions src/css/tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
z-index: 3004;
}

#tabContainer.white {
background-color: white;
}

#tabContainer.compare {
top: 100vh;
}

#tabContainer.noHeight {
height: 0px;
}

#sheetHeader,
#tabHeader {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- Toutes les informations sont affichées dans un onglet resizable
et ancré en bas de l'écran.
-->
<div id="tabContainer" style="height: 0px;">
<div id="tabContainer" class="noHeight">
<div id="tabHeader"><div id="tabHandle"></div><div id="tabClose" tabindex="0" title="Fermer le volet"></div></div>
<%= require('html-loader!./tabs/layermanagerWindow.html').default %>
<%= require('html-loader!./tabs/directionsWindow.html').default %>
Expand Down
4 changes: 2 additions & 2 deletions src/js/compare-poi/compare-poi.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class ComparePoi {
this.dom.text.classList.remove("d-none");
this.dom.title.innerText = `${this.theme}`;
DOM.$comparePoiWindow.classList.remove("d-none");
DOM.$tabContainer.style.removeProperty("top");
DOM.$bottomButtons.style.removeProperty("bottom");
DOM.$tabContainer.classList.remove("compare");
DOM.$bottomButtons.classList.remove("compare");
DOM.$sideBySideLeftLayer.classList.add("d-none");
DOM.$sideBySideRightLayer.classList.add("d-none");
Globals.currentScrollIndex = 2;
Expand Down
6 changes: 1 addition & 5 deletions src/js/directions/directions-results-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,13 @@ let DirectionsResultsDOM = {
*/
__addResultsDetailsContainerDOMElement () {
// contexte de la classse
var self = this;

var div = document.createElement("div");
div.id = "directionsDetails";
div.className = "";

var inputShow = this.dom.inputShow = document.createElement("input");
inputShow.id = "directionsShowDetail";
inputShow.type = "checkbox";
inputShow.addEventListener("change", function (e) {
self.toggleDisplayDetails(e);
});
div.appendChild(inputShow);

var labelShow = document.createElement("label");
Expand Down Expand Up @@ -172,6 +167,7 @@ let DirectionsResultsDOM = {
var canvasProfile = document.createElement("canvas");
canvasProfile.id = "directions-elevationline";
canvasProfile.className = "elevationLineCanvas";
// FIXME: STYLE: passer par une classe et style CSS
canvasProfile.style.width = "100%";
divList.appendChild(canvasProfile);
}
Expand Down
22 changes: 0 additions & 22 deletions src/js/directions/directions-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,6 @@ class DirectionsResults {
Globals.menu.close("directionsResults");
}

/**
* listener issu du dom sur la visualisation des détails du parcours
* @param {*} e
* @fixme trouver une solution full css !
*/
toggleDisplayDetails(e) {
// INFO
// l'affichage ne peut pas être realisé en CSS only
// (car ils ne sont pas issus du même parent)
// input[id="directionsShowDetail"]:checked + label + #directionsListDetails {
// display: block;
// }
var div = document.getElementById("directionsListDetails");
if (e.target.checked) {
div.style.display = "flex";
Globals.currentScrollIndex = 2;
Globals.menu.updateScrollAnchors();
} else {
div.style.display = "none";
}
}

updateDuration(newDuration) {
const oldDuration = this.options.duration;
this.options.duration = newDuration;
Expand Down
2 changes: 2 additions & 0 deletions src/js/elevation-line-control/elevation-line-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ElevationLineControl {
this.chart = null;

this.loadingDom = document.createElement("div"); // div de la patience
// FIXME: STYLE: passer par une classe et style CSS
this.loadingDom.style.width = "100%";
this.loadingDom.style.aspectRatio = "2 / 1";
this.loadingDom.style.position = "sticky";
Expand Down Expand Up @@ -396,6 +397,7 @@ Distance du départ : ${distanceText} ${this.unit}`;
this.target.after(this.loadingDom);
this.loadingDomInDocument = true;
}
// FIXME: STYLE: passer par une classe et style CSS
this.loadingDom.style.removeProperty("display");
}

Expand Down
40 changes: 1 addition & 39 deletions src/js/event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,11 @@ function addListeners() {
Globals.currentScrollIndex = 2;
}
}
if (Globals.backButtonState === "routeDraw") {
DOM.$bottomButtons.style.removeProperty("bottom");
DOM.$bottomButtons.style.removeProperty("left");
DOM.$bottomButtons.style.removeProperty("width");
if (!window.matchMedia("screen and (min-aspect-ratio: 1/1) and (min-width:400px)").matches) {
if (!Globals.routeDraw.readonly) {
DOM.$bottomButtons.style.bottom = "calc(72px + 112px + var(--safe-area-inset-bottom))";
}
} else {
DOM.$bottomButtons.style.left = "min(50vw, calc(100vh + var(--safe-area-inset-left) + 42px))";
DOM.$bottomButtons.style.width = "auto";
if (!Globals.routeDraw.readonly) {
DOM.$bottomButtons.style.bottom = "calc(112px + var(--safe-area-inset-bottom))";
}
}
}
if (["selectOnMapDirections", "selectOnMapIsochrone", "selectOnMapLandmark", "compare"].includes(Globals.backButtonState)) {
Globals.currentScrollIndex = 0;
}
if (Globals.backButtonState === "compareLayers2") {
DOM.$sideBySideLeftLayer.style.removeProperty("left");
if (window.matchMedia("screen and (min-aspect-ratio: 1/1) and (min-width:400px)").matches) {
DOM.$sideBySideLeftLayer.style.left = "calc(50% + 15px)";
}
}

if (["compare", "compareLayers1", "compareLayers2"].includes(Globals.backButtonState)) {
DOM.$bottomButtons.style.removeProperty("width");
if (window.matchMedia("screen and (min-aspect-ratio: 1/1) and (min-width:400px)").matches) {
DOM.$bottomButtons.style.width = "calc(100vw - var(--safe-area-inset-left) - var(--safe-area-inset-right))";
}
const slider = document.querySelector(".maplibregl-compare");
if (slider) {
let sliderX;
Expand All @@ -204,19 +179,6 @@ function addListeners() {
}, 50);
}
}
if (["compareLayers1", "compareLayers2"].includes(Globals.backButtonState)) {
if (window.matchMedia("screen and (min-aspect-ratio: 1/1) and (min-width:400px)").matches) {
DOM.$sideBySideLeftLayer.style.left = "calc(min(50vw, 100vh + var(--safe-area-inset-left) + 42px) + 15px)";
DOM.$sideBySideFadeSlider.style.left = "calc(min(50vw, 100vh + var(--safe-area-inset-left) + 42px) + 78px)";
DOM.$sideBySideFadeSlider.style.transform = "unset";
DOM.$sideBySideFadeSlider.style.width = "calc(100vw - 144px - var(--safe-area-inset-left) - var(--safe-area-inset-right) - min(50vw, 100vh + var(--safe-area-inset-left) + 42px) - 15px)";
} else {
DOM.$sideBySideLeftLayer.style.removeProperty("left");
DOM.$sideBySideFadeSlider.style.removeProperty("left");
DOM.$sideBySideFadeSlider.style.removeProperty("width");
DOM.$sideBySideFadeSlider.style.removeProperty("transform");
}
}
Globals.menu.updateScrollAnchors();
};

Expand Down
3 changes: 3 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,23 @@ function app() {
// Définition des icones
Globals.myPositionIcon = document.createElement("div");
Globals.myPositionIcon.class = "myPositionIcon";
// FIXME: STYLE: passer par une classe et style CSS
Globals.myPositionIcon.style.width = "51px";
Globals.myPositionIcon.style.height = "51px";
Globals.myPositionIcon.style.backgroundSize = "contain";
Globals.myPositionIcon.style.backgroundImage = "url(" + PositionImg + ")";

Globals.myPositionIconGrey = document.createElement("div");
Globals.myPositionIconGrey.class = "myPositionIconGrey";
// FIXME: STYLE: passer par une classe et style CSS
Globals.myPositionIconGrey.style.width = "51px";
Globals.myPositionIconGrey.style.height = "51px";
Globals.myPositionIconGrey.style.backgroundSize = "contain";
Globals.myPositionIconGrey.style.backgroundImage = "url(" + PositionImgGrey + ")";

Globals.searchResultIcon = document.createElement("div");
Globals.searchResultIcon.class = "searchResultIcon";
// FIXME: STYLE: passer par une classe et style CSS
Globals.searchResultIcon.style.width = "36px";
Globals.searchResultIcon.style.height = "36px";
Globals.searchResultIcon.style.backgroundSize = "contain";
Expand Down
1 change: 1 addition & 0 deletions src/js/isochrone/isochrone-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ let IsochroneDOM = {
__setComputeButtonLoading () {
this.dom.isochroneCompute.value = "";
this.dom.isochroneCompute.disabled = true;
// FIXME: STYLE: passer par une classe et style CSS
this.dom.isochroneCompute.style.backgroundImage = "url(" + LoadingWhite + ")";
document.querySelectorAll("#isochroneLocationContainer").forEach((el) => {
el.classList.add("disabled");
Expand Down
1 change: 1 addition & 0 deletions src/js/map-interactivity/interactivity-indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class InteractivityIndicator {
active () {
this.hardDisabled = false;
DOM.$interactivityBtn.classList.remove("d-none");
// FIXME: STYLE: passer par une classe et style CSS
DOM.$interactivityBtn.style.removeProperty("opacity");
DOM.$interactivityBtn.style.removeProperty("color");
document.getElementById("interactivityBtnText").innerText = "La carte est interactive";
Expand Down
1 change: 1 addition & 0 deletions src/js/map-interactivity/map-interactivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class MapInteractivity {
this.#multipleGFI(layersForGFI)
.then(async (resp) => {
this.loading = false;
// FIXME: STYLE: passer par une classe et style CSS
DOM.$mapCenter.style.removeProperty("background-image");
DOM.$mapCenter.style.removeProperty("background-size");
DOM.$mapCenter.classList.add("d-none");
Expand Down
Loading

0 comments on commit 26eeb76

Please sign in to comment.