I tried to understand the argument made for styled components vs. ‘traditional’ CSS. But when reviewing these arguments I found out that they typically use bad code as proof for their point.
See e.g. the following SCSS code:
$blue = #5DBCD2;
@mixin button-styles($bg-color, $color) {
background: $bg-color;
color: $color;
border: none;
border-radius: 0.20em;
&:hover{
background: darken($bg-color, 6%);
cursor: pointer;
}
}
.button {
@include button-styles(#ddd, black)
}
.button--primary {
@include button-styles($blue, white)
}
To pair with a simple component along the lines of:
const Buttons = props => (
Default
Primary
)
export default Buttons
The suggested alternative is:
import themeVars from "myTheme"
import styled from "styled-components"
import { darken } from "polished"
const B...
Cypress is a new, open source integration test runner for modern JS applications (its development is sponsored by their online dashboard that allows you to record test-runs). It doesn’t require setting up Selenium, or other browser plugin, manually. Add it to your package.json and everything you need will be set up:
npm install cypress --save-dev
You can open even a GUI using:
./node_modules/.bin/cypress open
Alternatively, you can run the tests headless using the run
command:
./node_modules/.bin/cypress run
Running the test will leave you with video recordings of what has been happening visually on the frontend for further review.
Ok. All nice, but you're right, these are tests running against a locally run server. So let's move the examples directory out of scope of the test runner:
mv cypress/integration/examples cypress/integration-examples
*(when exploring a new framework, I typically like …
Being unable to find a really concise description at a stable endpoint, the "scripts"
-section of package.json
, central to node
/npm
/yarn
/euh. JavaScript-development these days, here it is.
The package.json
is a json file which typically contains things like version and name of a project, the typical metadata. It also contains the dependencies of a project. But this is about the scripts-section. Completely optional, but so convenient that typically your project has one already:
{
"name": "hello world",
"version": "0.0.1",
"main": "index.js",
"scripts": {
}
}
The "scripts"
-section contains snippets of code that you typically run using npm
or yarn
:
So let's say you're typing git add . && git commit -m "wip" && git push
a lot (totally not recommended), you could do:
{
"name": "hello world",
"version": "0.0.1",
"main": "index.js",
"scripts": {
"wipitup": "git add . && ...
Dit artikel van murblog van Maarten Brouwers (murb) is in licentie gegeven volgens een Creative Commons Naamsvermelding 3.0 Nederland licentie .