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

@xnocss/all

v0.0.5

Published

short class online parse

Downloads

13

Readme

XClass

中文简介

Real time parse short class to css,custom rule to parse text.

This tool supports all frameworks, uses native js to operate dom, and is not associated with any framework.


Brief introduction

The reason for the tool is that I am fed up with the class name, Tailwindcss and windcss feel too heavyweight, I am a fan of antfu, and I have been watching his live broadcast, because I have learned about antfu's unocss, and it feels so cool. However, due to the company's project, the Node version is only 12. For some reasons, it cannot be upgraded, and there are many colleagues who develop together. It is impossible to mobilize all colleagues to upgrade Node together. The minimum unocss requires node version 16, so this tool was produced. , it is parsed in real time. Since I wrote it myself, I can customize some things I need. Of course, in terms of performance, it is definitely not as good as other compiled frameworks, but it is not slow, output in milliseconds. For ordinary projects, it is completely sufficient. Originally, I just wanted to write a vue component for my own use, but gradually found that it can support all of them during the optimization process, so why not?

Function introduction

  • [X] Support custom rule parsing style
  • [X] Support custom pseudo-class prefixes, such as hover, after
  • [X] debug mode, which supports debugging all the parsed content on a div, and debugging the parsed content of a short class.
  • [X] Cache mode. All short classes will be cached after parsing, and will be directly obtained next time. Of course, non-cache mode can also be supported, and version can also be set. Version upgrade will delete other version caches, and cache time can be set
  • [X] Custom colors, such as bg-primary, some frames used in the project, can be used directly after configuration
  • [X] Immediate processing. After setting on a div, the current rule will be parsed immediately and then the dom will be inserted
  • [X] Responsive
  • [X] Native framework support
  • [X] Custom collection class

Use Instance

安装

npm install -S xclass-vue
or
npm install -S xclass-all

Vue-Example:

import XClassVue from 'xclass-vue'
let app = createApp(App)
app.use(XClassVue,{...options})
<!--Use v-xclass attr recognition,The tag of v-xclass will be parsed-->
<div v-xclass class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>

Native:

import XClassAll from 'xclass-all'
XClassAll({...options})
<!--Use xclass attr recognition,The tag of xclass will be parsed-->
<div xclass class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>

结果:

options config:

{
    //Custom colors, when used such as bg-primary, are translated into background:#936ee6;
    colors:{
        primary:'#936ee6'
    },
    //Custom interception rules, such as W-10, will be intercepted and translated into the following rules width:10px;
    rules:[
        [
            /^(?:size-)?(min-|max-)?([wh])-?(.+)$/,
            (rule,text) => {
                let arr = rule.exec(text)
                let str = `${arr[1] || ''}${arr[2] == 'w'?'width':'height'}:${handleSize(arr[3])};`
                return str 
            }
        ]
    ],
    //Whether it is a new rule, overwriting the out-of-the-box rule
    ruleNew:true,
    // Pseudo-class definitions, prefixed with hover: e.g. hover:f-color-white will be translated as div:hover{color:white;}
    pseudoClassDefine:{
        'hover:':':hover',
        'first:':':first-of-type'
    },
    // Reactive definitions, with md: as a prefix, e.g. md:hover:f-color-white will be translated as @media screen and (max-width:500px){div:hover{color:white;}}
    responsiveDefine:{
        'md:':'@media screen and (max-width:500px)'
    },
    //Collection short class definition, custom will be escaped todiv{width:100px;height:100px;border-radius:16px;}
    shortDefine:{
        'custom':'w-100 h-100 radius-16'
    },
    //Cache time, -1 is permanent, unit ms
    cacheExpire:-1,
    //Version number, with clearing the cache, if you upgrade to 1.0.1, the 1.0.0 version cache will be cleared
    version:'1.0.0',
    //debug
    debug:false,
    // Whether to clear the cache each time
    clearCache:false
}

Label suffix

test

<!-- After enabling debug mode -->
<!-- Suffixes containing test will be printed, and all class parsing results will be printed -->
<div xclass:test class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>
<!-- The suffix containing test will be printed, and only the W-100 padding-12 parsing result will be printed -->
<div xclass:test="w-100 padding-12" class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>

real

<!-- DOMs containing real will be parsed immediately, and the rest of the DOMs will only be parsed in the window -->
<div xclass.real class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>
<!-- Can be used together -->
<div xclass:test.real="w-100 padding-12" class="w-100 padding-12 bg-primary hover:bg-warning hover:f-color-white flex align-center justify-center radius-50 cursor-pointer">example</div>