Code Monkey home page Code Monkey logo

Comments (3)

trusktr avatar trusktr commented on September 2, 2024

I believe this is because the selector is too reliant on the structure (something we should move away from in Docsify 5.0):

// Nav Headings
ul > li {
> span,
> strong {
display: block;
margin: var(--sidebar-nav-strong-margin);
padding: var(--sidebar-nav-strong-padding);
border-width: var(--sidebar-nav-strong-border-width, 0);
border-style: solid;
border-color: var(--sidebar-nav-strong-border-color);
color: var(--sidebar-nav-strong-color);
font-size: var(--sidebar-nav-strong-font-size);

from docsify-themeable.

trusktr avatar trusktr commented on September 2, 2024

For 4.0, should that selector be modified to

 ul > li,
 ul > li > p { 
     > span, 
     > strong { 

?

I'm not sure about that span yet though.

In my plain CSS of my site, I added this:

.sidebar-nav ul > li > p > strong,
.sidebar nav ul > li > p > strong {
	display: block;
	margin: var(--sidebar-nav-strong-margin);
	padding: var(--sidebar-nav-strong-padding);
	border-width: var(--sidebar-nav-strong-border-width, 0);
	border-style: solid;
	border-color: var(--sidebar-nav-strong-border-color);
	color: var(--sidebar-nav-strong-color);
	font-size: var(--sidebar-nav-strong-font-size);
	font-weight: var(--sidebar-nav-strong-font-weight);
	text-transform: var(--sidebar-nav-strong-text-transform);
}

After placing that CSS I could then style my headers like in the design in the screenshot at #48 (comment).

from docsify-themeable.

jhildenbiddle avatar jhildenbiddle commented on September 2, 2024

Remove the empty lines between your list items. This causes docsify to generate extra, unnecessary markup for the sidebar navigation.

Instead of this:

-   **Foo**

    -   [Hello](/hello)

-   **Bar**

    -   [Goodbye](goodbye.md)

Do this:

- **Foo**
  - [Hello](/hello)
- **Bar**
  - [Goodbye](goodbye.md)

This will generate the following HTML which works as expected with docsify-themeable's CSS:

<div class="sidebar-nav">
  <ul>
    <li>
      <strong>Foo</strong>
      <ul>
        <li><a href="#/hello">Hello</a></li>
      </ul>
    </li>
    <li>
      <strong>Bar</strong>
      <ul>
        <li><a href="#/goodbye">Goodbye</a></li>
      </ul>
    </li>
  </ul>
</div>

The CSS selector used in docsify-themeable is based on the HTML structure because this is the only way to target sidebar elements given the HTML generated by docsify. Ideally, docsify would render sidebar markdown consistently by accounting for things like empty lines between list items. If/when this happens, a CSS selector based on the HTML structure will be a non-issue. Arguably, it makes for cleaner HTML and fewer classnames to manage in CSS, which (ideally) devs would never have to see anyway because they're using custom properties to change styles.

Hope this helps!

from docsify-themeable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.