6.1.22 • Published 2 years ago

labo-components v6.1.22

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

Labo Components

This repo contains the front-end components in use in the Clariah Media Suite project. It runs in paralell with the back-end server architecture, maintained in the separate clariah-mediasuite repository.

This project is published as an npm module.

Note on 24th March 2021 build (React 17, webpack 5)

Required fixes:

Code splitting (TODO)

https://www.valentinog.com/blog/webpack/ https://webpack.js.org/guides/code-splitting/

Development setup

Integration with server side Clariah Mediasuite

To develop components in this repo, it needs to be linked to the clariah-mediasuite project. See its installation instructions for how to set it up.

Once clariah-mediasuite is installed, we need to link the two projects.

Clone labo-components (recommended as sibling directory to the clariah-mediasuite repo):

git clone git@github.com:beeldengeluid/labo-components.git .

Navigate to the node modules dir inside the clariah-mediasuite project:

cd src/static/node_modules

Remove the npm installed labo-components dir:

`rm -R labo-components`

Create a symlink in the currect dir pointing to the git cloned labo-components (assuming the two repos are located in sibling directories):

ln -s ../../../../labo-components/  .

Navigate back to the root of the cloned labo-components directory and install its dependencies:

npm install

Then run the development version:

npm run dev

Now run the server as explained in the clariah-mediasuite README and you should be able to see your front-end updates in the browser when you edit the labo-components project 🎉

Style compilation

SASS is used to generate the main stylesheet (/src/static/css/main.css).

Whenever you want to change the overall styling you need to run the watcher using a npm command:

npm run watch

While the watcher is running any changes to the *.scss files in the /static/sass folder will be compiled into /src/static/css/main.css

Creating a new recipe

We refer to the different tools that together make up the Media Suite as 'recipes'. The best way to learn how the media suite works is by creating a new recipe, which will give you the opportunity to start assembling your own choice of components.

Before starting, it's good to realise there are several ways of using the component library, but there is a recommended one for integration in the media suite, which we'll discuss right away.

Adding a recipe to the recipes page (recommended)

By following the recommended approach, your custom recipe will appear in the recipes page of the media suite.

Step 1: Create a recipe JSON file

The recipes.html file is the template that renders certain (manually chosen) recipes from the resources/recipes folder in blocks on the page to choose from.

To make your recipe appear on this page, first you need to add a new JSON file (with a meaningful name reflecting the functionality of the recipe) in /resources/recipes:

{
    "id" : "my_recipe",
    "name" : "Your own recipe!",
    "type" : "my_recipe",
    "phase" : "recipe-building",
    "description" : "Your recipe that does very cool things. Aim for world peace!",
    "ingredients" : {
        "key1" : "value1",
        "key2" : "value2"
    }
}

Note There is also an example.json you can copy and modify for convenience

The name is used as the title of your recipe on the recipes page

The description is used as the description for your recipe on the recipes page

The type parameter is used to load the correct recipe *.jsx file from the labo-component's index.jsx file, which is the main interface for using the component library, but more on that later on.

The phase is used to place your recipe in the right category on the recipes page. Please use one of the already existing values to reflect the intended research phase your recipe is suitable for. If it's something new, please make up a meaningful label.

The ingredients are basically any key/value pairs you'd like to use to easily configure your recipe.

Since hot loading does not work yet, you have to restart the server to make you recipe JSON load into server memory.

After that you can finally make your recipe appear in the recipes.html by insert a block of HTML like this:

<!-- EXAMPLE  -->
<div id="{{recipes['my_recipe'].id}}" class="col-sm-6 col-md-4">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-rocket"></i>&nbsp; {{recipes['my_recipe'].name}}</h3>
        </div>
        <div class="panel-body">
            {{recipes['my_recipe'].description}}
        </div>
        <div class="panel-footer text-right"><a href="{{recipes['my_recipe'].url}}">View recipe</a></div>
    </div>
</div>
Step 2: Create the .jsx file in the component library

Currently the component library also contains the application specific recipes as top-level React components. In a later version, the media suite recipes will probably be moved into this repo.

