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