-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style location widget for bootstrap5. Inlcude dark mode variant
- Loading branch information
Showing
14 changed files
with
832 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import $ from 'jquery'; | ||
|
||
import {BS5LocationWidget} from './widget.js'; | ||
import {register_array_subscribers} from './widget.js'; | ||
|
||
export * from './widget.js'; | ||
|
||
$(function() { | ||
if (window.ts !== undefined) { | ||
ts.ajax.register(BS5LocationWidget.initialize, true); | ||
} else if (window.bdajax !== undefined) { | ||
bdajax.register(BS5LocationWidget.initialize, true); | ||
} else { | ||
BS5LocationWidget.initialize(); | ||
} | ||
register_array_subscribers(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {LocationWidgetMarkerPopup} from '../widget.js'; | ||
import {LocationWidget} from '../widget.js'; | ||
|
||
const locationIcon = L.divIcon({ | ||
html: '<i class="bi bi-geo-alt-fill custom-marker"></i>', | ||
className: 'leaflet-div-icon', | ||
iconSize: [32, 32], | ||
iconAnchor: [16, 32], | ||
popupAnchor: [0, -32] | ||
}); | ||
|
||
export class BS5LocationWidgetMarker { | ||
|
||
constructor(widget, lat, lon) { | ||
this.widget = widget; | ||
let marker = new L.Marker([lat, lon], {icon: locationIcon}, {draggable: true}); | ||
marker.addTo(widget.markers); | ||
new LocationWidgetMarkerPopup(widget, marker); | ||
marker.on('dragend', this.dragend_handle.bind(this)); | ||
} | ||
|
||
dragend_handle(evt) { | ||
let latlng = evt.target._latlng, | ||
widget = this.widget; | ||
widget.lat = latlng.lat; | ||
widget.lon = latlng.lng; | ||
widget.zoom = widget.map.getZoom(); | ||
} | ||
} | ||
|
||
export class BS5LocationWidget extends LocationWidget { | ||
|
||
static initialize(context) { | ||
$('div.location-map', context).each(function() { | ||
if (window.yafowil_array !== undefined && | ||
window.yafowil_array.inside_template($(this))) { | ||
return; | ||
} | ||
new BS5LocationWidget($(this)); | ||
}); | ||
} | ||
|
||
constructor(elem) { | ||
super(elem); | ||
} | ||
|
||
create_marker(lat, lon) { | ||
console.log('XXXX') | ||
return new BS5LocationWidgetMarker(this, lat, lon); | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// yafowil.widget.array integration | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
function location_on_array_add(inst, context) { | ||
BS5LocationWidget.initialize(context); | ||
} | ||
|
||
export function register_array_subscribers() { | ||
if (window.yafowil_array === undefined) { | ||
return; | ||
} | ||
window.yafowil_array.on_array_event('on_add', location_on_array_add); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
SASS_BIN="./node_modules/sass/sass.js" | ||
SASS_DIR="./scss" | ||
TARGET_DIR="./src/yafowil/widget/location/resources" | ||
|
||
$SASS_BIN $SASS_DIR/bootstrap5.scss --no-source-map $TARGET_DIR/bootstrap5/widget.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
.location-wrapper { | ||
// bootstrap 5 input-group styles | ||
|
||
.leaflet-control-geosearch { | ||
.results { | ||
border-top-left-radius: 0; | ||
border-top-right-radius: 0; | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
border: 1px solid var(--bs-border-color); | ||
color: var(--bs-body-color); | ||
background-color: var(--bs-body-bg); | ||
|
||
&:not(.active) { | ||
border: 0; | ||
} | ||
|
||
> * { | ||
padding: 0.375rem 0.75rem; | ||
font-size: 1rem; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
border: none; | ||
|
||
&:hover, &.active { | ||
background-color: var(--bs-secondary-bg); | ||
border: none; | ||
} | ||
} | ||
} | ||
|
||
> form { | ||
border: 0; | ||
background: none; | ||
|
||
&.open input { | ||
border-bottom-left-radius: 0; | ||
border-bottom-right-radius: 0; | ||
} | ||
|
||
input { | ||
display: block; | ||
width: 100%; | ||
height: 36px; | ||
padding: 0.375rem 0.75rem; | ||
font-size: var(--bs-body-font-size); | ||
font-weight: var(--bs-body-font-weight); | ||
line-height: var(--bs-body-line-height); | ||
color: var(--bs-body-color); | ||
background-clip: padding-box; | ||
border: 1px solid var(--bs-border-color); | ||
appearance: none; | ||
border-radius: var(--bs-border-radius); | ||
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; | ||
background-color: var(--bs-body-bg); | ||
|
||
&:focus { | ||
color: var(--bs-body-color); | ||
background-color: var(--bs-body-bg); | ||
border-color: var(--bs-border-color); | ||
outline: 0; | ||
box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25); | ||
} | ||
|
||
&::placeholder { | ||
color: var(--bs-placeholder-color); | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
a.reset { | ||
background: none; | ||
line-height: 36px; | ||
height: 36px; | ||
font-size: 0; | ||
|
||
> * { | ||
display: none; | ||
} | ||
|
||
&::before { | ||
content: "\F659"; | ||
font-family: 'bootstrap-icons'; | ||
font-size: 1rem; | ||
color: var(--bs-body-color); | ||
} | ||
} | ||
} | ||
.leaflet-geosearch-bar form { | ||
padding: 0; | ||
} | ||
|
||
.leaflet-control-zoom { | ||
font-size: var(--bs-body-font-size); | ||
font-weight: var(--bs-body-font-weight); | ||
line-height: var(--bs-body-line-height); | ||
color: var(--bs-body-color); | ||
border: 1px solid var(--bs-border-color); | ||
background-color: var(--bs-body-bg); | ||
|
||
.leaflet-control-zoom-in { | ||
font-size: 0; | ||
border-top-left-radius: var(--bs-border-radius)!important; | ||
border-top-right-radius: var(--bs-border-radius)!important; | ||
|
||
&::before { | ||
content: "\F64D"; | ||
font-family: 'bootstrap-icons'; | ||
font-size: 1rem; | ||
color: currentColor; | ||
} | ||
} | ||
.leaflet-control-zoom-out { | ||
font-size: 0; | ||
border-bottom-left-radius: var(--bs-border-radius)!important; | ||
border-bottom-right-radius: var(--bs-border-radius)!important; | ||
|
||
&::before { | ||
content: "\F63B"; | ||
font-family: 'bootstrap-icons'; | ||
font-size: 1rem; | ||
color: currentColor; | ||
} | ||
} | ||
} | ||
|
||
.leaflet-div-icon { | ||
background: transparent; | ||
border: none; | ||
} | ||
.custom-marker { | ||
font-size: 2rem; | ||
color: var(--bs-primary); | ||
} | ||
|
||
div.location-map { | ||
height: 360px; | ||
width: 100%; | ||
} | ||
|
||
.leaflet-popup-content-wrapper, .leaflet-popup-tip { | ||
background: var(--bs-secondary-bg); | ||
box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4); | ||
|
||
a { | ||
color: var(--bs-body-color); | ||
font-size: var(--bs-body-font-size); | ||
} | ||
} | ||
|
||
.leaflet-popup-close-button { | ||
font-size: 0!important; | ||
|
||
&::before { | ||
content: "\F659"; | ||
font-family: 'bootstrap-icons'; | ||
font-size: .7rem; | ||
color: var(--bs-body-color); | ||
} | ||
} | ||
} | ||
|
||
[data-bs-theme="dark"] { | ||
.leaflet-container { | ||
background: #000; | ||
} | ||
|
||
.leaflet-popup-content-wrapper, .leaflet-popup-tip { | ||
box-shadow: 0 3px 14px rgba(0, 0, 0, 1); | ||
} | ||
|
||
.leaflet-layer, | ||
.leaflet-control-zoom-in, | ||
.leaflet-control-zoom-out, | ||
.leaflet-control-attribution { | ||
filter: invert(100%) hue-rotate(355deg) brightness(95%) contrast(90%); | ||
} | ||
} |
Oops, something went wrong.