Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karibash/pixel-units
Type-safe and mutually convertible pixel units.
https://github.com/karibash/pixel-units
pixel typescript units
Last synced: about 1 month ago
JSON representation
Type-safe and mutually convertible pixel units.
- Host: GitHub
- URL: https://github.com/karibash/pixel-units
- Owner: Karibash
- License: mit
- Created: 2020-11-21T14:30:08.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-10T06:54:32.000Z (about 2 years ago)
- Last Synced: 2024-05-01T17:15:46.133Z (8 months ago)
- Topics: pixel, typescript, units
- Language: TypeScript
- Homepage:
- Size: 132 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# pixel-units
[![Github](https://img.shields.io/github/followers/Karibash?label=Follow&logo=github&style=social)](https://github.com/Karibash?tab=followers)
[![Twitter](https://img.shields.io/twitter/follow/Karibash?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=Karibash)## 🔧 Features
### Absolute length units
- [x] px
- [x] cm
- [x] mm
- [x] Q
- [x] in
- [x] pc
- [x] pt### Relative length units
- [x] rem
- [x] em
- [x] vw
- [x] vh
- [x] vmin
- [x] vmax### Multiplication units
- [x] percent
- [x] magnification## 👏 Getting Started
The basic usage is as follows:
```typescript
import { Unit, convertUnits } from '@karibash/pixel-units';const pixel: Unit<'px'> = '32px';
const rem = convertUnits(pixel, 'rem');console.log(rem);
// -> 2rem
```## 🚀 Installation
```
$ npm install @karibash/pixel-units
```## 🤝 Contributing
Contributions, issues and feature requests are welcome.
Feel free to check [issues page](https://github.com/Karibash/pixel-units/issues) if you want to contribute.
## 📝 License
Copyright © 2020 [@Karibash](https://twitter.com/karibash).
This project is [```MIT```](https://github.com/Karibash/pixel-units/blob/master/LICENSE) licensed.