GithubHelp home page GithubHelp logo

academia-de-codigo / react-semantic-toasts Goto Github PK

View Code? Open in Web Editor NEW
87.0 87.0 31.0 816 KB

React Semantic UI notifications library

License: MIT License

JavaScript 86.60% CSS 13.40%
notifications react semantic toasts

react-semantic-toasts's People

Contributors

carsonfarmer avatar dependabot[bot] avatar doncicuto avatar ferrao avatar foysalit avatar jamesgiu avatar loganarnett avatar maximemaillet avatar mjsarfatti avatar mrrefactoring avatar mstlaurent-paradigm avatar neeg avatar pawelj-pl avatar zerquix18 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-semantic-toasts's Issues

Can you make semantic-ui-css optional?

Oi Rui!

Thanks for the great package! I've set it up and it's really easy to use and nice looking with those tiny animations. :)

I don't use semantic-ui-css in my project and it's not a required dependency of semantic-ui-react. However, this package fails if semantic-ui-css is not added. Please note that semantic-ui-css is a package that weights about 600KB. I've checked similar issues and noticed you moved the dependency to peer dependencies. This still doesn't solve the issue.

Would it be possible to have unstyled version of the package or some similar solution?

Thanks!

Build error due to require("... .css") codes

Can you make a css detached version?
Or Please let me know how to prevent build confliction...

