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