Skip to content

CodeCoupler Costa Components Launcher

Visualizes a component registry and can trigger loading the components defined in the registry.

It creates a list of the components in the form:

1
2
3
4
5
6
7
8
9
<ul>
  <li>
    <a tabindex="0">
      <div class="icon">manifest.iconHtml</div>
      <div class="name">manifest.name</div>
    </a>
  </li>
  <!-- Further <li> elements  -->
</ul>

The manifest name is by default initially hidden. The user can click on an expand button to show the names. Otherwise the names will be shown in tooltips.

Groups will be displayed in popovers.

The overall inner structure of the component consists of the ul list shown above and two additional div elements that provide buttons to show and hide the names:

1
2
3
4
5
6
7
8
9
<div class="[collapsed | expanded][empty | filled]">
  <ul>...</ul>
  <div class="toggler-expand">
    <svg>...</svg>
  </div>
  <div class="toggler-collapse">
    <svg>...</svg>
  </div>
</div>

Depending on its state, the root element can have the class collapsed or expanded. The div elements with the classes toggler-collapse and toggler-expand are shown and hidden in turn.

The root element gets the class empty if no li element exists or all elements are not visible to the current user because of authentication restrictions. Otherwise, it receives the filled class. The two toggle elements are hidden if the root element has the empty class.

Authentication

The identity parameter can be used to pass a reactive object from an authentication module. This object is monitored for changes. Any li elements that the user does not have access to are assigned the restricted class and are hidden by default:

1
2
3
4
5
<ul>
  <li class="restricted">
    <!-- ...  -->
  </li>
</ul>

Styling

The component provides only the bare minimum of styling. It simply ensures that names are shown and hidden, that the correct toggle button is displayed (or both hidden if empty), and that the mouse pointer changes when you hover over the list items or the toggle button.

You will need to style it yourself to display it as desired. Here's an example of how to display the list vertically, which you could use in a sidebar:

.your-component {
  min-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;

  /* How to customize names based on collapsed/expanden status:
  &.collapsed ul li a .name {}
  &.expanded ul li a .name {}
  */

  /* How to customize toggle buttons based on filled/empty status:
  &.empty .toggler-collapse,
  &.empty .toggler-expand {}
  &.filled .toggler-collapse,
  &.filled .toggler-expand {}
  */

  & ul {
    flex-grow: 1;
    margin: 20px 10px 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;

    /* How to customize restriced elements:
    & li.restricted {}
    */

    & li {
      & a {
        padding: 5px;
        align-items: center;
        display: flex;
        flex-direction: row;

        & .name {
          font-size: 14px;
          white-space: nowrap;
          padding-left: 14px;
          flex-grow: 1;
        }

        & .icon {
          font-size: 24px;
          flex-grow: 0;

          & svg {
            width: 30px;
            height: 30px;
            display: block; /* make svg and outer div equal in size */

            & * {
              fill: var(--color-primary);
            }
          }
        }
      }
    }
  }

  & .toggler-collapse,
  & .toggler-expand {
    text-align: end;

    & svg {
      width: 30px;
      height: 30px;

      & * {
        fill: var(--color-primary);
      }
    }
  }
}

Popover

The popovers will be rendered into the body of the document. For this reason, in addition to the popover class, you can assign an additional class to the popovers using the popoverClasses prop to target it more precisely.

Popovers contains specific inner elements.

Header:

& .popover-header {}

Body:

& .popover-body {}

List inside body:

& .popover-body {
  & ul {
    & li {
      & a {
        & .name {}
        & .icon {}
      }
    }
  }
}

Colorizing arrow depending on placement:

&[data-popper-placement^="bottom"] > .popover-arrow::after,
&[data-popper-placement^="bottom"] > .popover-arrow::before {
  border-bottom-color: #your-color-here;
}

&[data-popper-placement^="left"] > .popover-arrow::after,
&[data-popper-placement^="left"] > .popover-arrow::before {
  border-left-color: #your-color-here;
}

&[data-popper-placement^="top"] > .popover-arrow::after,
&[data-popper-placement^="top"] > .popover-arrow::before {
  border-top-color: #your-color-here;
}

&[data-popper-placement^="right"] > .popover-arrow::after,
&[data-popper-placement^="right"] > .popover-arrow::before {
  border-right-color: #your-color-here;
}

Tooltips

The tooltips will be rendered into the body of the document. For this reason, in addition to the tootip class, you can assign an additional class to the popovers using the tooltipClasses prop to target it more precisely.

Tooltips contains specific inner elements.

Body:

& .tooltip-inner {}

Colorizing arrow depending on placement:

&[data-popper-placement^="right"] .tooltip-arrow::before {
  border-right-color: #your-color-here;
}

&[data-popper-placement^="left"] > .popover-arrow::before {
  border-left-color: #your-color-here;
}

&[data-popper-placement^="top"] > .popover-arrow::before {
  border-top-color: #your-color-here;
}

&[data-popper-placement^="right"] > .popover-arrow::before {
  border-right-color: #your-color-here;
}

Options Reference

identity

Reactive identity object aof an authentication module. This identity will be used to check restrictions. If a component have restrictions that do not match the identity, the component will not be shown.

registry

The registry to visualize

popoverClasses and tooltipClasses

The popoivers and tooltips will be rendered into the body of the document. For this reason, you can assign an additional classes to the popver and tooltip elements to target them more precisely.

loadOverrides

Override for every start definition object that will be used to load a component.

`defaultGroupManifest:

The default name and icon for groups.

collapsed

Is by default true. If set to false the list will be shown expanded initaially.

toggler

Is by default true. If set to false the toggle button to expand/collapse the list will be hidden.

debug

If set to true the tooltips and popovers will never close. Useful for debuging styling.