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