# vue-aspect-ratio

> ![screenshot](https://raw.githubusercontent.com/albertodeago/vue-aspect-ratio/master/assets/screen.png)

Latest version **0.1.1** (published 2019-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-aspect-ratio
pnpm add vue-aspect-ratio
yarn add vue-aspect-ratio
bun add vue-aspect-ratio
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-11-30 |
| First published | 2019-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 42.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | albertodeagostini.dev@gmail.com |
| Maintainers | albertodeago |

## Links

- npm: https://www.npmjs.com/package/vue-aspect-ratio
- npm.io page: https://npm.io/package/vue-aspect-ratio

## Dependencies (1)

- [core-js](https://npm.io/package/core-js.md) ^3.3.2

## Recent versions

- 0.1.1 (latest) — 2019-11-30
- 0.1.0 — 2019-11-30

## README

![screenshot](https://raw.githubusercontent.com/albertodeago/vue-aspect-ratio/master/assets/screen.png)

# vue-aspect-ratio

A component to render a certain aspect ratio element.  
It exposes a default slot that will have the desided ratio.  
Weights 3.8kb not gzipped.


## How to install and use

To install the package in your application just type
```
npm install vue-aspect-ratio
```

Then, to install as a global component
``` javascript
import Vue from "vue";
import VueAspectRatio from "vue-aspect-ratio";

Vue.component("vue-aspect-ratio", VueAspectRatio)
```

Or you can register locally in one of your components as follows
``` javascript
import VueAspectRatio from "vue-aspect-ratio";

export default {
    name: "AmazingComponent",
    props: [myprop],
    components: {
        "vue-aspect-ratio": VueAspectRatio
    }
}
```

Using in templates
``` html
<div class="my-container">
    <vue-aspect-ratio ar="16:9" width="640px">
        <div>your content goes here</div>
    </vue-aspect-ratio>
</div>
```

NOTE: You may need to set in css "height: 100%" on your content that goes inside vue-aspect-ratio to fill the entire space if your content is not long enough.

## Parameters and events

Component props:

| Name   | Type   | Mandatory | Example | Description      |
|--------|--------|-----------|---------|------------------|
| ar     | String | false     | "16:9"  | the aspect ratio |
| width  | String | false     | "640px" | the css value of the width to set on the element |

It does not emit any event

## Contributing

The project is opened to contributes, suggestions and improvements. You can use the [Issues](https://github.com/albertodeago/vue-aspect-ratio/issues) section.


### Project setup

Fork the project, open it up and type
```
npm install
```

To run the example page, it will open a dev server listening to localhost:8080 (usually), type:
```
npm run dev
```

To build for production
```
npm run build
```

To lint the project
```
npm run lint
```

To prepare for pubblication
```
npm run prepublish
```

### Test

The project uses [Cypress](https://www.cypress.io/)
If you want to open the interactive cypress dashboard to run and check tests
```
npm run test:open
```

If you instead just want to run the tests in headless mode
```
npm run test
```

Note: tests required dev server to be up and running

## Author and License

[Alberto De Agostini](https://twitter.com/albertodeago88)

Licensed under MIT

---
_Source: https://npm.io/package/vue-aspect-ratio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
