Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

help-beta: Add ZulipTip custom component that does not have a header.

Shubham Padiacb852b0fa699
diff --git a/docs/THIRDPARTY b/docs/THIRDPARTY
index ecd1f0ae0c5..c36ed532ecd 100644
--- a/docs/THIRDPARTY
+++ b/docs/THIRDPARTY
@@ -238,6 +238,11 @@ Source: https://lucide.dev/icons/user-x
Copyright: 2013-2022 Cole Bemis
License: ISC License
+Files: web/shared/icons/lightbulb.svg
+Source: https://lucide.dev/icons/lightbulb
+Copyright: 2013-2022 Cole Bemis
+License: ISC License
+
Files: web/shared/icons/clock.svg
Copyright: 2013-2023 Cole Bemis (https://feathericons.com)
License: Expat
diff --git a/help-beta/src/components/ZulipTip.astro b/help-beta/src/components/ZulipTip.astro
new file mode 100644
index 00000000000..d0c43132342
--- /dev/null
+++ b/help-beta/src/components/ZulipTip.astro
@@ -0,0 +1,66 @@
+---
+import assert from "node:assert/strict";
+
+import type {Element} from "hast";
+import {fromHtml} from "hast-util-from-html";
+import {toHtml} from "hast-util-to-html";
+
+import lightbulb_svg from "../../../web/shared/icons/lightbulb.svg?raw";
+
+const lightbulb_icon_fragment = fromHtml(lightbulb_svg, {fragment: true});
+const lightbulb_icon_first_child = lightbulb_icon_fragment.children[0]!;
+assert.ok(
+ lightbulb_icon_first_child.type === "element" &&
+ lightbulb_icon_first_child.tagName === "svg",
+);
+lightbulb_icon_first_child.properties.class = "zulip-unplugin-icon";
+// We need to make the fill transparent for the bulb to look hollow
+// and the default vertical-align of text-bottom was not looking
+// good beside the `Tip` text.
+lightbulb_icon_first_child.properties.style =
+ "vertical-align: text-top; fill: transparent; stroke: currentColor;";
+
+let prefix_element_list = [
+ lightbulb_icon_first_child,
+ {
+ type: "element",
+ tagName: "strong",
+ properties: {},
+ children: [
+ {
+ type: "text",
+ // Whitespace before the text to ensure space between
+ // this text and the preceding icon.
+ value: " Tip: ",
+ },
+ ],
+ } as Element,
+];
+
+const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
+const first_element = tree.children[0];
+assert.ok(first_element?.type === "element");
+
+// This is currently happening only in one case, for _ImportSelfHostedServerTips.mdx
+// where the tip contains an unordered list. Just placing the element as is without
+// a paragraph does not look good in that case.
+if (first_element.tagName !== "p") {
+ prefix_element_list = [
+ {
+ type: "element",
+ tagName: "p",
+ properties: {},
+ children: [...prefix_element_list],
+ } as Element,
+ ];
+}
+
+first_element.children = [...prefix_element_list, ...first_element.children];
+tree.children[0] = first_element;
+---
+
+<aside aria-label="Tip" class=`starlight-aside starlight-aside--tip`>
+ <div class="starlight-aside__content">
+ <Fragment set:html={toHtml(tree)} />
+ </div>
+</aside>
diff --git a/tools/convert-help-center-docs-to-mdx b/tools/convert-help-center-docs-to-mdx
index 689167cd703..2c41cf12ae0 100755
--- a/tools/convert-help-center-docs-to-mdx
+++ b/tools/convert-help-center-docs-to-mdx
@@ -452,10 +452,10 @@ def convert_admonitions_to_asides(
f"import ZulipNote from '{components_dir_path}/ZulipNote.astro';"
)
elif klass == "tip":
- type = "tip"
- title = "Tip"
- replacement = f'\n{match.group(1)}<Aside type="{type}" title="{title}">\n{admonition_content}\n{match.group(1)}</Aside>\n'
- import_statement_set.add("import { Aside } from '@astrojs/starlight/components'")
+ replacement = f"\n{match.group(1)}<ZulipTip>\n{admonition_content}\n{match.group(1)}</ZulipTip>\n"
+ import_statement_set.add(
+ f"import ZulipTip from '{components_dir_path}/ZulipTip.astro';"
+ )
elif klass == "keyboard_tip":
replacement = f"\n{match.group(1)}<KeyboardTip>\n{admonition_content}\n{match.group(1)}</KeyboardTip>\n"
import_statement_set.add(
diff --git a/web/shared/icons/lightbulb.svg b/web/shared/icons/lightbulb.svg
new file mode 100644
index 00000000000..3f117df8b26
--- /dev/null
+++ b/web/shared/icons/lightbulb.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>
\ No newline at end of file