0.4.2 • Published 16 days ago

vellum-doc v0.4.2

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
16 days ago

\

A simple document web component for web publishing. Creates and index

Demo

Installation

npm i vellum-doc

Usage

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

<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>

The element can be customized using the following CSS variables:

VariableDescriptionDefault
--index-widthWidth of the index sidebar.300px
--index-divider-borderBorder style of the index/document divider (as the border) declaration1px solid
--index-font-sizeBase font size for the index.15px
--gapGap between index and document.0
--index-font-familyFont family of the document index.san-serif
--index-level-1-fontFont 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-fontFont 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-fontFont style of the index links to level 3 headers (h3) as defined by the font property.1em with inherited font.
--index-level-4-fontFont style of the index links to level 4 headers (h4) as defined by the font property.0.9em with inherited font.

Setup

Install dependencies:

npm i

Build

This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.

To build the JavaScript version of your component:

npm run build

To watch files and rebuild when the files are modified, run the following command in a separate shell:

npm run build:watch

Both the TypeScript compiler and lit-analyzer are configured to be very strict. You may want to change tsconfig.json to make them less strict.

Dev Server

This sample uses modern-web.dev's @web/dev-server for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See modern-web.dev's Web Dev Server documentation for more information.

To run the dev server and open the project in a new browser tab:

npm run serve

There is a development HTML file located at /dev/index.html that you can view at http://localhost:8000/dev/index.html. Note that this command will serve your code using Lit's development mode (with more verbose errors). To serve your code against Lit's production mode, use npm run serve:prod.

Editing

If you use VS Code, we highly recommend the lit-plugin extension, which enables some extremely useful features for lit-html templates:

  • Syntax highlighting
  • Type-checking
  • Code completion
  • Hover-over docs
  • Jump to definition
  • Linting
  • Quick Fixes

The project is setup to recommend lit-plugin to VS Code users if they don't already have it installed.

Linting

Linting of TypeScript files is provided by ESLint and TypeScript ESLint. In addition, lit-analyzer is used to type-check and lint lit-html templates with the same engine and rules as lit-plugin.

The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing .eslintrc.json and tsconfig.json.

To lint the project run:

npm run lint

Formatting

Prettier is used for code formatting. It has been pre-configured according to the Lit's style. You can change this in .prettierrc.json.

Prettier has not been configured to run when committing files, but this can be added with Husky and pretty-quick. See the prettier.io site for instructions.

0.4.2

16 days ago

0.4.1

18 days ago

0.4.0

29 days ago

0.3.1

30 days ago

0.3.0

1 month ago

0.2.1

1 month ago

0.2.0

1 month ago

0.2.2

1 month ago

0.1.0

2 months ago

0.1.1

2 months ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago