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

@7anshuai/vue-auto-sizer

v0.1.2

Published

Vue component that automatically adjusts the width and height of a single child.

Downloads

143

Readme

vue-auto-sizer

Vue component that automatically adjusts the width and height of a single child.

Note: vue-auto-sizer is a vue clone of react-virtualized-auto-sizer

Usage

Installtion

$ npm install @7anshuai/vue-auto-sizer

Prop Types

| Property | Type | Required? | Description | | :------------ | :------- | :-------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- | | defaultHeight | Number | | Height passed to child for initial render; useful for server-side rendering. This value will be overridden with an accurate height after mounting. | | defaultWidth | Number | | Width passed to child for initial render; useful for server-side rendering. This value will be overridden with an accurate width after mounting. | | disableHeight | Boolean | | Fixed height; if specified, the child's height property will not be managed | | disableWidth | Boolean | | Fixed width; if specified, the child's width property will not be managed | | nonce | String | | Nonce of the inlined stylesheets for Content Security Policy | | onResize | Function | | Callback to be invoked on-resize; it is passed the following named parameters: ({ height: number, width: number }). |

Examples

Some vue components require explicit dimensions but sometimes you just want a component to just grow to fill all of the available space. The AutoSizer component can be useful in this case.

One word of caution about using AutoSizer with flexbox containers. Flex containers don't prevent their children from growing and AutoSizer greedily grows to fill as much space as possible. Combining the two can cause a loop. The simple way to fix this is to nest AutoSizer inside of a block element (like a <div>) rather than putting it as a direct child of the flex container. Read more about common AutoSizer questions here.

<template>
  <div id="app">
    <h1>
      <img alt="Vue logo" src="./assets/logo.png">
    </h1>

    <p>
      vue-auto-sizer is a vue clone of <a href="https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md">React virtualized auto sizer</a>
    </p>

    <div class="auto-sizer-wrapper">
      <auto-sizer v-slot="{ size: { height, width} }">
        <div :style="{ height: height + 'px', width: width + 'px' }">
          Auto sized content...
        </div>
      </auto-sizer>
    </div>
  </div>
</template>

<script>
import AutoSizer from '@7anshuai/vue-auto-sizer'

export default {
  name: 'App',
  components: {
    AutoSizer
  },
  methods: {
    onResize ({ height, width }) {
      console.log(height, width)
    }
  }
}
</script>

<style>
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.auto-sizer-wrapper {
  flex: 1 1 auto;
}
</style>

Development

yarn install

Compiles and hot-reloads for development

yarn serve

Compiles and minifies for production

yarn build

Compiles and minifies for npm package

yarn build:lib

Run your unit tests

yarn test:unit

Lints and fixes files

yarn lint

Customize configuration

See Configuration Reference.