Skip to content

substrate-system/wavy-hr

Repository files navigation

wavy hr

tests types module semantic versioning install size GZip size license

An hr tag with style.

See a live demo

Important

Be sure to copy the file ./dist/wave.svg into the root public folder on your web server. The CSS depends on that file.

install

npm i -S @substrate-system/wavy-hr

API

ESM and common JS via package.json exports field.

ESM

import '@substrate-system/wavy-hr'

Common JS

require('@substrate-system/wavy-hr')

CSS

Import CSS

import '@substrate-system/wavy-hr/css'

Or minified:

import '@substrate-system/wavy-hr/css/min'

use

This calls the global function customElements.define. Just import, then use the tag in your HTML.

JS

import '@substrate-system/wavy-hr'

HTML

<div>
    <wavy-hr></wavy-hr>
</div>

pre-built JS

This package exposes minified JS files too. Copy them to a location that is accessible to your web server, then link to them in HTML.

copy

cp ./node_modules/@substrate-system/wavy-hr/dist/index.min.js ./public/wavy-hr.min.js

HTML

<script type="module" src="./wavy-hr.min.js"></script>

Server-side rendering

For server-side rendering scenarios, you can use the /html export to generate the HTML string without requiring a browser environment.

import { render } from '@substrate-system/wavy-hr/html'

const html = render()
// Returns: '<hr class="wavy-hr" />'

Use case example

// In your server-side rendering code
import { render } from '@substrate-system/wavy-hr/html'

function renderPage() {
    return `
        <!DOCTYPE html>
        <html>
        <head>
            <link rel="stylesheet" href="https://github.com/path/to/wavy-hr.css">
        </head>
        <body>
            <h1>My Page</h1>
            ${render()}
            <p>More content...</p>
        </body>
        </html>
    `
}

Note

When using server-side rendering, you still need to include the CSS file and the wave.svg asset for proper styling. The render export only provides the markup structure.