Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/princevora/hex-to-rgba
A npm package to convert a hex code to rgba
https://github.com/princevora/hex-to-rgba
Last synced: 5 days ago
JSON representation
A npm package to convert a hex code to rgba
- Host: GitHub
- URL: https://github.com/princevora/hex-to-rgba
- Owner: princevora
- License: mit
- Created: 2024-06-30T03:24:06.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-10T04:08:35.000Z (4 months ago)
- Last Synced: 2024-11-08T06:43:27.067Z (7 days ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# hex-to-rgba
A npm package to convert a hex code to rgba## Installation
```
npm i palette-to-rgba
```
## Usage
```js
// Import the object
import palette from "palette-to-rgba";// Call the function
palette.hexToRgba('FFF');// output:
// 'rgba(255, 255, 255, 1)'
```
## Test
```
Color Utils
hexToRgba()
✔ should convert #FFFFFF to rgba(255, 255, 255, 1)
✔ should handle shorthand hex codes like #FFF
✔ should handle hex codes without hash like "FFF"
Invalid hex color format.
✔ should return black for invalid hex codes
✔ should handle alpha values correctly
✔ should default to alpha 1 if not specified
✔ should process lowercase hex codes correctly
Invalid hex color format.
✔ should return black for empty strings
✔ should handle whitespace in input9 passing (44ms)
```