npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@prokomssp/fantdu

v1.9.2

Published

Fant du webcomponent module

Downloads

17

Readme

#Fant du

Native webcomponent of the "Fant-du" module.

Installation

Paste in:

registry=https://prokom.myget.org/F/sspmodules/auth/a2fedf63-3d19-4430-aa16-db322de4867b/npm/

Run

npm i fantdu -S

Include the script into your build system.

Grunt:

Include this into under your concat config.

concat:{
    dist : {
        src:[
            "node_modules/fantdu/dist/fantdu.min.js"
        ]
    }
}

Webpack:

TO BE ADDED....

Usage

<fant-du client="kommuneNavn"></fant-du> 

Call this script on the main page (Layout in epi)

window.addEventListener('load', function (e) {
    FantDu.startTrace("traceId here", "client id (same as client in above)", e);
});

Options

| Attribute | Description | Optional | |---|---|---| | client | Client id e.g "Kristiansand" | No | | traceId | Trace id | yes | | url | Override the fetch url | yes | | yes-color | Override the yes button color | yes | | title-text | Override the title text | yes | | placeholder-text | Override the placeholder text | yes | | second-title-text | Override the title after pressing yes/no | yes | | post-message | Override the post message after submit | yes | | css | Full custom css override | yes | | skip-yes-no | Skip directly to confirmation with answer no. This is useful for 404 sites. | yes | | error-title | Set custom error title | yes | | error-message | Set custom error message | yes | | onYes | Name of function to call after yes is clicked | yes | | onNo | Name of function to call after no is clicked | yes | | onSubmitSuccess | Name of function to call after a successful submit | yes | | onSubmitFail | Name of function to call after a failed submit | yes | | hide-receipt-text | Hide the receipt text after submit | yes | | pre-textarea-text | Text over the text area | yes | | post-textarea-text | Text under the text area | yes |

Example

<fant-du
    client="Kristiansand"
    traceId="cookie id here" 
    url="custom ajax url"
    yes-color="blue"
    no-color="orange"
    title-text="Hei du, fant du eller?"
    placeholder-text="Dette er custom placeholder tekst"
    second-title-text="Hva forsøkte du å finne?"
    post-message="Takk!"
    skip-yes-no="false"
    error-title="custom feil"
    error-message="custom feil melding"
    css="
        .fant-du__buttons{
            border-radius:0;
        }
    "
    onYes="yesCb"
    onNo="noCb"
    onSubmitSuccess="submitSuccess"
    onSubmitFail="submitFail"
    hide-receipt-text="true"
    pre-textarea-text="pre text"
    post-textarea-text="post text"
>  
</fant-du>    

Example of callbacks


// Make sure these functions are globally accessible where fant-du is used.

function yesCb(){
    console.log("Yes callback");
}

function noCb(){
    console.log("No callback");
}

//Return argument is the result sent to the server
function submitSuccess(result){
    console.log("Result submitted: ", result);
}

//Return argument is the error message from the server
function submitFail(error){
    console.log("Fail: ", error);
}

DOM manipulation example

You can also edit the attributes using javascript

const fantdu = document.querySelector("fant-du");
const myCss = `
    .fant-du__buttons{
        border-radius:0;
    }
`;
fantdu.setAttribute("css",myCss);

Quirks

  • Native shadow-dom encapsulation is not supported yet in Edge, ShadyCSS polyfill is used to simulate CSS encapsulation under IE11/Edge.
  • Included webcomponents, fetch and promise polyfill for IE11.

Full status of development can be found here: https://www.webcomponents.org/

Browser support

  • All modern browsers
  • IE 11

If you need lower IE support, use the older version.