]> git.openstreetmap.org Git - rails.git/blob - app/assets/stylesheets/common.scss
681e898127ad5df3586184fe3a0cdacd757e6ca1
[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-close-controls,
355     #sidebar_loader,
356     #sidebar_content {
357       display: none;
358     }
359   }
360
361   .welcome {
362     display: none;
363   }
364
365   #banner {
366     display: none;
367
368     img {
369       display: block;
370       width: $sidebarWidth;
371     }
372   }
373
374   #map {
375     height: 100%;
376     overflow: hidden;
377
378     &.query-active {
379       cursor: help;
380     }
381
382     &.query-disabled {
383       cursor: not-allowed;
384     }
385
386     .leaflet-marker-draggable {
387       cursor: move;
388     }
389
390     .query-marker {
391       animation: 1500ms forwards query-marker-fade;
392
393       @keyframes query-marker-fade {
394         to { opacity: 0 }
395       }
396     }
397   }
398
399   #map-ui {
400     display: none;
401     position: relative;
402     float: right;
403     width: 250px;
404     height: 100%;
405     overflow: auto;
406   }
407 }
408
409 @include media-breakpoint-down(md) {
410   body.map-layout {
411     #sidebar, #map {
412       position: relative;
413       overflow-x: hidden;
414       width: 100%;
415       height: 50%;
416     }
417
418     #map-ui {
419       width: 100%;
420       height: 50%;
421       overflow-y: scroll;
422     }
423
424     .overlay-sidebar.overlay-right-sidebar {
425       #sidebar {
426         position: absolute;
427         width: 350px;
428         height: auto;
429         overflow: hidden;
430       }
431
432       #map {
433         height: 100%;
434       }
435     }
436   }
437 }
438
439 .layers-ui {
440   .base-layers > * {
441     height: 3.5rem;
442
443     > .btn {
444       box-sizing: content-box;
445       top: - map.get($border-widths, 4);
446       left: - map.get($border-widths, 4);
447       --bs-btn-border-color: var(--bs-body-bg);
448     }
449     > .btn:hover {
450       --bs-btn-border-color: var(--bs-primary-border-subtle);
451     }
452   }
453
454   .overlay-layers {
455     li.disabled { color: $darkgrey; }
456   }
457 }
458
459 .share-ui {
460   #mapnik_scale {
461     width: 100px;
462   }
463 }
464
465 .leaflet-top {
466   top: 10px !important;
467   .leaflet-control {
468     margin-right: 0px !important;
469     margin-top: 0px !important;
470   }
471 }
472
473 .leaflet-popup-scrolled {
474   padding-right: $lineheight;
475   border-bottom: 0px !important;
476   border-top: 0px !important;
477 }
478
479 .leaflet-popup-content-wrapper, .leaflet-popup-tip,
480 .leaflet-contextmenu, .leaflet-contextmenu-item,
481 .leaflet-control-attribution, .leaflet-control-scale-line {
482   @extend .bg-body, .text-body;
483 }
484
485 .leaflet-control-attribution, .leaflet-control-scale-line {
486   @extend .bg-opacity-75;
487   text-shadow: none !important;
488 }
489
490 .leaflet-contextmenu-item.over {
491   @extend .bg-body-secondary, .border-secondary, .border-opacity-10;
492 }
493
494 .leaflet-popup-content-wrapper {
495   @extend .rounded-1;
496
497   a {
498     color: var(--bs-link-color) !important;
499   }
500 }
501
502 @include color-mode(dark) {
503   .leaflet-container .leaflet-control-attribution a {
504     color: var(--bs-link-color);
505   }
506
507   .leaflet-control-scale-line {
508     border-color: rgba(var(--bs-light-rgb), .75) !important;
509   }
510 }
511
512 @mixin dark-map-color-scheme {
513   .leaflet-tile-container,
514   .mapkey-table-entry td:first-child > * {
515     filter: var(--dark-mode-map-filter);
516   }
517
518   .leaflet-tile-container .leaflet-tile {
519     filter: none;
520   }
521 }
522
523 body[data-map-theme="dark"] {
524   @include dark-map-color-scheme;
525 }
526
527 @include color-mode(dark) {
528   body:not([data-map-theme]) {
529     @include dark-map-color-scheme;
530   }
531 }
532
533 /* Rules for attribution text under the main map shown on printouts */
534
535 .donate-attr { color: darken($green, 10%) !important; }
536
537 /* Temporary label size override until we remove site-wide font customisation */
538
539 form {
540   label {
541     font-size: 16px;
542   }
543   .col-form-label {
544     font-size: 16px;
545   }
546 }
547
548 /* Stop bootstrap 5 from floating legends when they don't need to be */
549 legend {
550   float: none;
551 }
552
553 /* Override the text colour for primary and secondary buttons, to match our
554    bootstrap 4 colours. Note this has accessibility issues, which is why
555    bootstrap 5 calculates black as the appropriate colour, and we should
556    reconsider our colours at some point with that in mind. */
557
558 .btn-primary {
559   @include button-variant($primary, $primary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
560 }
561
562 .btn-secondary {
563   @include button-variant($secondary, $secondary, $color: $white, $hover-color: $white, $active-color: $white, $disabled-color: $white);
564 }
565
566 .btn-outline-secondary {
567   @include button-outline-variant($secondary, $color-hover: $white, $active-color: $white);
568 }
569
570 /* Rules for the search and direction forms */
571
572 header .search_forms,
573 .directions_form {
574   display: none;
575 }
576
577 .search_form {
578   .describe_location {
579     font-size: 10px;
580   }
581 }
582
583 /* Rules for routing */
584
585 td.distance {
586     font-size: x-small;
587 }
588 tr.turn {
589     cursor: pointer;
590 }
591
592 .routing_marker_column {
593   margin-left: .35rem;
594   margin-right: .35rem;
595   width: 15px;
596
597   img {
598     cursor: move;
599   }
600 }
601
602 /* Rules for the history sidebar */
603
604 .changeset-above-sidebar-viewport {
605   --changeset-border-color: #CC7755;
606   --changeset-fill-color: #888888;
607 }
608 .changeset-in-sidebar-viewport {
609   --changeset-border-color: #FF9500;
610   &.changeset-highlighted {
611     --changeset-border-color: #FF6600;
612   }
613   --changeset-fill-color: #FFFFAF;
614 }
615 .changeset-below-sidebar-viewport {
616   --changeset-border-color: #8888AA;
617   --changeset-fill-color: #888888;
618 }
619
620 #sidebar .changesets {
621   li {
622     &.selected {
623       @extend :hover;
624     }
625
626     a.stretched-link > span, a:not(.stretched-link), [title] {
627       position: relative;
628       z-index: 2; /* needs to be higher than Bootstrap's stretched link ::after z-index */
629     }
630   }
631 }
632
633 /* Rules for the browse sidebar */
634
635 #sidebar_content {
636   .browse-section {
637     padding-bottom: $spacer;
638     margin-bottom: $spacer;
639     border-bottom: 1px solid $grey;
640
641     h4:first-child {
642       word-wrap: break-word;
643     }
644   }
645
646   .browse-section:last-of-type {
647     border-bottom: none;
648   }
649
650   .browse-tag-list {
651     table-layout: fixed;
652     white-space: pre-wrap;
653     word-wrap: break-word;
654     word-break: break-word;
655
656     tr:last-child th, tr:last-child td {
657       border-bottom: 0;
658     }
659   }
660
661   .query-results {
662     display: none;
663   }
664 }
665
666 /* Force LTR/RTL alignment for placeholder text */
667
668 .form-control::placeholder {
669   text-align: left;
670 }
671
672 /* Rules for export sidebar */
673
674 .export_form {
675   .export_area_inputs {
676     input[type="text"] {
677       width: 100px;
678     }
679   }
680
681   .export_boxy {
682     > * {
683         margin: -1px;
684     }
685   }
686 }
687
688 /* Rules for edit pages */
689
690 .site-edit {
691   #content {
692     position: absolute;
693     top: $headerHeight;
694     bottom: 0;
695     width: 100%;
696   }
697 }
698
699 /* Rules for non-map content pages */
700
701 .content-inner {
702   max-width: 960px;
703   padding: $lineheight;
704 }
705
706 /* Rules for login and signup pages */
707
708 .sessions-new, .users-new, .users-create {
709   #content .content-inner {
710     max-width: 760px;
711   }
712 }
713
714 .header-illustration {
715   background-position: right;
716   background-repeat: no-repeat;
717   position: relative;
718   min-height: 200px;
719   width: 100%;
720   left: 0;
721   bottom: 0;
722
723   &.new-user-main {
724     background-image: image-url("sign-up-illustration.svg");
725     background-position-x: 70px;
726   }
727
728   &.confirm-main {
729     background-image: image-url("confirm-illustration.svg");
730   }
731
732   &.new-user-terms {
733     background-image: image-url("terms-illustration.svg");
734   }
735 }
736
737 [dir=rtl] .header-illustration {
738   transform: scaleX(-1);
739
740   h1 {
741     transform: scaleX(-1);
742   }
743
744   ul {
745     transform: scaleX(-1);
746   }
747 }
748
749 /* Rules for small maps in content areas */
750
751 .content_map {
752   height: 200px;
753   margin-bottom: $lineheight;
754 }
755
756 @include media-breakpoint-up(md) {
757   .content_map {
758     height: 400px;
759   }
760 }
761
762 /* Rules for the user map */
763
764 .content_map .leaflet-popup-content {
765   margin: $spacer;
766   min-height: 50px;
767 }
768
769 /* Rules for user popups on maps */
770
771 .user_popup {
772   p {
773     padding: 0 0 5px 0;
774     margin: 0 0 0 60px;
775     font-size: 12px;
776   }
777 }
778
779 /* Rules for the diary entry page */
780
781 .diary_entries {
782   #map {
783     height: 400px;
784     display: none;
785   }
786   .diary-comment .col-auto {
787     width: 62px;
788   }
789   .diary-comment .col {
790     max-width: 690px;
791   }
792 }
793
794 /* Rules for the issues page */
795
796 .issues.issues-index {
797   td.reporting_users {
798     max-width: 5rem;
799   }
800 }
801
802 /* Rules for the account confirmation page */
803
804 .accounts-terms-show {
805   .legale {
806     padding: $lineheight;
807     margin-bottom: $lineheight;
808     overflow: auto;
809     height: 20em;
810
811     li {
812       list-style: inherit;
813     }
814
815     ol ol {
816       list-style-type: lower-alpha;
817     }
818   }
819 }
820
821 /* Rules for user images */
822
823 img.user_image {
824   max-width: 100px;
825   max-height: 100px;
826 }
827
828 img.user_thumbnail {
829   max-width: 50px;
830   max-height: 50px;
831 }
832
833 img.user_thumbnail_tiny {
834   width: 25px;
835   height: 25px;
836   object-fit: contain;
837 }
838
839 /* General styles for action lists / subnavs */
840
841 nav.secondary-actions {
842   margin-left: -11px;
843   overflow: hidden;
844   > ul {
845     display: flex;
846     flex-direction: row;
847     flex-wrap: wrap;
848     margin-bottom: 0;
849     margin-left: -1px;
850     padding: 0;
851     > li {
852       flex-basis: auto;
853       list-style: none;
854       border-left: 1px solid $grey;
855       padding-left: $lineheight * 0.5;
856       margin-right: $lineheight * 0.5;
857       margin-bottom: $lineheight * 0.125;
858     }
859   }
860 }
861
862 div.secondary-actions {
863   padding: 10px;
864   text-align: center;
865 }
866
867 /* Rules for rich text */
868
869 .richtext {
870   code {
871     background: var(--bs-secondary-bg);
872     padding: 2px 3px;
873   }
874
875   pre {
876     background: var(--bs-secondary-bg);
877     padding: 2px 3px;
878     white-space: pre-wrap;
879
880     code {
881       padding: 0;
882     }
883   }
884
885   img {
886     padding: $lineheight;
887     background-color: var(--bs-tertiary-bg);
888     display: block;
889     max-width: 100%;
890     margin: auto;
891   }
892
893   blockquote {
894     border-left: $lineheight solid var(--bs-tertiary-bg);
895     padding-left: $lineheight;
896     margin: 0;
897     color: var(--bs-secondary-color);
898   }
899 }
900
901 /* Rules for the "About" page */
902
903 .site-about #content {
904   .content-inner {
905     max-width: 760px;
906   }
907
908   .attr {
909     margin-top: -20px;
910
911     h1 {
912       span {
913         color: $vibrant-green;
914       }
915     }
916
917     .user-image {
918       height: 150px;
919       background-position: 0 50%;
920       background-repeat: no-repeat;
921       background-image: image-url('about/osm.png');
922       background-size: cover;
923       background-color: $vibrant-green;
924     }
925
926     .byosm {
927       background: $vibrant-green;
928     }
929
930     .byosm span {
931       display: inline-block;
932       width: 1em;
933       margin-left: -1em;
934     }
935   }
936 }
937
938 /* Rules for tables with usernames */
939
940 .messages-table .username,
941 #block_list .username {
942   max-width: 20em;
943 }
944
945 /* Rules for navigation tabs */
946
947 .nav-tabs .username {
948   max-width: 20em;
949 }
950
951 .bg-body-secondary .nav-tabs {
952   --bs-border-color: var(--bs-secondary-border-subtle);
953   --bs-secondary-bg: var(--bs-secondary-border-subtle);
954   margin-bottom: -1px;
955 }
956
957 /* Rules for traces */
958
959 img.trace_image {
960   mix-blend-mode: darken;
961 }
962
963 @include color-mode(dark) {
964   img.trace_image {
965     filter: invert(1);
966     mix-blend-mode: lighten;
967   }
968 }
969
970 /* Rules for map sidebar icons */
971
972 .browse-section .browse-element-list {
973   line-height: 1.25rem;
974
975   .browse-icon {
976     height: 1.25rem;
977   }
978
979   .d-flex > .browse-icon {
980     height: max(20px, 1.25rem);
981   }
982
983   @include color-mode(dark) {
984     .browse-icon-invertible {
985       filter: invert(.8) hue-rotate(180deg);
986     }
987   }
988 }
989
990 .heatmap-wrapper {
991   height: 130px;
992 }