]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
Merge remote-tracking branch 'upstream/pull/6143'
[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-tag-list {
627     table-layout: fixed;
628     white-space: pre-wrap;
629     word-wrap: break-word;
630     word-break: break-word;
631
632     tr:last-child th, tr:last-child td {
633       border-bottom: 0;
634     }
635   }
636
637   .browse-element-list {
638     line-height: 1.25rem;
639
640     .browse-icon {
641       height: 1.25rem;
642     }
643
644     .d-flex > .browse-icon {
645       height: max(20px, 1.25rem);
646     }
647   }
648
649   .query-results {
650     display: none;
651   }
652 }
653
654 @include color-mode(dark) {
655   #sidebar_content .browse-element-list .browse-icon-invertible {
656     filter: invert(.8) hue-rotate(180deg);
657   }
658 }
659
660 /* Force LTR/RTL alignment for placeholder text */
661
662 .form-control::placeholder {
663   text-align: left;
664 }
665
666 /* Rules for export sidebar */
667
668 .export_form {
669   .export_area_inputs {
670     input[type="text"] {
671       width: 100px;
672     }
673   }
674
675   .export_boxy {
676     > * {
677         margin: -1px;
678     }
679   }
680 }
681
682 /* Rules for edit pages */
683
684 .site-edit {
685   #content {
686     position: absolute;
687     top: $headerHeight;
688     bottom: 0;
689     width: 100%;
690   }
691 }
692
693 /* Rules for non-map content pages */
694
695 .content-inner {
696   max-width: 960px;
697   padding: $lineheight;
698 }
699
700 /* Rules for login and signup pages */
701
702 .sessions-new, .users-new, .users-create {
703   #content .content-inner {
704     max-width: 760px;
705   }
706 }
707
708 .header-illustration {
709   background-position: right;
710   background-repeat: no-repeat;
711   position: relative;
712   min-height: 200px;
713   width: 100%;
714   left: 0;
715   bottom: 0;
716
717   &.new-user-main {
718     background-image: image-url("sign-up-illustration.svg");
719     background-position-x: 70px;
720   }
721
722   &.confirm-main {
723     background-image: image-url("confirm-illustration.svg");
724   }
725
726   &.new-user-terms {
727     background-image: image-url("terms-illustration.svg");
728   }
729 }
730
731 [dir=rtl] .header-illustration {
732   transform: scaleX(-1);
733
734   h1 {
735     transform: scaleX(-1);
736   }
737
738   ul {
739     transform: scaleX(-1);
740   }
741 }
742
743 /* Rules for small maps in content areas */
744
745 .content_map {
746   height: 200px;
747   margin-bottom: $lineheight;
748 }
749
750 @include media-breakpoint-up(md) {
751   .content_map {
752     height: 400px;
753   }
754 }
755
756 /* Rules for the user map */
757
758 .content_map .leaflet-popup-content {
759   margin: $spacer;
760 }
761
762 /* Rules for user popups on maps */
763
764 .user_popup {
765   p {
766     margin: 0 0 5px 0 !important;
767     font-size: 12px;
768   }
769 }
770
771 /* Rules for the diary entry page */
772
773 .diary_entries {
774   #map {
775     height: 400px;
776     display: none;
777   }
778   .diary-comment .col-auto {
779     width: 62px;
780   }
781   .diary-comment .col {
782     max-width: 690px;
783   }
784 }
785
786 /* Rules for the issues page */
787
788 .issues.issues-index {
789   td.reporting_users {
790     max-width: 5rem;
791   }
792 }
793
794 /* Rules for the account confirmation page */
795
796 .accounts-terms-show {
797   .legale {
798     padding: $lineheight;
799     margin-bottom: $lineheight;
800     overflow: auto;
801     height: 20em;
802
803     li {
804       list-style: inherit;
805     }
806
807     ol ol {
808       list-style-type: lower-alpha;
809     }
810   }
811 }
812
813 /* Rules for user images */
814
815 img.user_image {
816   max-width: 100px;
817   max-height: 100px;
818 }
819
820 img.user_thumbnail {
821   max-width: 50px;
822   max-height: 50px;
823 }
824
825 img.user_thumbnail_tiny {
826   width: 25px;
827   height: 25px;
828   object-fit: contain;
829 }
830
831 /* General styles for action lists / subnavs */
832
833 nav.secondary-actions {
834   margin-left: -11px;
835   overflow: hidden;
836   > ul {
837     display: flex;
838     flex-direction: row;
839     flex-wrap: wrap;
840     margin-bottom: 0;
841     margin-left: -1px;
842     padding: 0;
843     > li {
844       flex-basis: auto;
845       list-style: none;
846       border-left: 1px solid $grey;
847       padding-left: $lineheight * 0.5;
848       margin-right: $lineheight * 0.5;
849       margin-bottom: $lineheight * 0.125;
850     }
851   }
852 }
853
854 div.secondary-actions {
855   padding: 10px;
856   text-align: center;
857 }
858
859 /* Rules for rich text */
860
861 .richtext {
862   code {
863     background: var(--bs-secondary-bg);
864     padding: 2px 3px;
865   }
866
867   pre {
868     background: var(--bs-secondary-bg);
869     padding: 2px 3px;
870     white-space: pre-wrap;
871
872     code {
873       padding: 0;
874     }
875   }
876
877   img {
878     padding: $lineheight;
879     background-color: var(--bs-tertiary-bg);
880     display: block;
881     max-width: 100%;
882     margin: auto;
883   }
884
885   blockquote {
886     border-left: $lineheight solid var(--bs-tertiary-bg);
887     padding-left: $lineheight;
888     margin: 0;
889     color: var(--bs-secondary-color);
890   }
891 }
892
893 /* Rules for the "About" page */
894
895 .site-about #content {
896   .content-inner {
897     max-width: 760px;
898   }
899
900   .attr {
901     margin-top: -20px;
902
903     h1 {
904       span {
905         color: $vibrant-green;
906       }
907     }
908
909     .user-image {
910       height: 150px;
911       background-position: 0 50%;
912       background-repeat: no-repeat;
913       background-image: image-url('about/osm.png');
914       background-size: cover;
915       background-color: $vibrant-green;
916     }
917
918     .byosm {
919       background: $vibrant-green;
920     }
921
922     .byosm span {
923       display: inline-block;
924       width: 1em;
925       margin-left: -1em;
926     }
927   }
928 }
929
930 /* Rules for tables with usernames */
931
932 .messages-table .username,
933 #block_list .username {
934   max-width: 20em;
935 }
936
937 /* Rules for navigation tabs */
938
939 .nav-tabs .username {
940   max-width: 20em;
941 }
942
943 .bg-body-secondary .nav-tabs {
944   --bs-border-color: var(--bs-secondary-border-subtle);
945   --bs-secondary-bg: var(--bs-secondary-border-subtle);
946   margin-bottom: -1px;
947 }
948
949 /* Rules for traces */
950
951 img.trace_image {
952   mix-blend-mode: darken;
953 }
954
955 @include color-mode(dark) {
956   img.trace_image {
957     filter: invert(1);
958     mix-blend-mode: lighten;
959   }
960 }
961
962 /* Rules for the social links */
963
964 @include color-mode(dark) {
965   .social_links img {
966     filter: invert(1);
967   }
968 }
969
970 /* Rules for the heatmap */
971
972 .heatmap {
973   grid-template-columns: auto;
974   grid-auto-columns: minmax(1em, 1fr);
975   grid-template-rows: auto;
976   grid-auto-rows: minmax(1em, 1fr);
977   font-size: x-small;
978   gap: 0.3em;
979
980   [data-date], [data-date] span {
981     display: block;
982     aspect-ratio: 1;
983     border-radius: 25%;
984   }
985
986   [data-date] {
987     background-color: #ededed;
988     span {
989       background-color: #14432a;
990     }
991     &[data-count] {
992       background-color: #4dd05a;
993     }
994     &:hover {
995       box-shadow: 0px 0px 0px 1px #8884;
996     }
997   }
998 }
999
1000 @include color-mode(dark) {
1001   .heatmap {
1002     [data-date] {
1003       background-color: #2d333b;
1004       span {
1005         background-color: #4dd05a;
1006       }
1007       &[data-count] {
1008         background-color: #14432a;
1009       }
1010     }
1011   }
1012 }
1013
1014 .tooltip.wide {
1015   --bs-tooltip-max-width: none;
1016 }