# @revolt-digital/cool-frames

> ### Install

Latest version **0.1.0** (published 2022-07-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @revolt-digital/cool-frames
pnpm add @revolt-digital/cool-frames
yarn add @revolt-digital/cool-frames
bun add @revolt-digital/cool-frames
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-07-13 |
| First published | 2022-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 49.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fernandomunoz |
| Maintainers | andresrevolt, eapuulesrevolt, maitzeth, franco-revolt, fmrevolt |

## Links

- npm: https://www.npmjs.com/package/@revolt-digital/cool-frames
- Repository: https://github.com/revolt-digital/coolFrames
- Homepage: https://github.com/revolt-digital/coolFrames#readme
- Issues: https://github.com/revolt-digital/coolFrames/issues
- npm.io page: https://npm.io/package/@revolt-digital/cool-frames

## Dependencies (1)

- [react-swipeable](https://npm.io/package/react-swipeable.md) ^7.0.0

## Recent versions

- 0.1.0 (latest) — 2022-07-13
- 0.0.12 — 2022-03-22
- 0.0.11 — 2022-03-21
- 0.0.10 — 2022-03-18
- 0.0.9 — 2022-03-18
- 0.0.8 — 2022-03-17
- 0.0.7 — 2022-03-16
- 0.0.6 — 2022-03-15
- 0.0.5 — 2022-03-15
- 0.0.4 — 2022-03-15
- 0.0.3 — 2022-03-15
- 0.0.2 — 2022-03-15
- 0.0.1 — 2022-03-15

## README

## Custom hook for react: useWindowSize

### Install

```
yarn add @revolt-digital/use-state-ref
yarn add @revolt-digital/cool-frames
```

### Styles

You can import the .scss or .css styles

```
@import '~@revolt-digital/cool-frames/lib/styles.scss';
```

### How to use it?

```
import React, { useEffect } from 'react';
import useWindowSize from '@revolt-digital/use-window-size';
import { CoolFramesProvider, CoolFrames } from '@revolt-digital/cool-frames';

const frames = [
    {
        label: 'Intro',
        sub: [],
        Component: Intro
    },
    {
        label: 'Trio',
        sub: [],
        Component: ExtendedDescription,
        desktop: false
    },
    {
        label: 'How does it work?',
        sub: ['SignUp', 'Upload', 'Discover'],
        Component: HowWorks
    },
]; 

export default () => {
    const windowSize = useWindowSize();
    ...
    
    useEffect(() => {
        const vh = window.innerHeight * .01;
        document.documentElement.style.setProperty('--vh', `${vh}px`);
    }, [windowSize.height]);

    return (
        <CoolFramesProvider frames={frames}>
            ...
            <CoolFrames />
        </CoolFramesProvider>
    );
};
```

### Options

| Name | Type | Description |
| :---: | :---: | :---: |
| frames | Frame[] | Array of frames. A frame represents a single view in a determined position. Params: label, subs (subFrames), Component, desktop (true by default) and extraProps (if it were needed). |

### Hook

| Name | Type | Description |
| :---: | :---: | :---: |
| frames | Frame[] |  |
| selectedIndex | number | Index in the stepper. |
| prevIndex | number | It is the previous index selected. |
| frameIndex | number | It represent the subframe index. It will be 0 when there aren't subframes for the frame. |
| setSelectedIndex | (index: number) => void; |  |
| isFrameSelected | (index: number) => void; |  |
| getSubFrameIndex | (index: number) => void; |  |
| translateY | number |  |
| lastDirection | Direction | It can be 'up, 'down' or undefined. |

### How does it look?

![Alt text](./examples/pic-2.png "Desktop")

![Alt text](./examples/pic-1.png "Mobile")

---
_Source: https://npm.io/package/@revolt-digital/cool-frames · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
