Code Monkey home page Code Monkey logo

h-bar's People

Contributors

dependabot[bot] avatar mariusa avatar reecem avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mariusa

h-bar's Issues

Dismiss notifications

Is your feature request related to a problem? Please describe.
The post notifications always hang around, and to be able to clear them one would need to add their own stuff to hide it.

Describe the solution you'd like
Be able to have the banner have a dismiss x or dismiss word on the end and then store the action in localStorage with a hash/ or timestamp that waits until a new post is available.

It would need to look at the localStorage before displaying the data, as it would still need to make a get request of the posts to be able to determine if the post notification has been displayed.

Describe alternatives you've considered
The alternative would be having a injectable component that adds the button with an onclick listener that the user then defines their own callback that handles storing the dismiss action and then also removes the banner.

Then they would also define another callback that the system would then check to see if the banner should be shown

Additional context
N/A

Cannot read properties of undefined (reading 'linkWrapper')

Hi,

Thanks for the project, trying it out gives an error:
Cannot read properties of undefined (reading 'linkWrapper')

Describe the bug
A clear and concise description of what the bug is.

To Reproduce


<script src="https://cdn.jsdelivr.net/npm/@reecem/h-bar@latest/dist/hBar.min.js"></script>
<script>
    hBar.init({
        link: "The link url, can be force and no need to fetch from API",
        title: "The link title goes here",

        url: "https://api.github.com/repos/ReeceM/h-bar/releases",
        parser: (data) => {
            // getting the first release on the list of releases from github.
            const { name, html_url } = data[0]
            console.log("hbar parser html_url", html_url)

            return {
                title: `Lateset version available ${name}`,
                link: html_url
            }
        },

        secondaryLinks: [
            {
                title: "Docs",
                link: "http:://docs.example.com"
            },
            {
                title: "Support",
                link: "http://help.example.com"
            }
        ],
        options: {
            theme: "blue",
        }
    })

    hBar.fetchData()
</script>

Could you please also publish the 2.0 version? Maybe it's fixed there.

Templating methods

The way in which the current template of creating the notification is very limited and restricted. Especially the styling.

Describe the solution you'd like
It would be nice to be able to define a template in <template> tags and then have tags inside that are matched to the object returned or parsed.

It should then match the tags, and also account for any XSS, could use dompurify for this, not really rolling my own.

Describe alternatives you've considered
Haven’t done so.

Additional context
n/a

Have a tiny padding on the right too (remove hb--mr-2 ?)

Hi,

classes: `hb--mr-2 hb-flex hb-p-1 hb-rounded-md ${this.theme.dismiss} hover:hb-text-white hover:hb-bg-gray-800 focus:hb-outline-none focus:hb-bg-gray-800`,

By default, the bar looks like this on a small screen:
Screenshot from 2022-12-21 11-49-29

When disabling hb--mr-2, it fixes the display to have a tiny padding on the right too

.hb--mr-2 {
    /* margin-right: -0.5rem; */
}

Screenshot from 2022-12-21 11-49-34

Maybe that class shouldn't be added?

Allow Loading of predefined JSON (static) objects

When using this on another platform, the data might be already there from other sources (my situation). Rather than make another API call to url, I propose having another parameter, eg announcements, which would have the content as returned by the API, eg

announcements: [
{
"url": "https://api.github.com/repos/ReeceM/h-bar/releases/27306040",
"assets_url": "https://api.github.com/repos/ReeceM/h-bar/releases/27306040/assets",
"upload_url": "[https://uploads.github.com/repos/ReeceM/h-bar/releases/27306040/assets{?name,label}](https://uploads.github.com/repos/ReeceM/h-bar/releases/27306040/assets%7B?name,label})",
"html_url": "https://github.com/ReeceM/h-bar/releases/tag/2.0.0-rc1",
"id": 27306040,
"author": {
...

One could set either announcements or url in the init() call. If announcements is set, just skip fetching content from URL and proceed with next step, probably parser.

This extents the usability of this library to many other cases, rather than being forced to load content from an URL.

Originally posted by @mariusa in #28 (comment)

post 2.0 feature: smarter close

Desired UX:
As a user visiting a site, I want to

  • be able to close an announcement and never see that again (in that browsing session or never?)
  • see multiple announcements if more are published, even though I closed others

To make this possible, I propose for h-bar

  1. When close is clicked, save in sessionStorage or localStorage an md5 hash of that announcement as being closed
  2. When initialized with multiple announcements, skip those already closed

This behavior could be enabled when passed a storage option, which developer can set to either sessionStorage or localStorage.

What do you think?

Make the default banner separate class

The original styling of the banner is nice, but was closely linked to the main hBar instance.

  • move the default ordinal banner to split class
  • include the default styling with this
  • make it a separate import when using in web

More Themes that are usable

Feature/Improvement

Currently only have a blue and gray theme set for the banner styling. It is customizable and could have more added.

Also make the custom theme styling variable in the init() function more practical.

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.