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