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

sugar-reactive-js

v1.3.4

Published

提供简单的响应式UI能力

Downloads

48

Readme

sugar-js

This is a library that provides responsive capabilities

Install

npm install sugar-reactive-js

Use

    <div id="app">

        <div class="nav">
            <div class="web_name">
                <img src="//store.44finefood.com/logo/2022-04-27/306EFED3C8A8.png" class="headling_logo" alt="">
            </div>
            <img src="https://666.44finefood.com/Content/images/menu.svg" class="menu" @click="open" alt=""/>
        </div>
    
        <div class="article_body">
            <div class="title">
                {{state.title}}
            </div>
            <div class="content" s-html="state.content" ref="htmlRef">
            </div>
        </div>
    
        <div class="article_join">
            <div class="item" s-for="(item,index) in list" :style="index === (list.length - 1) ? 'border:0' : ''">
                <div class="image_box">
                    <img :src="item.cover" @click="showImage(item)"/>
                </div>
                <div class="label_box">
                    {{item.title}}
                </div>
            </div>
        </div>
    
        <sugar-dialog :model="active" @close="close" :instance="htmlRef">
            <div class="menu_fixed_box">
    
            </div>
        </sugar-dialog>
    
        <sugar-dialog :model="showImageActive" @close="closeImage">
            <img :src="popImage" style="width: 100%;height: auto"/>
        </sugar-dialog>
    
    </div>


    <script>


        const {
            makeSugar,
            onMounted,
            ref,
            instance,
            sugarUI,
            useState,
            useEffect
        } = SUGAR;
    
        var sugar = makeSugar({
            bulk() {
    
                const [state, setState] = useState({
                    name: 0,
                    title: '狗狗因為太害怕人類,被安排于兩天后安樂死,幸好她出現了..',
                    content: `<p>自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業自曝遭富婆大額打賞!TVB知名男星內地連續直播12小時!被贊太敬業<span id="vft" data-wordc="231"></span></p><p style="font-weight: 600; color: #CC6633;font-size:15px !important ">
                    版權所有,禁止轉載。 違者必究法律責任。
                </p>`
                });
    
                const [list, setList] = useState([]);
    
                const [active, setActive] = useState(false);
    
                const htmlRef = instance(null);
    
                const [showImageActive, setShowImageActive] = useState(false);
    
                const [popImage, setPopImage] = useState('');
    
                function close() {
                    setActive(false);
                }
    
                function open() {
                    setActive(true);
                }
    
                function closeImage() {
                    setShowImageActive(false);
                }
    
                function showImage(item) {
                    setPopImage(item.cover);
                    setShowImageActive(true);
                }
    
                onMounted(() => {
                    setList([{
                        title: '你要悄悄的變好,然後驚豔所有人:真正厲害的人,會懂得「蘑菇定律」!',
                        cover: '//cdn.supertime01.com/thumb.ashx?path=%2fdpxs%2f20240520%2f2DA622C0761Ew800h1200.Jpeg&width=150&height=200'
                    }, {
                        title: '#耽美 釣系yyds!汪嘰的雅正徹底離家出走了',
                        cover: '//cdn.sweetastes.com/thumb.ashx?path=%2fdpxs%2f20221007%2f6F15A9339A07w300h400.Jpeg&width=150&height=200'
                    }]);
                });
    
                useEffect(() => {
                    console.log('检测到了', active.value);
                }, [active]);
    
                return {
                    state,
                    active,
                    list,
                    close,
                    open,
                    htmlRef,
                    showImageActive,
                    closeImage,
                    popImage,
                    showImage
                };
            }
        });
    
        sugar.install(sugarUI);
    
        sugar.mount('#app');
    
    
    </script>

SSR

    createSSRApp({
        render: `<div>
                <div @click="change" :style="'font-size:' + state.fontSize + 'px'">{{state.name}}</div>
                <div s-for="(item,index) in state.list">{{index}}</div>
                </div>`,
        bulk: () => {
                    const [state, setState] = useState({
                        name: '张三',
                        list: [{}, {}, {}],
                        fontSize: 14
                    });
        
                    function change() {
                        setState({
                            ...state.value,
                            fontSize: state.value.fontSize + 1
                        })
                    }
                    return {
                        state,
                        change
                    };
                }
    });