@txdot-gis/txdot-toolbox-js
v1.0.15
Published
Shared processing and web map functions for TxDOT applications
Downloads
204
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
└── config
Usage
Install
npm install @txdot-gis/txdot-toolbox-js --save
Basic 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
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 config