2.1.0-beta.48 • Published 1 year ago

@emoneyadvisor/emui-planning-networth v2.1.0-beta.48

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

emui-planning-networth

Usage

All components are published in two locations: a private registry and the emacontent CDN.

Registry

npm install @emoneyadvisor/emui-planning-networth
yarn add @emoneyadvisor/emui-planning-networth
pnpm add @emoneyadvisor/emui-planning-networth

Import the module

The default module will register the custom element.

import '@emoneyadvisor/emui-planning-networth';

Declare the custom element as valid JSX

React's IntrinsicElements include a finite set of known tags. These can be extended to support custom elements. The type published by the main module will typically the PascalCase name after emui-.

import { DOMAttributes } from 'react';
import type { ComponentName } from '@emoneyadvisor/emui-planning-networth';

type CustomElement<T> = Partial<T & DOMAttributes<T> & { children: any }>;

declare global {
   namespace JSX {
     interface IntrinsicElements {
       ['emui-planning-networth']: CustomElement<ComponentName>;
     }
   }
}

CDN

All components have separate modules published to the CDN. They can referenced directly or downloaded. Possible URL examples include:

https://beta.emacontent.com/emoney-ui/<package version>/emui-planning-networth>.js

https://emacontent.com/emoney-ui/<package version>/emui-planning-networth.js

The component can be used on the page as an ES module.

<html>
   <head>
     <link
       rel="stylesheet"
       href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.1.0/dist/themes/light.css"
     />
     <link
       rel="stylesheet"
       href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.1.0/dist/themes/dark.css"
     />
     <script type="module" src="@emoneyadvisor/emui-planning-networth"></script>
   </head>

   <body>
     <emui-planning-networth></emui-planning-networth>

     <script type="text/javascript">
       document.addEventListener('DOMContentLoaded', () => {
         const component = document.querySelector('emui-planning-networth');

         component.addEventListener('click', () => { ... });
       });
     </script>
   </body>
</html>

Planning Components

The Planning Components are web components that allow users to view and interact with their financial planning data. The components are built using the Web Components standard, which allows them to be used in a wide variety of web development frameworks and environments. All planning components utilize container queries to ensure that they are responsive relative to the size of their containing element. Narrower containers will result in a more compact view of the data, while wider containers will result in a more detailed view of the data.

All components require 3 pieces of external information in order to function:

  1. An API key, which is used to authenticate the client making the API requests.
  2. A user access token, which is used on behalf of the user to issue API requests.
  3. The client id, which is the unique identifier for the client whose data is being displayed.

Installing the component

There are 7 components that make up the planning components:

emui-planning-asset-allocation: Displays a breakdown of assets by type or class with a donut chart to help visualize relative allocation.

emui-planning-expenses-summary: Displays client expenses.

emui-planning-goal-summary: Displays client goals and progress towards funding.

emui-planning-networth: Displays total net worth with a bar chart for visual aid.

emui-planning-probability-of-success-goals: Displays probability of success charts for each goal.

emui-planning-probability-of-success-overall: Displays overall probability of success in a single chart with details table.

emui-planning-probability-of-success-summary: Displays overall probability of success in a single chart as well as a breakdown by goal.

Placing the component on a page or in an application

Once the component is installed, it can be used in any web development framework or environment that supports Web Components. The component can be placed on a page or in an application by adding the appropriate HTML tag to the page or application code.

For example, to use the Net Worth component, you would add the following HTML tag to the page or application code:

<emui-planning-networth></emui-planning-networth>

Obtaining an access token

See the API Documentation for details on obtaining an access token.

Configuration

The initial configuration can be set on the component via the config attribute. All planning components use the same configuration object. This can be passed in as a JSON serialized string or by directly setting the public config property of the component.

const config = {
   accessToken: '',
   apiKey: '',
   clientId: '',
};

const emuiPlanning = document.querySelector('emui-planning-networth');
emuiPlanning.config = config;

Responding to component events

Each component will dispatch events for clicking the "View Details" link and for any request errors.

In either case, an event listener can be added to the component to handle the event.

const emuiPlanning = document.querySelector('emui-planning-networth');
emuiPlanning.addEventListener('emui-planning-networth-{event}', () => {
   // Handle the event
});

Theming

CSS parts are exposed for each of the components, allowing you to target different pieces of the component to override styles.

emui-planning-networth::part(header-text) {
   color: red;
}

Additionally, there are CSS variables that can be reassigned to update the components' styles.

:host {
   --emui-planning-view-details-color: red;
}

All components - loading

npm.io

All components - error

npm.io

Net Worth

npm.io

The Planning Net Worth component displays the user's net worth as a dollar amount, a summary of assets by type, and a bar chart of their asset groups and liabilities.

If the client has more than 3 asset groups, the top 3 asset groups will be displayed, along with a "Other" category that represents the sum of all other asset groups.

Properties

PropertyTypeDefaultDescription
categoryFmt"new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n notation: 'compact',\n currencySign: 'accounting',\n })"The category currency format. Used to format category values greater than or equal to $1,000,000.
colorsobject"rgb(38, 83, 125)","rgb(102, 81, 145)","rgb(249, 93, 106)","rgb(255, 124, 67)","rgb(255, 166, 0)"Array of CSS color values to be used by the category tiles and chart. Should not exceed 5 colors.
defaultCurrencyFmt"new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n maximumFractionDigits: 0,\n currencySign: 'accounting',\n })"The default currency format. Used to format calculated net worth and category values less than $1,000,000.
showDetailsLinkbooleanControls whether the "View Details" link is rendered.

Events

EventDescription
emui-planning-networth-request-failedFired when any API request fails. Includes message in the event detail.
emui-planning-networth-view-detailsFired when the user clicks on the "View Details" link.

Slots

NameDescription
error-details-iconThe error details icon. Defaults to an SVG icon.

CSS Shadow Parts

PartDescription
category-nameThe category name
category-rowThe category row
category-tileThe category tile
category-valueThe category value
error-detailsThe error details wrapper
error-details-iconThe error details icon
error-details-textThe error details text
error-details-titleThe error details title
header-subtextThe header subtext element
header-textThe header text element
loading-detailsThe loading details wrapper
loading-details-textThe loading details text
view-detailsThe view details button

CSS Custom Properties

PropertyDefaultDescription
--emui-planning-header-subtext-color"rgba(102, 112, 133, 1)"The color of the subtext within the header of the component.
--emui-planning-networth-category-border-color"rgba(216, 220, 227, 1)"The bottom border color of the category rows.
--emui-planning-placeholder-color"rgba(197, 205, 217, 1)"The background color of the loading placeholders within the header of the component.
--emui-planning-spinner-indicator-color"rgba(49, 95, 135, 1)"The color of the spinner indicator when in the loading state.
--emui-planning-spinner-track-color"transparent"The color of the spinner track when in the loading state.
--emui-planning-spinner-track-width"5px"The width of the spinner track when in the loading state.
--emui-planning-view-details-color"rgba(50, 114, 169, 1)"The color of the "View Details" link.
--emui-planning-view-details-hover-color"rgba(26, 45, 64, 1)"The hover color of the "View Details" link.