Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes broken style when using MapboxDirections and MapboxGeocoder #226

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controls/geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Geocoder {

// Template
var el = document.createElement('div');
el.className = 'mapboxgl-ctrl-geocoder';
el.className = 'mapboxgl-ctrl-geocoder mapboxgl-ctrl-geocoder-directions';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't use replace mapboxgl-ctrl-geocoder here with mapboxgl-ctrl-geocoder-directions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that was my first thought. But this will break styles for the guys who already using current class name, this why I added additional class

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But does this mean if I'm changing styles for the MapboxGeocoder I'll inadvertently also change the style used by MapboxDirections?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, it is possible to break style by adding something in MapboxGeocoder, but I don't think this may happen. For example outline: 2px solid red in MapboxGeocder styles will add a red outline for MapboxDirections because outline isn't overridden in MapboxDirections styles.


var icon = document.createElement('span');
icon.className = 'geocoder-icon geocoder-icon-search';
Expand Down
38 changes: 19 additions & 19 deletions src/mapbox-gl-directions.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* Mapboxgl Geocoder */
/* Basics */
.mapboxgl-ctrl-geocoder,
.mapboxgl-ctrl-geocoder *,
.mapboxgl-ctrl-geocoder *:after,
.mapboxgl-ctrl-geocoder *:before {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions *,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions *:after,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions *:before {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
.mapboxgl-ctrl-geocoder {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions {
font:15px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
position:relative;
background-color:white;
Expand All @@ -18,11 +18,11 @@
margin-left:40px;
border-radius:0 0 3px 0;
}
.mapbox-directions-origin .mapboxgl-ctrl-geocoder {
.mapbox-directions-origin .mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions {
border-radius:0 3px 0 0;
}

.mapboxgl-ctrl-geocoder input[type='text'] {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions input[type='text'] {
font-size:12px;
width:100%;
border:0;
Expand All @@ -40,41 +40,41 @@
position:relative;
z-index:1;
}
.mapboxgl-ctrl-geocoder input:focus {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions input:focus {
color:rgba(0,0,0,.75);
outline:0;
outline:thin dotted\8;
}

.mapboxgl-ctrl-geocoder .geocoder-icon-search {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions .geocoder-icon-search {
position:absolute;
top:10px;
left:10px;
}
.mapboxgl-ctrl-geocoder button {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions button {
padding:0;
margin:0;
background-color:#fff;
border:none;
cursor:pointer;
}
.mapboxgl-ctrl-geocoder .geocoder-pin-right * {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions .geocoder-pin-right * {
background-color:#fff;
z-index:2;
position:absolute;
right:10px;
top:10px;
display:none;
}
.mapboxgl-ctrl-geocoder .geocoder-pin-right *.active { display:block; }
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions .geocoder-pin-right *.active { display:block; }

.mapboxgl-ctrl-geocoder,
.mapboxgl-ctrl-geocoder ul {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul {
box-shadow:none;
}

/* Suggestions */
.mapboxgl-ctrl-geocoder ul {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul {
background-color:#fff;
border-radius: 0 0 3px 3px;
left:0;
Expand All @@ -93,7 +93,7 @@
top:auto;
bottom:100%;
}
.mapboxgl-ctrl-geocoder ul > li > a {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul > li > a {
clear:both;
cursor:default;
display:block;
Expand All @@ -104,9 +104,9 @@
white-space:nowrap;
border-bottom:1px solid rgba(0,0,0,0.1);
}
.mapboxgl-ctrl-geocoder ul > li:last-child > a { border-bottom:none; }
.mapboxgl-ctrl-geocoder ul > li.active > a,
.mapboxgl-ctrl-geocoder ul > li > a:hover {
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul > li:last-child > a { border-bottom:none; }
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul > li.active > a,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder-directions ul > li > a:hover {
background-color:#eee;
text-decoration:none;
cursor:pointer;
Expand Down