聊天侧边栏

:information_source: Summary 自动打开并以侧边栏的形式显示聊天,只要有空间,并利用高度
:hammer_and_wrench: Repository GitHub - Arkshine/discourse-chat-sidebar
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Credits: @Alon1 (sponsored request)[1]

This theme component aims to open automatically and display the chat like a sidebar, as long as space exists, and take advantage of the height.

  • Windows resize support
  • Composer support
  • Can stick either to the content or window on both sides
  • User can choose the position (saved in the browser’s local storage)
  • Can revert to the original chat state if it was previously opened
  • The chat original user’s preferences are untouched
  • Partial theme support (most of the popular ones)

This should work on most of the themes.
Let me know if it misses options or something doesn’t work on a theme! :smile:

Settings

Name Default Description
breakpoint auto Breakpoint in px for the chat sidebar to appear.
Set to auto to use the default sidebar and content width as a natural breakpoint (recommended).
width 400px Width of the chat sidebar.
position [2] right Position of the chat sidebar.

left: Stick to the left side of the content
right: Stick to the right side of the content
outside-left: Stick to the left side of the window
outside-right: Stick to the right side of the window
theme_style When possible, use the current theme style on these chat sidebar position.
Available only for most of the popular themes.
This is not a reliable setting (theme name can be changed).
Disable to use the default theme style.
allow_user_preference[3] Allow users to set their chat sidebar preferences.
Note: this is saved in the user’s browser local storage.

Available values:
position: Allow users to set the chat sidebar position

Todo

  • Tests
  • Smoother transitions
  • More user’s preferences?

Dev Notes

Initially, I tried to insert the <ChatDrawer /> component into another outlet so it would be easier to manipulate and keep it in the flow. Unfortunately, the original component can’t be suppressed entirely (I’m thinking of the events). At least, I could not find a way to overwrite it.

It leaves me no choice but to follow the hard JS way at the cost of a little more CPU intensive but less intrusive (though manual resizing only happens sometimes).


  1. If interested, Alon’s use case here. ↩︎

  2. Make sure you refresh the page. ↩︎

  3. Important: this setting uses the latest API to show the icon in the header and requires the latest Discourse version. ↩︎

24 个赞

做得好! :clap: :slight_smile:

这是否支持 Discourse Bars 🍻 🍸 (a sidebar framework) ,因为将其与其他侧边栏小部件结合使用会很方便?

7 个赞

抱歉,目前它不支持 Discourse Bars。

该组件使用原始聊天抽屉,并且定位是手动完成的。
我认为,除非我们可以使用/移动原始的 <ChatDrawer /> 组件到我们想要的位置,否则这将很困难。不过我同意;那将很棒!:slight_smile:

至少可以与 Bar 的侧边栏一起显示

我的组件使用 #main-outlet-wrapper 元素作为参考,因此其中的任何内容都可以正常工作。

4 个赞

太棒了!

3 个赞

这是否仅在侧边栏折叠时才有效?我注意到如果我不折叠侧边栏,聊天侧边栏就不会显示。

1 个赞

在此当前版本中,如果聊天侧边栏没有足够的空间放置,它不会强制主内容缩小。这是设计使然。

也许在某些情况下这会很有用。我不介意添加一个用户选项来允许这样做。:thinking:

1 个赞

好的,我明白了,谢谢你的组件,它确实很方便。

1 个赞

我怀疑这个组件在 3.6.0.beta2-latest 版本之后就不能正常工作了?无论我选择什么,它总是在右边,就像原始体验一样……有人能正常使用吗?

这个组件现在确实能正常工作了!我大部分时间都在我的 MacBook 用户屏幕上测试,当组件没有足够空间时,它根本不显示任何内容,这可能就是我感到困惑的原因。现在一切都完美运行了。

2 个赞

我还没有测试,但感谢您的报告,我会尽快检查!

2 个赞

超级组件 :+1: 这是个好主意

我提交了一个 PR 来修复已知的弃用项。:+1:

感谢 @DevTeVe 的测试!

4 个赞

非常感谢您付出额外的努力来帮助我 :heart:

因此,我与 @Arkshine 私下进行了交流,由于我有一些建议,我们决定在这里提出它们!

  1. 可调整大小的聊天窗口(宽度和高度)
  2. 允许它在覆盖屏幕上的文本时仍然浮动。
  3. 如果宽度也是自动的,那就太好了;这样,即使它看起来很小,它也能找到一种适应的方式,而在设置中(非默认),我们会有一个类似“最小像素”的选项,并附带一个警告,说明“如果设置了,聊天将恢复为默认值,除非至少达到 xxx 值。”
2 个赞