theophilusx.yorick.sidebar

Provides a vertical menu sidebar.

defsidebar-item

(defsidebar-item & {:keys [type title href icon-data id items class], :or {type :item, id (keyword (gensym "side-bar-"))}})

Define an item for the sidebar. The item can either be a simple link item or it can be a sub-menu item. Items are defined by a map which can have the following keys:

Key Description
:type Type of the item. Either :item for a simple link item or
:menu for a nested sub-menu item. Defaults to :item.
:title The title for sub-menus.
:href The href for the link.
:id An id attribute for the item. If not provided, defaults to
a unique value with the prefix side-bar-.
:icon-data An icon data map (see theophilusx.yorick.icons)
:class a string or vector of strings specifying CSS class names.
:items For items of type :menu, this key is a vector of
defsidebar-item maps representing the sub-menu items.

is-active?

(is-active? sid id)

Return true if the id argument is equal to the value stored at the location specified by the sid storage identifier keyword in the global state atom defined in `theophilusx.yorick.store/global-state.

make-item

(make-item i sid)

Create a sidebar menu item. The i argument is an item map. See the function defsidebar-item for a description of the supported map keys. The sid storage identifier keyword specifies where the id associated with this item will be stored in the global state atom defined in theophilusx.yorick.store/global-state

make-menu

(make-menu m sid)

Generate a sidebar menu or a nested menu within the sidebar. The m argument is an item map. See defsidebar-item function for a description of available keys and their meaning. The sid storage identifier keyword determines where the selected menu item id is stored within the global state atom defined in theophilusx.yorick.store/global-state.

set-active

(set-active sid id)

Set the value of the key specified by the sid storage identifier keyword in the global state atom defined by theophilusx.yorick.store/global-state to the value id.

sidebar

(sidebar data)

Defines a sidebar menu. A sidebar is defined by a map with the keys

Key Description
:sid a storage identifier keyword used to determine the key
within the global state in
theophilusx.yorick.store/global-state where the
current menu id should be stored.
:default-link The default menu id to be set as active when the
sidebar is first loaded
:data A defsidebar-item map defining the parent menu with
the child menus defined as a vector of defsidebar-tiem
items in the :items key.