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