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

@automatication/uxp-optimized

v2.0.5

Published

Library of react components optimized for Adobe's Unified Extensibility Platform

Downloads

6

Readme

Uxp Optimized

Introduction

Uxp Optimized is a library of browser compatible react components specifically optimized for Adobe's Unified Extensibility Platform.

Installation

npm install @adobe/uxp-optimized

or

yarn add @adobe/uxp-optimized

Virtualizer

A react virtualizer for efficiently rendering long lists of items. Similar to react-virtualized.

Usage

Virtualizer API

import Virtualizer from "@adobe/uxp-optimized/Virtualizer";

//  1. Create your items.
let items = [
    { key: "a", type: "comment", text: "Comment 1"},
    { key: "b", type: "comment", text: "Comment 2"},
    { key: "c", type: "image", image: "./path/to/image.png"},
    ...
];

//  2. Create the Virtualizer
return <Virtualizer
    items={items}
    itemKey="key"
    itemType="type"
    style={{ width: 500, height: 500}}
>
{
    //  3. Provide a function to convert items to react components.
    item => item.type === "comment" ? <div class="comment">{item.text}</div> : <img src={item.image}></img>;
}
</Virtualizer>

Custom CSS Properties

See the FlowLayout sample.

.MyVirtualizer {
    /* The vertical gap to add between horizontal rows, default = 0px */
    --row-gap: 20px;
    /* The horizontal gap to add between flex or column layout items, default = 0px */
    --column-gap: 20px;
}

.MyVirtualItem {
    /* Enables column width sizing. Use "auto" or an integer value. */
    --column-count-self: auto | number;
    /* If using "auto" above, then provide this or both min-width and max-width */
    --optimum-width: 100px;
}

Samples

Basic Flow Layout Sample

Progressive Css Layout Sample

React Hooks

useSize

A hook which will call a function every time an elements size changes on UXP or web.

import { useSize } from "@adobe/uxp-optimized/react";

function Growable() {
    let ref = useRef<HTMLDivElement>(null);
    useSize(ref, (element) => {
        console.log("Resized", element.clientWidth, element.clientHeight);
    });
    return <div ref={ref}></div>;
}

Development

Installation

git clone https://github.com/adobe/uxp-optimized.git
cd uxp-optimized
yarn install

Testing in browser

yarn watch_sample

Open http://localhost:1234 in your browser.

Note: The browser must currently support ResizeObserver api.

Testing on UXP

Install torq-native in a peer directory and then run:

./watch.sh

This should launch the sample in the UXP demo as a plugin.

Performance Tips for UXP

  • Minimize number of elements rendered per virtual item.
  • All virtual items with the same html structure should share the same "itemType".
    • Items are only recycled within the same "itemType".
  • Prefer to use display: none; instead of visibility: hidden; for invisible elements.
    • display: none means native elements don't have to be created.
    • We don't want to pay a cost for elements that only might become visible.

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the MIT License. See LICENSE for more information.