Open Source DOM Component
Search popular tech websitesby Read Write Tools
|The rwt-xenotools DOM component links to popular tech forums to search for questions and answers related to this document's topic.|
Sometimes visitors are unsatisfied with the information provided in your document and need to further research the topic. As a convenience to your visitors you can provide quick links to external forums that may have additional information about the your document's main topic.
The rwt-xenotools DOM component facilitates this by keeping a social-media style linkbar hidden at the bottom of the page until the user needs it.
When activated, the linkbar slides over the page content, showing a collection of icons associated with popular tech forums.
Activation may also be initiated through the component's
toggleMenu method or through its event interface.
The component has these features:
- Each third-party link is prefilled with a query value that is determined by the document's
- When appropriate, some links are prefilled with a hashtag values that are determined by the document's
- The Reddit link uses any value provided by the document's
- The Github link uses any value provided by the document's
- The linkbar has an event interface for showing and hiding itself.
- The linkbar emits a custom event to close sibling menus and dialog boxes.
- A keyboard listener is provided to allow a shortcut key to open/close the linkbar.
In the wild
To see an example of this component in use, visit the BLUEPHRASE website and press F6 "Link to Q&A forums". 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-xenotools DOM component works in any browser that supports modern W3C standards. Templates are written using BLUEPHRASE 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.
Installation using NPM
If you are familiar with Node.js and the
package.json file, you'll be comfortable installing the component just using this command:
npm install rwt-xenotools
If you are a front-end Web developer with no prior experience with NPM, follow these general steps:
- Install Node.js/NPM on your development computer.
- Create a
package.jsonfile in the root of your web project using the command:
npm install rwt-xenotools
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.
Installation using Github
If you are more comfortable using Github for installation, follow these steps:
- Create a directory
node_modulesin the root of your web project.
- Clone the rwt-xenotools DOM component into it using the command:
git clone https://github.com/readwritetools/rwt-xenotools.git
Using the DOM component
After installation, you need to add two things to your HTML page to make use of it.
- Add a
scripttag to load the component's
<script src='/node_modules/rwt-xenotools/rwt-xenotools.js' type=module></script>
<rwt-xenotools id=xenotools shortcut='F6' role=navigation />
The linkbar's inputs are prefilled with values provided in the document's <meta> tags. Here's an example:
<meta name=xenotools:query content='h1, h2, h3' />
<meta name=xenotools:tagged content=html />
<meta name=xenotools:language content=HTML />
<meta name=xenotools:subreddit content=HTML5 />
Dialog size and position
The linkbar is positioned in a fixed location at the bottom of the viewport. Its position and size may be overridden using CSS by defining new values for the bottom, width and height variables.
Dialog color scheme
The default color palette for the dialog uses a dark mode theme. You can use CSS to override the variables' defaults:
The component issues life-cycle events.
- 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-loadedevent is received. Call this asynchronously with
|Documentation||READ WRITE HUB|
|Component catalog||DOM COMPONENTS|
|Publication venue||READ WRITE STACK|
The rwt-xenotools DOM component is licensed under the 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.