cytoscape / ipycytoscape

A Cytoscape Jupyter widget
https://ipycytoscape.readthedocs.io/en/master/
BSD 3-Clause "New" or "Revised" License
270 stars 62 forks source link

CSS vs Style #181

Open joseberlines opened 4 years ago

joseberlines commented 4 years ago

In the examples included in the repo I observe two ways of setting style:


cytoscapeobj.set_style([                        {
                        'selector': 'node[classes]',
                             'style': {
                                  'font-family': 'helvetica',
                                  'font-size': '20px',
                        }},

etc etc

and also:

cytoscapeobj.set_style([{
                        'selector': 'node',
                        'css': {
                            'content': 'data(name)',
                            'text-valign': 'center',
                            'color': 'white',
                            'text-outline-width': 2,
                            'text-outline-color': 'green',
                            'background-color': 'green'

etc etc

                        }

when do you use 'css' and when do you use 'style'?

ianhi commented 4 years ago

I believe that cytoscapejs treats them exactly the same. See for example https://js.cytoscape.org/#eles.style image

however, the styling is not strictly the same as CSS so it's probably better to use style which is what the cytoscapejs examples do.

ianhi commented 4 years ago

it would be great to comb over the docs and replace all the css with style. If anyone wants to tackle that and needs help building the docs feel free to drop a comment here.

joseberlines commented 4 years ago

cool. good to know style is the way to go