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

@myuw-web-components/myuw-profile

v1.7.0

Published

Web component that provides an avatar button and profile menu

Downloads

2,291

Readme

myuw-profile

Getting Started

Import and include the component as follows, but note that it will not display by default, until initialized through its event API!

<!-- import the module -->
<script type="module" src="https://unpkg.com/@myuw-web-components/myuw-profile@latest?module"></script>

<!-- fallback for browsers without ES2015 module support -->
<script nomodule src="https://unpkg.com/@myuw-web-components/myuw-profile@latest"></script>

<!-- initialize -->
<script>
  customElements
    .whenDefined('myuw-profile')
    .then(() => document.dispatchEvent(new CustomEvent('myuw-login', { detail: {} })))
  ;
</script

<myuw-profile
  login-url=""
  logout-url=""
  background-color=""
></myuw-profile>

Note: The evergreen "latest" version can be used for convenience, but in production settings it is recommended to use the latest release version specifically, and upgrade only after testing!

Displaying the component

Because it has multiple states depending on whether there is an active session, all elements of the profile component are hidden by default. The component listens for a CustomEvent called "myuw-login" and its state is dependent on the data you pass when you dispatch that event:

/*
    Notes about configuring the event:
    - The event MUST contain a "detail" object. The contents of the detail object determine what the component will display:
        - An empty "detail" object ( detail: {} ) will result in the login button being displayed
        - An empty "person" object ( person: {} ) will result in a generic session being displayed (using the person icon). This should only be used when the session doesn't provide a user's name, username, email, etc.
        - A person object containing a "firstName" ( person: {firstName: "Name"} ) will result in the full session display
    - The "bubbles" property is optional unless you're dispatching the event from an element/scope other than "document"
*/
var customEvent = new CustomEvent('myuw-login', {
  bubbles: true, // optional
  detail: { // required always
    person: { // required for generic session display
      "firstName": "User" // required for full session display
    }
  }
});
// Dispatch the event
document.dispatchEvent(customEvent);

Initial page load

If you want the component to show something on the initial page load (and not be hidden), make sure to dispatch the "myuw-login" event after all web components are loaded and upgraded (i.e. ready to be interacted with). The webcomponentsjs polyfill provides and event you can hook into:

document.addEventListener('WebComponentsReady', function() {
    var customEvent = new CustomEvent('myuw-login', {
        // Configure the event data to display what you want
    });
    // Dispatch the event
    document.dispatchEvent(customEvent);
});

Configurable properties

  • Login URL (login-url): The URL to redirect users to on login
  • Logout URL (logout-url): The Logout URL to redirect users to on logout
  • Background color (background-color): Use this to dynamically set the background color of the profile menu button

Slots

  • Profile Navigation Item (nav-item): Add a custom item to the profile button's navigation menu, this slot expects an <a> tag

CSS Variables

  • --myuw-profile-font: Set the font stack for this component
  • --myuw-profile-login-color: Set the font color of the "Login" button
  • --myuw-profile-background-color: Set the background color of the circular menu button
  • --myuw-menu-color: The text color of links/buttons in the profile menu

For more information about CSS variables and how they work with MyUW Web Components, reference the styles component

Cross-browser testing provided by:

Releasing

Update version using npm version with appropriate selection: patch, minor, or major. Deploy npm package to the world using npm publish (if you don't have publish rights contact authors). Push git changes to the github via git push origin master.