rwt-dockable-panels v1.0.33
html
Premium DOM Component
Dockable Panels
Expand, collapse, dock and float
Motivation
Some apps have lots of interactive manipulations for working with a canvas or object. Putting the tools and options for these manipulation commands within menus is a weak design pattern. The use of floatable, dockable, and collapsable panels is a better alternative because it lets the user initiate commands with shorter mouse transit times and fewer clicks. It also provides the user with a personalized mental map of where the commands can be initiated, something that a hierarchical menu doesn't do well.
The component has these features:
- The component comprises a collection of panels that contain logically related information.
- Each panel has a titlebar for self-identification and a panel area comprising DOM elements.
- The titlebar has an expand/collapse button which allows the panel's elements to be shown or hidden.
- The titlebar has a float/dock button which allows the panel to be detached/attached from the main panel.
- Floating panels can be moved with the mouse by dragging the titlebar.
- The initial position of the menu is relative to any one of the four viewport corners.
In the wild
To see an example of this component in use, visit the simply.earth website. It uses this component for its Tangent, Scale, Rotate, Locate, and Identify panels. 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-dockable-panels 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.
Download
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'srwt-dockable-panels.jsfile:
<script src='/node_modules/rwt-dockable-panels/rwt-dockable-panels.js' type=module></script>             - Add the component tag somewhere on the page. - For scripting purposes, apply an idattribute.
- For WAI-ARIA accessibility apply a role=contentinfoattribute.
- Apply a - cornerattribute with one of these values to set the location of the toolbar relative to its parent.- top-right
- top-left
- bottom-right
- bottom-leftdefault
 
- Apply a - sourcerefattribute with a reference to a JSON file containing the panel configuration. (Or optionally use the programmatic interface for panel configuration.)
- Optionally, apply a - stateattribute to set the initial state of the toolbar.- closedThe toolbar menu should initially be collapsed.
- opendefault The toolbar menu should initially be expanded.
 
- Optionally, apply a - shortcutattribute with a value like- 'F1',- 'F2',- 'F3', to allow the toolbar to be opened and closed using the keyboard.
- Optionally, apply an embeddedattribute with a value of "embedded" when the component is used inside another DOM component.
 
- For scripting purposes, apply an 
Example:
<rwt-dockable-panels id=toolbarId sourceref='/panels.json' corner=top-right state=open shortcut='F1' role=contentinfo></rwt-dockable-panels>Panel configuration
The panels can be configured programmatically or through a JSON file. Both accept similar objects, described here:
JSON file configuration
A JSON file containing a collection of panel configurations can be specified as
an attribute of the component. Do this with HTML like <rwt-dockable-panels sourceref='panels.json'></rwt-dockable-panels>
The JSON object should contain an object with two properties:
- toolbaran object for configuring the entire component, having:- titlebarthe plain text or HTML to use for the main menu.
 
- panelsan array of panel objects for configuring the panels, having:- optionsan object to configure each panel's basic properties:- idthe HTML identifier for the panel
- titlebarthe text title for the panel
- tabIndexthe HTML tabIndex, optional
- tooltipthe fly-over popup title for the panel, optional
 
- panelLinesan array of line objects to configure the elements of the panel, line by line.- lineTypespecifies what to put on the line, see below
- idthe HTML identifier for the line's principal element, see below
 
 
These are the possible lineTypes and their configuration properties:
- "input"- labelTextthe text to place before the- INPUTelement
- idthe identifier for the- INPUTelement
- textAfterany text to place after the- INPUTelement, optional
- tooltipthe fly-over popup title for the- INPUTelement, optional
 
- "button"- buttonTextthe text to place on the- BUTTONelement
- idthe identifier for the- BUTTONelement
- tooltipthe fly-over popup title for the- BUTTONelement, optional
 
