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