@txdot-gis/txdot-toolbox-js
v1.0.24
Published
Shared processing and web map functions for TxDOT applications
Downloads
63
Readme
txdot-toolbox-js
Shared processing and web map JS functions for TxDOT applications alongside shared styling properties and content (e.g. logos)
Overview
TxDOT uses a variety of shared functionality and styling across web applications and sites. This package serves as a toolbox with these JS functions and CSS styling properties for easy import and use.
The styling properties are created both from classic CSS and modern SCSS but unique and are not duplicated in either. They are each organized in their respective folders src/style/css and src/style/scss. Individual files in each folder are recognized via import in their folder's _index.scss file. All TxDOT styling classes are named with prefix txdot-.
The JS tools available in this package are organized by subfolder under the primary package variable txdotToolbox. Call them via dot notation from the package variable. Their specific argument requirement documentation can be found in their specific function file (i.e. src/<subfolder>/<function file>.js).
They include:
└── txdotToolbox
├── spm
│ ├── jumpToGoogle(lat, lon, level)
│ ├── jumpToGoogleEsri(mapView)
│ ├── jumpToSpm(lat, lon, level, points, routes)
│ ├── jumpToSpmEsri(mapView, points, routes)
│ └── jumpToSrd(routeId, beginDfo, endDfo, attributes)
├── elrs
│ ├── buildPointGeoJson(convertedData)
│ └── buildLineGeoJson(routes)
├── logo
│ ├── cdnUrl(logoItem)
│ ├── icon
│ │ ├── black
│ │ │ └── jpg
│ │ ├── blue
│ │ │ ├── jpg
│ │ │ ├── png
│ │ │ └── svg
│ │ ├── cmyk
│ │ │ └── jpg
│ │ ├── gray
│ │ │ └── jpg
│ │ ├── rgb
│ │ │ ├── png
│ │ │ └── svg
│ │ └── white
│ │ ├── png
│ │ └── svg
│ ├── square
│ │ └── <...same as icon>
│ ├── wide
│ │ └── <...same as icon>
│ └── misc
│ ├── architect
│ │ ├── png
│ │ ├── blue
│ │ │ ├── png
│ │ │ └── square
│ │ ├── compass
│ │ │ └── black
│ │ └── globe
│ │ ├── black
│ │ └── white
│ ├── darrelBarrel
│ │ └── svg
│ ├── dataDictionary
│ │ └── png
│ ├── dataDictionaryPdf
│ │ └── png
│ ├── elrs
│ │ └── png
│ ├── geolab
│ │ └── png
│ ├── openDataPoral
│ │ └── svg
│ └── r2d2
│ └── png
└── tailwind
└── configUsage
Install
npm install @txdot-gis/txdot-toolbox-js --saveBasic ES6 Usage
To make styling available, import style.css in entry .css or .js file. If tailwind is installed and being used in your project, this will enable preprocessed styling classes.
/* index.css */
@import url('@txdot-gis/txdot-toolbox-js/dist/style.css');OR
// index.js
import '@txdot-gis/txdot-toolbox-js/dist/style.css'THEN
<!-- index.html -->
<div id='scss-example'>
<button type='button' className='background text'>SCSS Example</button>
</div>
<div>
<button type='button' className='css-example'>CSS Example</button>
</div>To access functions, import the npm package
import { spm } from '@txdot-gis/txdot-toolbox-js' // all JS objects and functions available through individual import
...
const latitude = 29.212940817521442
const longitude = -103.28362089838606
const zoomLevel = 9
spm.jumpToGoogle(latitude, longitude, zoomLevel)Basic CDN Usage
<head>
<link rel="stylesheet" href="https://unpkg.com/@txdot-gis/txdot-toolbox-js@latest/dist/style.css" /> <!-- source CSS -->
<script src="https://unpkg.com/@txdot-gis/txdot-toolbox-js@latest/dist/index.js"></script> <!-- source JS -->
<script >
const latitude = 29.212940817521442
const longitude = -103.28362089838606
const zoomLevel = 9
const jumpGoogleListener = document.querySelector('#jumpToGoogle')
jumpGoogleListener.addEventListener('click', (event) => {
txdotToolbox.spm.jumpToGoogle(latitude, longitude, zoomLevel) // all JS objects and functions available through dot notation
})
</script>
</head>
<body>
<div id='scss-example'>
<button type='button' class='background text'>SCSS Example</button>
</div>
<div>
<button type='button' class='css-example'>CSS Example</button>
</div>
<br>
<button type="button" id="jumpToGoogle">Jump To Google</button>
</body>Tailwind Configuration v4
For current TailwindCSS v4, utilize the shared TxDOT Tailwind configuration by importing tailwind_v4 from the package in the project's root css file immediately after importing tailwindcss.
@import 'tailwindcss';
@import '@txdot-gis/txdot-toolbox-js/dist/tailwind_v4';Tailwind Configuration v3
For the older TailwindCSS v3, utilize the shared TxDOT Tailwind configuration by importing the config object and exporting as the default in your project's tailwind.config.js file. Notice, depending on your project structure, the file itself will likely need to be imported opposed to dot notation from the package root.
import config from '@txdot-gis/txdot-toolbox-js/src/tailwind/config.js'
export default configTxDOT Color Palette in Javascript
The library of TxDOT colors used by the stylesheets within this package are available in javascript as a separate module by importing the txdotColors object from the separate javascript file.
import txdotColors from '@txdot-gis/txdot-toolbox-js/dist/txdotColors'They can be accessed as css variables within HTML as well. Link to the txdotColors.css stylesheet with a standard <link> tag and then access each with a var() function and --color- prefix on the camelcased color variable name.
<link rel="stylesheet" href="https://unpkg.com/@txdot-gis/txdot-toolbox-js@latest/dist/txdotColors.css" /> <!-- source CSS -->
<style>
#domId {
background-color: var(--color-txdotHighlight);
}
</style>
<!-- or for use in Javascript, import and bind to window for global access -->
<script type="module">
import txdotColors from "https://unpkg.com/@txdot-gis/txdot-toolbox-js@latest/dist/txdotColors.js";
window.txdotColors = txdotColors;
</script>