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