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