Code Monkey home page Code Monkey logo

vellum-doc's Introduction

<vellum-doc>

A simple custom element for web publishing. Enriches plain HTML with an index pane based on the document outline. Inspired by Docsify.

Demo | Developer Guide | Roadmap

Usage

Include the <script> in your markup:

<script
  type="module"
  src="https://www.unpkg.com/[email protected]/vellum-doc.js"></script>

Or, if you host the script as part of your project (recommended):

<script type="module">
  import 'vellum-doc/vellum-doc.js'
</script>

Example:

<vellum-doc>
  <h1>Commodi</h1>
  <p>
    Lorem ipsum dolor sit amet. Id omnis amet sit autem voluptas et dicta
    consequatur ut amet rerum ad consequatur nemo ea necessitatibus enim. Aut
    velit accusantium qui molestiae beatae ad sunt odit sit recusandae sapiente
    id tempora mollitia nam praesentium laborum rem molestiae placeat.
  </p>
  <h2>Et nobis reprehenderit quo minus iste sit dolore ipsam!</h2>
  <p>
    Ut quam odio et quae unde ut sunt quas qui unde cupiditate? 33 sequi
    molestiae quo autem vitae ut itaque nisi aut quod esse qui quibusdam labore
    ut voluptatibus sequi sit sapiente galisum. Nam facilis aspernatur et eius
    perspiciatis eum eveniet omnis aut repudiandae rerum ut sunt assumenda?
  </p>
</vellum-doc>

Anchors

Anchor links can be dynamically added to document headers using the anchors attribute:

<vellum-doc anchors>
  <h1>Commodi</h1>
</vellum-doc>

Styling

<vellum-doc> exposes the index part, which can be used to style the document index, overriding styles for the index/document divider (border-right) or background colour.

The element can also be customised using the following CSS variables:

Variable Description Default
--index-width Width of the index sidebar. 300px
--gap Gap between index and document. 0
--index-level-1-font Font style of the index links to level 1 headers (h1) as defined by the font property. 1.3em bold with inherited font.
--index-level-2-font Font style of the index links to level 2 headers (h2) as defined by the font property. 1.15em bold with inherited font.
--index-level-3-font Font style of the index links to level 3 headers (h3) as defined by the font property. 1em with inherited font.
--index-level-4-font Font style of the index links to level 4 headers (h4) as defined by the font property. 0.9em with inherited font.

For example:

vellum-doc {
  --gap: 50px;
  --index-level-1-font: bold 2.5em Alegreya;
}

vellum-doc::part(index) {
  border-right: dashed red;
  padding-left: 10px;
  padding-right: 10px;
}

vellum-doc's People

Contributors

rg-wood avatar

vellum-doc's Issues

Index unstyled on iOS Safari browser

OS: iOS v16 or earlier
Browser: Safari
Model numbers: iPhone SE, iPhone SE 2020, iPhone SE 2022, iPhone 13

The index pane looses styling on the Samsung Internet browser:

iPhone screenshot of vellum-doc demo

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.