0.1.0 • Published 2 years ago

@revolt-digital/cool-frames v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

NameTypeDescription
framesFrame[]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

NameTypeDescription
framesFrame[]
selectedIndexnumberIndex in the stepper.
prevIndexnumberIt is the previous index selected.
frameIndexnumberIt 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;
translateYnumber
lastDirectionDirectionIt can be 'up, 'down' or undefined.

How does it look?

Alt text

Alt text

0.1.0

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago