mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
starlight_help: Do not use type assertions in astro components.
Partially fixes #35435. For KeyboardTip.astro and ZulipTip.astro, we were using type assertions and thus needed to suppress eslint warnings that were being thrown.
This commit is contained in:
committed by
Tim Abbott
parent
5501954637
commit
f20dc8f6cf
@@ -21,22 +21,13 @@ keyboard_icon_first_child.properties.class = "zulip-unplugin-icon";
|
||||
// the next line as `Keyboard tip:`. We have to edit slot HTML tree
|
||||
// directly instead to solve this. Same case applies for the keyboard
|
||||
// icon we are inserting. We just inject the icon as raw svg.
|
||||
const prefix_element_list = [
|
||||
keyboard_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: " Keyboard tip: ",
|
||||
},
|
||||
],
|
||||
} as Element,
|
||||
];
|
||||
const prefix_text_element: Element = {
|
||||
type: "element",
|
||||
tagName: "strong",
|
||||
properties: {},
|
||||
children: [{type: "text", value: " Keyboard tip: "}],
|
||||
};
|
||||
const prefix_element_list = [keyboard_icon_first_child, prefix_text_element];
|
||||
|
||||
const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
|
||||
const first_element = tree.children[0];
|
||||
|
@@ -22,22 +22,20 @@ lightbulb_icon_first_child.properties.class =
|
||||
// `Tip:`. We have to edit slot HTML tree directly instead to solve this.
|
||||
// Same case applies for the ligthbulb icon we are inserting. We just
|
||||
// inject the icon as raw svg.
|
||||
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 prefix_text_element: Element = {
|
||||
type: "element",
|
||||
tagName: "strong",
|
||||
properties: {},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
// Whitespace before the text to ensure space between
|
||||
// this text and the preceding icon.
|
||||
value: " Tip: ",
|
||||
},
|
||||
],
|
||||
};
|
||||
let prefix_element_list = [lightbulb_icon_first_child, prefix_text_element];
|
||||
|
||||
const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
|
||||
const first_element = tree.children[0];
|
||||
@@ -47,14 +45,13 @@ assert.ok(first_element?.type === "element");
|
||||
// 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,
|
||||
];
|
||||
const paragraph_wrapping_element: Element = {
|
||||
type: "element",
|
||||
tagName: "p",
|
||||
properties: {},
|
||||
children: [...prefix_element_list],
|
||||
};
|
||||
prefix_element_list = [paragraph_wrapping_element];
|
||||
}
|
||||
|
||||
first_element.children = [...prefix_element_list, ...first_element.children];
|
||||
|
Reference in New Issue
Block a user