StackBlur backgrounds

:warning: This is not supposed to be used as a theme by itself.

This is a theme component that’s supposed to handle the background only. It’s supposed to be incorporated into your theme design.


Repo: GitHub - hnb-ku/StackBlur-backgrounds-discourse-theme-component · GitHub

This component uses Mario Klingemann’s StackBlur library (2kb gzipped - MIT license) to generate high scroll performance blurred backgrounds based on an image you select in a <canvas> element.

Examples: (these are compressed so they have artifacts - the backgrounds are smooth)

If I use this photo:

Then the resulting Discourse background would look like this:

And on mobile

More samples with other images:

The quality of the image you use does not really matter because the blur is very forgiving so I recommend highly compressed jpgs no larger than 1080p - All you want is the colors.


Installation

Install the repo as you would with any other theme component:

Once that’s done follow these steps:

1- Create a new theme
2- Name it whatever you want
3- Add this in the common header section:

<canvas 
id="background_b" 
data-src='BACKGROUND_URL_GOES_HERE'
data-blur="BLUR_AMOUNT" 
></canvas> 

4- Change BACKGROUND_URL_GOES HERE to the url of your image
(Has to be either hosted on your domain or on a domain with correct CORS set up)

5- Change BLUR_AMOUNT to the desired amount of blur (0 - 180) higher means more blur.

5- Add StackBlur backgrounds as a theme component under your newly created theme.


:warning: Important

The demo samples use the “Simple Dark” color scheme

You may have noticed the slight dark background behind the topic list.

This is not a part of the theme component

That is achieved with the the following CSS:

#main-outlet {
    background: rgba(0, 0, 0, .5);
    padding-left: 2em;
    padding-right: 2em;
}

Also, the default mobile theme adds a solid color background to the <body> element so you would need to remove that if you want the blurred background to show on mobiles. You can do that like so:

.mobile-view {
	body {
		background: none;
	}
}

27개의 좋아요

I’m using 1920x1080 image & no matter what theme I try using with this component, the image is being stretched. The blur appears to be working fine. Any thoughts on what could cause this?

Wouldn’t it be easier and faster to simply generate the blurred image and use that as the background? Why have the source JPG at all, plus an extra dependency..?

I guess if you are changing the background dynamically, that’s all I can think of?

7개의 좋아요

오늘 로그에서 이것을 확인했습니다:
image

StackBlurBackground@https://forum.duelistsunite.org/theme-javascripts/7cca6d0005bbe0e73e1acff07a8802eb7ec3a2e3.js?__ws=forum.duelistsunite.org:29:22

start@https://forum.duelistsunite.org/theme-javascripts/7cca6d0005bbe0e73e1acff07a8802eb7ec3a2e3.js?__ws=forum.duelistsunite.org:24:32

모든 기능이 정상적으로 작동하므로, 이것이 참조 오류인지 아니면某种 경고인지 확실하지 않습니다. 그냥 보고하려고 합니다.

이것을 구현해 보려고 했는데, 포럼 컴포넌트가 완전히 투명해져서 텍스트를 읽기가 엄청나게 어려워집니다.

@Johani

아쉽게도 여전히 깨져 있습니다. @Johani, 장기적으로 이 기능을 지원하지 않을 거라면 이 주제를 그냥 삭제하는 게 어떨까요? 수정하는 것도 괜찮으니, 당신 판단에 맡깁니다.

2개의 좋아요

제 사이트에서 사용 중인데, 모든 것이 정상적으로 작동하는 것 같습니다. 여기서는 문제가 없습니다. 다만, CSS를 조금 수정했습니다. Discourse를 처음 설치한 이후로 계속 이걸 사용하고 있습니다.

1개의 좋아요

유망해 보이지만 다음 오류가 발생합니다:
Uncaught ReferenceError: assignment to undeclared variable img

          var blur = $("#background_b").data("blur");
          img = new Image();
          c = document.getElementById("background_b");
          ctx = c.getContext("2d");
          w = window.innerWidth;
          h = window.innerHeight;

여기서는 세미콜론 대신 쉼표를 사용하려는 의도였을 것 같습니다.

이 플러그인에는 broken 태그가 붙어 있어 제대로 작동하지 않습니다. 참고만 해주세요 :slight_smile:

1개의 좋아요

방금 알아챘어요, 감사합니다!

1개의 좋아요