Since you've only created a JSON file and want to create a whole new recipe type, you now have to create a new *.jsx file for your recipe and map your recipe in the index.jsx of the labo-components.

Open the labo-components code in your editor and add a new *.jsx file to the /app directory. The easiest is to copy ExampleRecipe.jsx and rename it (and its class name!) to whatever you like. Otherwise your recipe code should contain the following as the bare minimum:

import IDUtil from './util/IDUtil';

class MyRecipe extends React.Component {

    constructor(props) {
        super(props);
        this.state = {}
    }

    render() {
            return (
                <div className={IDUtil.cssClassName('example-recipe')}>

                </div>
            )
        }
    }

}

export default MyRecipe;

Following this, make sure to map the recipe type to your React class in index.jsx by extending the cookRecipe function as follows:

else if(recipe.type === 'myRecipe.type') {
    render(
        <MyRecipe recipe={recipe} params={params} user={user}/>,
        document.getElementById(elementId)
    );
}

Now to compile your changes please run the following command in the main directory of the labo-components code:

npm run dev

This will watch for any changes you make in the code (within the /app directory) and will try to build the code. If it fails it will print in what part of the code the error originates.

After you've managed a succesfull build, you need to do one more thing to make your new recipe work: edit the recipe.html (template that imports the labo-components library and is responsible for rendering recipes in the media suite) as follows:

<!--<script type="text/javascript" src="/static/node_modules/labo-components/dist/labo-components.js"></script>-->
<script src="/PATH_TO_YOUR_DEVELOPMENT_VERSION_OF_LABO_COMPONENTS/dist/labo-components.js" type="text/javascript"></script>

This makes sure the media suite code does not look for the component library in the node_modules, but looks for the development version you've just built.

Now (possibily after clearing your browser cache) you can now click on your recipe in the recipes.html and go to a working dummy recipe!

6.1.19

2 years ago

6.1.20

2 years ago

6.1.22

2 years ago

6.1.21

2 years ago

6.2.1

2 years ago

6.1.14

2 years ago

6.1.13

2 years ago

6.1.12

2 years ago

6.1.11

2 years ago

6.1.9

2 years ago

6.1.10

2 years ago

6.1.8

2 years ago

6.1.6

2 years ago

6.1.5

2 years ago

6.1.4

2 years ago

6.1.3

2 years ago

6.1.2

3 years ago

6.1.1

3 years ago

6.0.9

3 years ago

6.0.6-pt

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.4-pt

3 years ago

6.0.6-ctu

3 years ago

6.0.5-pt

3 years ago

6.0.3-ctu

3 years ago

6.0.2-ctu

3 years ago

6.0.1

3 years ago

6.0.2

3 years ago

6.0.0

3 years ago

5.6.4

3 years ago

5.6.3

3 years ago

5.6.2

3 years ago

5.6.1

3 years ago

5.6.0

3 years ago

5.5.3

3 years ago

5.5.2

3 years ago

5.3.19

3 years ago

5.4.1

3 years ago

5.5.1

3 years ago

5.3.18

3 years ago

5.3.17

3 years ago

5.3.16

3 years ago

5.3.15

3 years ago

5.3.14

3 years ago

5.3.13

3 years ago

5.3.12

3 years ago

5.3.11

3 years ago

5.3.10

3 years ago

5.3.9

3 years ago

5.3.8

3 years ago

5.3.7

3 years ago

5.3.6

3 years ago

5.3.5

3 years ago

5.3.4

3 years ago

5.3.3

3 years ago

5.3.2

4 years ago

5.3.1

4 years ago

5.1.13

4 years ago

5.1.12

4 years ago

5.1.11

4 years ago

5.1.10

4 years ago

5.1.9

4 years ago

5.1.8

4 years ago

5.1.6

4 years ago

5.1.5

4 years ago

5.1.4

4 years ago

5.0.24

4 years ago

5.1.3

4 years ago

5.0.23

4 years ago

5.0.22

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.0.21

4 years ago

5.0.20

4 years ago

5.0.19

4 years ago

5.0.18

4 years ago

5.0.17

4 years ago

5.0.16

