Fibonacci Spacing
Spacing for a design system, but it's fibonacci!
Install
Using npm
:
npm install @quassum/fibonacci-spacing
Using yarn
:
yarn add @quassum/fibonacci-spacing
Usage
Basic usage
import { getFibonacciSpacing } from '@quassum/fibonacci-spacing';
const spacing = getFibonacciSpacing();
Options
You can also provide some options, for example you could provide a different unit to generate:
const spacing = getFibonacciSpacing({ unit: 'rem' });
Notice that when changing the unit, the generates spacing
constant generates the correct types for each value in fibonacci sequence.
You could also invert the values.
In that case when accessing the values by their fibonacci numbered keys, you will get value which is equal to 1 divided by that value.
For example, following shows the examples of the values you get:
const spacing = getFibonacciSpacing({ unit: 'rem', invert: true });
spacing[1];
spacing[5];
spacing[8];
TypeScript
When you run getFibonacciSpacing
function, the returned result is typed as literal string types, so the types you get are the same as the values.
const spacing = getFibonacciSpacing();
const first = spacing[1]
Contributors
License
MIT