- "multi-button"- buttonsan array of objects to define each button, having:- buttonTextthe text to place on the- BUTTONelement
- idthe identifier for the- BUTTONelement
- tooltipthe fly-over popup title for the- BUTTONelement, optional
 
 
- "dropdown"- labelTextthe text to place before the- SELECTelement
- idthe identifier for the- SELECTelement
- tooltipthe fly-over popup title for the- SELECTelement, optional
- selectionsan array of- OPTIONS, specified as objects, each having:- vthe- OPTIONvalue
- tthe- OPTIONtext
 
 
- "slider+input"- idis the identifier to be assigned to the text- INPUTbeing created (the range slider will append "-slider" to this id)
- curveis the distribution of slider values: "callback", "linear" or "log"; defaults to linear if not defined
- fromSlideris a callback function that synchronizes- INPUTvalue when the current slider position changes
- toSlideris a callback function that synchronizes the current slider position when the- INPUTvalue changes
- fromUseris a callback function to convert user text to internal value
- toUseris a callback function to convert internal value to user text
- numDecimalsis the number of decimal points kept in the internal value (defaults to 2).
- minValueis the minimum acceptable "value" in user units; defaults to "" if not specified
- maxValueis the maximum acceptable "value" in user units; defaults to "" if not specified
- minPositionis the minimum slider position; defaults to 0 if not specified
- maxPositionis the maximum slider position; defaults to 100 if not specified
- stepPositionis the accuracy of the slider; defaults to 1 if not specified
- labelTextis the text to be displayed in the- LABELbefore the two- INPUTelements
- tooltipis the text to display on hover, optional
- widthInPxis a string value specifying the width of the input field, with a trailing 'px', optional
- textAfteris the optional short text to display after the- INPUT, optional
 
- "generic"- idthe identifier for the "chef-generic" panel's outer- DIVelement
- innerHTMLis the generic HTML to be displayed
- heightInPxthe CSS value for the panel's height, defaults to 'fit-content'
- overflowXWhether to show a horizontal scrollbar: "scroll", "hidden", "clip", "auto"
- overflowYWhether to show a vertical scrollbar: "scroll", "hidden", "clip", "auto"
 
- "custom"- idthe identifier for the "chef-custom" panel's outer- DIVelement
- innerHTMLis the custom HTML to be displayed
- heightInPxthe CSS value for the panel's height, defaults to 'fit-content'
- overflowXWhether to show a horizontal scrollbar: "scroll", "hidden", "clip", "auto"
- overflowYWhether to show a vertical scrollbar: "scroll", "hidden", "clip", "auto"
 
- "table"- idis the identifier to be assigned to the- TABLEbeing created
- innerHTMLis the TABLE's inner HTML
- minHeightInPxis a number of pixels, expressed as a string ending in 'px', like '156px'
- maxHeightInPxis a number of pixels, expressed as a string ending in 'px', like '156px'
- heightInPxthe CSS value for the panel's height, defaults to '100%'
- overflowXWhether to show a horizontal scrollbar: "scroll", "hidden", "clip", "auto"
- overflowYWhether to show a vertical scrollbar: "scroll", "hidden", "clip", "auto"
 
Programmatic configuration
The component has methods to programmatically configure panels. They use objects with the same properties as just described. The methods are:
Programmatic manipulation
The component also has methods to programmatically manipulate the toolbar and its panels.
Programmatic access
The component has methods to access the inner buttons and titlebars.
Customization
Initial position
Initially the toolbar is positioned a certain distance from one of the
viewport's corners, specified using the corner attribute and two of these offset
variables.
rwt-dockable-panels {
    --top: 30px;
    --bottom: 30px;
    --left: 30px;
    --right: 30px;
    --z-index: 1;
}Visuals and color scheme
The font for the component can be changed with the --font-family variable.
The width of the component can be set with the --width variable.
The default color palette for the menu uses a dark mode theme. You can use CSS to override the variables' defaults:
rwt-dockable-panels {
    --color: var(--pure-white);
    --border-color: var(--pure-white);
    --background-color1: var(--surfie-green);
    --background-color2: var(--coral-atoll);
    --background-color3: var(--tiber);
    --background-color4: var(--eden);
}Life-cycle events
The component issues life-cycle events.
Reference
License
The rwt-dockable-panels DOM component is not freeware. After evaluating it and before using it in a public-facing website, eBook, mobile app, or desktop application, you must obtain a license from Read Write Tools .
Activation
To activate your license, copy the rwt-registration-keys.js file to the root
directory of your website, providing the customer-number and access-key sent to
your email address, and replacing example.com with your website's hostname.
Follow this example:
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago