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

@web-package/react-widgets

v1.0.0-beta6

Published

This is package that provides templates that can significantly reduce CSS development works in a react development environment.

Downloads

432

Readme

Introduction

This package provides templates that significantly reduce CSS development work in a React environment, while enhancing readability and maintainability by consolidating style definitions. It fosters a more suitable development environment for Declarative UI. Additionally, it includes widgets designed to improve performance.

[!NOTE] Other widgets will be added sequentially in the README.md, and detailed usage will be covered through the related website once this package is officially released.

Consider integrating not only business logic but also design logic into script code, See Also, If you want the change-log by version for this package. refer to Change Log for details.

return <Box backgroundColor="red">Hello, World</Box>
return (
    <Scrollable.Horizontal>
        <Row gap="5px" padding="15px">...[children]</Row>
    </Scrollable.Horizontal>
)

Preview

The image below is a simple use gif of Quark Icons and a website created using @web-package/react-widgets and its extension, @web-package/react-widget-router.

preview

Usage

How to make responsive animated size?

Interestingly, even when wrapped with this widget, it does not impact the layout calculations of existing child elements. This is because the React widget package is designed to assist with layout calculations while striving to minimize any impact on the existing layout.

return (
    <AnimatedSize duration="0.3s">
        <Box>Hello, World 1</Box>
        <Box>Hello, World 2</Box> <!-- Dynamic inserted -->
        <Box>Hello, World 3</Box> <!-- Dynamic inserted -->
    </AnimatedSize>
)

Simple Preview

preview

How to make responsive folding animation?

You can be using the AnimatedFoldable.Vertical or AnimatedFoldable.Horizontal widgets to resolve it.

function ExampleComponent() {
    const [visible, setVisible] = useState(true);

    return (<>
        <button onClick={() => setVisible(!visible)}>Fold</button>
        { /* or using AnimatedFoldable.Vertical widget */ }
        <AnimatedFoldable.Horizontal visible={visible} duration="0.3s">
            <Row>
                <Box>Hello, World 1</Box>
                <Box>Hello, World 2</Box>
                <Box>Hello, World 3</Box>
            </Row>
        </AnimatedFoldable.Horizontal>
    </>)
}

Simple Preview

preview

How to animate child component changes?

If you want to animate dynamic changes in a child component (e.g. when transitioning out of a loading screen or in other similar cases), you can easily achieve this by simply using the AnimatedTransition widget.

See Also, You don't need to forward the value property value by unconditionally, but it helps define more clearly whether the child component state has changed.

export default function ExampleComponent() {
    const [count, setCount] = useState(0);

    // You can be using like this:
    // 
    // { // when using CSS animation
    //     fadeIn: "keyframe-name"
    //     fadeOut: "keyframe-name"
    // }
    return (
        <Column size="100%">
            <button onClick={() => setCount(count + 1)}>Count Up</button>
            <AnimatedTransition value={count} animation={{
                duration: "0.3s",
                fadeIn:  {from: {opacity: 0}, to: {opacity: 1}},
                fadeOut: {from: {opacity: 1}, to: {opacity: 0}}
            }}>
                <Box>Hello, World! {count}</Box>
            </AnimatedTransition>
        </Column>
    )
}

How to make Tab Navigation?

You can be using the TabNavigation.Vertical or TabNavigation.Horizontal widgets to resolve it.

export default function ExampleComponent() {
    const [index, setIndex] = useState(0);

    return (
        <TabNavigation.Horizontal index={index}  gap="15px" duration="0.5s">
            <h1 onClick={() => setIndex(0)}>Item 1</h1>
            <h1 onClick={() => setIndex(1)}>Item 2</h1>
            <h1 onClick={() => setIndex(2)}>Item 3</h1>
        </TabNavigation.Horizontal>
    )
}

Simple Preview

ezgif-6-50460d4d25

How to make responsive grid?

You can be using the ConstraintBuilder with Grid widgets to resolve it.

return (
    <ConstraintBuilder<number>
        constraints={[
            new Constraint(1000, Infinity, 3),
            new Constraint(600, 1000, 2),
            new Constraint(-Infinity, 600, 1)
        ]}
        /* You need to set this option accordingly according to the situation. */
        usememo={true}
        builder={(value: number) => {
            return (
                <Grid gap="5px" rowCount={value}>
                    <Text>1</Text>
                    <Text maxLine={1}>2</Text>
                    <Text type={TextType.h1} maxLine={1}>3</Text>
                    <Text type={TextType.h2} maxLine={2}>4</Text>
                    <Text type={TextType.h3} maxLine={3}>5</Text>
                </Grid>
            );
        }
    } />
)