@reading-room/primer-utils
v2.0.1
Published
Primer utils
Readme
primer-utils
primer-utils is a collection of utility js and scss functions. They are built to work with the Primer framework but can be used independently.
Prerequisites
This project requires Node.js v24.14.1 or higher.
This project requires sass v1.98.0 or higher.
Installation
To install the project, run the following command:
npm install @reading-room/primer-utilsUsage
javascript
To use the utils, import the functions you need from the package:
import { replaceUrlParameter, updateUrlParameter } from '@reading-room/primer-utils'
// Use the functions
const newUrl = replaceUrlParameter('http://example.com?foo=bar', 'foo', 'baz')
console.log(newUrl) // http://example.com?foo=bazscss
To use the scss functions, import the functions you need from the package:
@use '@reading-room/primer-utils/scss' as utils;
// Use the functions
.some-class {
font-size: utils.px2rem(16);
}Testing
To run the tests, run the following command:
npm testUpdating Primer
Ideally all dependencies should be kept up to date to take advantage of new features and security updates.
You can run the following command to update all dependencies to the latest minor version.
npx npm-check-updates --target minor -uFor a major primer-utils version release, you should update all dependencies to the latest major version.
npx npm-check-updates -uThis will likely require manual intervention to resolve breaking changes introduced by the updates.
Ensure upgrades are performed across Primer, primer-library and primer-utils at the same time to ensure compatibility.
