هل من الممكن تغيير أيقونة إشعارات الموظفين؟

Is it possible to change the icon used on Staff Notices, either through css or a setting that I just haven’t found? Preferably we’d like to swap it out for a custom picture rather than a FA icon.

إعجاب واحد (1)

We do not have a setting for that and I think doing it in CSS only is difficult, but you can create a theme component to replace it.

In CSS, you will hide the old icon:

.post-notice {
  .d-icon-user-shield {
    display: none;
  }
}

In JavaScript (you put this in <head> of the theme component), you will decorate the notice and add the new icon:

<script type="text/discourse-plugin" version="0.8">
  const { iconNode } = require("discourse-common/lib/icon-library");
  api.decorateWidget('post-notice:before', helper => {
    return iconNode('heart');
  });
</script>

… or if you want to replace with an image…:

<script type="text/discourse-plugin" version="0.8">
  api.decorateWidget('post-notice:before', helper => {
    return helper.h('img', {
      src: 'https://www.discourse.org/a/img/home-spot-1.png',
      style: 'margin-right: 0.65em',
      height: 30,
      width: 30
    });
  });
</script>

With themes and theme components, the sky is the limit. If you want to learn more, we have a resource for that:

12 إعجابًا

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

لقد جربت هذا للتو؛ كان مقطع كود جافاسكريبت الأول بحاجة إلى تحديث بسيط.

يحتاج هذا الآن إلى وضعه في علامة تبويب جافاسكريبت لمكون سمة (أو سمة) بدلاً من ذلك:

import { apiInitializer } from "discourse/lib/api";
import { iconNode } from "discourse-common/lib/icon-library";

export default apiInitializer("0.11.1", (api) => {
  api.decorateWidget("post-notice:before", () => {
    return iconNode("heart");
  });
});

لم أنظر في استخدام صورة بدلاً من ذلك، آسف.

3 إعجابات

بعد إضافته إلى السمة الخاصة بي، رأيت تحذيرًا بسبب Upcoming post stream changes - How to prepare themes and plugins. لذلك أنا قلق من أن تحديثًا آخر سيكون مطلوبًا قريبًا.

لقد جربت هذا لأنني كنت فضوليًا لمعرفة ما إذا كان يؤثر فقط على ملاحظات الموظفين أو أيضًا على ملاحظات المستخدمين الجدد والعائدين، حيث أن كل هذه ملاحظات ما بعد.
إنه يؤثر على جميع ملاحظات ما بعد، بينما يخفي CSS أعلاه الدرع فقط. لذلك ينتهي بك الأمر برمزين على ملاحظات المستخدمين الجدد والعائدين.

إعجاب واحد (1)

هذا غير مرضٍ على الإطلاق!!
في عجلة من أمري لنشر ذلك، فاتني أنني لم أزل api.decorateWidget. لا بد أنني تجاهلت الخطأ على موقعي دون أن أدرك ذلك.
أنا متأكد من أن CSS يمكن استهدافها بشكل أفضل، لكنني اكتشفت للتو Quote Callouts - أعتقد أن هذا سيفي بحالتي استخدامي بشكل أفضل على أي حال.

3 إعجابات