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