]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
Merge remote-tracking branch 'upstream/pull/6001'
[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: #333;
259   background-color: rgba(0,0,0,.6);
260   outline: none;
261
262   &:hover,
263   &:focus {
264     background-color: black;
265   }
266
267   &.disabled,
268   &.leaflet-disabled {
269     background-color: #333;
270     background-color: rgba(0,0,0,.5);
271     cursor: default;
272   }
273
274   &-first {
275     border-start-start-radius: 4px;
276   }
277
278   &-last {
279     border-end-start-radius: 4px;
280     margin-bottom: 10px;
281   }
282 }
283
284 .leaflet-control.active .control-button {
285   background-color: $vibrant-green;
286 }
287
288 /* Rules for the sidebar and main map area */
289
290 .map-layout {
291   #content {
292     overflow: hidden;
293     position: absolute;
294     top: $headerHeight;
295     bottom: 0;
296     width: 100%;
297   }
298
299   #sidebar, #map {
300     position: relative;
301     height: 100%;
302     overflow-x: hidden;
303     overflow-y: auto;
304   }
305
306   #sidebar {
307     float: left;
308     width: $sidebarWidth;
309   }
310
311   .overlay-sidebar #sidebar {
312     position: absolute;
313     height: auto;
314     overflow: hidden;
315
316     #banner {
317       display: block;
318     }
319
320     .welcome {
321       display: block;
322     }
323
324     .sidebar-close-controls,
325     #sidebar_loader,
326     #sidebar_content {
327       display: none;
328     }
329   }
330
331   .welcome {
332     display: none;
333   }
334
335   #banner {
336     display: none;
337
338     img {
339       display: block;
340       width: $sidebarWidth;
341     }
342   }
343
344   #map {
345     height: 100%;
346     overflow: hidden;
347
348     &.query-active {
349       cursor: help;
350     }
351
352     &.query-disabled {
353       cursor: not-allowed;
354     }
355
356     .leaflet-marker-draggable {
357       cursor: move;
358     }
359
360     .query-marker {
361       animation: 1500ms forwards query-marker-fade;
362
363       @keyframes query-marker-fade {
364         to { opacity: 0 }
365       }
366     }
367   }
368
369   #map-ui {
370     display: none;
371     position: relative;
372     float: right;
373     width: 250px;
374     height: 100%;
375     overflow: auto;
376   }
377 }
378
379 @include media-breakpoint-down(md) {
380   body.map-layout {
381     #sidebar, #map {
382       position: relative;
383       overflow-x: hidden;
384       width: 100%;
385       height: 50%;
386     }
387
388     #map-ui {
389       width: 100%;
390       height: 50%;
391       overflow-y: scroll;
392     }
393
394     .overlay-sidebar.overlay-right-sidebar {
395       #sidebar {
396         position: absolute;
397         width: 350px;
398         height: auto;
399         overflow: hidden;
400       }
401
402       #map {
403         height: 100%;
404       }
405     }
406   }
407 }
408
409 .layers-ui {
410   .base-layers > * {
411     height: 3.5rem;
412
413     > .btn {
414       box-sizing: content-box;
415       top: - map.get($border-widths, 4);
416       left: - map.get($border-widths, 4);
417       --bs-btn-border-color: var(--bs-body-bg);
418     }
419     > .btn:hover {
420       --bs-btn-border-color: var(--bs-primary-border-subtle);
421     }
422   }
423
424   .overlay-layers {
425     li.disabled { color: $darkgrey; }
426   }
427 }
428
429 .share-ui {
430   #mapnik_scale {
431     width: 100px;
432   }
433 }
434
435 .leaflet-top {
436   top: 10px !important;
437   .leaflet-control {
438     margin-right: 0px !important;
439     margin-top: 0px !important;
440   }
441 }
442
443 .leaflet-popup-scrolled {
444   padding-right: $lineheight;
445   border-bottom: 0px !important;
446   border-top: 0px !important;
447 }
448
449 .leaflet-popup-content-wrapper, .leaflet-popup-tip,
450 .leaflet-contextmenu, .leaflet-contextmenu-item,
451 .leaflet-control-attribution, .leaflet-control-scale-line {
452   @extend .bg-body, .text-body;
453 }
454
455 .leaflet-control-attribution, .leaflet-control-scale-line {
456   @extend .bg-opacity-75;
457   text-shadow: none !important;
458 }
459
460 .leaflet-contextmenu-item.over {
461   @extend .bg-body-secondary, .border-secondary, .border-opacity-10;
462 }
463
464 .leaflet-popup-content-wrapper {
465   @extend .rounded-1;
466
467   a {
468     color: var(--bs-link-color) !important;
469   }
470 }
471
472 @include color-mode(dark) {
473   .leaflet-container .leaflet-control-attribution a {
474     color: var(--bs-link-color);
475   }
476
477   .leaflet-control-scale-line {
478     border-color: rgba(var(--bs-light-rgb), .75) !important;
479   }
480 }
481
482 @mixin dark-map-color-scheme {
483   .leaflet-tile-container,
484   .mapkey-table-entry td:first-child > * {
485     filter: var(--dark-mode-map-filter);
486   }
487
488   .leaflet-tile-container .leaflet-tile {
489     filter: none;
490   }
491 }
492
493 body[data-map-theme="dark"] {
494   @include dark-map-color-scheme;
495 }
496
497 @include color-mode(dark) {
498   body:not([data-map-theme]) {
499     @include dark-map-color-scheme;
500   }
501 }
502
503 /* Rules for attribution text under the main map shown on printouts */
504
505 .donate-attr { color: darken($green, 10%) !important; }
506
507 /* Temporary label size override until we remove site-wide font customisation */
508
509 form {
510   label {
511     font-size: 16px;
512   }
513   .col-form-label {
514     font-size: 16px;
515   }
516 }
517
518 /* Stop bootstrap 5 from floating legends when they don't need to be */
519 legend {
520   float: none;
521 }
522
523 /* Override the text colour for primary and secondary buttons, to match our
524    bootstrap 4 colours. Note this has accessibility issues, which is why
525    bootstrap 5 calculates black as the appropriate colour, and we should
526    reconsider our colours at some point with that in mind. */
527
528 .btn-primary {
529   @include button-variant($primary, $primary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
530 }
531
532 .btn-secondary {
533   @include button-variant($secondary, $secondary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
534 }
535
536 .btn-outline-secondary {
537   @include button-outline-variant($secondary, $color-hover: $white, $active-color: $white);
538 }
539
540 /* Rules for the search and direction forms */
541
542 header .search_forms,
543 .directions_form {
544   display: none;
545 }
546
547 .search_form {
548   .describe_location {
549     font-size: 10px;
550   }
551 }
552
553 /* Rules for routing */
554
555 td.distance {
556     font-size: x-small;
557 }
558 tr.turn {
559     cursor: pointer;
560 }
561
562 .routing_marker_column {
563   margin-left: .35rem;
564   margin-right: .35rem;
565   width: 15px;
566
567   img {
568     cursor: move;
569   }
570 }
571
572 /* Rules for the history sidebar */
573
574 .changeset-above-sidebar-viewport {
575   --changeset-border-color: #CC6655;
576   --changeset-fill-color: #DDBBBB;
577   --changeset-outline-color: #FFF4F4;
578 }
579 .changeset-in-sidebar-viewport {
580   --changeset-border-color: #FF9500;
581   --changeset-fill-color: #FFFFAF;
582   --changeset-outline-color: #FFFFFF;
583   &.changeset-highlight-outline {
584     filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .75));
585   }
586 }
587 .changeset-below-sidebar-viewport {
588   --changeset-border-color: #8888AA;
589   --changeset-fill-color: #CCCCDD;
590   --changeset-outline-color: #F4F4FF;
591 }
592 .changeset-highlight-outline {
593   filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, .25));
594 }
595
596 #sidebar .changesets {
597   .changeset-color-hint-bar {
598     height: 2px;
599     background: var(--changeset-border-color);
600   }
601
602   li {
603     &.selected {
604       @extend :hover;
605     }
606
607     a.stretched-link > span, a:not(.stretched-link), [title] {
608       position: relative;
609       z-index: 2; /* needs to be higher than Bootstrap's stretched link ::after z-index */
610     }
611   }
612 }
613
614 /* Rules for the browse sidebar */
615
616 #sidebar_content {
617   .browse-section {
618     padding-bottom: $spacer;
619     margin-bottom: $spacer;
620     border-bottom: 1px solid $grey;
621
622     h4:first-child {
623       word-wrap: break-word;
624     }
625   }
626
627   .browse-section:last-of-type {
628     border-bottom: none;
629   }
630
631   .browse-tag-list {
632     table-layout: fixed;
633     white-space: pre-wrap;
634     word-wrap: break-word;
635     word-break: break-word;
636
637     tr:last-child th, tr:last-child td {
638       border-bottom: 0;
639     }
640   }
641
642   .query-results {
643     display: none;
644   }
645 }
646
647 /* Force LTR/RTL alignment for placeholder text */
648
649 .form-control::placeholder {
650   text-align: left;
651 }
652
653 /* Rules for export sidebar */
654
655 .export_form {
656   .export_area_inputs {
657     input[type="text"] {
658       width: 100px;
659     }
660   }
661
662   .export_boxy {
663     > * {
664         margin: -1px;
665     }
666   }
667 }
668
669 /* Rules for edit pages */
670
671 .site-edit {
672   #content {
673     position: absolute;
674     top: $headerHeight;
675     bottom: 0;
676     width: 100%;
677   }
678 }
679
680 /* Rules for non-map content pages */
681
682 .content-inner {
683   max-width: 960px;
684   padding: $lineheight;
685 }
686
687 /* Rules for login and signup pages */
688
689 .sessions-new, .users-new, .users-create {
690   #content .content-inner {
691     max-width: 760px;
692   }
693 }
694
695 .header-illustration {
696   background-position: right;
697   background-repeat: no-repeat;
698   position: relative;
699   min-height: 200px;
700   width: 100%;
701   left: 0;
702   bottom: 0;
703
704   &.new-user-main {
705     background-image: image-url("sign-up-illustration.svg");
706     background-position-x: 70px;
707   }
708
709   &.confirm-main {
710     background-image: image-url("confirm-illustration.svg");
711   }
712
713   &.new-user-terms {
714     background-image: image-url("terms-illustration.svg");
715   }
716 }
717
718 [dir=rtl] .header-illustration {
719   transform: scaleX(-1);
720
721   h1 {
722     transform: scaleX(-1);
723   }
724
725   ul {
726     transform: scaleX(-1);
727   }
728 }
729
730 /* Rules for small maps in content areas */
731
732 .content_map {
733   height: 200px;
734   margin-bottom: $lineheight;
735 }
736
737 @include media-breakpoint-up(md) {
738   .content_map {
739     height: 400px;
740   }
741 }
742
743 /* Rules for the user map */
744
745 .content_map .leaflet-popup-content {
746   margin: $spacer;
747 }
748
749 /* Rules for user popups on maps */
750
751 .user_popup {
752   p {
753     padding: 0 0 5px 0;
754     margin: 0 0 0 60px;
755     font-size: 12px;
756   }
757 }
758
759 /* Rules for the diary entry page */
760
761 .diary_entries {
762   #map {
763     height: 400px;
764     display: none;
765   }
766   .diary-comment .col-auto {
767     width: 62px;
768   }
769   .diary-comment .col {
770     max-width: 690px;
771   }
772 }
773
774 /* Rules for the issues page */
775
776 .issues.issues-index {
777   td.reporting_users {
778     max-width: 5rem;
779   }
780 }
781
782 /* Rules for the account confirmation page */
783
784 .accounts-terms-show {
785   .legale {
786     padding: $lineheight;
787     margin-bottom: $lineheight;
788     overflow: auto;
789     height: 20em;
790
791     li {
792       list-style: inherit;
793     }
794
795     ol ol {
796       list-style-type: lower-alpha;
797     }
798   }
799 }
800
801 /* Rules for user images */
802
803 img.user_image {
804   max-width: 100px;
805   max-height: 100px;
806 }
807
808 img.user_thumbnail {
809   max-width: 50px;
810   max-height: 50px;
811 }
812
813 img.user_thumbnail_tiny {
814   width: 25px;
815   height: 25px;
816   object-fit: contain;
817 }
818
819 /* General styles for action lists / subnavs */
820
821 nav.secondary-actions {
822   margin-left: -11px;
823   overflow: hidden;
824   > ul {
825     display: flex;
826     flex-direction: row;
827     flex-wrap: wrap;
828     margin-bottom: 0;
829     margin-left: -1px;
830     padding: 0;
831     > li {
832       flex-basis: auto;
833       list-style: none;
834       border-left: 1px solid $grey;
835       padding-left: $lineheight * 0.5;
836       margin-right: $lineheight * 0.5;
837       margin-bottom: $lineheight * 0.125;
838     }
839   }
840 }
841
842 div.secondary-actions {
843   padding: 10px;
844   text-align: center;
845 }
846
847 /* Rules for rich text */
848
849 .richtext {
850   code {
851     background: var(--bs-secondary-bg);
852     padding: 2px 3px;
853   }
854
855   pre {
856     background: var(--bs-secondary-bg);
857     padding: 2px 3px;
858     white-space: pre-wrap;
859
860     code {
861       padding: 0;
862     }
863   }
864
865   img {
866     padding: $lineheight;
867     background-color: var(--bs-tertiary-bg);
868     display: block;
869     max-width: 100%;
870     margin: auto;
871   }
872
873   blockquote {
874     border-left: $lineheight solid var(--bs-tertiary-bg);
875     padding-left: $lineheight;
876     margin: 0;
877     color: var(--bs-secondary-color);
878   }
879 }
880
881 /* Rules for the "About" page */
882
883 .site-about #content {
884   .content-inner {
885     max-width: 760px;
886   }
887
888   .attr {
889     margin-top: -20px;
890
891     h1 {
892       span {
893         color: $vibrant-green;
894       }
895     }
896
897     .user-image {
898       height: 150px;
899       background-position: 0 50%;
900       background-repeat: no-repeat;
901       background-image: image-url('about/osm.png');
902       background-size: cover;
903       background-color: $vibrant-green;
904     }
905
906     .byosm {
907       background: $vibrant-green;
908     }
909
910     .byosm span {
911       display: inline-block;
912       width: 1em;
913       margin-left: -1em;
914     }
915   }
916 }
917
918 /* Rules for tables with usernames */
919
920 .messages-table .username,
921 #block_list .username {
922   max-width: 20em;
923 }
924
925 /* Rules for navigation tabs */
926
927 .nav-tabs .username {
928   max-width: 20em;
929 }
930
931 .bg-body-secondary .nav-tabs {
932   --bs-border-color: var(--bs-secondary-border-subtle);
933   --bs-secondary-bg: var(--bs-secondary-border-subtle);
934   margin-bottom: -1px;
935 }
936
937 /* Rules for traces */
938
939 img.trace_image {
940   mix-blend-mode: darken;
941 }
942
943 @include color-mode(dark) {
944   img.trace_image {
945     filter: invert(1);
946     mix-blend-mode: lighten;
947   }
948 }
949
950 /* Rules for map sidebar icons */
951
952 .browse-section .browse-element-list {
953   line-height: 1.25rem;
954
955   .browse-icon {
956     height: 1.25rem;
957   }
958
959   .d-flex > .browse-icon {
960     height: max(20px, 1.25rem);
961   }
962
963   @include color-mode(dark) {
964     .browse-icon-invertible {
965       filter: invert(.8) hue-rotate(180deg);
966     }
967   }
968 }
969
970 .heatmap-wrapper {
971   height: 130px;
972 }