]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
Remove background-color rgba fallback from Leaflet controls
[rails.git] / app / assets / stylesheets / common.scss
1 @use "sass:map";
2 @import "parameters";
3 @import "bootstrap";
4 @import "rails_bootstrap_forms";
5
6 /* Styles common to large and small screens */
7
8 /* Default rules for the body of every page */
9
10 body {
11   font-size: $typeheight;
12   --dark-mode-map-filter: none;
13 }
14
15 time[title] {
16   text-decoration: underline dotted;
17 }
18
19 /* Utility for de-emphasizing content */
20
21 .text-body-secondary a {
22   color: $blue;
23 }
24
25 /* Bootstrap contextual table classes overrides in dark mode */
26
27 @include color-mode(dark) {
28   .table-primary {
29     --bs-table-bg: rgb(var(--bs-primary-rgb), .25);
30   }
31   .table-secondary {
32     --bs-table-bg: rgb(var(--bs-secondary-rgb), .25);
33   }
34   .table-success {
35     --bs-table-bg: rgb(var(--bs-success-rgb), .25);
36   }
37   .table-primary, .table-secondary, .table-success {
38     --bs-table-color: initial;
39     border-color: inherit;
40   }
41 }
42
43 /* Utility for delayed loading spinner */
44
45 .delayed-fade-in {
46   animation: 300ms linear forwards delayed-fade-in;
47 }
48
49 @keyframes delayed-fade-in {
50   0%   { opacity: 0 }
51   66%  { opacity: 0 }
52   100% { opacity: 1 }
53 }
54
55 /* Bootstrap close button overrides for nested light/dark themes */
56
57 [data-bs-theme="dark"],
58 [data-bs-theme] [data-bs-theme="dark"] {
59   --bs-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
60 }
61
62 [data-bs-theme="light"],
63 [data-bs-theme] [data-bs-theme="light"] {
64   --bs-btn-close-filter: none;
65 }
66
67 /* Rules for the header */
68
69 #menu-icon {
70   display: none;
71   position: absolute;
72   top: 0;
73   right: 0;
74   background: image-url("menu-icon.svg") no-repeat;
75   background-size: 30px 30px;
76   width: 30px;
77   height: 30px;
78   margin: 14px 10px 0 0;
79   opacity: 0.6;
80 }
81
82 @include color-mode(dark) {
83   #menu-icon {
84     filter: invert(1);
85   }
86 }
87
88 header {
89   height: $headerHeight;
90   position: relative;
91   font-size: 14px;
92
93   > * {
94     padding: $lineheight * 0.5;
95   }
96
97   h1 {
98     height: $headerHeight;
99     font-size: 18px;
100   }
101
102   .btn {
103     font-size: 14px;
104   }
105
106   .username {
107     max-width: 12em;
108   }
109 }
110
111 nav.primary {
112   #edit_tab .btn-outline-primary {
113     @include button-outline-variant($green, $color-hover: $white, $active-color: $white);
114   }
115
116   .disabled {
117     .btn-outline-primary {
118       color: $grey;
119       cursor: default;
120
121       .caret {
122         border-top-color: $grey;
123       }
124
125       &:hover {
126         background-color: lighten($green, 30%);
127       }
128     }
129   }
130
131   // Small tweaks to the toggle to stop the primary colour showing through
132   // when the menu is shown
133   .show > .btn-outline-primary.dropdown-toggle {
134     background-color: $green;
135     border-color: $green;
136
137     &:focus {
138       box-shadow: 0 0 0 0.2rem fade-out($green, 0.5);
139     }
140   }
141 }
142
143 nav.secondary {
144   .nav-link {
145     padding: 0 0.3rem;
146   }
147
148   > ul {
149     height: 1.5em;
150   }
151 }
152
153 nav.primary, nav.secondary {
154   .dropdown-item {
155     &:hover, &:active {
156       background-color: $green;
157       color: white;
158     }
159   }
160 }
161
162 #compact-secondary-nav {
163   display: none;
164 }
165
166 body.small-nav {
167   #menu-icon {
168     display: block;
169   }
170
171   header {
172     flex-direction: column;
173     height: auto;
174     min-height: $headerHeight;
175
176     &.closed nav {
177       display: none !important;
178     }
179
180     .search_forms {
181       display: block;
182     }
183
184     .username {
185       max-width: unset;
186     }
187   }
188
189   #sidebar .search_forms {
190     display: none;
191   }
192
193   nav.primary {
194     margin-right: 0;
195     padding: 0;
196
197     #edit_tab {
198       width: 100%;
199       padding: 10px;
200     }
201   }
202
203   nav.secondary {
204     flex-direction: column;
205
206     > ul {
207       height: auto;
208       justify-content: center;
209     }
210
211     .user-menu, .login-menu {
212       width: 100%;
213     }
214   }
215
216   #compact-secondary-nav {
217     display: none;
218   }
219
220   .compact-hide {
221     display: inline-block;
222   }
223
224   .overlay-sidebar #sidebar .welcome {
225     display: none;
226   }
227
228   .overlay-sidebar #sidebar #banner {
229     display: none;
230   }
231 }
232
233 /* Utility for styling notification numbers */
234
235 .count-number {
236   background: transparentize(lighten($green, 25%), .25);
237   color: $gray-800;
238   font-weight: $font-weight-normal;
239 }
240
241 /* Rules for Leaflet maps */
242
243 .leaflet-top.leaflet-right,
244 .leaflet-top.leaflet-left {
245   height: 100%;
246   column-gap: 10px;
247   display: flex;
248   flex-direction: column;
249   flex-wrap: wrap-reverse;
250 }
251
252 .leaflet-control .control-button {
253   display: block;
254   height: 40px;
255   width: 40px;
256   color: white;
257   padding: 10px;
258   background-color: rgba(0,0,0,.6);
259   outline: none;
260
261   &:hover,
262   &:focus {
263     background-color: black;
264   }
265
266   &.disabled,
267   &.leaflet-disabled {
268     background-color: rgba(0,0,0,.5);
269     cursor: default;
270   }
271
272   &-first {
273     border-start-start-radius: 4px;
274   }
275
276   &-last {
277     border-end-start-radius: 4px;
278     margin-bottom: 10px;
279   }
280 }
281
282 .leaflet-control.active .control-button {
283   background-color: $vibrant-green;
284 }
285
286 /* Rules for the sidebar and main map area */
287
288 .map-layout {
289   #content {
290     overflow: hidden;
291     position: absolute;
292     top: $headerHeight;
293     bottom: 0;
294     width: 100%;
295   }
296
297   #sidebar, #map {
298     position: relative;
299     height: 100%;
300     overflow-x: hidden;
301     overflow-y: auto;
302   }
303
304   #sidebar {
305     float: left;
306     width: $sidebarWidth;
307   }
308
309   .overlay-sidebar #sidebar {
310     position: absolute;
311     height: auto;
312     overflow: hidden;
313
314     #banner {
315       display: block;
316     }
317
318     .welcome {
319       display: block;
320     }
321
322     .sidebar-close-controls,
323     #sidebar_loader,
324     #sidebar_content {
325       display: none;
326     }
327   }
328
329   .welcome {
330     display: none;
331   }
332
333   #banner {
334     display: none;
335
336     img {
337       display: block;
338       width: $sidebarWidth;
339     }
340   }
341
342   #map {
343     height: 100%;
344     overflow: hidden;
345
346     &.query-active {
347       cursor: help;
348     }
349
350     &.query-disabled {
351       cursor: not-allowed;
352     }
353
354     .leaflet-marker-draggable {
355       cursor: move;
356     }
357
358     .query-marker {
359       animation: 1500ms forwards query-marker-fade;
360
361       @keyframes query-marker-fade {
362         to { opacity: 0 }
363       }
364     }
365   }
366
367   #map-ui {
368     display: none;
369     position: relative;
370     float: right;
371     width: 250px;
372     height: 100%;
373     overflow: auto;
374   }
375 }
376
377 @include media-breakpoint-down(md) {
378   body.map-layout {
379     #sidebar, #map {
380       position: relative;
381       overflow-x: hidden;
382       width: 100%;
383       height: 50%;
384     }
385
386     #map-ui {
387       width: 100%;
388       height: 50%;
389       overflow-y: scroll;
390     }
391
392     .overlay-sidebar.overlay-right-sidebar {
393       #sidebar {
394         position: absolute;
395         width: 350px;
396         height: auto;
397         overflow: hidden;
398       }
399
400       #map {
401         height: 100%;
402       }
403     }
404   }
405 }
406
407 .layers-ui {
408   .base-layers > * {
409     height: 3.5rem;
410
411     > .btn {
412       box-sizing: content-box;
413       top: - map.get($border-widths, 4);
414       left: - map.get($border-widths, 4);
415       --bs-btn-border-color: var(--bs-body-bg);
416     }
417     > .btn:hover {
418       --bs-btn-border-color: var(--bs-primary-border-subtle);
419     }
420   }
421
422   .overlay-layers {
423     li.disabled { color: $darkgrey; }
424   }
425 }
426
427 .share-ui {
428   #mapnik_scale {
429     width: 100px;
430   }
431 }
432
433 .leaflet-top {
434   top: 10px !important;
435   .leaflet-control {
436     margin-right: 0px !important;
437     margin-top: 0px !important;
438   }
439 }
440
441 .leaflet-popup-scrolled {
442   padding-right: $lineheight;
443   border-bottom: 0px !important;
444   border-top: 0px !important;
445 }
446
447 .leaflet-popup-content-wrapper, .leaflet-popup-tip,
448 .leaflet-contextmenu, .leaflet-contextmenu-item,
449 .leaflet-control-attribution, .leaflet-control-scale-line {
450   @extend .bg-body, .text-body;
451 }
452
453 .leaflet-control-attribution, .leaflet-control-scale-line {
454   @extend .bg-opacity-75;
455   text-shadow: none !important;
456 }
457
458 .leaflet-contextmenu-item.over {
459   @extend .bg-body-secondary, .border-secondary, .border-opacity-10;
460 }
461
462 .leaflet-popup-content-wrapper {
463   @extend .rounded-1;
464
465   a {
466     color: var(--bs-link-color) !important;
467   }
468 }
469
470 @include color-mode(dark) {
471   .leaflet-container .leaflet-control-attribution a {
472     color: var(--bs-link-color);
473   }
474
475   .leaflet-control-scale-line {
476     border-color: rgba(var(--bs-light-rgb), .75) !important;
477   }
478 }
479
480 @mixin dark-map-color-scheme {
481   .leaflet-tile-container,
482   .mapkey-table-entry td:first-child > * {
483     filter: var(--dark-mode-map-filter);
484   }
485
486   .leaflet-tile-container .leaflet-tile {
487     filter: none;
488   }
489 }
490
491 body[data-map-theme="dark"] {
492   @include dark-map-color-scheme;
493 }
494
495 @include color-mode(dark) {
496   body:not([data-map-theme]) {
497     @include dark-map-color-scheme;
498   }
499 }
500
501 /* Rules for attribution text under the main map shown on printouts */
502
503 .donate-attr { color: darken($green, 10%) !important; }
504
505 /* Temporary label size override until we remove site-wide font customisation */
506
507 form {
508   label {
509     font-size: 16px;
510   }
511   .col-form-label {
512     font-size: 16px;
513   }
514 }
515
516 /* Stop bootstrap 5 from floating legends when they don't need to be */
517 legend {
518   float: none;
519 }
520
521 /* Override the text colour for primary and secondary buttons, to match our
522    bootstrap 4 colours. Note this has accessibility issues, which is why
523    bootstrap 5 calculates black as the appropriate colour, and we should
524    reconsider our colours at some point with that in mind. */
525
526 .btn-primary {
527   @include button-variant($primary, $primary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
528 }
529
530 .btn-secondary {
531   @include button-variant($secondary, $secondary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
532 }
533
534 .btn-outline-secondary {
535   @include button-outline-variant($secondary, $color-hover: $white, $active-color: $white);
536 }
537
538 /* Rules for the search and direction forms */
539
540 header .search_forms,
541 .directions_form {
542   display: none;
543 }
544
545 .search_form {
546   .describe_location {
547     font-size: 10px;
548   }
549 }
550
551 /* Rules for routing */
552
553 td.distance {
554     font-size: x-small;
555 }
556 tr.turn {
557     cursor: pointer;
558 }
559
560 .routing_marker_column {
561   margin-left: .35rem;
562   margin-right: .35rem;
563   width: 15px;
564
565   img {
566     cursor: move;
567   }
568 }
569
570 /* Rules for the history sidebar */
571
572 .changeset-above-sidebar-viewport {
573   --changeset-border-color: #CC6655;
574   --changeset-fill-color: #DDBBBB;
575   --changeset-outline-color: #FFF4F4;
576 }
577 .changeset-in-sidebar-viewport {
578   --changeset-border-color: #FF9500;
579   --changeset-fill-color: #FFFFAF;
580   --changeset-outline-color: #FFFFFF;
581   &.changeset-highlight-outline {
582     filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .75));
583   }
584 }
585 .changeset-below-sidebar-viewport {
586   --changeset-border-color: #8888AA;
587   --changeset-fill-color: #CCCCDD;
588   --changeset-outline-color: #F4F4FF;
589 }
590 .changeset-highlight-outline {
591   filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .25));
592 }
593
594 #sidebar .changesets {
595   .changeset-color-hint-bar {
596     height: 2px;
597     background: var(--changeset-border-color);
598   }
599
600   li {
601     &.selected {
602       @extend :hover;
603     }
604
605     a.stretched-link > span, a:not(.stretched-link), [title] {
606       position: relative;
607       z-index: 2; /* needs to be higher than Bootstrap's stretched link ::after z-index */
608     }
609   }
610 }
611
612 /* Rules for the browse sidebar */
613
614 #sidebar_content {
615   .browse-section {
616     padding-bottom: $spacer;
617     margin-bottom: $spacer;
618     border-bottom: 1px solid $grey;
619
620     h4:first-child {
621       word-wrap: break-word;
622     }
623   }
624
625   .browse-section:last-of-type {
626     border-bottom: none;
627   }
628
629   .browse-tag-list {
630     table-layout: fixed;
631     white-space: pre-wrap;
632     word-wrap: break-word;
633     word-break: break-word;
634
635     tr:last-child th, tr:last-child td {
636       border-bottom: 0;
637     }
638   }
639
640   .query-results {
641     display: none;
642   }
643 }
644
645 /* Force LTR/RTL alignment for placeholder text */
646
647 .form-control::placeholder {
648   text-align: left;
649 }
650
651 /* Rules for export sidebar */
652
653 .export_form {
654   .export_area_inputs {
655     input[type="text"] {
656       width: 100px;
657     }
658   }
659
660   .export_boxy {
661     > * {
662         margin: -1px;
663     }
664   }
665 }
666
667 /* Rules for edit pages */
668
669 .site-edit {
670   #content {
671     position: absolute;
672     top: $headerHeight;
673     bottom: 0;
674     width: 100%;
675   }
676 }
677
678 /* Rules for non-map content pages */
679
680 .content-inner {
681   max-width: 960px;
682   padding: $lineheight;
683 }
684
685 /* Rules for login and signup pages */
686
687 .sessions-new, .users-new, .users-create {
688   #content .content-inner {
689     max-width: 760px;
690   }
691 }
692
693 .header-illustration {
694   background-position: right;
695   background-repeat: no-repeat;
696   position: relative;
697   min-height: 200px;
698   width: 100%;
699   left: 0;
700   bottom: 0;
701
702   &.new-user-main {
703     background-image: image-url("sign-up-illustration.svg");
704     background-position-x: 70px;
705   }
706
707   &.confirm-main {
708     background-image: image-url("confirm-illustration.svg");
709   }
710
711   &.new-user-terms {
712     background-image: image-url("terms-illustration.svg");
713   }
714 }
715
716 [dir=rtl] .header-illustration {
717   transform: scaleX(-1);
718
719   h1 {
720     transform: scaleX(-1);
721   }
722
723   ul {
724     transform: scaleX(-1);
725   }
726 }
727
728 /* Rules for small maps in content areas */
729
730 .content_map {
731   height: 200px;
732   margin-bottom: $lineheight;
733 }
734
735 @include media-breakpoint-up(md) {
736   .content_map {
737     height: 400px;
738   }
739 }
740
741 /* Rules for the user map */
742
743 .content_map .leaflet-popup-content {
744   margin: $spacer;
745   min-height: 50px;
746 }
747
748 /* Rules for user popups on maps */
749
750 .user_popup {
751   p {
752     padding: 0 0 5px 0;
753     margin: 0 0 0 60px;
754     font-size: 12px;
755   }
756 }
757
758 /* Rules for the diary entry page */
759
760 .diary_entries {
761   #map {
762     height: 400px;
763     display: none;
764   }
765   .diary-comment .col-auto {
766     width: 62px;
767   }
768   .diary-comment .col {
769     max-width: 690px;
770   }
771 }
772
773 /* Rules for the issues page */
774
775 .issues.issues-index {
776   td.reporting_users {
777     max-width: 5rem;
778   }
779 }
780
781 /* Rules for the account confirmation page */
782
783 .accounts-terms-show {
784   .legale {
785     padding: $lineheight;
786     margin-bottom: $lineheight;
787     overflow: auto;
788     height: 20em;
789
790     li {
791       list-style: inherit;
792     }
793
794     ol ol {
795       list-style-type: lower-alpha;
796     }
797   }
798 }
799
800 /* Rules for user images */
801
802 img.user_image {
803   max-width: 100px;
804   max-height: 100px;
805 }
806
807 img.user_thumbnail {
808   max-width: 50px;
809   max-height: 50px;
810 }
811
812 img.user_thumbnail_tiny {
813   width: 25px;
814   height: 25px;
815   object-fit: contain;
816 }
817
818 /* General styles for action lists / subnavs */
819
820 nav.secondary-actions {
821   margin-left: -11px;
822   overflow: hidden;
823   > ul {
824     display: flex;
825     flex-direction: row;
826     flex-wrap: wrap;
827     margin-bottom: 0;
828     margin-left: -1px;
829     padding: 0;
830     > li {
831       flex-basis: auto;
832       list-style: none;
833       border-left: 1px solid $grey;
834       padding-left: $lineheight * 0.5;
835       margin-right: $lineheight * 0.5;
836       margin-bottom: $lineheight * 0.125;
837     }
838   }
839 }
840
841 div.secondary-actions {
842   padding: 10px;
843   text-align: center;
844 }
845
846 /* Rules for rich text */
847
848 .richtext {
849   code {
850     background: var(--bs-secondary-bg);
851     padding: 2px 3px;
852   }
853
854   pre {
855     background: var(--bs-secondary-bg);
856     padding: 2px 3px;
857     white-space: pre-wrap;
858
859     code {
860       padding: 0;
861     }
862   }
863
864   img {
865     padding: $lineheight;
866     background-color: var(--bs-tertiary-bg);
867     display: block;
868     max-width: 100%;
869     margin: auto;
870   }
871
872   blockquote {
873     border-left: $lineheight solid var(--bs-tertiary-bg);
874     padding-left: $lineheight;
875     margin: 0;
876     color: var(--bs-secondary-color);
877   }
878 }
879
880 /* Rules for the "About" page */
881
882 .site-about #content {
883   .content-inner {
884     max-width: 760px;
885   }
886
887   .attr {
888     margin-top: -20px;
889
890     h1 {
891       span {
892         color: $vibrant-green;
893       }
894     }
895
896     .user-image {
897       height: 150px;
898       background-position: 0 50%;
899       background-repeat: no-repeat;
900       background-image: image-url('about/osm.png');
901       background-size: cover;
902       background-color: $vibrant-green;
903     }
904
905     .byosm {
906       background: $vibrant-green;
907     }
908
909     .byosm span {
910       display: inline-block;
911       width: 1em;
912       margin-left: -1em;
913     }
914   }
915 }
916
917 /* Rules for tables with usernames */
918
919 .messages-table .username,
920 #block_list .username {
921   max-width: 20em;
922 }
923
924 /* Rules for navigation tabs */
925
926 .nav-tabs .username {
927   max-width: 20em;
928 }
929
930 .bg-body-secondary .nav-tabs {
931   --bs-border-color: var(--bs-secondary-border-subtle);
932   --bs-secondary-bg: var(--bs-secondary-border-subtle);
933   margin-bottom: -1px;
934 }
935
936 /* Rules for traces */
937
938 img.trace_image {
939   mix-blend-mode: darken;
940 }
941
942 @include color-mode(dark) {
943   img.trace_image {
944     filter: invert(1);
945     mix-blend-mode: lighten;
946   }
947 }
948
949 /* Rules for map sidebar icons */
950
951 .browse-section .browse-element-list {
952   line-height: 1.25rem;
953
954   .browse-icon {
955     height: 1.25rem;
956   }
957
958   .d-flex > .browse-icon {
959     height: max(20px, 1.25rem);
960   }
961
962   @include color-mode(dark) {
963     .browse-icon-invertible {
964       filter: invert(.8) hue-rotate(180deg);
965     }
966   }
967 }
968
969 .heatmap-wrapper {
970   height: 130px;
971 }