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: Use steps component instead of using steps.css.

Shubham Padia502c8072b005
diff --git a/help-beta/astro.config.mjs b/help-beta/astro.config.mjs
index 3cfa1f476f0..4571b4c76d8 100644
--- a/help-beta/astro.config.mjs
+++ b/help-beta/astro.config.mjs
@@ -76,7 +76,7 @@ export default defineConfig({
},
pagination: false,
routeMiddleware: "./src/route_data.ts",
- customCss: ["./src/styles/main.css", "./src/styles/steps.css"],
+ customCss: ["./src/styles/main.css"],
sidebar: [
{
label: "Zulip homepage",
diff --git a/help-beta/src/components/FlattenList.astro b/help-beta/src/components/FlattenedSteps.astro
similarity index 91%
rename from help-beta/src/components/FlattenList.astro
rename to help-beta/src/components/FlattenedSteps.astro
index 5e7619995bf..72cd78b3acf 100644
--- a/help-beta/src/components/FlattenList.astro
+++ b/help-beta/src/components/FlattenedSteps.astro
@@ -1,6 +1,7 @@
---
import assert from "node:assert/strict";
+import {Steps} from "@astrojs/starlight/components";
import {fromHtml} from "hast-util-from-html";
import {toHtml} from "hast-util-to-html";
@@ -39,4 +40,4 @@ const flattened = {
};
---
-<Fragment set:html={toHtml(flattened)} />
+<Steps><Fragment set:html={toHtml(flattened)} /></Steps>
diff --git a/help-beta/src/styles/steps.css b/help-beta/src/styles/steps.css
deleted file mode 100644
index 463734a95fd..00000000000
--- a/help-beta/src/styles/steps.css
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-The contents of this file is just css taken from
-https://github.com/withastro/starlight/blob/d7ecbcdd42ee6500965e79ae74aac94840c7bc48/packages/starlight/user-components/Steps.astro
-We want to apply these styles to all lists ordered lists in our help
-center. Future starlight upgrades have the potential to break this
-css if they change the underlying variable names, but the breaks
-would be obvious when testing the upgrade and if it becomes a
-consistent issue, we can look into some other solution.
-*/
-
-ol {
- --bullet-size: calc(var(--sl-line-height) * 1rem);
- --bullet-margin: 0.375rem;
-
- list-style: none;
- counter-reset: steps-counter var(--sl-steps-start, 0);
- padding-inline-start: 0;
-}
-
-ol > li {
- counter-increment: steps-counter;
- position: relative;
- padding-inline-start: calc(var(--bullet-size) + 1rem);
- /* HACK: Keeps any `margin-bottom` inside the `<li>`’s padding box to avoid gaps in the hairline border. */
- padding-bottom: 1px;
- /* Prevent bullets from touching in short list items. */
- min-height: calc(var(--bullet-size) + var(--bullet-margin));
-}
-
-ol > li + li {
- /* Remove margin between steps. */
- margin-top: 0;
-}
-
-/* Custom list marker element. */
-ol > li::before {
- content: counter(steps-counter);
- position: absolute;
- top: 0;
- inset-inline-start: 0;
- width: var(--bullet-size);
- height: var(--bullet-size);
- line-height: var(--bullet-size);
-
- font-size: var(--sl-text-xs);
- font-weight: 600;
- text-align: center;
- color: var(--sl-color-white);
- background-color: var(--sl-color-gray-6);
- border-radius: 99rem;
- box-shadow: inset 0 0 0 1px var(--sl-color-gray-5);
-}
-
-/* Vertical guideline linking list numbers. */
-ol > li::after {
- --guide-width: 1px;
- content: "";
- position: absolute;
- top: calc(var(--bullet-size) + var(--bullet-margin));
- bottom: var(--bullet-margin);
- inset-inline-start: calc((var(--bullet-size) - var(--guide-width)) / 2);
- width: var(--guide-width);
- background-color: var(--sl-color-hairline-light);
-}
-
-/* Adjust first item inside a step so that it aligns vertically with the number
- even if using a larger font size (e.g. a heading) */
-ol > li > :first-child {
- /*
-The `lh` unit is not yet supported by all browsers in our support matrix
-— see https://caniuse.com/mdn-css_types_length_lh
-In unsupported browsers we approximate this using our known line-heights.
-*/
- --lh: calc(1em * var(--sl-line-height));
- --shift-y: calc(0.5 * (var(--bullet-size) - var(--lh)));
- transform: translateY(var(--shift-y));
- margin-bottom: var(--shift-y);
-}
-
-ol > li > :first-child:where(h1, h2, h3, h4, h5, h6) {
- --lh: calc(1em * var(--sl-line-height-headings));
-}
-
-@supports (--prop: 1lh) {
- ol > li > :first-child {
- --lh: 1lh;
- }
-}
diff --git a/tools/convert-help-center-docs-to-mdx b/tools/convert-help-center-docs-to-mdx
index 0cafe2dadb4..4c4293a23c0 100755
--- a/tools/convert-help-center-docs-to-mdx
+++ b/tools/convert-help-center-docs-to-mdx
@@ -309,12 +309,12 @@ def insert_flattened_steps_component(
components_dir_path: str,
) -> str:
"""
- We insert FlattenList components where include files
+ We insert FlattenedSteps components where include files
are being treated as part of ordered lists. Astro renders
included files as it's own component, which would result in
multiple ordered lists instead of a single list if we did
not use this component. See the astro component file itself
- to know more how FlattenList works.
+ to know more how FlattenedSteps works.
"""
file_include_pattern = re.compile(r"^ {,3}\{!([^!]+)!\} *$", re.MULTILINE)
lines = markdown_string.splitlines()
@@ -343,7 +343,7 @@ def insert_flattened_steps_component(
# If a file with `is_only_ordered_list` set to True is followed
# immediately by a similar file with it set to true, our loop
# will try to insert the same text at the same position twice
- # resulting in two opening <FlattenList> one after the other.
+ # resulting in two opening <FlattenedSteps> one after the other.
# Using a set avoids this problem.
insertions = set()
@@ -351,10 +351,10 @@ def insert_flattened_steps_component(
match_line_index = markdown_string[: match.start()].count("\n")
upper_bound = traverse_to_boundary(match_line_index - 1, step=-1)
- insertions.add((upper_bound + 1, "<FlattenList>"))
+ insertions.add((upper_bound + 1, "<FlattenedSteps>"))
lower_bound = traverse_to_boundary(match_line_index + 1, step=1)
- insertions.add((lower_bound, "</FlattenList>"))
+ insertions.add((lower_bound, "</FlattenedSteps>"))
for match in SETTINGS_LINK_PATTERN.finditer(markdown_string):
insert_flatten_list(match)
@@ -370,7 +370,7 @@ def insert_flattened_steps_component(
if insertions:
import_statement_set.add(
- f"import FlattenList from '{components_dir_path}/FlattenList.astro';"
+ f"import FlattenedSteps from '{components_dir_path}/FlattenedSteps.astro';"
)
# Insert tags in reverse order to avoid index shifting
for index, tag in sorted(insertions, reverse=True):