ドッキングされたヘッダーバーのロゴ

こんにちは

これは@Johaniの素晴らしいソリューションを使用できると思います。


このようなものです:arrow_double_down:

新しいコンポーネントを作成し、以下を追加します。

ヘッダーセクション

<div class="header-anchor"></div>

<script type="text/discourse-plugin" version="0.8">
if (!"IntersectionObserver" in window) return;

const { on } = require("discourse-common/utils/decorators");

const stickyClass = "sticky";

api.modifyClass("component:site-header", {
  @on("didInsertElement")
  stickyHeaderCheck() {
    const anchor = document.querySelector(".header-anchor");
    const header = this.element;

    new IntersectionObserver(entries => {
      if (!entries[0].isIntersecting) {
        header.classList.add(stickyClass);
      } else {
        header.classList.remove(stickyClass);
      }
    }).observe(anchor);
  }
});

</script>

CSSセクション

.d-header {
  #site-logo.logo-big {
    display: none;
  }
  .sticky & {
    #site-logo.logo-big {
      display: inline;
    }
  }
}

これにより、一番上のロゴが非表示になり、スクロールしたときにのみ表示されます。

「いいね!」 2