V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
ClassicOldSong
V2EX  ›  分享创造

写了个新前端 UI 库玩具

  •  
  •   ClassicOldSong ·
    ClassicOldSong · 2021-10-30 16:11:10 +08:00 via iPhone · 2426 次点击
    这是一个创建于 881 天前的主题,其中的信息可能已经有所发展或是发生改变。
    更多是一个技术验证,不过看起来可用性也还是有一些的

    不需要编译,在原生 JS 语义的范围内我觉得能做成这样已经挺极限了

    NPM: https://www.npmjs.com/package/singui

    GitHub: https://github.com/ClassicOldSong/SingUI

    在线体验(也是暂时的使用文档):
    https://stackblitz.com/edit/singui-demo?file=index.js
    6 条回复    2021-10-31 13:52:49 +08:00
    Cbdy
        1
    Cbdy  
       2021-10-30 16:25:14 +08:00
    js 还是用 template literals 弄 dsl 吧,像 vue 、htm 、emotion 做得那样
    ClassicOldSong
        2
    ClassicOldSong  
    OP
       2021-10-30 16:42:51 +08:00 via iPhone
    @Cbdy 原本就是想看看纯 js 的极限在什么地方
    另外 template literal 的话势必涉及到一定程度的解析编译,也逃不过正则,我希望这个库能够运行在一些非常极端的条件下比如没有正则的单片机 js runtime 下,所以就变成了这个样子
    lujjjh
        3
    lujjjh  
       2021-10-30 17:12:26 +08:00 via iPhone
    ClassicOldSong
        4
    ClassicOldSong  
    OP
       2021-10-30 17:48:40 +08:00 via iPhone
    @lujjjh 挺好的,但 coffee 的语义和 js 还是不太一样。。。
    Cbdy
        5
    Cbdy  
       2021-10-31 09:02:13 +08:00
    @ClassicOldSong runtime 不够 aot 来凑
    ClassicOldSong
        6
    ClassicOldSong  
    OP
       2021-10-31 13:52:49 +08:00 via iPhone
    @Cbdy 其实挺够的
    没有 virtualdom ,整体体积只有 3kb ,指哪打哪也不需要 AOT 了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2479 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:47 · PVG 23:47 · LAX 08:47 · JFK 11:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.