npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expandable-grid

v2.0.1

Published

React grid component with expandable items and adaptive functionality, crafted using position: absolute CSS.

Downloads

20

Readme

Expandable Grid

React grid component with expandable items and adaptive functionality, crafted using position: absolute CSS.

NPM Version

The grid expandable component is an interactive layout tool designed to create grids with expandable and collapsible elements. This dynamic component allows users to reveal or hide content within the grid, enhancing the user experience by accommodating detailed information without overwhelming the interface. It functions similarly to an accordion mechanism, adapted for grid usage. When configured as a single-column grid, it transforms into a classic accordion, offering a familiar experience with a versatile twist.

Installation

npm i --save expandable-grid

or

yarn add expandable-grid

Examples

Locale

To build the example locally, clone the repository and run:

npm install
npm run build

cd example

npm install
npm run watch

Then open localhost:1234 in a browser.

Code sandbox

You can check this component on https://codesandbox.io/

Base usage of the component

To quickly integrate the grid into your application, the only required properties are items and columns' count. When instantiated without any additional properties, the component defaults to a pre-configured grid setup.

import { ExpandableGrid, IExpandableGridItemProps } from 'expandable-grid';
import { FC } from 'react';

<ExpandableGrid
  items={[Item, Item, Item, Item]}
  columnsCount={3}
/>;

const Item: FC<IExpandableGridItemProps> = ({ onToggle, isExpanded, onClose, onExpand, index }) => {
  return <div></div>;
};

Customization with class names and styles

You can enhance the visual presentation by applying custom classNames and inline styles to the grid elements.

import { ExpandableGrid, IExpandableGridItemProps } from 'expandable-grid';
import { FC } from 'react';

<ExpandableGrid
  items={[Item, Item, Item, Item]}
  columnsCount={3}
  gridClassName={'grid-class-name'}
  gridItemClassName={'grid-item-class-name'}
  gridExpandedItemClassName={'grid-expanded-item-class-name'}
  style={{ transitionDuration: '100ms' }}
  itemStyle={{ transitionDuration: '200ms' }}
/>;

const Item: FC<IExpandableGridItemProps> = ({ onToggle, isExpanded, onClose, onExpand, index }) => {
  return <div></div>;
};

Parameter customization and responsive settings

You can define key parameters to control the spacing and sizing of the grid and its elements.

import { ExpandableGrid, IExpandableGridItemProps } from 'expandable-grid';
import { FC } from 'react';

// Constants parameters
<ExpandableGrid
  items={[Item, Item, Item, Item]}
  columnsCount={3}
  parameters={{
    rowGap: 10,
    columnGap: 10,
    itemHeight: 100,
    expandedItemHeight: 150,
  }}
/>;

// Adaptive variants
// The key for each parameter corresponds to the window width, 
// and the value determines the parameter that will be applied at that specific width
<ExpandableGrid
  items={[Item, Item, Item, Item]}
  columnsCount={{ 320: 1, 768: 3, 1200: 6 }}
  parameters={{
    rowGap: { 320: 10, 768: 12, 1200: 16 },
    columnGap: { 320: 10, 768: 12, 1200: 16 },
    itemHeight: { 320: 100, 768: 150, 1200: 200 },
    expandedItemHeight: { 320: 150, 768: 200, 1200: 300 },
  }}
/>;

const Item: FC<IExpandableGridItemProps> = ({ onToggle, isExpanded, onClose, onExpand, index }) => {
  return <div></div>;
};

Default values for parameters are given below:

const DEFAULT_PARAMETERS = {
  rowGap: 20,
  columnGap: 20,
  itemHeight: 150,
  expandedItemHeight: 350,
};

Meta

Distributed under the MIT license. See LICENSE for more information.

https://github.com/dPaskhin/expandable-grid/blob/master/LICENSE.md

Contributing

  1. Fork it (https://github.com/dPaskhin/expandable-grid/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -m 'feat: add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request