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

prescrypto-elements

v2.0.3

Published

> A collection of [custom elements](https://web.dev/custom-elements-v1/) for implementing the functionality of prescrypto.com

Downloads

38

Readme

Prescrypto Elements

A collection of custom elements for implementing the functionality of prescrypto.com

Quick Start

CDN

<!-- 1. Load the PrescryptoElements library in the global scope  -->
<script src="https://unpkg.com/prescrypto-elements/dist/prescrypto-elements.umd.js"></script>

<!-- 2. Register a custom element, in this example the prescription history widget PrxPrescriptions -->
<script type="text/javascript">
  customElements.define("prx-prescriptions", PrescryptoElements.PrxPrescriptions);
</script>

<!-- 3. Add PrxPrescriptions with the required attributes to the HTML -->
<prx-prescriptions token="mi-token-prescrypto"></prx-prescriptions>

Libreria

  1. Install prescrypto-elements.

    # NPM
    npm install prescrypto-elements --save
    
    # Yarn
    yarn add prescrypto-elements
  2. Add an element to append PrxPrescriptions to.

    <body>
      <div id="prx-app"></div>
    </body>
  3. Import and register the custom element.

    import { PrxPrescriptions } from "prescrypto-elements";
    
    // Must run in the browser so the customElements method is available
    customElements.define("prx-prescriptions", PrxPrescriptions);
    
    // Create an instance of the custom element with the JavaScript API
    const prx = new PrxPrescriptions({ token: "mi-token-prescrypto" });
    
    // Add the element to the DOM
    document.getElementById("prx-app").appendChild(prx);

CSS

Prescrypto's custom elements are encapsulated in Shadow DOM. Due to this reason, you can not apply styles with .class o #id, instead you must use ::part(). Below you can see an example of the DOM nodes used to render PrxPrescriptions. Note the part attributes.

<table part="table">
  <thead part="thead">
    <tr part="tr trhead">
      <th part="th">ID</th>
      <th part="th">Patient</th>
      <th part="th">Email</th>
      <th part="th">Diagnosis</th>
      <th part="th">Date</th>
    </tr>
  </thead>
  <tbody part="tbody">
    <tr part="tr trbody">
      <td part="td td-id">{{ id }}</td>
      <td part="td td-name">{{ patient.name }}</td>
      <td part="td td-email">{{ patient.email }}</td>
      <td part="td td-diagnosis">{{ diagnosis }}</td>
      <td part="td td-creater">{{ created_at }}</td>
    </tr>
  </tbody>
</table>

To style the PrxPrescriptions component, those parts can be addressed via pseudo-selectors:

prx-prescriptions {
  font-family: "Roboto", sans-serif;
  font-size: 14px;
}

/* Styles for the <table> element */
prx-prescriptions::part(table) {
  border-collapse: collapse;
  text-overflow: ellipsis;
}

/* Styles for the <tr> element */
prx-prescriptions::part(tr) {
  white-space: nowrap;
}

/* Styles for the <thead> element */
prx-prescriptions::part(thead) {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  color: #627282;
  text-transform: uppercase;
  text-align: left;
}

/* Styles for the <th> element */
prx-prescriptions::part(th) {
  padding: 13px;
}

/* Styles for the <tr> element inside of <thead> */
prx-prescriptions::part(trhead) {
  border-bottom: 1px solid #edeff2;
}

/* Styles for the <tr> element inside of <tbhody> */
prx-prescriptions::part(trbody) {
  border-bottom: 1px solid #dcdfe3;
}

/* Styles for the <td> element */
prx-prescriptions::part(td) {
  color: #1b2734;
  line-height: 1.5;
  padding: 13px;
}

/* Style for the <td> with the id */
prx-prescriptions::part(td-id) {
  font-weight: 700;
}

/* Style for the <td> with the name */
prx-prescriptions::part(td-name) {
  font-weight: 700;
}