Snippets to make your life easier as far as component creation goes
You'll only have to define this once
In PHPStorm, go to Preferences > Editor > File and Code Templates and create a templae file with an `njk` extension.
Copy paste the code below in it.
#set( $elt = ${NAME} )
#set( $eltFullName = ${StringUtils.removeAndHump(${elt}, "-")})
#set( $eltFullName = $eltFullName.substring(0,1).toLowerCase()+$eltFullName.substring(1))
// replace all parentheses by accolades
<div class="(( namespace ))$eltFullName(% for mod in modifiers %) (( mod ))(% endfor %)(% for mod in classes %) (( mod ))(% endfor %)"></div>
When set up, go to your PHPStorm Preferences > Editor > File and Code Templates > SCSS.
Copy paste the code below in it. To create a .scss component file, right click new > stylesheet.
The code below will automatically add the project prefix when creating the file, and format it respecting the ABEM methodology.
/* variables specific to current element */
\$element-specific-variables: "";
#set( $filename = ${NAME} )
#set( $filenameNoUnderscore = $filename.replace("_", "") )
#set( $elt = ${StringUtils.removeAndHump(${filenameNoUnderscore}, "-")})
#set( $elt = $elt.substring(0,1).toLowerCase()+$elt.substring(1))
.#{\$namespace}${elt} {
/* Save root element context for easy access if nesting is needed */
\$self: &;
/* properties of current element + media queries */
/* Pseudo Elements */
&::before {
}
&::after {
}
/*
Include elements that are linked to the current element but have to reside at the root level of the stylesheet
(e.g: keyframes)
*/
@at-root {}
/* children - write selector in full in comments in order to facilitate search */
// ${elt}__childElement
&__childElement {
// follows same logic as parent
}
/* modifiers */
// ${elt} -altStyle
&.-altStyle {
// follows same logic as base element
}
/* random parent element */
/*
*
* Syntax : .randomParentElt & {}
*
*/
/* Pseudo Classes */
&:hover {
@media (hover: hover) {
}
}
&:focus {
}
&:active {
}
&:focus,
&:active {
}
}