Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New list type: Steps #7760

Open
4 tasks done
ofek opened this issue Nov 28, 2024 · 7 comments
Open
4 tasks done

New list type: Steps #7760

ofek opened this issue Nov 28, 2024 · 7 comments
Labels
change request Issue requests a new feature or improvement

Comments

@ofek
Copy link
Collaborator

ofek commented Nov 28, 2024

Context

https://squidfunk.github.io/mkdocs-material/reference/lists/

Description

It would be nice to have a dedicated way to display list items that represent steps the user must follow to achieve a particular task.

Related links

Use Cases

A user must follow directions to achieve a desired outcome like the installation of a program.

Visuals

image

image

Before submitting

@squidfunk
Copy link
Owner

Thanks for suggesting! We already have this on our list, and we'll revisit this once we got our current efforts sorted out ☺️

@squidfunk squidfunk added the change request Issue requests a new feature or improvement label Nov 28, 2024
@A3Bagged
Copy link

A3Bagged commented Dec 19, 2024

I've actually came up with a markdown extension for this.
i was looking for the same thing.

I don't know python well so code could be improved but i've done my best and it works.
I've included it on my ci.yml with pip install stepslist so that i can use it online.

Link to repo

I've tried making it with <steps> & </steps> tags but after 2 days of tinkering i found out that markdown or mkdocs closes any open html tags so it would actually output as:

<p><steps></steps></p>
<ol>
<li>

etc..

for further info take a look at #7775

Changing to using --steps-- & --!steps-- has allowed me to do this.

These can then be styled with css using the class name .md-steps and ::before ::after pseudo elements to have something like your example.

Mine currently look like this
image

@squidfunk
Copy link
Owner

Looks great, thanks for sharing!

@facelessuser
Copy link
Contributor

I kind of liked the "steps" idea, so I figured I'd post this. I didn't bother with a specialized "steps" extension or using custom tags and just utilized existing wrapping approaches and standard tags. I provided the necessary CSS so people could mimic this if they'd like. The colors can be overridden with whatever if something else is preferred. It should work with the default light and dark theme.

Screenshot 2025-01-06 at 9 30 51 PM
:root > * {
	 --md-steps-bg-color: var(--md-code-bg-color);
	 --md-steps-fg-color: var(--md-code-fg-color);
	 --md-steps-border-color: hsla(0, 0%, 75%, 1);
}

:root > *[data-md-color-scheme="slate"] {
	 --md-steps-border-color: hsla(225, 15%, 30%, 1);
}

.md-typeset div.steps > ol {
	 counter-reset: item;
}

.md-typeset div.steps > ol li {
	 position: relative;
	 padding-left: 1em;
	 list-style: none;
}

.md-typeset div.steps > ol li::before {
	 position: absolute;
	 top: 0;
	 left: 0;
	 z-index: -1;
	 display: block;
	 width: 1.75em;
	 height: 1.75em;
	 margin-left: -1.25em;
	 color: var(--md-steps-fg-color);
	 font-weight: 600;
	 font-size: 0.9em;
	 text-align: center;
	 background-color: var(--md-steps-bg-color);
	 border: 1px solid var(--md-steps-border-color);
	 border-radius: 100px;
	 content: counter(item);
	 counter-increment: item;
}

.md-typeset div.steps > ol li::after {
	 position: absolute;
	 top: 0;
	 bottom: 0;
	 left: -0.36em;
	 display: block;
	 width: 1px;
	 margin-top: 2em;
	 border-left: 1px solid var(--md-steps-border-color);
	 content: '';
}
 

@squidfunk
Copy link
Owner

squidfunk commented Jan 7, 2025

Nice, thanks for sharing! What we envision is that this works without "Yet Another Markdown Syntax Extension", and in this case, it does by just wrapping it with a div. However, in the future we want to provide options to have more involved components that are easy to use, encapsulating an arbitrary amount of business and rendering logic. This is why we are not going to rush this, but take it back to the drawing board.

We already have some solid concepts that generalize well, but first need to finish our current foundational work.

@A3Bagged
Copy link

A3Bagged commented Jan 7, 2025

@facelessuser looks good! Wrapping it inside a class “steps” is alot easier (though the reason why i did the extension is the people that write the docu arent familiar with html)

@facelessuser
Copy link
Contributor

@A3Bagged I'm not criticizing the use of an extension, just decided to post a solution for those that are okay using existing availability. I likely won't use a specialized extension, but I understand that some may prefer such. The CSS can easily be modified to work with custom tags as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement
Projects
None yet
Development

No branches or pull requests

4 participants