Abstract |
---|
The rwt-newton DOM component displays document references using standardized styling. |
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.
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 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: - Download and install the DOM component using the command:
npm init
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
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'srwt-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:
span slot=h2
The h2 heading text (optional).span slot=h3
The h3 heading text (optional).span slot=dt
A definition term.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>
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>
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 thecomponent-loaded
event is received. Call this asynchronously withawait
.
Documentation | READ WRITE HUB | |
Source code | github | |
Component catalog | DOM COMPONENTS | |
Package installation | npm | |
Publication venue | READ WRITE STACK |
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.