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

@netology-group/wc-user-list

v0.8.0

Published

`user-list` web component

Downloads

3

Readme

<user-list>

downloads

user-list is an element for displaying a list of users with their avatars and online statuses that provides useful filtering, sorting and grouping options.

Installation

npm install --save netology-group/wc-user-list

Example

HTML:

<user-list
  id="list1"
  me="3"
  melead
  canblock
  withfilter
  sortby="online:desc,name:asc,blocked:desc"
  groupby="role"
></user-list>

You need to pass array of users for list:

var userList1 = document.getElementById('list1')

userList1.users = [
  {
    id: 1,
    name: 'Calhoun Beer',
    avatar: 'https://robohash.org/nihilveritatisfugit.png?size=64x64&set=set1',
    online: false,
    role: 'user',
    blocked: false
  },
  {
    id: 2,
    name: 'Oneida Ivimey',
    avatar: 'https://robohash.org/quisetofficia.png?size=64x64&set=set1',
    online: false,
    role: 'user',
    blocked: true
  },
  {
    id: 3,
    name: 'Sheila MacCombe',
    avatar: 'https://robohash.org/consequaturnihildolores.png?size=64x64&set=set1',
    online: false,
    role: 'user',
    blocked: true
  }
]

Using in project

To start using user-list you need to add next line in your project root.

import '@netology-group/wc-user-list/dist/user-list'

Also you need to add webcomponents-bundle polyfill and custom-elements-es5-adapter (see webcomponentsjs).

<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.0.2/webcomponents-bundle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.0.2/custom-elements-es5-adapter.js"></script>

Build

You may want to build your own custom user-list-like element. Here's how:

import {
  UserList,
  withStyles,
  withFilter,
  withSort,
  withGroup
} from '@netology-group/wc-user-list'

// custom styles
const css = `...`
// custom map of strings for grouping
const withGroupConfig = {
  mapping: {
    admin: 'Admins',
    moderator: 'Moderators',
    presenter: 'Presenters',
    user: 'Users'
  }
}

window.customElements.define('custom-user-list', withGroup(withSort(withFilter(withStyles(UserList, css))), withGroupConfig))

Demo

npm start

User object

Example:

{
  id: 1,
  name: 'Calhoun Beer',
  avatar: 'https://robohash.org/nihilveritatisfugit.png?size=64x64&set=set1',
  online: false,
  role: 'user',
  blocked: false
}

| Property | Type | Required | | --- | --- | --- | | id | Number | yes | | name | String | yes | | avatar | String | yes | | online | Boolean | no | | blocked | Boolean | yes |

API

Attributes and properties:

| Name | Kind | Type | Description | | --- | --- | --- | --- | | users | property | Array | Array of users | | me | attribute | Number | Highlight user with specified id | | melead | attribute | Boolean | Show highlighted user on top of list | | canblock | attribute | Boolean | When set, "lock" action is available | | withfilter | attribute | Boolean | Show input field for filtering users by name | | sortby | attribute | String | Allows to sort users in list by one or many properties with ordering | | groupby | attribute | String | Allows to group users by value of specified key in user object |

sortby format:

  • attribute not set - without sorting
  • sortby="online,name,blocked" - sort by key online, then by key name and finally by key blocked (default order is desc)
  • sortby="online,name:asc,blocked" - sort by key online, then by key name with order asc and finally by key blocked

Events:

| Name | Example | Description | | --- | --- | --- | | toggle-user-lock | {detail: {id: 2}} | Dispatched when user click on "lock" icon. id - id of user to witch the "lock" action was applied |