0.2.2 • Published 1 month ago

z-indexify v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

NPM Build Status Codecov Bundle Size Known Vulnerabilities CodeFactor OpenSSF Scorecard MIT License

Works with Styled Components and TailwindCSS

Table of Contents

Install

# NPM
npm install --save z-indexify

# Yarn
yarn add z-indexify

Usage

With Styled Components

// In your theme.ts used on ThemeProvider
import { zIndexify } from 'z-indexify';

const zIndex = zIndexify(['header', 'overlay', 'sidebar']);
const theme = {
  // others...
  zIndex,
};

// And on Styled
const Header = styled.header`
  z-index: ${({ theme }) => theme.zIndex.header}; /** z-index: 100; */
`;

With TailwindCSS

// In your tailwind.config.ts
import type { Config } from 'tailwindcss';
import { zIndexify } from 'z-indexify';

const zIndex = zIndexify(['header', 'overlay', 'sidebar'], {
  minIndex: 500,
});

const config: Config = {
  content: [...],
  theme: {
    extend: {
      // ...your configs
      zIndex,
    }
  },
};

export default config;

image

API

  • zIndexify(labels, options])

    • labels
      • Type: array
      • Name of your z-indexes in asc order.
      • To change order values, simple reorder the array values. e.g.:
        ['foo', 'bar', 'baz'] //=> foo: 100, bar: 101, baz: 102
        ['bar', 'baz', 'foo'] //=> bar: 100, baz: 101, foo: 103
    • options
      • Type: object
      • Configuration options if you need
  • options

    ParamTypeDescriptionDefaulte.g.
    minIndexnumberIndex starts of100{ minIndex: 300 } starts with: z-index: 300
    inversebooleanInvert array values orderfalse['foo', 'bar'] will produce: { foo: 101, bar: 100 }
    stepnumberThe gap between number1{ step: 10 } creates: { 100, 110, 120, 130, ... }

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

0.2.1

1 month ago

0.2.0

1 month ago

0.2.2

1 month ago

0.1.2

1 month ago

0.1.1

1 month ago

0.1.0

1 month ago