Giter Club home page Giter Club logo

php-flasher / flasher-js Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 3.6 MB

This repository contains the necessary JavaScript files for displaying notification messages in web development projects using the Flasher library, including files for popular notification message plugins like Toastr, Noty, and PNotify.

Home Page: https://php-flasher.io

License: MIT License

JavaScript 6.58% TypeScript 79.62% SCSS 13.79%
php-flasher flash-messages notification-system user-feedback toastr sweetalert pnotify noty notyf desktop-notifications

flasher-js's Introduction

flasher-js

flasher-js's People

Contributors

murrant avatar yoeunes avatar yoeunes-spin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

murrant

flasher-js's Issues

[SweetAlert2] Inline CSS overrides theme styling

Problem

I have setup PHP Flasher with Webpack Encore in Symfony 6.x, but I noticed when I wanted to add a theme for SweetAlert2, the theme styles were getting overridden by some inline CSS that flasher had added to the DOM.

Example code

main.js

import Swal from 'sweetalert2'
global.Swal = Swal;

import flasher from '@flasher/flasher';
global.flasher = flasher;

import sweetalert from '@flasher/flasher-sweetalert';
global.sweetalert = sweetalert;

flasher.yaml

flasher:
  default: sweetalert
  root_script: ~
  use_cdn: false
  auto_translate: true
  auto_render: true
  flash_bag:
    enabled: true
    mapping:
      success: [ 'success' ]
      error: [ 'error', 'danger' ]
      warning: [ 'warning', 'alarm' ]
      info: [ 'info', 'notice', 'alert' ]
  filter_criteria:
    limit: 5

  presets:
    login:
      type: 'info'
      message: 'Welcome back'
      options:
        toast: true
        position: bottom-end
        showConfirmButton: false
        timer: 30000

    logout:
      type: 'info'
      message: 'Have a nice day'
      options:
        toast: true
        position: bottom-end
        showConfirmButton: false
        timer: 30000

flasher_sweetalert:
  scripts: ~

Result in DOM

I'm not sure why, and what the purpose is of this, but I'm getting atleast 4 additional style elements added to the DOM.

image

  • One entry starting with .fl-main-container (see this code):

image

Note: All these entries are added after my existing application <style> tags, and before the first <script> tag, so it will always override additional SweetAlert2 theme styles.

Desired solution

As the additional/unnecessary CSS styling added to the DOM breaks theme styling for SweetAlert2, I want to know how I can prevent flasher from adding these styles. Is this maybe a config setting, or something I have to do when importing the modules, or is this is a bug?

I propose to separate JS and CSS for all the packages (not just SweetAlert2).

flasher global instance with webpack

I'm using webpack 5 for my project and in case anyone needs this. I was able to get a global instance of Flasher working using the following method.

webpack config:

module: {
        rules: [
            {
                test: require.resolve("toastr"),
                loader: "expose-loader",
                options: {
                    exposes: ["toastr"],
                },
            },
            {
                test: require.resolve("@flasher/flasher"),
                loader: "expose-loader",
                options: {
                    exposes: ["Flasher"],
                },
            }
        ]
}

in app.js:

import toastr from "toastr";

// toastr defaults
toastr.options.timeOut = 10000;
toastr.options.closeButton = true;
toastr.options.escapeHtml = true;
toastr.options.progressBar = true;
toastr.options.closeOnHover = false;

import { default as Flasher } from "@flasher/flasher";
import { default as ToastrFactory } from "@flasher/flasher-toastr";
Flasher.getInstance().addFactory("toastr", new ToastrFactory());

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.