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