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