1.1.12 • Published 1 year ago

capsule-mobiteach-components v1.1.12

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

npm version

Capsule mobiteach components

Useful react components to use in Mobiteach capsules

Usage

yarn add capsule-mobiteach-components # or npm install capsule-mobiteach-components

Import the components you want to use from the package

import { example } from 'capsule-mobiteach-components';

GUI Components

A list of useful design components for Mobiteach capsules

MbtLeaveButton

A leave button that is placed on the top right of the parent and a function is called when clicked

PropDescriptionDefault
OnLeavecalled upon on click

MbtPopup

A popup with a clickable dimmed background

PropDescriptionDefault
OnLeavecalled upon clicking on the dimmed background() => {}
childrenJSX Element(s) that will show on the popup

MbtScenesMenu

Menu showing the scenes

PropDescriptionDefault
showIf the menu is visible or not
sizeSize of the menu150
modeVertical or horizontal menuModeType.HORIZONTAL
childrenJSX Element(s) that will show on the menu

MbtScenesIcon

Usually used alongside with MbtScenesMenu, represents the icon of a single scene

PropDescriptionDefault
backgroundImage of the scene
nameName of the scene
modeHorizontal of Vertical for size reasons
sizeSize wanted
onSceneIconClickFunction called upon clicking on the scene
selectedIf the scene is selected makes a blue outline around itfalse

MbtBrick

A brick, fully customizable
Brick state can be any of the following:

"INVISIBLE | INACTIVE | ACTIVE | INPROGRESS | DONE | FAILED | SUCCESS"

Type can be:

"GOTO | QUIZ | POST-IT | DOC | URL | IMAGE360 | VIDEO360"

And documentType:

"pdf | doc | docx | ppt | pptx | xls | xlsx | image | mp3 | mp4"
PropDescriptionDefault
namenamed of the brick
typebrick typeUnknown
documentTypedocument type if it's a DOC
statebrick state"ACTIVE"
showSubIconif the brick sub icon is showntrue
showTextif the brick text below is showntrue
htmlAttrAll custom html attributesnone

MbtDialog

A dialog in absolute that the size depends on the parent There's 2 options and a default value.

  • Either in a grid (that starts with 1 not 0) with:
    • Start (ex: {2, 2})
    • End (ex: {4, 4})
    • nbSquares (ex: 5)

So the dialog will show up like this relative to it's parent in this example, grid of 5 and starts at 2,2 (s) and ends at 4,4 (e)

  • Or in absolute with percentages
    • posStart (ex : {10,10})
    • width (ex: 80)
    • height (ex: 80)

It applies the css properties top,left,width,height in position absolute to the dialog

  • If you want to use the modes above you have to provide ALL 3 props related to it, if the props are invalid or none are given the default values will make it take up all available space :
    • posStart: {0 , 0}
    • height: 100
    • width: 100
PropDescriptionDefault
startStart position on the grid
endEnd position on the grid
nbSquaresNumber of squares in the grid
posStartPercentage from the top and left it starts (ex: {top: 5, left: 5}){ top: 0, left: 0 }
heightHeight in percentage100
widthWidth in percentage100
mode'preview' has an opacity and 'plain' is normal'plain'
childrenJSX Element(s) in the component
htmlAttrAll the html attributes are optional

MbtFullScreen

A fullscreen button

PropDescriptionDefault
divRefref of the div you want to get in fullscreen

MbtLoader

Loader with a z-index of 10000

PropDescriptionDefault
showIf the loader is showing or not

MbtDragElement

PropDescriptionDefault
positionthe position
dropRefref of the drop element
showDragImageIf the drag image shows
dataData
childrenJSX Element(s) shown under this element
...htmlAttrany html attributes

Mobiteach Activities

MbtDocument

A document activity

Example of a documentState :

documentState: {
    results: null,
    successRate: 0 | 1,
    activityCompletedRate: 0...1,
    activityState: {
        currentPdfPageNumber: newPage
        mediaCurrentTime: currentTime
    }
}
PropDescriptionDefault
activityThe activity gotten form the API
documentStateThe initial state of the document{}
onDocumentLeaveFunction called upon leaving the document through the button(state) => {}
onDocumentAdvanceFunction called upon changing page/advancing in the document(state) => {}
onDocumentFinishFunction called upon finishing the document(state) => {}
onStatusChangeWhen the status of the document changes, best function to use to get the status(state) => {}
baseUrlIf there's a baseUrl before the path of the document""

