Giter Club home page Giter Club logo

Comments (7)

notcod avatar notcod commented on May 24, 2024 1

image
First one is https://fkhadra.github.io/react-toastify/introduction
second one is sonner with config:
image
I think I achieve my goal, I was using react integration in my project but I think I can move my project to this one, I would like to change toast drag to left right instead of current just to up, how I can make it?

Also it would be nice to add opacity while swiping

from qwik-sonner.

diecodev avatar diecodev commented on May 24, 2024

Hi, thanks for the issue.

I don't think your proposal is in line with the default Toast design. However, it would be helpful if you could create a design in figma or similar where you use the default toast and add the progress bar, to see how it looks and make a final decision.

Note

Btw, if you want to implement this exact design, you can use the toast.custom() function.

from qwik-sonner.

notcod avatar notcod commented on May 24, 2024

image
image

My prettier config fuck up code with a lot of changes, but here is git https://github.com/notcod/qwik-sonner/commits/main/
If I get time tomorrow I will re-make it and push clean code if you like idea

export interface ToastProps {
  /// ...rest
  progressBar?: boolean;
  progressBarColor?: string;
}

interface ToastOptions {
  /// ...rest
  progressBar?: boolean;
  progressBarColor?: string;
}
export const Toast = component$((props: ToastProps) => {
  const percent = useSignal(100);
  useStyles$(`
    .pre-loading{
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 5px;
      background: #f2f2f2;
      border-radius: 0 0 5px 5px;
    }
    .loading{
      width: 100%;
      height: 5px;
      width: 0;
      transition: width 0.5s;
      border-radius: 0 0 0 5px; 
    }
  `);
  ///// ...rest

  let timeoutId: number;
  const startTimer = () => {
    ///// ...rest

    intervalId = setInterval(() => {
        const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.value;
        percent.value = (0.98 - elapsedTime / duration.value) * 100;
      }, duration.value / 50);
  };

  cleanup(() => clearTimeout(intervalId));
  ///// ...rest
  return (
    /// ...rest
        {props.progressBar && (
          <div class="pre-loading">
            <div class="loading" style={` width:${percent.value}%; background: ${props.progressBarColor || 'black'}`} />
          </div>
        )}
      </Fragment>
    )}
    </li>
  );
});




export const Toaster = component$<ToasterProps>((props) => {
  /// ...rest
  return (
    <Toast
    /// ...rest
    progressBar={toastOptions?.progressBar}
    progressBarColor={toastOptions?.progressBarColor}
  /// ...rest

from qwik-sonner.

diecodev avatar diecodev commented on May 24, 2024

hey @notcod gj, mate. What should I do for you? Wdyt about create a custom stylesheet for the component?

from qwik-sonner.

notcod avatar notcod commented on May 24, 2024

I edited it to satisfy my project needs, but didn't get time to push clean commits to your repository. I just uploaded test site and realised that toast works only when page accessed via spa Link.... I will take a look at this problem tomorrow, probably the reason is useTask$, but will confirm latter.
check it https://fc52ca83.qwik-toastify.pages.dev/
updated icons and colors, shuffled your code a little, probably messed up default things but got what I needed, here is code https://github.com/notcod/toastify
Btw, I learned few things from your code, you are really experienced in the field
image

from qwik-sonner.

notcod avatar notcod commented on May 24, 2024

I made it able to swipe left/right instead of default up/down, also dismisable by clicking on it, maybe you should put it as optional? I can commit feature you want to your code, which one would you like?

from qwik-sonner.

diecodev avatar diecodev commented on May 24, 2024

Hey @notcod, pls create a PR to make the toast dismissible for left/right.

As for your proposed new design, I regret to inform you that after talking with my partner (@devalexpy), we consider that it does not go according to sonner design (the original version based on react) so we do not consider good idea to implement your proposed one. However, I am glad to know that you were able to adapt qwik-sonner to your needs.

from qwik-sonner.

Related Issues (4)

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.