Skip to content

References to related documents, using standardized styling, a standards-based DOM Component

License

Notifications You must be signed in to change notification settings

readwritetools/rwt-newton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paolozzi statue of Isaac Newton
Open Source DOM Component

Newton

Standing on the shoulders of giants

by Read Write Tools Aug 2, 2020
Abstract
The rwt-newton DOM component displays document references using standardized styling.

In the wild

To see an example of this component in use, visit the Compleat Botanica website. This component typically has no visible UI. To understand what's going on under the hood, use the browser's inspector to view the HTML source code and network activity, and follow along as you read this documentation.

Installation

Prerequisites

The rwt-newton DOM component works in any browser that supports modern W3C standards. Templates are written using BLUE PHRASE notation, which can be compiled into HTML using the free Read Write View desktop app. It has no other prerequisites. Distribution and installation are done with either NPM or via Github.

Download

Download using NPM

OPTION 1: Familiar with Node.js and the package.json file?
Great. Install the component with this command:

npm install rwt-newton	

OPTION 2: No prior experience using NPM?
Just follow these general steps:

  • Install Node.js/NPM on your development computer.
  • Create a package.json file in the root of your web project using the command:
  • npm init		
  • Download and install the DOM component using the command:
  • npm install rwt-newton		

Important note: This DOM component uses Node.js and NPM and package.json as a convenient distribution and installation mechanism. The DOM component itself does not need them.

Download using Github

If you prefer using Github directly, simply follow these steps:

  • Create a node_modules directory in the root of your web project.
  • Clone the rwt-newton DOM component into it using the command:
  • git clone https://github.com/readwritetools/rwt-newton.git		

Using the DOM component

After installation, you need to add two things to your HTML page to make use of it.

  • Add a script tag to load the component's rwt-newton.js file:
<script src='/node_modules/rwt-newton/rwt-newton.js' type=module></script>             
  • Add the component tag somewhere on the page, supplying four pieces of slotted text:

    1. span slot=h2 The h2 heading text (optional).
    2. span slot=h3 The h3 heading text (optional).
    3. span slot=dt A definition term.
    4. span slot=dd A definition description. This typically has an anchor tag with the external reference.

Here's an example:

<rwt-newton role=navigation>
    <span slot=h2>Giants</span>
    <span slot=h3>Isaac Newton</span>
    <span slot=dt>Famous quotes</span>
    <span slot=dd><a href='https://example.com/shoulders-of-giants.html'> If I Have Seen Further</a> Using the understanding gained by major thinkers who have gone before in order to make intellectual progress.</span>
</rwt-newton>

Customization

The reference area has limited customization. Only the background color may be customized. Supply a background color using the background attribute.

<rwt-newton role=navigation background='#777'>
    ...
</rwt-newton>

Life-cycle events

The component issues life-cycle events.

component-loaded
Sent when the component is fully loaded and ready to be used. As a convenience you can use the waitOnLoading() method which returns a promise that resolves when the component-loaded event is received. Call this asynchronously with await.

Reference

DOM components logo Documentation READ WRITE HUB
git logo Source code github
DOM components logo Component catalog DOM COMPONENTS
npm logo Package installation npm
Read Write Stack logo Publication venue READ WRITE STACK

License

The rwt-newton DOM component is licensed under the MIT License.

MIT License

Copyright © 2020 Read Write Tools.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

References to related documents, using standardized styling, a standards-based DOM Component

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published