4 years ago

5.0.15

4 years ago

5.0.13

4 years ago

5.0.14

4 years ago

5.0.12

4 years ago

5.0.11

4 years ago

5.0.10

4 years ago

5.0.9

4 years ago

5.0.8

4 years ago

5.0.7

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.2

4 years ago

4.8.18

4 years ago

4.8.17

4 years ago

4.8.16

4 years ago

4.8.15

4 years ago

4.8.14

4 years ago

4.8.13

4 years ago

4.8.12

4 years ago

4.8.11

4 years ago

4.8.9

4 years ago

4.8.10

4 years ago

4.8.8

4 years ago

4.8.6

4 years ago

4.8.5

4 years ago

4.8.4

4 years ago

4.8.3

4 years ago

4.8.2

4 years ago

4.8.1

4 years ago

4.8.0

4 years ago

4.7.80

4 years ago

4.7.79

4 years ago

4.7.78

4 years ago

4.7.77

4 years ago

4.7.76

4 years ago

4.7.75

4 years ago

4.7.74

4 years ago

4.7.72

4 years ago

4.7.71

4 years ago

4.7.70

4 years ago

4.7.69

4 years ago

4.7.68

4 years ago

4.7.67

4 years ago

4.7.66

4 years ago

4.7.65

4 years ago

4.7.64

4 years ago

4.7.63

4 years ago

4.7.62

4 years ago

4.7.61

4 years ago

4.7.60

4 years ago

4.7.59

4 years ago

4.7.57

4 years ago

4.7.58

4 years ago

4.7.56

4 years ago

4.7.54

4 years ago

4.7.55

4 years ago

4.7.53

4 years ago

4.7.52

4 years ago

4.7.51

4 years ago

4.7.50

4 years ago

4.7.49

4 years ago

4.7.48

4 years ago

4.7.47

4 years ago

4.7.46

4 years ago

4.7.45

4 years ago

4.7.43

4 years ago

4.7.44

4 years ago

4.7.42

4 years ago

4.7.41

4 years ago

4.7.40

4 years ago

4.7.35

4 years ago

4.7.38

4 years ago

4.7.39

4 years ago

4.7.36

4 years ago

4.7.37

4 years ago

4.7.34

4 years ago

4.7.33

4 years ago

4.7.31

4 years ago

4.7.32

4 years ago

4.7.30

4 years ago

4.7.28

4 years ago

4.7.29

4 years ago

4.7.27

4 years ago

4.7.26

4 years ago

4.7.24

4 years ago

4.7.25

4 years ago

4.7.20

4 years ago

4.7.23

4 years ago

4.7.21

4 years ago

4.7.22

4 years ago

4.7.17

4 years ago

4.7.18

4 years ago

4.7.19

4 years ago

4.7.16

4 years ago

4.7.15

4 years ago

4.7.14

4 years ago

4.7.13

4 years ago

4.7.6

4 years ago

4.7.5

4 years ago

4.7.0

4 years ago

4.6.0

4 years ago

4.5.1

4 years ago

4.5.0

4 years ago

4.4.0

4 years ago

4.3.8

4 years ago

4.3.7

4 years ago

4.3.6

4 years ago

4.3.5

5 years ago

4.3.4

5 years ago

4.3.3

5 years ago

4.3.2

5 years ago

4.3.1

5 years ago

4.3.0

5 years ago

4.2.5

5 years ago

4.2.4

5 years ago

4.2.3

5 years ago

4.2.2

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago

4.0.7

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.8

5 years ago

3.3.7

5 years ago

3.3.6

5 years ago

3.3.5

5 years ago

3.3.4

5 years ago

3.3.3

5 years ago

3.3.2

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.7

5 years ago

3.2.6

5 years ago

3.2.5

5 years ago

3.2.4

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

2.8.3

5 years ago

2.8.2

5 years ago

2.8.1

5 years ago

2.8.0

5 years ago

2.7.0

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.0

6 years ago

2.4.7

6 years ago

2.4.6

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.8

6 years ago

1.8.7

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.23

6 years ago

1.1.22

6 years ago

1.1.21

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago