_phylo.scss 12.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
///  (!) Heads up: custom web font & SVG text BBox
///
///  There is a lot of inconvenience to use a non-safe web font with Chromium
///  engine and SVG (for example: [1], [2], [3], [4])
///
///  Main issues are:
///    - browser engine late loading: creating a race condition where the
///      SVG text is rendered via another default fallback webfont than
///      the one we have set
///    - browser engine non compliancy with certain font file type: creating
///      potential unanticipated issue
///
///  Empirically, we have found that even with a safe lazy loading (ie.
///  using `<Promise> document.fonts.ready`), results were not satisfying
///  with the original font used in the default Memiescape ("Inter-regular")
///
///  Our workaround here has been to KISS via removing every CSS rules
///  created with the "Inter-regular" font. Instead it will fallback of the
///  application set font ; which with our default theme worked very well
///  to our need AND mimicking almost perfectly the "Inter-regular" one
///
///  [1] https://stackoverflow.com/questions/16426223/why-svg-bbox-method-on-text-element-gives-different-result-in-different-browser
///  [2] https://stackoverflow.com/questions/38270865/why-does-svg-viewed-in-chrome-51-not-position-correctly-with-added-gap-after-tex
///  [3] https://stackoverflow.com/questions/14789059/pixel-perfect-consistent-text-width-in-svg-or-html
///  [4] https://stackoverflow.com/questions/41059999/text-tag-in-svg-not-rendering-correctly-in-chrome

/* Grid constants */

$graph-margin: 16px;

$layout-height: calc(100vh - #{ $topbar-height} );
$graph-height: calc(100vh - #{ $topbar-height } - #{ $graph-margin * 2 });

$isoline-height: 174px;

$left-column-width: 10%;
$center-column-width: 85%;
$right-column-width: 5%;

/* Colors */

$graph-background-color: $body-bg;
$graph-layout-line-color: #EBE4DD;
$graph-text-color: #0D1824;
$graph-heading-color: #B5B5B5;

$visible-peak: #0D1824;
$hidden-peak: #A9A9A9;

$mark-default: #4A5C70;
$mark-hover: #F3BE54;
$mark-focus: #F24C3D;
$mark-unfocus: #FFECEC;

$group-unfocus: #A9A9A9;

$source-focus: #A6BDDB;

$isoline-background-color: $gray-150;
$isoline-stroke-color: #74B5FF;

$fill-default-color: #61A3A9;
$fill-idle-color: #F5EEE6;

$emergence-color: #012840;
$decreasing-color: #11638F;

////////////////////////////////////////////////////////////////

/// (?) SVG related classes (isoline, scape)

.phylo {

  /* ---------- axis ---------- */

  .x-axis path {
    stroke: $graph-layout-line-color;
    stroke-width: 1.5px;
  }

  .y-axis path {
    stroke:$graph-layout-line-color;
    stroke-width: 1.5px;
  }

  .y-highlight {
    stroke: $mark-hover;
    stroke-width: 1.5px;
  }

  .x-mark {
    fill: $mark-default;
    stroke-width: 1px;
    stroke: $graph-background-color;
  }
  // (!) unused class
  .x-mark-over {
    fill: $mark-hover;
  }
  // (!) unused class
  .x-mark-focus {
    fill: $mark-focus;
  }

  .tick text:hover {
    cursor: pointer;
  }

  .y-label {
    font-size: 10px;
    font-weight: normal;
  }
  // (!) unused class (see `Resources.js:groupOver`)
  .y-label-bold {
    font-size: 12px;
    font-weight: bold;
  }

  .y-mark-year-inner {
    fill: $mark-default;
  }
  // (!) unused class (see `Resources.js:groupOver`)
  .y-mark-year-inner-highlight {
    fill: $mark-hover;
  }

  .y-mark-year-outer {
    fill: $graph-background-color;
    stroke: $mark-default;
    stroke-width: 1px;
  }
  // (!) unused class (see `Resources.js:groupOver`)
  .y-mark-year-outer-highlight {
    fill: $graph-background-color;
    stroke: $mark-hover;
    stroke-width: 3px;
  }

  .y-mark-month {
    fill: $mark-default;
  }

  /* ---------- header ---------- */

  .header {
    fill: $emergence-color;
    cursor: pointer;
  }

  .header-wrapper {
    display: none;
    fill: $graph-background-color;
    filter: drop-shadow(0px 3px 3px rgba(0, 0, 0, 0.1));

    &--hover {
      display: initial;
    }
  }


  /* ---------- group ---------- */

  .group-outer {
    stroke-width: 0.8px;
    stroke: $graph-background-color;
    fill: $graph-background-color;
  }

  .group-inner {
    stroke-width: 0.8px;
    stroke: $graph-text-color;
    fill: $graph-text-color;
    /*cursor: pointer;*/
    z-index: 10;
  }

  .group-heading {
    fill: $graph-background-color;
    stroke: $graph-heading-color;
  }

  .group-focus {
    stroke: $mark-focus;
  }

  .source-focus {
    stroke: $isoline-stroke-color;
    // @NOTE #219: single source of truth for color management (HTML attribute
    //             style takes precedence over CSS ones)
    fill: $source-focus !important;
  }

  .group-unfocus {
    stroke: $group-unfocus;
  }

  .group-path {
    cursor: pointer;
  }

  /* ---------- labels ---------- */

  .ngrams {
    visibility:  hidden;
  }

  .term {
    cursor: pointer;
  }

  .term:hover {
    font-weight: bold;
  }

  // .term-unfocus {
  //   fill: #A9A9A9;
  // }

  // .term-focus {
  //   fill: black;
  // }

  .term-path {
    fill: none;
    stroke: $mark-focus;
    stroke-width: 1.5px;
  }

  .emerging {
    /*text-decoration: underline #F0684D;*/
    /*fill:#5AA350;*/
    /*fill: #5AA350;*/
    fill: $mark-focus;
  }

  .decreasing {
    /*text-decoration: underline #74B5FF;*/
    fill: $decreasing-color;
  }

  .path-focus {
    fill: none;
    stroke: $mark-focus;
    stroke-width: 1.5px;
  }

  .path-unfocus {
    stroke: $group-unfocus;
  }

  .path-heading {
    stroke: $graph-heading-color;
  }

  /* ---------- phylo ---------- */

  .branch-hover {
    fill: $mark-hover;
    opacity: 0.5;
  }

  /* isoline */

  .peak {
    stroke: $graph-background-color;
    stroke-width: 1px;
    font-size: 18px;
    text-anchor: middle;
    visibility: visible;
  }

  .peak-over {
    font-size: 18px;
    stroke-width: 2px;
    cursor: pointer;
    stroke: $mark-hover;
    z-index: 100;
  }

  .peak-focus {
    font-size: 18px;
    stroke-width: 2px;
    stroke: $mark-focus;
  }

  .peak-focus-source {
    font-size: 18px;
    stroke-width: 2px;
    stroke: $isoline-stroke-color;
  }

  .peak-label {
    text-align: center;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    color: $graph-background-color;
    border-radius: 3px;
    border-style: solid;
    border-width: 2px;
    border-color: $graph-background-color;
    background: $visible-peak;
    padding: 5px;
    z-index: 10;
    position: absolute;
    visibility: hidden;
  }

}

////////////////////////////////////////////////////////////////

.phylo {
  position: relative;
  width: 100%;
  height: $layout-height;

  &--preloading {
    // (!) As the drawing process need must have all its elements displayed,
    //     the browser scrollbar will flicker during the process
    //     So during this time (in addition to the preloader spinner), we
    //     ensure the height of the layout does not exceed the browser height
    //     limit, hence avoiding a flickering effect
    overflow: hidden;
  }

  &__spinner-wrapper {
    @include fit-positions;

    position: absolute;
    z-index: z-index("phylo-layout", "spinner");
    background: $body-bg;
  }

  &__spinner {
    $size: 100px;
    $weight: 6px;

    position: absolute;
    font-size: $weight;
    height: $size;
    width: $size;
    // (?) `centered` mixin will not work here, due to Bootstrap process
    //     interfering with the transform rule
    top: calc( 50% - #{ $size / 2 } );
    left: calc( 50% - #{ $size / 2 } );
  }

  &__sidebar {
    position: fixed;
    width: $sidebar-width;
    height: $sidebar-height;
    z-index: z-index('phylo-layout', 'sidebar');

    @include right-handed {
      right: 0;
      border-left: 1px solid $border-color;
    }

    @include left-handed {
      left: 0;
      border-right: 1px solid $border-color;
    }

  }
}


////////////////////////////////////////////////////////////////

.phylo-isoline {
  display: flex;
  position: relative;
  height: $isoline-height;
  background-color:$isoline-background-color;
  border-bottom: 1px solid $border-color;
  user-select: none;

  // @XXX: Annoying UI artefact where the SVG breaks its provided size
  //       This might be due to the underlying ratio of the matrix placement
  //       (ie. for a given "height", it forces a "width")
  //
  //          ↳ Workaround here is to limit the size of the SVG (its only
  //            a patch surgery, as the `Element.width` property will still
  //            be at its wrong value)
  svg {
    max-width: 100%;
  }
}

////////////////////////////////////////////////////////////////

.phylo-margin {
  height: $graph-margin;
}

.phylo-grid {
  position: relative;
  user-select: none;

  &__content {
    display: flex;
    height: $graph-height;
    position: relative;
  }

  &__blueprint {
    @include fit-positions();

    display: flex;
    height: $graph-height;
    position: absolute;
    visibility: hidden;

    &__left {
      width: $left-column-width;
      height: inherit;
    }
    &__center {
      width: $center-column-width;
      height: inherit;
    }
    &__right {
      width: $right-column-width;
      height: inherit;
    }
  }

  &__content {

    &__scape {
      width: calc( #{ $left-column-width } + #{ $center-column-width });
    }
  }
}

////////////////////////////////////////////////////////////////

.phylo-topbar {
  $fixed-button-width: 136px;

  @include aside-topbar();

arturo's avatar
arturo committed
444 445
  padding-left: $topbar-item-margin;
  padding-right: $topbar-item-margin;
446 447 448 449
  display: flex;

  &__toolbar,
  &__sidebar {
arturo's avatar
arturo committed
450 451 452
    width: $topbar-fixed-button-width;
    margin-left: $topbar-item-margin;
    margin-right: $topbar-item-margin;
453 454 455 456
  }

  &__source {
    width: $topbar-input-width;
arturo's avatar
arturo committed
457 458
    margin-left: $topbar-item-margin;
    margin-right: $topbar-item-margin;
459 460 461 462 463 464
  }

  &__autocomplete {
    display: flex;
    width: $topbar-input-width;
    position: relative;
arturo's avatar
arturo committed
465 466
    margin-left: $topbar-item-margin;
    margin-right: $topbar-item-margin;
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
  }

  &__suggestion {
    // as the input is above the "search" one, and is used only as an
    // autocompletion term, we remove every interaction on it...
    pointer-events: none;
    // ...overriding Bootstrap native rules to just display its text node to
    // the user
    &.form-control {
      border-color: transparent;
    }
  }

  &__search {
    z-index: 1;
    position: absolute;
    // (see above comment about "suggestion")
    &.form-control {
      background-color: transparent;
    }
  }

  &__submit {
    display: none;
  }
}

////////////////////////////////////////////////////////////////

.phylo-sidebar {
arturo's avatar
arturo committed
497
  @include sidebar;
498 499 500
}

.phylo-details-tab {
arturo's avatar
arturo committed
501
  $margin-x: $sidebar-tab-margin-x;
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
  $margin-y: space-x(2);

  &__counter {
    margin: $margin-y $margin-x;

    &__item {
      margin-left: space-x(2);
      list-style: initial;
    }

    &__value {
      font-weight: bold;
    }
  }

  &__delimiter {
    margin: $margin-y $margin-x;
  }

  &__link {
    margin: $margin-y $margin-x;
  }
}

.phylo-selection-tab {
arturo's avatar
arturo committed
527
  $margin-x: $sidebar-tab-margin-x;
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
  $margin-y: space-x(2);

  &__highlight {
    margin: $margin-y $margin-x;

    &__badge {
      font-size: $font-size-base;
      white-space: normal;
      word-break: break-word;
    }

    &__type {
      padding: $badge-padding-y $badge-padding-x;
      font-weight: bold;
    }
  }

  &__selection {
    margin: $margin-y $margin-x 0;

    &__item {
      white-space: normal;
      word-break: break-word;
      line-height: initial;

      &:not(:last-child) {
        margin-bottom: space-x(0.75);
      }
    }

    &__show-more {
      margin-top: $margin-y;
    }
  }

  &__counter {

    &__item {
      margin-left: space-x(2);
      list-style: initial;
    }

    &__value {
      color: $info;
    }
  }

  &__nil {
    margin: $margin-y $margin-x
  }

  &__separator {
    color: $gray-500;
    text-align: center;
  }
}

////////////////////////////////////////////////////////////////

.phylo-toolbar {
  $section-margin: space-x(2.5);
  $button-margin: space-x(2);

  display: flex;
  border-bottom: 1px solid $border-color;
  padding: $section-margin;
  background-color: $body-bg;

  &__gap {
    width: $button-margin;
    display: inline-block;
  }

  @include right-handed {
    flex-direction: row;

    &__section {
      margin-right: $section-margin;
    }
  }

  @include left-handed {
    flex-direction: row-reverse;

    &__section {
      margin-left: $section-margin;
    }
  }
}