Skip to content

Financial Calculator

This component can be added to post content with the Financial Calculator block in the Gutenberg editor.

Anatomy

  1. Inputs
  2. Results

This is a small interactive financial calculator estimator. The reactive inputs are handled with alpine.js. Currently alpine is enqueued on this page or otherwise only if the gutenberg block is detected in the post content. If this component will be used in another page template, alpine will need to be enqueued as well.

JavaScript

The financial calculator's reactive nature is powered by alpine.js and therefore does not have an associated JS file, but it does rely on a couple helper functions contained in utilities.js. Instead the object passed to alpine is stored right in the template file next to the markup.

If no init_program is supplied, on load the calculator will check to see if the smart_rfi cookie exists and try to set the selected program with a matching ID.

WordPress

This component can be added to post content with the Financial Calculator block in the Gutenberg editor. It contains the following:

  • Provides an interface to specify default cost values in the editor, to be used if a program doesn't have its own values. Currently these defaults are stored with each instance of the block.
  • Automatically generates the program list from all the programs and specializations and their related data fields for costs, etc.
  • Sets init_program if the current page URL contains a UUID parameter or is a post that has a matching post id or UUID.
  • Enqueues alpine.js if the block exists in the page content.

Specifications

Properties

PropertyTypeDescriptionRequiredDefault
levelsarray List of program levels each containing a list of programs for that level. This is used to build the program select menu Yes-
└ itemobject - --
└ namestring Program Level name Yes-
└ programsobject - Yes-
/^.*$/string Property name is a unique ID, value is the program name --
init_programstring ID of one of the programs passed to be selected by default. Useful for when the calculator is on a program-specific page No-
programsobject - Yes-
/^.*$/object Property name is a unique ID for the program --
└ namestring - Yes-
└ rateinteger - Yes-
└ creditsinteger - Yes-
└ maxTransferCreditsinteger - Yes-
credits_labelstring Optional special term for credits No-
classstring list of additional classes to apply to main element. No-

Styling

Custom Properties

NameDefaultResetsDescription
--tux-comp-financial-calculator--results-bgrgba(136, 136, 136, 0.2)Yes-

Changelog

6.4.0 (2023-11-27)

3.0.0 (2023-02-21)

  • fix: improve transfer credits field messaging (#379) (d5cc72b)
  • fix: remove empty degree levels from program list (#375) (e1c8df2)
  • feat: lock input and show hint when no transfer credits are accepted (#376) (34caf54)

2.3.1 (2022-12-16)

  • fix: insert 'program' word into js data (#360) (9a72ca8)

1.27.0 (2021-12-10)

  • fix: add custom 'program_label' property (e4efcd9)

1.23.1 (2021-08-20)

  • fix: add spacing to results box (ff0518c)

1.16.0 (2021-02-17)

  • fix: add better error checking for uuid via cookie (add7ea6)

1.7.0 (2020-07-13)

  • fix: add real tooltip copy (a2ebabb)

1.5.0 (2020-06-23)

  • fix: check for default values (6d389a6)
  • fix: support ie and edge (796ccf0)
  • financial-calculator added

Contains

Other core components embedded within this template.

Examples

Default

Expenses

No transfer credits accepted for this program

Financial Aid

Please select a program to begin.

Total Credits
Tuition
Books
Other
Total Cost
Federal Aid
Scholarships
Personal Gifts
Total Assistance
Grand Total

Request Information

{{ include( 'components/financial-calculator.twig', {
	levels: {...}
	programs: "{0:{name:'Select a Program',rate:0,credits:0,maxTransferCredits:0},12:{name:'Example - BS in Accounting',rate:400,credits:120,maxTransferCredits:45},83:{name:'Example - MBA',rate:700,credits:30,maxTransferCredits:6}}"
} ) }}