]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
Merge remote-tracking branch 'upstream/pull/4764'
[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, .leaflet-popup-tip,
461 .leaflet-contextmenu, .leaflet-contextmenu-item,
462 .leaflet-control-attribution, .leaflet-control-scale-line {
463   @extend .bg-body, .text-body;
464 }
465
466 .leaflet-control-attribution, .leaflet-control-scale-line {
467   @extend .bg-opacity-75;
468   text-shadow: none !important;
469 }
470
471 .leaflet-contextmenu-item.over {
472   @extend .bg-body-secondary, .border-secondary, .border-opacity-10;
473 }
474
475 .leaflet-popup-content-wrapper {
476   @extend .rounded-1;
477
478   a {
479     color: var(--bs-link-color) !important;
480   }
481 }
482
483 @include color-mode(dark) {
484   .leaflet-tile-container,
485   .mapkey-table-entry td:first-child > * {
486     filter: brightness(.8);
487   }
488
489   .leaflet-control-attribution a {
490     color: var(--bs-link-color);
491   }
492
493   .leaflet-control-scale-line {
494     @extend .border-light, .border-opacity-75;
495   }
496 }
497
498 /* Rules for attribution text under the main map shown on printouts */
499
500 .donate-attr { color: darken($green, 10%) !important; }
501
502 /* Rules for the sidebar */
503
504 #browse_status {
505   input {
506     display: block;
507     margin-left: auto;
508     margin-right: auto;
509   }
510 }
511
512 /* Temporary label size override until we remove site-wide font customisation */
513
514 form {
515   label {
516     font-size: 16px;
517   }
518   .col-form-label {
519     font-size: 16px;
520   }
521 }
522
523 /* Stop bootstrap 5 from floating legends when they don't need to be */
524 legend {
525   float: none;
526 }
527
528 /* Override the text colour for primary and secondary buttons, to match our
529    bootstrap 4 colours. Note this has accessibility issues, which is why
530    bootstrap 5 calculates black as the appropriate colour, and we should
531    reconsider our colours at some point with that in mind. */
532
533 .btn-primary {
534   @include button-variant($primary, $primary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
535 }
536
537 .btn-secondary {
538   @include button-variant($secondary, $secondary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
539 }
540
541 .btn-outline-secondary {
542   @include button-outline-variant($secondary, $color-hover: $white, $active-color: $white);
543 }
544
545 /* Rules for the search and direction forms */
546
547 header .search_forms,
548 .directions_form {
549   display: none;
550 }
551
552 .search_form {
553   .describe_location {
554     font-size: 10px;
555   }
556 }
557
558 /* Rules for search sidebar */
559
560 #sidebar .search_results_entry {
561   .search_more .loader {
562     display: none;
563   }
564 }
565
566 /* Rules for routing */
567
568 div.direction {
569   background-image: image-url('routing-sprite.png');
570   width: 20px;
571   height: 20px;
572   background-repeat: no-repeat;
573 }
574 @for $i from 0 through 25 {
575 div.direction.i#{$i} { background-position: #{($i)*-20}px 0px; }
576 }
577
578 @include color-mode(dark) {
579   div.direction {
580     filter: invert(1);
581   }
582 }
583
584 td.distance {
585     font-size: x-small;
586 }
587 tr.turn {
588     cursor: pointer;
589 }
590
591 .routing_marker { width: 15px; cursor: move; }
592
593 .browse_status {
594   display: none;
595 }
596
597 /* Rules for the history sidebar */
598
599 #sidebar .changesets {
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   .changeset_more .loader {
612     display: none;
613     width: 100%;
614   }
615 }
616
617 /* Rules for the browse sidebar */
618
619 #sidebar_content {
620   .browse-section {
621     padding-bottom: $spacer;
622     margin-bottom: $spacer;
623     border-bottom: 1px solid $grey;
624
625     h4:first-child {
626       word-wrap: break-word;
627     }
628   }
629
630   .browse-section:last-of-type {
631     border-bottom: none;
632   }
633
634   .browse-tag-list {
635     table-layout: fixed;
636     white-space: pre-wrap;
637     word-wrap: break-word;
638     word-break: break-word;
639
640     tr:last-child th, tr:last-child td {
641       border-bottom: 0;
642     }
643   }
644
645   .note-description {
646     overflow: hidden;
647     margin: 0 0 10px 10px;
648   }
649
650   .query-results {
651     display: none;
652   }
653 }
654
655 /* Bootstrap buttons don't have any vertical margin, so
656    they touch when adjacent buttons wrap onto a new line
657    e.g. wide form buttons on a narrow sidebar */
658
659 .btn-wrapper {
660   > .btn {
661     margin-bottom: $spacer * 0.25;
662   }
663 }
664
665 /* Force LTR/RTL alignment for placeholder text */
666
667 .form-control::placeholder {
668   text-align: left;
669 }
670
671 /* Rules for export sidebar */
672
673 .export_form {
674   .export_area_inputs {
675     input[type="text"] {
676       width: 100px;
677     }
678   }
679
680   .export_boxy {
681     > * {
682         margin: -1px;
683     }
684     #minlon {
685       /*rtl:ignore*/ float: left;
686     }
687     #maxlon {
688       /*rtl:ignore*/ float: right;
689     }
690   }
691 }
692
693 /* Rules for edit pages */
694
695 .site-edit {
696   #content {
697     position: absolute;
698     top: $headerHeight;
699     bottom: 0;
700     width: 100%;
701   }
702 }
703
704 /* Rules for non-map content pages */
705
706 .content-inner {
707   position: relative;
708   max-width: 960px;
709   margin: auto;
710   padding: $lineheight;
711 }
712
713 /* Overrides for pages that use new layout conventions */
714
715 .header-illustration {
716   background-position: 0 0;
717   background-repeat: no-repeat;
718   position: relative;
719   min-height: 200px;
720   width: 100%;
721   left: 0;
722   bottom: 0;
723
724   &.new-user-main {
725     background-image: image-url("sign-up-illustration.png");
726     background-position-x: 50px;
727   }
728
729   &.confirm-main {
730     background-image: image-url("confirm-illustration.png");
731   }
732
733   &.new-user-terms {
734     background-image: image-url("terms-illustration.png");
735   }
736 }
737
738 [dir=rtl] .header-illustration {
739   transform: scaleX(-1);
740
741   h1 {
742     transform: scaleX(-1);
743   }
744 }
745
746 /* Rules for small maps in content areas */
747
748 .content_map {
749   height: 200px;
750   margin-bottom: $lineheight;
751 }
752
753 @include media-breakpoint-up(md) {
754   .content_map {
755     height: 400px;
756   }
757 }
758
759 /* Rules for the user map */
760
761 .content_map .leaflet-popup-content {
762   margin: $spacer;
763   min-height: 50px;
764 }
765
766 /* Rules for user popups on maps */
767
768 .user_popup {
769   p {
770     padding: 0 0 5px 0;
771     margin: 0 0 0 60px;
772     font-size: 12px;
773   }
774 }
775
776 /* Rules for the diary entry page */
777
778 .diary_entries {
779   #map {
780     height: 400px;
781     display: none;
782   }
783   .diary-comment .col-auto {
784     width: 62px;
785   }
786   .diary-comment .col {
787     max-width: 690px;
788   }
789 }
790
791 /* Rules for the account confirmation page */
792
793 .users-terms {
794   .legale {
795     padding: $lineheight;
796     margin-bottom: $lineheight;
797     overflow: auto;
798     height: 20em;
799
800     li {
801       list-style: inherit;
802     }
803
804     ol ol {
805       list-style-type: lower-alpha;
806     }
807   }
808 }
809
810 /* Rules for user images */
811
812 img.user_image {
813   max-width: 100px;
814   max-height: 100px;
815 }
816
817 img.user_thumbnail {
818   max-width: 50px;
819   max-height: 50px;
820 }
821
822 img.user_thumbnail_tiny {
823   width: 25px;
824   height: 25px;
825   object-fit: contain;
826 }
827
828 /* General styles for action lists / subnavs */
829
830 nav.secondary-actions {
831   margin-left: -11px;
832   overflow: hidden;
833   > ul {
834     display: flex;
835     flex-direction: row;
836     flex-wrap: wrap;
837     margin-bottom: 0;
838     margin-left: -1px;
839     padding: 0;
840     > li {
841       flex-basis: auto;
842       list-style: none;
843       border-left: 1px solid $grey;
844       padding-left: $lineheight * 0.5;
845       margin-right: $lineheight * 0.5;
846       margin-bottom: $lineheight * 0.125;
847     }
848   }
849 }
850
851 div.secondary-actions {
852   padding: 10px;
853   text-align: center;
854 }
855
856 /* Rules for rich text */
857
858 .richtext {
859   code {
860     background: var(--bs-secondary-bg);
861     padding: 2px 3px;
862   }
863
864   pre {
865     background: var(--bs-secondary-bg);
866     padding: 2px 3px;
867     white-space: pre-wrap;
868
869     code {
870       padding: 0;
871     }
872   }
873
874   img {
875     padding: $lineheight;
876     background-color: var(--bs-tertiary-bg);
877     display: block;
878     max-width: 100%;
879     margin: auto;
880   }
881
882   blockquote {
883     border-left: $lineheight solid var(--bs-tertiary-bg);
884     padding-left: $lineheight;
885     margin: 0;
886     color: var(--bs-secondary-color);
887   }
888 }
889
890 /* Rules for the "Welcome" page */
891 .site-welcome, .site-fixthemap {
892   .sprite {
893     background-image: image-url("welcome-sprite.png");
894     background-size: 500px 250px;
895     display: block;
896   }
897
898   .sprite.small {
899     width: 50px;
900     height: 50px;
901   }
902
903   .sprite.x {
904     /*rtl:ignore*/ background-position: -50px 0;
905   }
906
907   .sprite.term {
908     margin-right: 10px;
909     vertical-align: middle;
910   }
911
912   .sprite.node {
913     /*rtl:ignore*/ background-position: -100px 0;
914   }
915
916   .sprite.way {
917     /*rtl:ignore*/ background-position: -150px 0;
918   }
919
920   .sprite.tag {
921     /*rtl:ignore*/ background-position: -200px 0;
922   }
923
924   .sprite.editor {
925     /*rtl:ignore*/ background-position: -250px 0;
926   }
927
928   .sprite.question {
929     /*rtl:ignore*/ background-position: -300px 0;
930   }
931
932   .sprite.rules {
933     /*rtl:ignore*/ background-position: -350px 0;
934   }
935 }
936
937 .site-about #content {
938   .content-inner {
939     max-width: 760px;
940   }
941
942   .attr {
943     margin-top: -20px;
944
945     h1 {
946       span {
947         color: $vibrant-green;
948       }
949     }
950
951     .user-image {
952       height: 150px;
953       background-position: 0 50%;
954       background-repeat: no-repeat;
955       background-image: image-url('about/osm.png');
956       background-size: cover;
957       background-color: $vibrant-green;
958     }
959
960     .byosm {
961       background: $vibrant-green;
962     }
963
964     .byosm span {
965       display: inline-block;
966       width: 1em;
967       margin-left: -1em;
968     }
969   }
970
971   .icon {
972     width: 30px;
973     height: 30px;
974     background: 40px 40px image-url('about/sprite.png') no-repeat;
975
976     &.local {
977       /*rtl:ignore*/
978       background-position: 0px 0px;
979     }
980     &.community {
981       /*rtl:ignore*/
982       background-position: 0px -40px;
983     }
984     &.open {
985       /*rtl:ignore*/
986       background-position: 0px -80px;
987     }
988     &.partners {
989       /*rtl:ignore*/
990       background-position: 0px -120px;
991     }
992     &.infringement {
993       /*rtl:ignore*/
994       background-position: 0px -160px;
995     }
996     &.legal {
997       /*rtl:ignore*/
998       background-position: -45px -160px;
999     }
1000   }
1001 }
1002
1003 .auth-container {
1004   max-width: 600px;
1005 }
1006
1007 /* Rules for tabs inside secondary background sections */
1008
1009 .bg-body-secondary .nav-tabs {
1010   --bs-border-color: var(--bs-secondary-border-subtle);
1011   --bs-secondary-bg: var(--bs-secondary-border-subtle);
1012   margin-bottom: -1px;
1013 }
1014
1015 /* Rules for traces */
1016
1017 img.trace_image {
1018   mix-blend-mode: darken;
1019 }
1020
1021 @include color-mode(dark) {
1022   img.trace_image {
1023     filter: invert(1);
1024     mix-blend-mode: lighten;
1025   }
1026 }
1027
1028 /* Rules for map sidebar icons */
1029
1030 .browse-section {
1031   .node::before,
1032   .way::before,
1033   .relation::before {
1034     display: inline-block;
1035     width: 25px;
1036     margin-left: -25px;
1037   }
1038
1039   .node, .way, .relation {
1040     margin-left: 25px;
1041   }
1042 }
1043
1044 @each $class, $item in $map-sidebar-icons {
1045   .browse-section #{$class}::before {
1046     content: image-url('browse/#{map.get($item, "filename")}');
1047   }
1048
1049   @if map.get($item, "invert") {
1050     @include color-mode(dark) {
1051       .browse-section #{$class}::before {
1052         filter: invert(.8) hue-rotate(180deg);
1053       }
1054     }
1055   }
1056 }