marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

Installing this in Angular project #163

Closed papakonstantinouko closed 7 years ago

papakonstantinouko commented 7 years ago

Hello, what are the steps to add this library to an Angular 2 application? Ideally I would like this to act as a module that I can load whenever I need it, not on the whole application.

papakonstantinouko commented 7 years ago

I managed to do this, no worries, it works fine.

michaelfaisst commented 7 years ago

@papakonstantinouko I'm currently having issues doing this as well. Can you tell me how you did it?

papakonstantinouko commented 7 years ago

I have this under dependencies in package.json "css-element-queries": "^0.4.0"

then in my component file I have these 2 lines underneath my imports

const RESIZE_SENSOR = require('../../../../node_modules/css-element-queries/src/ResizeSensor.js');
const ELEMENT_QUERIES = require('../../../../node_modules/css-element-queries/src/ElementQueries.js');

and the component implements AfterViewInit like this

ngAfterViewInit() {
    ELEMENT_QUERIES.init();
  }

and finally in the css I do things like this

li[min-width~="100px"] {
    padding-top: 3px;
}

li[min-width~="290px"] {
    padding-top: 13px;
}
michaelfaisst commented 7 years ago

@papakonstantinouko Thanks! Gonna try that : )