1.0.11 • Published 2 years ago

facebook-story v1.0.11

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

Facebook Story

React components to create components associated with Facebook like Story

Features

DoneName
Create text-based story
Create image-based story
View text-based story
View image-based story
Story card (with countdown)
⬜️Background music in text/image story

Installation

Install my-project with npm

npm install facebook-story
# or
yarn add facebook-story

Demo

You can find the demo here

Component References

Text story form

<TextStoryForm
  onCancel={reset}
  onSubmit={onSubmit}
  maxLength={100}
  onExceedMaxLength={() => alert('Exceed max length')}
  labels={{
    addTextLabel: 'Add text',
    cancelBtnLabel: 'Cancel',
    changeColorLabel: 'Change color',
    previewLabel: 'Preview',
    saveBtnLabel: 'Save',
  }}
/>
propTypeDescription
onCancelfunction: () => voidRequired. Function to handle cancellation logic for story text form
onSubmitfunction: (text: string) => voidRequired. Function to call when submitting story text form
labelsTLablesCustom heading labels for parts of text story form
maxLengthnumberMaximum number of characters of text story form
onExceedMaxLengthfunction: () => voidFunction to call when input text exceeds the maximum number of characters
TLabels;
keyTypeDescription
addTextLabelstringLabel of add text secion (Default: Add your text here)
previewLabelstringLabel of preview section (Default: Preview)
saveBtnLabelstringLabel of save button (submit button)
cancelBtnLabelstringLabel of cancellation button
changeColorLabelstringLabel of change background color section
changeFontLabelstringLabel of change text font family

Image Story Form

<ImageStoryForm
  onCancel={reset}
  onSubmit={onSubmit}
  uploadType={EImageFormUploadType.File}
  uploadFunction={uploadMediaFunction}
  width={300}
  height={300}
  labels={{
    addTextBtnLabel: 'Add text',
    cancelBtnLabel: 'Cancel',
    deleteSelectionsBtnLabel: 'Delete selections',
    saveBtnLabel: 'Save',
    textColorLabel: 'Text color',
  }}
  textProperties={{
    name: 'text',
    color: '#000000',
    fontSize: 20,
    fontFamily: 'Arial',
    fontWeight: 'bold',
    placeHolder: 'Enter text',
    textAlign: 'center',
  }}
/>
propTypeDescription
onCancelfunction: () => voidRequired. Function to handle cancellation logic for story text form
onSubmitfunction: (text: string) => voidRequired. Function to call when submitting story text form
textPropertiesTTextPropertiesCustom text properties of text object in image story
labelsTLabelsCustom heading labels for parts of image story form
widthnumberRequired. Width of the cavas holds the image story view
heightnumberRequired. Height of the cavas holds the image story view
uploadTypelink \| fileRequired. Type of uploading image, you can choose between link of uploaded image or upload your own image from your computer
uploadFunction(file: File) => Promise<string>Required of uploadType = 'file'. Upload function of image uploaded from your computer. Should returns a link
TTextProperties;
keyTypeDescription
placeHolderstringDefault text when adding new text to image story
colorstringText color
fontSizenumberFont-size of text
fontFamilystringFont family of text (make sure you imported that font into your project)
fontWeightstringFont weight of text
textAlignleft \| center \| right \| justifyAlignment of text
namestringName of object holds the text
TLabels;
keyTypeDescription
addTextLabelstringLabel of add text secion (Default: Add your text here)
textColorLabelstringLabel of changing text color input section
deleteSelectionsBtnLabelstringLabel of deleting selected objects button)
saveBtnLabelstringLabel of submit button
cancelBtnLabelstringLabel of cancellation button

Image Story Viewer

const data = {
    objects: Object[]; // see more in fabric.Object
    width: 500,
    height: 500
}

<ImageStoryViewer data={data} height={300} width={300}/>
propTypeDescription
dataTDataRequired. Data of image story
widthnumberRequired. Width of current canvas holds rendering field for image story
heightnumberRequired. Height of current canvas holds rendering field for image story
TData;
keyTypeDescription
objectsfabric.Object[]Required.Data of fabric objects to be rendered in canvas
widthnumberRequired.Width of canvas holds rendering field for image story in image story form
heightnumberRequired. Height of canvas holds rendering field for image story in image story form

Text Story Viewer

const data = {
    background: '#000',
    fontFamily: 'Arial',
    text: 'This is a text story'
}

<TextStoryViewer data={data}/>
propTypeDescription
dataTDataRequired. Data of text story
TData;
keyTypeDescription
backgroundstringRequired. Background of text story
fontFamilystringRequired. Font family of text story
textstringRequired. Content of text story

Story Card

<StoryCard data={data} width={200} height={200} />
propTypeDescription
dataTStoryCardData[]Required. Data of story card
widthnumberRequired. Width of story card
heightnumberRequired. Height of story card
TStoryCardData;
keyTypeDescription
type"Image" \| "Text" \| "Unknown"Required. Type of story
contentstringRequired. Content of story (stringified of json data from the create story form)

License

MIT

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago