Answer the question
In order to leave comments, you need to log in
PostCSS check for class existence &?
Started using PostCSS on a small project, used to use the Less preprocessor.
I often face the task that if an element has such a class, then apply such styles, for example:
.link {
color: blue;
// В Less можно использовать амперсанд (&) для решения такой задачи
&.active {
color: red;
}
}
/* Профиль пользователя */
.app-components-Aside-__user__1gy.app-components-Aside-__wrapper__1n4 {
height: 42px;
width: 100%;
background-color: red;
}
<div class="app-components-Aside-__user__1gy">
<div class="app-components-Aside-__user__1gy-wrapper"></div>
</div>
import React from 'react';
import { Link } from 'react-router';
/* component styles */
import s from './styles.css';
function Aside() {
return (
<aside className={s.root}>
<div className={s.user}>
<div className={s.user + '-wrapper'}></div>
</div>
</aside>
);
}
export default Aside;
Answer the question
In order to leave comments, you need to log in
Use precss for postcss
https://github.com/jonathantneal/precss
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question