Giter Site home page Giter Site logo

Comments (4)

sconix avatar sconix commented on August 16, 2024

Haven't seen such behavior so can't say what could be wrong. The styles are inlined within the component so can't think of anything that would cause them not to work. If you are using a directive then you need to load the style file separately, but not with component.

from ngx-dropzone-wrapper.

topa avatar topa commented on August 16, 2024

It seems that setting ViewEncapsulation.None or if you now your target browsers ViewEncapsulation.Native in the component which uses DropzoneComponent fixes that problem.
Probably angular's default is ViewEncapsulation.Emulated due to browser compatibility because ViewEncapsulation seems to be solved through shadow dom.

from ngx-dropzone-wrapper.

topa avatar topa commented on August 16, 2024

We've wrapped DropzoneComponent into a custom component, copied the styles from this package and imported dropzone styles directly from node_modules. At the end this approach gives us full access to the styles.

import { DropzoneComponent } from 'ngx-dropzone-wrapper';
import {
  Component,
  ViewEncapsulation,
  OnDestroy
} from '@angular/core';

@Component({
  selector: 'my-dropzone',
  templateUrl: './my-dropzone.component.html',
  styleUrls: [
    '../../../../../../node_modules/dropzone/dist/min/dropzone.min.css',
    './ngx-dropzone-wrapper.scss',
    './my-dropzone.scss',
  ],
  encapsulation: ViewEncapsulation.None
})
export class MyDropzoneComponent extends DropzoneComponent implements OnDestroy {

  ngOnDestroy() {
    if (this.dropzone) {
      this.dropzone.destroy();
    }
  }
}

A little bit hacky, but it works for now.

btw.: Overriding ngOnDestroy solved also #23 for us.

from ngx-dropzone-wrapper.

sconix avatar sconix commented on August 16, 2024

Yes thats how the style encapsulation works in Angular. You could always make your own styles fully and not use the Dropzone styles file, then you can do it without the ViewEncapsulation.None, but if you want to use the dropzone styles in your own component you need to have the ViewEncapsulation.None. If you import the styles in the global styles then I think it should also work without the ViewEncapsulation change.

Btw. the latest version should have the check in destroy so there should not be need for overriding.

from ngx-dropzone-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.