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

@crob/vue-stack-grid

v1.0.1

Published

A simple, efficient Vue 3 component for creating stacked grid layouts. It automatically adjusts items into a grid based on available space, with customizable column widths and gutters for precise layout control. Ideal for fluid, responsive designs.

Downloads

18

Readme

StackGrid for Vue 3

StackGrid is a Vue 3 component designed to make it easy and efficient to create dynamic, responsive grid layouts. It automatically arranges items based on the available container width, ensuring a visually appealing presentation on all devices.

twitter-card

Demo

See the demo for a live example of StackGrid in action.

Features

  • Responsive: Automatically adjusts to the container's width.
  • Customizable: Offers props for minimum column width, gutter width, and gutter height.
  • Slot Support: Utilize slots to customize the content of each grid item.
  • Vue 3 Composition API: Built with Vue 3's Composition API for better performance and readability.

Installation

To install StackGrid, use npm or yarn:

npm i @crob/vue-stack-grid

or

yarn add @crob/vue-stack-grid

Usage

Import StackGrid into your component and use it in your template. Provide it with the necessary props like items, columnMinWidth, gutterWidth, and gutterHeight. Use the slot item to customize how each item in the grid should be displayed.

<template>
  <StackGrid :items="items" :column-min-width="100" :gutter-width="10" :gutter-height="10">
    <template #item="{ item }">
      <div>{{ item }}</div>
    </template>
  </StackGrid>
</template>

<script setup>
import StackGrid from '@crob/vue-stack-grid';
const items = [...]; // your items here
</script>

Props

  • items (required): An array of items to display in the grid.
  • columnMinWidth (required): The minimum width of each column in pixels.
  • gutterWidth: The horizontal gap between columns in pixels. Default is 0.
  • gutterHeight: The vertical gap between rows in pixels. Default is 0.

Events

updated:reflow

The updated:reflow event is emitted after the grid layout has been recalculated. This can occur in response to various triggers, such as a window resize or manual invocation of the reflow process. This event provides a way for parent components to react to changes in the grid layout, enabling additional custom behavior or UI updates based on the new layout state.

Listening to the Event

To listen to the updated:reflow event, attach an event listener to the <StackGrid> component in your template. You can then define a method within your component to handle the event.

<template>
  <StackGrid @updated:reflow="handleReflowEvent"></StackGrid>
</template>

<script setup>
import { defineComponent } from 'vue';
import StackGrid from '@crob/vue-stack-grid';

const handleReflowEvent = () => {
  console.log('Grid layout was updated.');
  // Additional logic to handle the grid update...
};
</script>

Methods

reflow

Triggers a reflow of the grid layout. This can be useful if you've dynamically changed the items or their sizes and need to re-calculate the layout of the grid.
To use this method, you'll need to get a reference to the StackGrid component instance in your parent component. Here's an example of how to do this with Vue 3's Composition API:

<template>
  <StackGrid ref="stackGridRef" :items="items" :columnMinWidth="100" :gutterWidth="10" :gutterHeight="10">
    <template #item="{ item }">
      <div>{{ item }}</div>
    </template>
  </StackGrid>
  <button @click="reflowGrid">Reflow Grid</button>
</template>

<script setup>
import { ref } from 'vue';
import StackGrid from '@crob/vue-stack-grid';

const stackGridRef = ref();
const items = ref([...]); // Your items here

function reflowGrid() {
  if (stackGridRef.value) {
    stackGridRef.value.reflow();
  }
}
</script>

This section demonstrates how to access and call the reflow method exposed by the StackGrid component.

Contributing

Contributions are welcome! If you have an idea or suggestion, please feel free to fork the repository, make your changes, and submit a pull request.

License

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