15
loading...
This website collects cookies to deliver better user experience
CSS is very difficult. If they tell you otherwise, it's because they just want to make you happy
Maintaining standards is boring, time-consuming and expensive, but only if you do it the wrong way.
pre-commit
and pre-push
routines, greatly facilitate the code standardization and code review
process. But that's a topic for another post.CSS is not ahead of its time
In the beginning: I'll fix it here, and... ops it broke there..., hummm just fix it here and there... At the end: it feels like I'm at the beginning
Less, Sass, Stylus. How do they live? What do you eat?
/*nested*/
section {
nav {
ul {
li {
a {
}
}
}
}
}
/*in line*/
nav ul li a { ... }
scss
code with all this nesting, right?id
or more selector
, or even an !important
, which isn't cool.styled-components
are:// button/index.js
<Button className="primary" />
// public/index.html
<button class="sc-fznLPX jckqBg primary" />
properties
and themes
received.outlined
property to the Button component:// button/index.js
<Button outlined>Edit profile</Button>
// button/styles.js
export const Button = styled.button`
background-color: ${props =>
props.outlined ? 'transparent' : `${props.theme.colors.primary}`};
`
outlined
property. If yes, then I apply the background-color
as transparent. If not, I apply the value of the colors.primary
property, defined in the theme.js
file, to the background-color
.-webkit
, -moz-
, -ms
and -o-
do not need to be entered anymore, as styled-components
does this work automatically./* with styled-components */
export const Container = styled.section`
transition: all 2s linear;
`
/* without styled-components */
.container {
-moz-transition: all 2s linear;
-ms-transition: all 2s linear;
-o-transition: all 2s linear;
-webkit-transition: all 2s linear;
transition: all 2s linear;
}