MbtDome360

Dome360 can be used to show 360° images and videos

activity is of type:

{
  url: "src", 
  activityType: "IMAGE360" | "VIDEO360"
}
PropDescriptionDefault
activityThe activity
mediaCurrentTimeCurrent time if it's a video3600
onStatusChangeWhen the status of the activity changes(state) => {}
onDomeLeaveFunction called upon finishing the activity(state) => {}

MbtPostIt

Can be used to create post-its, the topic in activity is the title. The best function to use to get all the status changes is onStatusChange.

Activity of type:

{ topic : "" } 

And user of type:

{
  _id: 0, 
  firstname: "", 
  lastname: ""
}
PropDescriptionDefault
activityThe activity
userThe user
postItsIf already created postIts you can pass them in props{}
onPostItCreateFunction called upon creating a postIt(postIt) => {}
onPostItEditFunction called upon editing a postIt(postIt) => {}
onPostItDeleteFunction called upon deleting a postIt(postIt) => {}
onStatusChangeFunction called upon any change in the postIts(state) => {}
onPostItLeaveFunction called upon clicking the leave button() => {}
viewOnlyIf the postIts are in "view only" mode, can't edit or create

MbtQuiz

Shows the quiz and returns the state.

The initialState if not currentState prop is defined is:

initialState = {
    questionIndex: 0,
    answers: [],
    isFinish: false,
    status: "QUESTION"
}

Mode is the QUIZ mode, it can be:

mode: "MODE01 | MODE02 | MODE03"
PropDescriptionDefault
activityData about the activity gotten from the Mobitech API
modeThe mode of the quiz"MODE01"
currentStateThe current state of the activityInitialState
onStatusChangeFunction called upon any change in the state(state) => {}
onQuestionAnswerFunction called upon answering a question(state) => {}
onFinishFunction called upon finishing the QUIZ(state) => {}
onQuizLeaveFunction called upon clicking the leave button(state) => {}
hasLeaveButtonIf the QUIZ has a leave buttontrue
showResultOnFinishIf you want to show the results on finishtrue
baseUrlIf there's a baseUrlwindow.location.origin

MbtUrl

A url type activity, opens the URL in a new tab or in an iframe

PropDescriptionDefault
UrlNameName of the url
Urlurl
withIframeIf it opens in an iframefalse
onUrlLeaveFunction called upong clicking the leave button(state) => {}
onStatusChangeThe activity(state) => {}

Language

You can set and get the language used using the functions:

  • SetMbtLang("fr")
  • GetMbtLang()

To update the package in npm

  • Add the component you want to add to the package to the index.tsx file in the src folder
  • Run "npm run build" to compile the folder with babel
  • Change the version in package.json and run "npm publish"
  • Needs an npm account with access to the package, must use "npm login"
1.1.12

1 year ago

1.1.11

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.10

1 year ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.60

2 years ago

1.0.66

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.69

2 years ago

1.0.68

2 years ago

1.0.67

2 years ago

1.0.73

2 years ago

1.0.72

2 years ago

1.0.71

2 years ago

1.0.70

2 years ago

1.0.77

2 years ago

1.0.76

2 years ago

1.0.75

2 years ago

1.0.74

2 years ago

1.0.79

2 years ago

1.0.78

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.39

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.57

2 years ago

1.0.56

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.80

2 years ago

1.0.84

2 years ago

1.0.83

2 years ago

1.0.82

2 years ago

1.0.81

2 years ago

1.0.88

2 years ago

1.0.87

2 years ago

1.0.86

2 years ago

1.0.85

2 years ago

1.0.89

2 years ago

1.0.91

2 years ago

1.0.90

2 years ago

1.0.95

2 years ago

1.0.94

2 years ago

1.0.93

2 years ago

1.0.92

2 years ago

1.0.99

2 years ago

1.0.98

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

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