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