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