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