Discourse のクリスマス飾りを共有しよう!

こんにちは、

Discourse のヘッダーの下に追加できるクリスマス用のアニメーションライトをいくつかご紹介します。

これは Codepen の Toby による「Christmas Lights」の実装です:https://codepen.io/tobyj/pen/QjvEex
Discourse に合うようにコードを少し調整しました。

実際の動作はこちらでご覧ください:https://forum.monocycle.info/(1 月には削除する予定です)

スクリーンショット:

モバイル版(スティッキーヘッダーには追従しません):

ダークテーマの場合:

Discourse に追加する方法:

  1. 管理パネル → カスタマイズ → 現在のテーマを選択 → カスタム CSS/HTML
  2. CSS タブに以下のコードを追加します:

/* Christmas Lights

   Copyright (c) 2019 by Toby (https://codepen.io/tobyj/pen/QjvEex)
   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/

$globe-width:   12px;
$globe-height:  15px;
$globe-spacing: 40px;
$globe-spread: 3px;
$light-off-opacity: 0.4;
$speed: 0.5;

.lightrope {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  position: absolute;
  left: 0;
  z-index: 1;
  margin: -54px 0 0 0;
  padding: 0;
  pointer-events: none;
  width: 100%;
  li {
    position: relative;
    animation-fill-mode: both; 
    animation-iteration-count:infinite;
    list-style: none;
    margin: 0;
    padding: 0;
    display: block;
    width: $globe-width;
    height: $globe-height;
    border-radius: 50%;
    margin: $globe-spacing/2;
    display: inline-block;
    background: rgba(0,247,165,1);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,247,165,1);
    animation-name: flash-1;
    animation-duration: 2s;
    &:nth-child(2n+1) {
      background: rgba(0,255,255,1);
      box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,255,255,0.5);
      animation-name: flash-2;
      animation-duration: 0.4s;
    }
    &:nth-child(4n+2) {
      background: rgba(247,0,148,1);
      box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(247,0,148,1);
      animation-name: flash-3;
      animation-duration: 1.1s / $speed;
    }
    &:nth-child(odd) {
      animation-duration: 1.8s / $speed;
    }
    &:nth-child(3n+1) {
      animation-duration: 1.4s / $speed;
    }
    &:before {
      content: "";
      position: absolute;
      background: #222;
      width: ($globe-width - 2);
      height: $globe-height/3;
      border-radius: 3px;
      top: (0 - ($globe-height/6));
      left: 1px;
    }
    &:after {
      content: "";
      top: (0 - $globe-height/2);
      left: $globe-width - 3;
      position: absolute;
      width: $globe-spacing + 12;
      height: ($globe-height/3 * 2);
      border-bottom: solid #222 2px;
      border-radius: 50%;
    }
    &:last-child:after {
      content: none;
    }
    &:first-child {
      margin-left: -$globe-spacing/2-$globe-width;
    }
  }
}
@keyframes flash-1 { 
    0%, 100% { background: rgba(0,247,165,1);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,247,165,1);} 
    50% { background: rgba(0,247,165,$light-off-opacity);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,247,165,0.2);}
}
@keyframes flash-2 { 
    0%, 100% { background: rgba(0,255,255,1);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,255,255,1);} 
    50% { background: rgba(0,255,255,$light-off-opacity);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(0,255,255,0.2);}
}
@keyframes flash-3 { 
    0%, 100% { background: rgba(247,0,148,1);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(247,0,148,1);} 
    50% { background: rgba(247,0,148,$light-off-opacity);
    box-shadow: 0px $globe-height/6 $globe-width*2 $globe-spread rgba(247,0,148,0.2);}
}
/* mobile */
.mobile-view .lightrope {
    margin-top: -36px;
}
  1. ヘッダー後のタブに以下のコードを追加します:
<ul class="lightrope">
<li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ul>

(4K モニター全体にライトを広げたい場合は、<li></li> をさらに追加してください。現在は 2K モニターに合うように設定されています)

保存して楽しんでください!

ライトの外観を変更したい場合は、SCSS コードの冒頭にある以下の変数を編集してください:

$globe-width:   12px;
$globe-height:  15px;
$globe-spacing: 40px;
$globe-spread: 3px;
$light-off-opacity: 0.4;
$speed: 0.5;
「いいね!」 30

Absolutely amazing. I’m definitely having this on my Discourse site, for sure! :kiss:

「いいね!」 3

The classic Santa claus hats on avatars:


Hat from uihere.com : G6gA3Wn

How to add it to Discourse:

  1. Go to your admin panel -> customization -> choose your current theme -> custom CSS/HTML
  2. Add this code in your CSS tab:
.main-avatar:after {
    content: url(https://i.imgur.com/G6gA3Wn.png);
    position: absolute;
    top: -5px;
    left: -19px;
}
.mobile-view .main-avatar:after {
    top: -17px;
}

(the hats should only appear on a topic view)

Save and enjoy your hats!

I recommend you to host the hat image on your Discourse server.

「いいね!」 14

I know @dax posted some here a while ago, are they still valid?

「いいね!」 5

There is another christmas hat tutorial here: Christmas hats!
A christmas hat theme component here: Christmas hats component
A snowing effect: Discourse snowing effect?
Another snowing effect and a santa claus head as a loading image: Christmas theme

「いいね!」 10

1週間ほどでこれを取り入れるのが待ちきれません。OP さん、ありがとう!:relaxed:

「いいね!」 3

そんなテーマを感謝祭に必要としています。

「いいね!」 1

ありがとうございます!クリスマスの朝にライトを点けます。

「いいね!」 5

さまざまなクリスマスの装飾アイデアを組み合わせたテーマコンポーネントを作成しました。各フラエアは個別に有効化・無効化できます。

「いいね!」 6

素晴らしいアイデアですね!昨年も、クリスマスのフレイアについて触れるとすぐに「アバターには不要だ」と言うユーザーが数人いました。ふん、ふん、ふん。:neutral_face:

「いいね!」 4

素晴らしい、よくできました!

「いいね!」 5

Discourse の固定ヘッダーの動作が変更されたため、最初の投稿のクリスマスライトは固定されなくなりました。

しかし、それは大した問題ではありません。

また、古いマージン値を変更しました。

「いいね!」 3