]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
Merge remote-tracking branch 'upstream/pull/5952'
[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: #CC7755;
608   --changeset-fill-color: #888888;
609 }
610 .changeset-in-sidebar-viewport {
611   --changeset-border-color: #FF9500;
612   &.changeset-highlighted {
613     --changeset-border-color: #FF6600;
614   }
615   --changeset-fill-color: #FFFFAF;
616 }
617 .changeset-below-sidebar-viewport {
618   --changeset-border-color: #8888AA;
619   --changeset-fill-color: #888888;
620 }
621
622 #sidebar .changesets {
623   .changeset-color-hint-bar {
624     height: 2px;
625     background: var(--changeset-border-color);
626   }
627
628   li {
629     &.selected {
630       @extend :hover;
631     }
632
633     a.stretched-link > span, a:not(.stretched-link), [title] {
634       position: relative;
635       z-index: 2; /* needs to be higher than Bootstrap's stretched link ::after z-index */
636     }
637   }
638 }
639
640 /* Rules for the browse sidebar */
641
642 #sidebar_content {
643   .browse-section {
644     padding-bottom: $spacer;
645     margin-bottom: $spacer;
646     border-bottom: 1px solid $grey;
647
648     h4:first-child {
649       word-wrap: break-word;
650     }
651   }
652
653   .browse-section:last-of-type {
654     border-bottom: none;
655   }
656
657   .browse-tag-list {
658     table-layout: fixed;
659     white-space: pre-wrap;
660     word-wrap: break-word;
661     word-break: break-word;
662
663     tr:last-child th, tr:last-child td {
664       border-bottom: 0;
665     }
666   }
667
668   .query-results {
669     display: none;
670   }
671 }
672
673 /* Force LTR/RTL alignment for placeholder text */
674
675 .form-control::placeholder {
676   text-align: left;
677 }
678
679 /* Rules for export sidebar */
680
681 .export_form {
682   .export_area_inputs {
683     input[type="text"] {
684       width: 100px;
685     }
686   }
687
688   .export_boxy {
689     > * {
690         margin: -1px;
691     }
692   }
693 }
694
695 /* Rules for edit pages */
696
697 .site-edit {
698   #content {
699     position: absolute;
700     top: $headerHeight;
701     bottom: 0;
702     width: 100%;
703   }
704 }
705
706 /* Rules for non-map content pages */
707
708 .content-inner {
709   max-width: 960px;
710   padding: $lineheight;
711 }
712
713 /* Rules for login and signup pages */
714
715 .sessions-new, .users-new, .users-create {
716   #content .content-inner {
717     max-width: 760px;
718   }
719 }
720
721 .header-illustration {
722   background-position: right;
723   background-repeat: no-repeat;
724   position: relative;
725   min-height: 200px;
726   width: 100%;
727   left: 0;
728   bottom: 0;
729
730   &.new-user-main {
731     background-image: image-url("sign-up-illustration.svg");
732     background-position-x: 70px;
733   }
734
735   &.confirm-main {
736     background-image: image-url("confirm-illustration.svg");
737   }
738
739   &.new-user-terms {
740     background-image: image-url("terms-illustration.svg");
741   }
742 }
743
744 [dir=rtl] .header-illustration {
745   transform: scaleX(-1);
746
747   h1 {
748     transform: scaleX(-1);
749   }
750
751   ul {
752     transform: scaleX(-1);
753   }
754 }
755
756 /* Rules for small maps in content areas */
757
758 .content_map {
759   height: 200px;
760   margin-bottom: $lineheight;
761 }
762
763 @include media-breakpoint-up(md) {
764   .content_map {
765     height: 400px;
766   }
767 }
768
769 /* Rules for the user map */
770
771 .content_map .leaflet-popup-content {
772   margin: $spacer;
773   min-height: 50px;
774 }
775
776 /* Rules for user popups on maps */
777
778 .user_popup {
779   p {
780     padding: 0 0 5px 0;
781     margin: 0 0 0 60px;
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 map sidebar icons */
978
979 .browse-section .browse-element-list {
980   line-height: 1.25rem;
981
982   .browse-icon {
983     height: 1.25rem;
984   }
985
986   .d-flex > .browse-icon {
987     height: max(20px, 1.25rem);
988   }
989
990   @include color-mode(dark) {
991     .browse-icon-invertible {
992       filter: invert(.8) hue-rotate(180deg);
993     }
994   }
995 }
996
997 .heatmap-wrapper {
998   height: 130px;
999 }