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