/Users/dehypnosis/dev/syncodax-dev/web/node_modules/semantic-ui-css/components/reset.min.css:9
 */*,:after,:before{-webkit-box-sizing:inherit;box-sizing:inherit}html{-webkit-box-sizing:border-box;box-sizing:border-box}input[type=email],input[type=password],input[type=search],input[type=text]{-webkit-appearance:none;-moz-appearance:none}/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{

SyntaxError: Unexpected token *
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/dehypnosis/dev/syncodax-dev/web/node_modules/react-semantic-toasts/build/semantic-toast-container.js:4:1)

Toaster appears twice

Thanks for the toast, it's really easy to use!

When a condition met, toast appears in a particular component. SemanticToastContainer is placed inside of the component. When a user navigates to another component, and then comes back and toast condition is met again, two toasters appear.

An issue can be solved, if move SemanticToastContainer to the higher hierarchy.
However, in my case, I need toast time option to be 0 (toaster do not disappear until the user clicks close icon). If I move SemanticToastContainer to the higher hierarchy, toaster stays on all the pages/components until the user closes it.

I would like the toaster to stay or until the user close it, or until the user navigate to another context . Any suggestions how it can be solved? thanks!

Fix for index.d.ts?

Could you specify description in ToastOptions interface to allow also React node? It should work already, but interface is declared "wrongly" at the moment.

CSS Still included (0.4.0)

Hi @ferrao,

It appears the new version you released to NPM still includes all .css files in the /build directory. Did you forget to re-build before publishing to NPM?

Also, can you remove the import '../styles/react-semantic-alert.css'; statement from the semantic-toast-container.jsx file, and instead add to the documentation that developers need to import that file?? The reason for this, is that build tools (webpack, babel, etc..) by default do not include code that is in the node_modules directory. It would be better if the .css file you provided is imported so that it can easily be included in the local build packaging.

Thanks for the good work.

hidden element blocking content

There is a hidden element in the lower left corner (same as toast position) that is invisible, but blocking click events etc. See screenshot.

image

semantic-ui-react 2.0.3?

Hello, is this library being maintained? The current version of semantic-ui-react is 2.0.3 but react-semantic-toasts declares a peer dependency compatible with up to 0.88.

icon showed wrongly

when no icon props specified, it should automatically get the icon according to the type. but it only shows the success icon for all type.

'medium' is not a valid size option

defaults to value medium for the size.
That's not one of the valid choices: https://react.semantic-ui.com/collections/message/#variations-size

Warning: Failed prop type: Invalid prop `size` of value `medium` supplied to `Message`, expected one of ["mini","tiny","small","large","big","huge","massive"].
    in Message (created by SemanticToast)
    in SemanticToast (created by SemanticTransition)
    in div (created by SemanticTransition)
    in Transition (created by SemanticTransition)
    in SemanticTransition (created by SemanticToastContainer)
    in div (created by SemanticToastContainer)
    in SemanticToastContainer (at App.js:228)
    in div (at App.js:227)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App.js:226)
    in App (at src/index.js:6)

Typescript definition

still testing but should be in right way, here is the typescript definition:

declare module 'react-semantic-toasts' {
  import { ReactNode } from 'react'
  const SemanticToastContainer: () => JSX.Element
  const toast: (
    options: {
      title: string
      description: string
      type: 'info' | 'success' | 'warning' | 'error'
      icon?: any
      time?: number
    },
    onClose?: () => void,
    onClick?: () => void,
  ) => void

  export { SemanticToastContainer, toast }
}

Hard to override css

It looks like react-semantic-toasts does css imports directly into component jsx files. Since I use semantic-ui as a CSS framework base for most of my components, I have a lot of css that I override. When I imported react-semantic-toasts, I noticed a lot of my css was being override and finally found out that the react-semantic-toasts jsx files import css files directly. Is there a way we can separate the tight coupling of css imports?

npmjs is outdated

#39

I've commented there.

I notice that npmjs and github are not synced.

As npmjs code for semantic-toast.jsx is like this:

import React from 'react';
import PropTypes from 'prop-types';
import { Message } from 'semantic-ui-react';
import withTransition from './with-transition';

const icons = {
    info: 'announcement',
    success: 'checkmark',
    error: 'remove',
    warning: 'warning circle'
};

function SemanticToast(props) {
    const { type, title, description, size, color, list, onClose, onClick, onDismiss } = props;
    const icon = props.icon || icons[type];

    const onDispel = e => {
        e.stopPropagation();
        onDismiss();
        onClose();
    };

    return (
        <Message
            {...{ [type]: true }}
            onClick={onClick}
            onDismiss={onDispel}
            header={title}
            content={description}
            icon={icon}
            size={size}
            color={color}
            list={list}
            floating
        />
    );
}

SemanticToast.propTypes = {
    type: PropTypes.oneOf(['info', 'success', 'error', 'warning']).isRequired,
    title: PropTypes.string.isRequired,
    description: PropTypes.oneOfType([
        PropTypes.arrayOf(PropTypes.string),
        PropTypes.string,
        PropTypes.node
    ]).isRequired,
    icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
    size: PropTypes.string,
    color: PropTypes.string,
    list: PropTypes.arrayOf(PropTypes.string),
    onClick: PropTypes.func,
    onDismiss: PropTypes.func,
    onClose: PropTypes.func
};

SemanticToast.defaultProps = {
    onClick: undefined,
    onDismiss: undefined,
    onClose: undefined,
    icon: undefined,
    color: undefined,
    list: undefined,
    size: 'medium'
};

export default withTransition(SemanticToast);

And the github is like this:

import React from 'react';
import PropTypes from 'prop-types';
import { Message } from 'semantic-ui-react';
import withTransition from './with-transition';

const icons = {
    info: 'announcement',
    success: 'checkmark',
    error: 'remove',
    warning: 'warning circle'
};

function SemanticToast({ type, title, description, onClose, onDismiss, icon, ...props }) {
    const computedIcon = icon || icons[type];

    const onDispel = e => {
        e.stopPropagation();
        onDismiss();
        onClose();
    };

    return (
        <Message
            {...{ [type]: true }}
            onDismiss={onDispel}
            header={title}
            content={description}
            icon={computedIcon}
            floating
            {...props}
        />
    );
}

SemanticToast.propTypes = {
    type: PropTypes.oneOf(['info', 'success', 'error', 'warning']).isRequired,
    title: PropTypes.string.isRequired,
    description: PropTypes.oneOfType([
        PropTypes.arrayOf(PropTypes.string),
        PropTypes.string,
        PropTypes.node
    ]).isRequired,
    icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
    onDismiss: PropTypes.func,
    onClose: PropTypes.func
};

SemanticToast.defaultProps = {
    onDismiss: () => undefined,
    onClose: () => undefined,
    icon: undefined,
};

export default withTransition(SemanticToast);

I need the close to be working because currently my close button is not working (Crashing when calling onDismiss).

Don't dismiss while hovering

Expected behaviour

When a user is hovering over a toast, the toast shouldn't be dismissed, even if it times out. When the user moves mouse of the toast, it should be dismissed after a delay.

Actual behaviour

The toast gets dismissed even if the user is hovering over the toast message.

Explanation

This allows the user to delay dismissal of a toast, in case they need additional time reading the message.

Compilation fails with "Statements are not allowed in ambient contexts. TS1036"

Hi

I'm trying to use library in my project, but TS compiler fails with following error:

TypeScript error in node_modules/react-semantic-toasts/build/index.d.ts(35,2):
Statements are not allowed in ambient contexts.  TS1036

    33 | 
    34 |     export { SemanticToastContainer, toast, ToastOptions }
  > 35 | };
       |  ^
    36 | 

I'm using TypeScript 3.5.3 and react-semantic-toasts 0.6.2

It appears icon is required?

Hello --

First, thanks for doing this library! It works very well, and looks nice.

However, I just started getting an error (...I believe...) where it complains that the icon is required.

My example code is:

toast({
        title: 'Success!',
        description: 'Saved successfully.',
        time: 3000,
        type: 'success'
      }
    )

The error message is:

Warning: Failed prop type: The prop `icon` is marked as required in `SemanticToast`, but its value is `undefined`.

The documentation says that the icon argument is optional. I fixed my code with:

toast({
        title: 'Success!',
        description: 'Saved successfully.',
        time: 3000,
        type: 'success',
        icon: 'announcement'
      }
    )

but it seems unfortunate that I have to look in the code to find the right icon to use.

Thanks!

Render override other component

I discover that result HTML override other HTML.

In my example, i have a Semantic dropdown in top right.
My ToastContainer is in top right (by default). The HTML render is a div with classes ui-alerts top-right . With this div, my dropdown is not clickable !
I think it will be better to put this div in display none while is not active.

My actual approach is too change padding to 0px for force to have no width when toast container is empty.

Thanks

className to SemanticToastContainer

Could you please added opportunity assign a className to the
SemanticToastContainer in /lib/semantic-toast-container.jsx exmaple such as:

static propTypes = {
        position: PropTypes.oneOf([
            'top-right',
            'top-center',
            'bottom-right',
            'bottom-center',
            'bottom-left'
        ]),
        animation: PropTypes.string,
        className: PropTypes.string,
};
      static defaultProps = {
           position: 'top-right',
           animation: null, 
           className: null, 
      };
render() {
        const { position, className } = this.props;
        const animation = this.props.animation || animations[position];

        return (
            <div className={`ui-alerts ${position} ${className}`}>

Ability to set description to be a JSX component

I would expect to be able to do:

toast({
  type: 'warning',
  icon: 'envelope',
  title: 'Warning Toast',
  description: <p>THis is a <b>node</b></p>,
  time: 5000,
});

If you try you get this error:

Warning: Failed prop type: Invalid prop `description` of type `object` supplied to `SemanticToast`, expected `string`.

This is what Ant does: https://ant.design/components/message/#API
The content argument's type is string|ReactNode.

Duplicate import of Semantic UI

Hi Guys,

First of all, thank you for this great plugin.

I have found one issue, react-semantic-toasts package imports a duplicate version of Semantic UI package, this in return increases my bundle size.

Please check the screenshot below:

duplicate-import-of-react-toast

How can I resolve this?

Custom transition?

Hi,

Thanks for the great work! Is it possible to change or turn off the transition? The animation looks cool but I guess something simpler (such as sliding up/down) would be more preferred.

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.