The Web Components I made for learning!
You can find the components in action here.
Contains a modal element with a header, content along with confirm and cancel buttons.
Once the modal is opened a backdrop (blurred background) will be added behind it. Clicking on it will close the modal.
<uc-modal>
-
modal-header
The heading/title of the modal.
-
Default slot Anything else will go inside the default slot which is the content of the modal.
-
opened
Its presence determines whether the modal is opened or closed.
-
confirm
Fired when user clicks on the confirm button. Will also close the modal.
-
cancel
Fired when user clicks on the cancel button. Will also close the modal. Clicking on the backdrop will also fire the cancel button and close the modal.
-
open
Opens the modal.
-
close
Closes the modal.
A drawer with fixed positioning that can slide in from either top, right, bottom or left.
Once the drawer is opened a backdrop (blurred background) will be added behind it. Clicking on it will close the drawer.
<uc-drawer>
- Default slot: Anything inside the opening and closing
<uc-drawer>
will go inside the default slot.
-
opened
Its presence determines whether the drawer is opened or closed.
-
position
Determines from where the drawer will slide in from once it's opened. Possible values are:
- top
- right
- bottom
- left
None
-
open
Opens the drawer.
-
close
Closes the drawer.
A component that can display data provided to it in a hierarchical tree structure.
<uc-tree>
None
-
selectable
Determines whether the individual node items are selectable either by clicking or using methods provided by the component.
-
data
The data used to populate the tree. Should be a list of objects of the form:
[ { name: "Node 1", id: "00001", children: [ ... ], disabled: true, }, ... ]
- name : The name of the node. This will be the name displayed in the strucutre. Required attribute.
- id: Used to uniquely identify a node. Used for selection. Required attribute.
- children: A list of object of the same structure. Used to develop the hierarchical structure of the tree. Required attribute.
- disabled: Whether or not the particular node is clickable. Only applicable if
selectable
attribute is set. Is optional.
-
node-click
The event fired when user clicks on the node in the tree strcuture. Returns the
event
argument. The selected node object can be found inevent.details
.
-
setSelected(nodeId)
Takes the nodeId (the
id
property in the data) and sets it as the selected node. Ifselectable
attribute is not set, results in a warning in the console saying The nodes are not selectable. -
getSelected
Returns the currently selected node object. If
selectable
attribute is not set, results in a warning in the console saying The nodes are not selectable and returns null. -
clearSelected
Clears the current selection if any. If
selectable
attribute is not set, results in a warning in the console saying The nodes are not selectable.