1.0.1 • Published 3 years ago

@9gustin/storify-react v1.0.1

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

storify :D

stories for you react app

NPM JavaScript Style Guide

v1:

NPM package that show stories in a line(ordered by relevance and date)

URL

https://www.npmjs.com/package/@9gustin/storify-react

How to use

Add package to your aplication

npm i @9gustin/storify-react

Short

App.js

import React from 'react';
import {Storify, useStorify} from '@9gustin/storify-react';
import '@9gustin/storify-react/dist/index.css'
import initialState from './data/stories.json';

function App() {
  const { stories } = useStorify(initialState.stories);

  return (
    <Storify imgSize="5rem" storyBorderColor="blue" stories={stories} viewProfileCallback={(user) => {console.log(user)}}/>
  );
}

export default App;

Detailed

Import the Storify component and custom hook

import {Storify, useStorify} from '@9gustin/storify-react';

useStorify (Custom Hook)

ParamTypeDescription
initialStoriesStory[]represent the list of stories to start the state variable
ReturnTypeDescription
storiesStory[]represent the list of stories that are managed in the state, and you should pass it to the Storify component
addStoriesFunction:voidthat function gives you the possibility to add stories, and that's rendered in the Storify component
setStoriesFunction:voidthat function give you the possibility to set the list of stories, and that's rendered in the Storify component

Use:

    const { stories, addStories, setStories } = useStorify(initialStories);

Storify (Component)

Prop NameTypeDescription
imgSizestringrepresent the size of story buttons, receive the css property "width"/"height"
storiesStory[]represent the list of stories that the component should render
viewProfileCallbackFunction:Userthe function that would be called when the user wants to view an user profile
storyBorderColorstringrepresent the color of story buttons borders, that receive the css property border-color

Use:

    <Storify imgSize="5rem" storyBorderColor="blue" stories={stories} viewProfileCallback={(user) => {console.log(user)}}/>

Models

Story

PropertyTypeDescription
userUserthe owner of story
idstringthe identificator of story
createdAtstringthe creation date of story
imageUrlnumberthe url of story image

User

PropertyTypeDescription
usernamestringthe identificator of a user
imageUrlstringthe url of user profile image
relevancenumberthe stories are ordered firstly for the user relevance

About the order of stories

The stories (in the timeline of stories are ordered by user's relevance, and after by createdAt property of story, the users with new stories are shown first). And when the user clicks to view stories from a user the that's are shown by date ascending(from older to newer)

Import styles

import '@9gustin/storify-react/dist/index.css'

Future releases:

  • Next story automatically, with time/progress bar
  • Save actual user in state
  • take response to stories, with a custom callback
  • Button "Add story" with a custom callback
  • Custom stories(colors, to group of persons)

License

MIT © 9gustin