I am trying to get started with ParticleJs, and have been looking at this tutorial. I’ve been using my Particle Core for a little bit, but not with ParticleJS. So I was trying to run the example code, so my code looks liek this, so it can run the browser:
<!DOCTYPE html>
<html>
<div id = "spark-login" />
<script
src = "//cdn.jsdelivr.net/sparkjs/0.5.9/spark.min.js">
</script>
<script>
sparkLogin(function(data) {
// Your code here
});
</script>
</html>
The code does not work at all, if I try to run it in Chrome, the page is just blank. How do I get it to work?
The one in the ‘example’ folder works just fine for me…
Try adding http: before the slashes in your source. Also, checking the console output if often a good way to identify where the problems may lie. Give that a try next time
Yes, that one works for me, but why doesn’t the example. I think it’s important that I get that one to work too, so I understand the rest of the documentation.
I too had that issue. I suspect some in-line style is applied from within the library that is overwriting your style. What seemed to work for me was declaring it as !important. If I’m not mistaken, this should get fixed somewhere in the future, although I’m not certain when that would be.
Okay, so I declared it as !important, as seen below:
.spark-login-button {
float: center !important;
color: #16A085 !important;
}
It worked, sort of, it didn’t change the color of the button, rather, changing the color of the button’s text. How do I change the color of the button?
And, since particle is open-sourced, where can I find the original css file, from the ParticleJS so that I can do what I want? I looked on the github, but I couldn’t find it.
The library works for both node.js as well as in the browser, due to the fact that node.js runs on Javascript as well. That said, most, if not all of the examples are written with node.js in mind. For that, you need the require, which is something you don't need in the browser. You can leave that out, and it should work.
Keep in mind that those docs are a reference for the library with some examples included. It's not a tutorial of any kind. If you're new to javascript, it's not the ideal place to start learning it. There are some great tutorials out on the web which you're better off trying, if you're just getting started. W3schools is a good one for example. That said, you're more than welcome to ask any questions should you get stuck somewhere