This commit is contained in:
2026-11-29 07:30:49 +08:00
parent ea56e4cabd
commit 0026089761
71 changed files with 8054 additions and 1428 deletions
-37
View File
@@ -1,37 +0,0 @@
# 常用包
ARG node_modules = "typescript tslint-to-eslint-config prettier"
# 以 -g 方式安装
RUN su node -c "umask 0002 && npm install -g ${node_modules}" \
&& npm cache clean --force > /dev/null 2>&1
# 工作目录
WORKDIR /workspace
# 挂载卷
VOLUME /workspace
# 复制程序代码
COPY . .
# 暴露常用端口,http,vite
EXPOSE 8080 5173
# 默认启用命令行
CMD ["bash"]
# 复制宿主机的时区,覆盖容器的时区,避免时间不同步问题,无额外依赖
RUN ln -sf /usr/share/zoneinfo/PRC /etc/localtime
# 安装核心工具集和 CA 证书
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
wget \
vim \
git \
zsh && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
-1
View File
@@ -1 +0,0 @@
npm install
-12
View File
@@ -1,12 +0,0 @@
{
"name": "Node-Ts-Git",
"image": "mcr.microsoft.com/devcontainers/typescript-node:5-24-trixie",
"updateContentCommand": "bash ./.devcontainer/build.sh",
"postCreateCommand": "bash ./.devcontainer/setup.sh",
"forwardPorts": [3000, 5173, 8080],
"customizations": {
"vscode": {
"extensions": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
}
}
-5
View File
@@ -1,5 +0,0 @@
node_modules="typescript tslint-to-eslint-config prettier"
sudo chown -R node ${containerWorkspaceFolder}/node_modules
sudo chown -R node ${containerWorkspaceFolder}/build
[ -f package.json ]
npm install -g ${node_modules}"
-1
View File
@@ -1 +0,0 @@
registry = https://registry.npmmirror.com/
@@ -1,26 +0,0 @@
# 通用部分
盐,葡萄糖,变性淀粉。
盐是用来打开受体,葡萄糖是用来中和咸味,
味精,呈味核苷酸二钠。增鲜二件套。
乙基麦芽酚。去腥一件套。
# 深刻教训
你买了便宜的【透骨增项剂AAA】,配料表只写了【食用香精】,没具体写是哪一种香精。
回来是吃后,发现是【猪肉香精】,味道很臭,与你的原版黑鸭卤料味道不一样,导致整锅卤水发臭报废。
你自己调查黑鸭卤料的配方,发现是【牛肉香精】。
配料表的【香精部分】,没有写明白的一律不要买。
- 琥珀酸二钠,2g。
- 酵母抽取物,3g。
- 麦芽糊精,15g。
c
@@ -124,12 +124,19 @@
土地你是不可能有的,你能做的只有两个,加工与收割,而不是自己耗费大量资金去种植养殖。 土地你是不可能有的,你能做的只有两个,加工与收割,而不是自己耗费大量资金去种植养殖。
## 2.10 黑工是不是一个机会 ## 2.10 人的能力是有限的,必需进入知识的窄门
首先,无论哪个国家,底层都是经济困难的。 你知道有很多技术,都是能搞钱的,只是每一个技术,都要付出大量的时间和学习成本。
你去打工,收入增长了,但支出也增长了,每月也还是剩下 20% 的工钱。 你没有这么多时间和资源,去掌握全部,你意识到,你必须暂时放弃一些领域,才能让一个技能成功落地。
但是发达国家的钱,在穷国的购买力很强,利润来自汇率差,你需要把钱寄回。 入世,就是走出被庇护的打工人世界,在生存的逼迫下成为一个能独立生存的经济人。
## 2.11 人之所以碌碌无为核心原因就是脱离当下
有前景,并不会立即解决当下的问题,而且这个前景及其具有欺骗性,会让你牺牲当下的一切。
如果你已经牺牲了很多,你就有了很大的沉没成本,如果让你走另一条能立即解决当下问题,但需要从头开始的事,你会有很强的损失感,会选择熬下去。
要突破这个难关,确实需要你放下这个难以实现的前景,等当下问题解决了,再腾出小部分时间去推进。
对于能个体创业的
@@ -24,6 +24,8 @@
## 离岸金融,最初是为了规避通货膨胀,但也能规避纳税 ## 离岸金融,最初是为了规避通货膨胀,但也能规避纳税
## 人们选择这个货币,是因为这个货币不容易贬值 ## 人们选择这个货币,是因为这个货币不容易贬值
银行家会通过通货膨胀收割财富, 银行家会通过通货膨胀收割财富,
@@ -32,3 +34,42 @@
但是除了垄断,还有一些能收割的软措施,例如情绪收割。 但是除了垄断,还有一些能收割的软措施,例如情绪收割。
## 收割的核心筹码
收割者的核心筹码是,能力,资本,垄断,影响力,稀缺性,流量,情绪价值。
政府靠土地垄断,资本靠流量,情绪价值,能力。
被收割者,往往只拥有一样东西,廉价的,可被代替的时间。
收割的过程需要一个载体,那就是商品。
普通人想要避免被收割,只能拥有自己的生产资料,虽然不能让你当上收割者,但能让你少被收割,并蹭收割者的车。
蹭收割者的车,就是资本家吹什么,我们就跟什么。
要注意,能力不一定是稀缺的,如果这个能力不稀缺,但却是必须的,那你就要善于利用现成方案。
例如,编程,就不要去研发自己的框架了。
## 普通人不要做蒙眼者,根据现实的结果去反推,而不是根据网上的结果,那是资本家在塑造公共认知
做了一些事,发现不赚钱后,你就会对到底做哪些才能赚钱产生疑问,你甚至不会直接相信网上的虚假说法。
你不希望继续被网上的信息骗了,开始追求基于证据的判断,也就是根据别人的现实结果来判断,这件事到底能不能做。
你开始寻找已经致富的证据,于是你想到调查一下富人的一言一行,分析下他们正在做的都是什么。
当你再看到荒凉的普通人,你意识到如果一个活真的很赚钱,那么这个活一定有很多人都在做,因为这个活能养得起这么多人。
,例如卖水果的,油钱,风险,
## 销售是来钱最保险的方式
你搞生产,生产出来后,卖得出去才行,否则你就要自己承担生产成本。
我们一开始不能先求利润,而是必须先卖出去,薄利多销也要卖出去。
确保了销路,我们才能确保搞生产时,我们的生产的产品卖得出去。
##
@@ -46,7 +46,7 @@ D-异抗坏血酸为主,虽然也有很多其他的,但是这个就是维生
## 防腐剂 ## 防腐剂
肉桂酸钾,脱氢乙酸钠。
而传统的,山梨酸钾,苯甲酸钠,不适合高温食品,而且对酸碱度有较高要求,效果有限。 而传统的,山梨酸钾,苯甲酸钠,不适合高温食品,而且对酸碱度有较高要求,效果有限。
@@ -1,34 +1,8 @@
# Chapter 3 卤鸭 # Chapter 3 卤鸭
## 3.1 成品味道就是卤水味道稍微浓一点 ## 3.1 食材预处理
只要卤水的味道调好了,那么卤出来的货味道就好了。 ### 清洗与改刀
而调味,只需各种添加剂,其中有三样是必须的,肉宝王,乙基麦芽酚,壳香粉。
其他的添加剂,根据口味不同,按需添加。
烧烤味,是处于顶端的味道。
酱香味,仅次于烧烤味。
椒盐味,就是普通味,由多种粉混合而成,辣椒粉,孜然粉,胡椒粉,陈皮粉,话梅粉。
而金汤味,有点微酸,我觉得这个不是很好。
## 3.2 入味靠的是足够的盐度和冷泡
盐度,即溶液的浓度,能溶于水的物质都统称盐,因此盐度,不仅是食盐,其他的调味料也算盐。
卤水非必要不加热,加热的唯一目的,仅仅就是为了杀菌,如果加了防腐剂,同时又冷藏,你不加热杀菌都没问题。
加热会导致调味料的风味丢失,加热卤水是一个相当亏损的行为。
煮熟食材,不应该在卤水中煮熟,而是在普通水中焯熟,然后再放入冷卤水中浸泡。
残留疑问:所谓冷泡一定要冷藏4度吗,常温放凉泡可不可以?
## 3.3 食材清洗与改刀
清洗,就是剪油边,剪毛根,剪气管,捅鼻屎。 清洗,就是剪油边,剪毛根,剪气管,捅鼻屎。
@@ -36,11 +10,9 @@
无论哪一个部位,都过一遍上面的检查清单。 无论哪一个部位,都过一遍上面的检查清单。
## 3.4 焯水断生 ## 焯水断生
焯水的核心目的,是为了断生,断生即捞,去血水只是顺便的,千万不要搞错。 焯水的核心目的,是为了断生,后续的卤制,冷泡步骤仅仅只是入味而已。
所谓断生,就是意味着可以吃了,后续步骤仅仅只是入味而已。
火候有4个档次,大火,中火,小火,文火。 火候有4个档次,大火,中火,小火,文火。
@@ -64,7 +36,107 @@
时间过长,肉质都会发柴,皮烂。 时间过长,肉质都会发柴,皮烂。
## 3.5 上色 总之上面的数据仅仅是经验,具体还得看现场调节,总之就是断生即捞。
## 3.2 卤制与调味料
### 卤汤只负责熟透和提供基础味道
只要你试过几次,和别人卖的成品对比,你就会发现,卤汤永远不可能具备那种飘香上瘾的味道。
即使你加了科技进卤汤里,只要一加热,味道全部丧失。
你可以找那种,可选择加酱料的摊子,分开装,买回去后,看看两边的差异。
你发现,没有酱料的肉,就是基础的乙基麦芽酚的味道,和淡淡的香油味。
而酱汁才是核心的味道来源。
### 卤制时间
烧开后,下第一批货,鸭脖,计时15分钟。
下第二批货,鸭架,鸭头,鸭腿,鸭心,鸭脚,计时15分钟。
下第三批货,鸭翅,计时15分钟。
盖上盖子,焖泡30分钟。
### 盐度用量
首先声明一点,下面只是一些经验而已,无论如何标准化,最终到要以试味为主。
每斤水 18g 盐,每斤肉 7g 盐,只有盐度高了,盐才会渗透进肉里,肉才会有味道。
而乙基麦芽粉,肉宝王,卤肉增香膏,也有对应的量。
### 挂汁酱料,味道的核心
酱料是味道的核心,而汁能够挂上肉,不脱落下来,靠的就是粘稠度。
要增加酱料的浓稠度,就需要添加胶质,常见原料有黄原胶,琼脂,至于淀粉,需要控制好,不够简单易用。
酱料的成分,只能靠我们亲自品尝,倒推出来。
首先确定的有,乙基麦芽酚(去腥肉香),肉宝王(香料AAA是同一个味道)。
麻椒香精,辣椒香精,壳粉,是很好的上瘾科技,只是价格也贵了一倍。
飘香王,虽然没有味道,香味让人一闻就想吃。
那些便宜的鸭翅,只加了基础的酱香香精,这都是我亲自品尝试出来的。
保水剂,防腐剂,D异抗坏血酸钠(抗氧化发黑),这些还是需要加一点的,不加半天就发黑发酸。
## 3.3 卤汤防腐
### 3.3.1 烧开,油封,防腐剂,盐度,冷藏
卤汤腐败需要满足两个条件,第一,温度 4°-60°,第二,汤里有菌。
**烧开10分钟**,清除了汤里的现有菌,细菌在超过80°的水里10分钟就会被杀灭。
但每烧开一次,汤里的卤香味,复合香料味,就会损失一次,频繁烧开是很不划算的。
**油封**,阻止了空气中的细菌进入卤汤的难度,至少 2cm 厚,但保险起见 4cm 厚。
**盐度杀菌**,可以把第二天需要的盐,提前加入到卤汤中。
**防腐剂**,破坏细菌的繁殖环境,阻止细胞壁合成,专门对付残余的嗜热菌。
放进冰箱4°冷藏,大幅缓减了腐败速度,尤其是肉带进来的菌。
如果开店,卤货量大,卤汤多,那么这么多的卤汤都要放进冰箱是不现实的。
卤完货后,需要把卤汤烧开,擦干净,静置不动,只要汤里是无菌环境,就不会轻易发酸。
现实做法是多管齐下,就是油封,加盐,烧开,静置不动,你的卤汤第二天就不会发酸。
如果长时间不烧开,那就得冷冻起来了。
大体量的店,有冷库最好,要不然只能定时遥控烧开。
### 3.3.2 防腐剂选择
会腐败的不仅是肉,汤也会腐败,加量要考虑汤和肉。
不同的防腐剂,可使用的场景有区别。
每斤汤,肉桂酸钾 0.4g,脱氢乙酸钠 0.3g,乳酸链球菌素,D异抗坏血酸钠 0.5g,亚硝酸钠 0.6g。
每斤肉,肉桂酸钾 3g,乳酸链球菌素 0.0025g,D异抗坏血酸钠0.6g。
葡糖糖酸内酯,也可以防腐,原理是螯合金属离子,与细菌争夺金属离子,同时还能做凝固剂,本来一种添加剂就能同时充当多种功能。
不要用山梨酸钾,因为与D异抗坏血酸钠一起用,会产生微苦微涩口感,而且对 ph 要求高。
细菌会不会浮起来?不会,很多死菌会沉底。
防腐剂会浮在表面吗?不会,会均匀融于卤水。
## 3.4.3 上色
要红色,加红曲红,要黄色,加黄曲黄。 要红色,加红曲红,要黄色,加黄曲黄。
@@ -72,7 +144,7 @@
不用红曲红和红曲黄,上色是不可能的。 不用红曲红和红曲黄,上色是不可能的。
## 3.6 选桶 ## 3.4.4 选桶
如果要放进冰箱冷藏,最大选 45cm 直径的桶,大部分冰箱门的宽度也就 50cm,过大放不进去。 如果要放进冰箱冷藏,最大选 45cm 直径的桶,大部分冰箱门的宽度也就 50cm,过大放不进去。
@@ -135,5 +207,3 @@
对准内部鼻孔的位置冲水,水会从两个鼻孔出来。 对准内部鼻孔的位置冲水,水会从两个鼻孔出来。
洗干净之后,再从内部剪一刀脑壳,顶部掀开皮,剪一刀也是可以的,容易入味。 洗干净之后,再从内部剪一刀脑壳,顶部掀开皮,剪一刀也是可以的,容易入味。
@@ -0,0 +1,34 @@
# Chapter 6 黑鸭酱配方
## 起因
自从吃了黑鸭后,竟然觉得存在如此好吃的味道。不是一般的厉害。
于是想搞清楚黑鸭酱的配方。
## 甜辣风味核心
AI说,白糖/甜味剂(主甜),辣椒精/辣椒粉(辣),麻椒精/麻椒(麻),红曲米/老抽(上色),乙基麦芽酚增回味。
经亲自检验。
白糖/甜味剂(主甜),这个是对的,甜味剂是白糖的数十倍甜味,白糖只提供掩护。
辣椒精/辣椒粉(辣),麻椒精/麻椒(麻),这个是对的,只需一点,在上瘾的味道中添加,和其他味道中添加是不一样的效果。
红曲红/老抽(上色),这个是对的,胭脂红,红曲红,红区黄,无非就这几个,全是科技,那些什么糖色,黄栀子都是效果奇差的。
乙基麦芽酚,回味的味是肉香味,肌红蛋白与乙基麦芽酚反应,以此去腥,这个是厚肉内部肉香的基础。
## 复合酱香基底
AI说,甜面酱,耗油,黄豆酱,排骨酱,部分配方加生抽,卤香膏,是酱香味的来源。
经过亲自检验。
成品黄豆酱,确实有很浓的酱香味,但不知道去除调味料后的纯黄豆酱,味道怎么样。
成品耗油,一股鲜稠味,多了有点小臭,并不是核心味道来源,是来装饰主味道的。
@@ -0,0 +1,28 @@
## 养殖生蚝
在咸淡水内湾养殖。
## 古法蚝汁
顺着蚝缝撬开蚝壳。取出蚝肉,挑出破损变质的个体。
用清水洗净蚝肉,洗去表面泥沙,碎壳和粘液,清洗完的水静置沉淀,上层的澄清蚝水别丢。
将蚝水和耗肉,一起倒进锅里,补加清水没过蚝肉,保持持续翻滚状态,开始熬煮。
熬煮半个钟头以上,肉里的鲜味物质释放到汤里,等蚝肉收缩,汤色乳黄,就可以捞出蚝肉。
煮好的蚝汤,过滤2-3次,彻底去掉肉屑和杂质,得到透亮的稀蚝汁。
将稀蚝汁小火慢熬4-6小时,搅拌防糊底。
色泽从奶黄渐渐转成深褐色,当熬到适合的浓稠度,加入适量的食盐,白砂糖,味精等,最后加热10分钟。
冷却灭菌,装瓶即可。
## 现代化工合成
+124
View File
@@ -0,0 +1,124 @@
## 不采用任何语言的 enum 特性,彻底抛弃这一语言特性
本来使用 enum 就是为了限制值的选项,结果两个 enum 不存在任何子集关系。
```
enum Size {
XS = "xs",
}
enum ButtonSize {
XS = "xs",
}
assert.equal(Size.XS != ButtonSize.XS);
```
## 不采用 c++ 和 rust 语言的 union 特性,彻底抛弃这一语言特性
```
union Size {
xs:string,
// Could't write the fix value field.
// example: xs:string = "xs"
}
```
## 采用 ts 语言的 union type 特性,union 就应该是一个简单的,不统一类型的集合
```
type Size = "xs"| "sm" | undefind;
```
编译时可以确定大小,只需要取最大的那个即可。
可见这个类型会自动解值,
## 采用 rust 的借用检查,所有权,生命周期这些特性
## ts 的可选参数特性应该采用
```
type Size = "xs" | "md";
function size_recipe(size?:Size){}
// 注意,形参后面加?, 才可以省略,而不是下面这样。
type Size2 = "xs" | "md" | undefind;
// 这样是不可以省略的,undefined 只是其中一个选项而已。
function size_recipe(size:Size2){}
```
## 不采用 ts 对象特性
ts 的对象,必须要使用字段名访问,例如 obj.name ,且字段没有任何类型可言。
同名字段,不同类型,后面的可以覆盖前面的,最后导致类型变更,这导致编译时期无法确定大小。
我认为,每个字段都必须都有类型,字段可以是常量,string 类型常量, number 类型常量,他们的值是固定的。
这其实就是所谓的 class ,内部有一堆 static 常量,还有一些带类型的属性变量。
## 不允许 ts 的匿名类型
实战中,经常需要将多个函数的返回值,整合成一个类型。
ReturnType 是编译时动态推断的,改函数内的代码,不用修改返回的类型,非常好用。
但我希望强制起名,在函数圆括号后面,直接起一个名就好。
如果类型起了名字,那么直接用 {} & {} 字段扁平化 ,或者 A {a:B,c:C} 组成一个新的类型。
有些方法的泛型要传入一个类型,如果是匿名类型,且有一大堆函数,我们不可能一个个给它写完。
## 采用,ts 中的类型,其实都是一个类型集合
我发现,除了 TS ,其他语言的类型都是固定的。
TS 中的所有类型,其实都是 union type,我称呼这个为 “ union everywhere ”。
## 采用,模块使用双冒号::
成员变量访问使用点.语法。
类型声明使用单冒号: 。
数组成员访问,使用[key],或者[0] 。
这样的好处是,减少 AST 语义分析的难度。
试想一下,你发现一个点语法,难道你还要全文检索,这个到底是成员变量,还是子模块吗?
## 起名规则,采用 snake 命名更好,兼顾阅读美观,和避免与运算符混淆
snake 模式,极其容易看漏空格。
camel 模式,全大写的专业术语,会跟后一个单词拼接在一起。
短横线模式,容易误认为是运算符。
## ts 配置文件中的 path 是外部模块,算当前工程的一部分,而不是 devDep
path 是关于,什么属于当前源码的一部分,无关 dep 和 devDep。
但如果,你希望使用另一个项目作为 devDep,当作插件临时使用,那就不要写 path。
## 我制定的打包器项目结构
dist,作为编译输出目录 等价于。
index.js,作为入口文件名,不同语法的,会插入第二扩展名,例如,index.es.js。
这主要是防止增加文件复杂度,umd 并不属于 es 和 cjs 分类,没必要弄出一种 ujs 的新扩展名。
要是出现更多的情况要怎么办?给扫描器增加一大堆负担,babel 懂 ujs,cjs,mjs 这些格式吗。
你说防止语法检查器误改?确实 eslint 可能会破坏 umd 的书写语法。
声明文件,我自己创作的语言是强类型的,不需要这个声明文件。
但如如果是给 ts 搞,那就固定为 index.d.ts 。
+30
View File
@@ -0,0 +1,30 @@
## type
需要填 “module”,否则就是 cjs 。
## 永远不要使用 EsNext,它不断变化,除非你想体验新功能
不断变化,意味着,一个语法今天可用,明天不可用,并不是我们想要的只写一次,永远不用改。
你始终应该使用最后一个版本,或者固定一个版本。
## moduleResolution 定义接受的语法
在 es 标准中, 就是一个文件,就默认是一个 module,Resolution 就是如何解析读取文件。
这个就是 ts 编译器定义 “有效文件” 的,使用外部打包器,例如 Vite,就填 bundler,否则填 nodenext。
nodenext 就是接受一切语法的意思。
最后提醒一下,其他语言并不是都和 es一样,把每个文件都看作一个 module。
## module 定义本项目产物的输出语法
通常应该使用最后一个 esxxxx 版本,如果要为老项目增加新功能,就不要超过老项目的版本。
例如,一个老项目的 module 是 es2022,你写了一个插件,那么你插件的 module 不得超过es2022 。
## monorepo 目前只有一种方案, 就是 pnpm
试过了很多 npm, yarn, turborepo, bun, 都是不行 。
+69
View File
@@ -0,0 +1,69 @@
{
// 记住,【ts 库】,【ts + react 库】,【ts + react 应用】,是三个不同的配置。
// 其中【ts + react 应用】是一定要用 bundler 的,因为树摇很重要。
// 剩下两个,一般也有很多 ts 以外的文件,例如一大堆 css,svg,png文件。
"compilerOptions": {
// Option 1: If use Vite, set "bundler", let Vite to decision.
// Option 2: set "nodenext" to search and read all kinds of grammar file.
"moduleResolution": "nodenext",
// The write grammar for current project.
// "esxxxx" only can use with "moduleResolution":"bundler".
// this value must lower than moduleResolution, let current code can be resolution.
"module": "nodenext",
// The final complied output file grammar.
// Not influence the grammar you write code.
// Usually lower than newst version 4 year version for compatiblility.
"target": "es2022",
// If your code will run in browser, maybe you need this external API.
// If your code is pure backend, and not web server like Nextjs, you can delete this line.
// But node-web stack tech is all for web, you just set [ target, dom, dom.iterable ] enough.
"lib": ["es2022", "DOM", "DOM.Iterable"],
// Option 1: "rootDir":"." and "exclude":[] long list.
// Ts grammar will check vite.config.ts file outside the src folder.
// Option 2: "rootDir":"src"
// Ts grammar will ignore check vite.config.ts file that outside the src folder
// You will get error.
// I recommend use Option 1.
"rootDir": ".",
// If not use Vite, you use tsc, must specify this field.
"outDir": "./dist",
// package.json won't auto put the @types/node declare file in global scope.
// Ts grammar check will get error, "vite/client" is same.
"types": ["node", "vite/client"],
// Do not emit compiled output files, vite will take care of the that.
// if you not use vite, dist foloder is nothing.
"noEmit": true
// Vite will handle the resolution of the import paths.
},
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
"exclude": [
"node_modules",
"dist",
".turbo/**/*",
".cache/**/*",
".vite/**/*",
"vite.config.ts",
"*.config.ts",
"*.config.js",
"tsconfig.*.json",
"tsconfig.*",
"__tests__/**/*",
"test/**/*",
"tests/**/*",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.spec.ts",
"**/*.spec.tsx",
".storybook/**/*",
"stories/**/*",
"example/**/*",
"examples/**/*",
"scripts/**/*",
".env",
".env.*",
"public/**/*",
"docs/**/*",
"README.md",
"LICENSE"
]
}
+2209 -906
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"workspaces": [ "workspaces": [
"./packages/*", "packages/*",
"./apps/*" "apps/*"
] ]
} }
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+78
View File
@@ -0,0 +1,78 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
## React Compiler
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
Note: This will impact Vite dev & build performances.
You can also try [the experimental native React Compiler support in plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md#rust-react-compiler) by using `compiler: true` in the plugin options instead of using the Babel plugin.
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
You can also install [eslint-plugin-react-x](https://npmx.dev/package/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://npmx.dev/package/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
@@ -2,11 +2,12 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-project</title> <title>ui-gallery</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/gallery/main.tsx"></script> <script type="module" src="/src/main.tsx"></script>
</body> </body>
</html> </html>
+38
View File
@@ -0,0 +1,38 @@
{
"name": "@dg/ui-gallery",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.3.1",
"react-dom": "^19.3.1",
"@dg/ui-react": "workspace:*"
},
"devDependencies": {
"@babel/core": "^7.29.13",
"@eslint/js": "^10.0.1",
"@rolldown/plugin-babel": "^0.3.1",
"@types/babel__core": "^7.20.5",
"@types/node": "^26.6.6",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/devtools": "^0.8.3",
"@vitejs/devtools-rolldown": "^0.8.3",
"@vitejs/devtools-vite": "^0.8.3",
"@vitejs/plugin-react": "^6.3.0",
"babel-plugin-react-compiler": "^1.0.0",
"eslint": "^10.15.0",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.5.8",
"globals": "^17.14.0",
"typescript": "~6.0.3",
"typescript-eslint": "^8.73.0",
"vite": "^8.4.0"
}
}
+2427
View File
File diff suppressed because it is too large Load Diff
+18
View File
@@ -0,0 +1,18 @@
import { ButtonGallery } from "./gallery/button-gallery";
import { MenuGallery } from "./gallery/menu-gallery";
import { PopoverGallery } from "./gallery/popover-gallery";
function App() {
return (
<div className="app">
<Theme>
<ButtonGallery />
<PopoverGallery />
<MenuGallery />
</Theme>
</div>
);
}
export default App;
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

@@ -1,7 +1,6 @@
import { DownloadSvg } from "../src/assets/svg/download-svg"; import { IW } from "../common/iw";
import { Button } from "../src/components/button/button"; import { OW } from "../common/ow";
import { IW } from "./iw";
import { OW } from "./ow";
export const ButtonGallery = () => { export const ButtonGallery = () => {
return ( return (
@@ -8,7 +8,7 @@ import {
MenuRadioItem, MenuRadioItem,
MenuRadioItemGroup, MenuRadioItemGroup,
MenuTrigger, MenuTrigger,
} from "../src"; } from "../../../ui-react/src";
import { IW } from "./iw"; import { IW } from "./iw";
import { OW } from "./ow"; import { OW } from "./ow";
@@ -1,8 +1,8 @@
import { Button } from "../src/components/button/button"; import { Button } from "../../../ui-react/src/components/button/button";
import { Popover } from "../src/components/popover/popover"; import { Popover } from "../../../ui-react/src/components/popover/popover";
import { PopoverDropdown } from "../src/components/popover/popover-dropdown"; import { PopoverDropdown } from "../../../ui-react/src/components/popover/popover-dropdown";
import { PopoverTrigger } from "../src/components/popover/popover-trigger"; import { PopoverTrigger } from "../../../ui-react/src/components/popover/popover-trigger";
import { IW } from "./iw"; import { IW } from "./iw";
import { OW } from "./ow"; import { OW } from "./ow";
+9
View File
@@ -0,0 +1,9 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "es2023",
"lib": ["ES2023", "DOM"],
"module": "esnext",
"types": ["vite/client"],
"allowArbitraryExtensions": true,
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "es2023",
"lib": ["ES2023"],
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"module": "nodenext",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
+15
View File
@@ -0,0 +1,15 @@
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
import babel from '@rolldown/plugin-babel'
import { defineConfig } from 'vite'
// https://vite.dev/config/
export default defineConfig({
devtools: {
// Remove this `apply` property to enable devtools for build as well
apply: 'serve',
},
plugins: [
react(),
babel({ presets: [reactCompilerPreset()] })
],
})
+2 -1
View File
@@ -1 +1,2 @@
registry = https://registry.npmmirror.com/ registry=https://registry.npmmirror.com
shamefully-hoist = true
-16
View File
@@ -1,16 +0,0 @@
import { ButtonGallery } from "./button-gallery";
import { Theme } from "../src/components/theme/theme";
import { PopoverGallery } from "./popover-gallery";
import { MenuGallery } from "./menu-gallery";
export function App() {
return (
<div className="app">
<Theme>
<ButtonGallery />
<PopoverGallery />
<MenuGallery />
</Theme>
</div>
);
}
-10
View File
@@ -1,10 +0,0 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "../src/index.css";
import { App } from "./app.tsx";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>,
);
-29
View File
@@ -1,29 +0,0 @@
# 代码原则
## UI 开发应该用函数式组件
其实函数式组件,就是类组件里的一个 render 方法而已。
类组件里的各种成员变量,框架已经自动传入 render 的参数里了,非常方便。
再加上 tsx 和 rsx 的特殊语法解析器,智能提示全齐。
## 有些技术问题,早就有人开发了改进框架
有时候自己开发 react ,发现两个不是父子关系的组件,仍然需要通信。
例如,全选按钮,和列表按钮,不是父子关系。
这就需要一个所谓的 “全局状态库”,或者说 “配置模式”。
就像 settings 里的一大堆勾勾清单,使用 profile A,和 profile B,批量改变。
## 不要强求传入的数据有某种格式,而是兼容标准数据
例如 svg 格式的,要不要写成一个 component 呢?
试想一下,系统已经上线运营,你不可能添加任何代码,你只能给文件,系统愿不愿意数据转换,那是另一回事。
如果我想复用 svg 文件,不仅在 react 框架下用,还要在很多框架下用,我不能弄几套不同的版本,那样太占用空间。
因此,我必须维持 .svg 的原文件格式,不添加任何 jsx 语法。
+17 -32
View File
@@ -1,13 +1,18 @@
{ {
"name": "@dg/ui-react", "name": "@dg/ui-react",
"version": "1.0.0", "version": "1.0.0",
"private": true,
"type": "module", "type": "module",
"files": [ "license": "MIT",
"dist"
],
"sideEffects": [ "sideEffects": [
"*.css" "*.css"
], ],
"files": [
"dist/[^.]*",
"types/[^.]*",
"docs/[^.]*",
"doc/[^.]*"
],
"exports": { "exports": {
".": { ".": {
"import": { "import": {
@@ -16,42 +21,22 @@
}, },
"require": { "require": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"default": "./dist/index.cjs" "default": "./dist/index.cjs.js"
} }
}, },
"./index.css": "./dist/index.css" "./index.css": "./dist/index.css"
}, },
"scripts": {
"build": "vite build",
"dev": "npm run build && vite dev"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@microsoft/api-extractor": "^7.60.1",
"@types/node": "^24.19.2",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.1.2",
"eslint": "^10.15.0",
"eslint-plugin-react-hooks": "^7.1.1",
"glob": "^14.0.6",
"globals": "^17.14.0",
"prettier": "^3.10.1",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"tinyglobby": "^0.2.17",
"ts-node": "^10.9.2",
"typescript": "^6.0.3",
"typescript-eslint": "^8.73.0",
"unplugin-dts": "^1.1.2",
"vite": "^8.3.4"
},
"dependencies": { "dependencies": {
"@floating-ui/react": "^0.27.20", "@floating-ui/react": "^0.27.20",
"react-hotkeys-hook": "^5.3.3" "react-hotkeys-hook": "^5.4.0"
},
"devDependencies": {
"@types/node": "^26.6.6",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^19.0.0", "react": "^19.3.1",
"react-dom": "^19.0.0" "react-dom": "^19.3.1"
} }
} }
@@ -1,11 +1,9 @@
import { import { type CSSProperties } from "react";
type CSSProperties,
} from "react";
import { mergeClass } from "../../styles/utils/merge-class";
import { displayRecipe } from "../../styles/recipes/display-recipe"; import { displayRecipe } from "../../styles/recipes/display-recipe";
import { dotSizeRecipe } from "../../styles/recipes/dot-size-recipe"; import { dotSizeRecipe } from "../../styles/recipes/dot-size-recipe";
import type { CommonProps } from "../../utils/common-props";
import { brandRecipe } from "../../styles/recipes/brand-recipe"; import { brandRecipe } from "../../styles/recipes/brand-recipe";
import { mergeClass } from "../../styles/utils/merge-class";
import type { CommonProps } from "../../utils/common-props";
export type BadgeProps = CommonProps & { export type BadgeProps = CommonProps & {
size?: "xs" | "sm" | "md" | "lg"; size?: "xs" | "sm" | "md" | "lg";
@@ -39,12 +37,16 @@ export const Badge = (props: BadgeProps) => {
borderRadius: "9999px", borderRadius: "9999px",
}; };
const indicatorClass = mergeClass(
displayRecipe(),
const indicatorClass = mergeClass(displayRecipe(), dotSizeRecipe({ size }), brandRecipe({ brand: "danger" }), "pointer-events--none", className); dotSizeRecipe({ size }),
brandRecipe({ brand: "danger" }),
"pointer-events--none",
className,
);
return ( return (
<div {...rest} ref={ref} style={wrapperStyle}> <div {...rest} ref={ref} style={wrapperStyle}>
{children} {children}
<div className={indicatorClass} style={indicatorStyle}> <div className={indicatorClass} style={indicatorStyle}>
{indicatorContent} {indicatorContent}
+1
View File
@@ -20,6 +20,7 @@
@import './styles/css/overscroll-behavior.css'; @import './styles/css/overscroll-behavior.css';
@import './styles/css/overflow.css'; @import './styles/css/overflow.css';
@import './styles/css/outline.css'; @import './styles/css/outline.css';
@import './styles/css/opacity.css';
@import './styles/css/max-width.css'; @import './styles/css/max-width.css';
@import './styles/css/max-height.css'; @import './styles/css/max-height.css';
@import './styles/css/justify-self.css'; @import './styles/css/justify-self.css';
+9 -40
View File
@@ -1,44 +1,6 @@
export * from './utils/use-state-registry.ts'; import './index.css';
export * from './utils/slot.tsx';
export * from './utils/radiobox.tsx';
export * from './utils/merge-props.ts';
export * from './utils/down-grade-size.ts';
export * from './utils/common-props.ts';
export * from './components/checkbox-input/checkbox-input.tsx';
export * from './utils/camel-to-kebab.ts';
export * from './styles/utils/merge-class.ts'; export * from './styles/utils/merge-class.ts';
export * from './styles/utils/create-class-recipe.ts'; export * from './styles/utils/create-class-recipe.ts';
export * from './styles/recipes/variant-recipe.ts';
export * from './styles/recipes/item-size-recipe.ts';
export * from './styles/recipes/inline-size-recipe.ts';
export * from './styles/recipes/dot-size-recipe.ts';
export * from './styles/recipes/display-recipe.ts';
export * from './styles/recipes/container-recipe.ts';
export * from './styles/recipes/brand-recipe.ts';
export * from './components/theme/use-theme-context.ts';
export * from './components/theme/theme.tsx';
export * from './components/tag/tag.tsx';
export * from './components/slider/slider.tsx';
export * from './components/popover/use-popover-floating.ts';
export * from './components/popover/use-popover-context.ts';
export * from './components/popover/popover.tsx';
export * from './components/popover/popover-trigger.tsx';
export * from './components/popover/popover-dropdown.tsx';
export * from './components/menu/use-menu-trigger-context.ts';
export * from './components/radiobox-input/use-radiobox-input-group-context.ts';
export * from './components/menu/use-menu-floating.ts';
export * from './components/menu/use-menu-floating-context.ts';
export * from './components/menu/use-menu-context.ts';
export * from './components/menu/menu.tsx';
export * from './components/menu/menu-trigger.tsx';
export * from './components/menu/menu-radio-item.tsx';
export * from './components/menu/menu-radio-item-group.tsx';
export * from './components/menu/menu-item.tsx';
export * from './components/menu/menu-dropdown.tsx';
export * from './components/menu/menu-check-item.tsx';
export * from './components/icon/icon.tsx';
export * from './components/button/button.tsx';
export * from './components/badge/badge.tsx';
export * from './assets/svg/volume-mute-svg.tsx'; export * from './assets/svg/volume-mute-svg.tsx';
export * from './assets/svg/volume-low-svg.tsx'; export * from './assets/svg/volume-low-svg.tsx';
export * from './assets/svg/volume-high-svg.tsx'; export * from './assets/svg/volume-high-svg.tsx';
@@ -61,4 +23,11 @@ export * from './assets/svg/chevron-right-svg.tsx';
export * from './assets/svg/checkbox-unchecked-svg.tsx'; export * from './assets/svg/checkbox-unchecked-svg.tsx';
export * from './assets/svg/checkbox-checked-svg.tsx'; export * from './assets/svg/checkbox-checked-svg.tsx';
export * from './assets/svg/check-indicator-svg.tsx'; export * from './assets/svg/check-indicator-svg.tsx';
export * from './assets/svg/bold-svg.tsx'; export * from './assets/svg/bold-svg.tsx';
export * from './styles/recipes/variant-recipe.ts';
export * from './styles/recipes/item-size-recipe.ts';
export * from './styles/recipes/inline-size-recipe.ts';
export * from './styles/recipes/dot-size-recipe.ts';
export * from './styles/recipes/display-recipe.ts';
export * from './styles/recipes/container-recipe.ts';
export * from './styles/recipes/brand-recipe.ts';
@@ -27,12 +27,12 @@
border-radius: var(--radius-xl); border-radius: var(--radius-xl);
} }
.rounded--2xl { .rounded--xxl {
border-radius: var(--radius-2xl); border-radius: var(--radius-xxl);
} }
.rounded--3xl { .rounded--xxxl {
border-radius: var(--radius-3xl); border-radius: var(--radius-xxxl);
} }
.rounded--4 { .rounded--4 {
@@ -24,13 +24,13 @@
line-height: var(--line-height); line-height: var(--line-height);
} }
.text--2xl { .text--xxl {
font-size: var(--font-size-2xl); font-size: var(--font-size-xxl);
line-height: var(--line-height); line-height: var(--line-height);
} }
.text--3xl { .text--xxxl {
font-size: var(--font-size-3xl); font-size: var(--font-size-xxxl);
line-height: var(--line-height); line-height: var(--line-height);
} }
} }
@@ -45,11 +45,11 @@
font-weight: var(--font-weight-xl); font-weight: var(--font-weight-xl);
} }
.font-weight--2xl { .font-weight--xxl {
font-weight: var(--font-weight-2xl); font-weight: var(--font-weight-xxl);
} }
.font-weight--3xl { .font-weight--xxxl {
font-weight: var(--font-weight-3xl); font-weight: var(--font-weight-xxxl);
} }
} }
+4 -4
View File
@@ -23,11 +23,11 @@
gap: var(--gap-lg); gap: var(--gap-lg);
} }
.gap--2xl { .gap--xxl {
gap: var(--gap-2xl); gap: var(--gap-xxl);
} }
.gap--3xl { .gap--xxxl {
gap: var(--gap-3xl); gap: var(--gap-xxxl);
} }
} }
@@ -19,11 +19,11 @@
height: calc(var(--font-size-xl) / 2); height: calc(var(--font-size-xl) / 2);
} }
.h--dot-2xl { .h--dot-xxl {
height: calc(var(--font-size-2xl) / 2); height: calc(var(--font-size-xxl) / 2);
} }
.h--dot-3xl { .h--dot-xxxl {
height: calc(var(--font-size-3xl) / 2); height: calc(var(--font-size-xxxl) / 2);
} }
} }
@@ -39,19 +39,19 @@
} }
} }
.h--inline-2xl { .h--inline-xxl {
height: calc(var(--font-size-2xl) * var(--line-height)); height: calc(var(--font-size-xxl) * var(--line-height));
& svg { & svg {
height: calc(var(--font-size-2xl) * var(--line-height)); height: calc(var(--font-size-xxl) * var(--line-height));
width: calc(var(--font-size-2xl) * var(--line-height)); width: calc(var(--font-size-xxl) * var(--line-height));
} }
} }
.h--inline-3xl { .h--inline-xxxl {
height: calc(var(--font-size-3xl) * var(--line-height)); height: calc(var(--font-size-xxxl) * var(--line-height));
& svg { & svg {
height: calc(var(--font-size-3xl) * var(--line-height)); height: calc(var(--font-size-xxxl) * var(--line-height));
width: calc(var(--font-size-3xl) * var(--line-height)); width: calc(var(--font-size-xxxl) * var(--line-height));
} }
} }
} }
@@ -34,18 +34,18 @@
width: calc(var(--font-size-xl) * var(--line-height)); width: calc(var(--font-size-xl) * var(--line-height));
} }
} }
.h--item-2xl { .h--item-xxl {
height: var(--height-item-2xl); height: var(--height-item-xxl);
& svg { & svg {
height: calc(var(--font-size-2xl) * var(--line-height)); height: calc(var(--font-size-xxl) * var(--line-height));
width: calc(var(--font-size-2xl) * var(--line-height)); width: calc(var(--font-size-xxl) * var(--line-height));
} }
} }
.h--item-3xl { .h--item-xxxl {
height: var(--height-item-3xl); height: var(--height-item-xxxl);
& svg { & svg {
height: calc(var(--font-size-3xl) * var(--line-height)); height: calc(var(--font-size-xxxl) * var(--line-height));
width: calc(var(--font-size-3xl) * var(--line-height)); width: calc(var(--font-size-xxxl) * var(--line-height));
} }
} }
} }
@@ -14,10 +14,10 @@
.px--long-xl { .px--long-xl {
padding-inline: var(--padding-long-xl); padding-inline: var(--padding-long-xl);
} }
.px--long-2xl { .px--long-xxl {
padding-inline: var(--padding-long-2xl); padding-inline: var(--padding-long-xxl);
} }
.px--long-3xl { .px--long-xxxl {
padding-inline: var(--padding-long-3xl); padding-inline: var(--padding-long-xxxl);
} }
} }
+8 -8
View File
@@ -17,11 +17,11 @@
.px--xl { .px--xl {
padding-inline: var(--padding-xl); padding-inline: var(--padding-xl);
} }
.px--2xl { .px--xxl {
padding-inline: var(--padding-2xl); padding-inline: var(--padding-xxl);
} }
.px--3xl { .px--xxxl {
padding-inline: var(--padding-3xl); padding-inline: var(--padding-xxxl);
} }
/* =================================================== */ /* =================================================== */
@@ -44,11 +44,11 @@
.py--xl { .py--xl {
padding-block: var(--padding-xl); padding-block: var(--padding-xl);
} }
.py--2xl { .py--xxl {
padding-block: var(--padding-2xl); padding-block: var(--padding-xxl);
} }
.py--3xl { .py--xxxl {
padding-block: var(--padding-3xl); padding-block: var(--padding-xxxl);
} }
/* =================================================== */ /* =================================================== */
+16 -16
View File
@@ -335,8 +335,8 @@
--font-size-md: 14px; --font-size-md: 14px;
--font-size-lg: 15px; --font-size-lg: 15px;
--font-size-xl: 16px; --font-size-xl: 16px;
--font-size-2xl: 24px; --font-size-xxl: 24px;
--font-size-3xl: 30px; --font-size-xxxl: 30px;
--line-height: 1.33; --line-height: 1.33;
@@ -352,24 +352,24 @@
--font-weight-md: var(--font-weight-extranormal); --font-weight-md: var(--font-weight-extranormal);
--font-weight-lg: var(--font-weight-semibold); --font-weight-lg: var(--font-weight-semibold);
--font-weight-xl: var(--font-weight-semibold); --font-weight-xl: var(--font-weight-semibold);
--font-weight-2xl: var(--font-weight-semibold); --font-weight-xxl: var(--font-weight-semibold);
--font-weight-3xl: var(--font-weight-bold); --font-weight-xxxl: var(--font-weight-bold);
--height-item-xs: 20px; --height-item-xs: 20px;
--height-item-sm: 24px; --height-item-sm: 24px;
--height-item-md: 28px; --height-item-md: 28px;
--height-item-lg: 32px; --height-item-lg: 32px;
--height-item-xl: 42px; --height-item-xl: 42px;
--height-item-2xl: 56px; --height-item-xxl: 56px;
--height-item-3xl: 64px; --height-item-xxxl: 64px;
--radius-xs: 2px; --radius-xs: 2px;
--radius-sm: 3px; --radius-sm: 3px;
--radius-md: 4px; --radius-md: 4px;
--radius-lg: 5px; --radius-lg: 5px;
--radius-xl: 8px; --radius-xl: 8px;
--radius-2xl: 12px; --radius-xxl: 12px;
--radius-3xl: 16px; --radius-xxxl: 16px;
--radius-none: 0; --radius-none: 0;
--radius-full: 9999px; --radius-full: 9999px;
@@ -378,8 +378,8 @@
--padding-md: 6px; --padding-md: 6px;
--padding-lg: 7px; --padding-lg: 7px;
--padding-xl: 16px; --padding-xl: 16px;
--padding-2xl: 2px; --padding-xxl: 2px;
--padding-3xl: 2px; --padding-xxxl: 2px;
--times-of-padding-long: 2; --times-of-padding-long: 2;
@@ -388,16 +388,16 @@
--padding-long-md: calc(var(--padding-md) * var(--times-of-padding-long)); --padding-long-md: calc(var(--padding-md) * var(--times-of-padding-long));
--padding-long-lg: calc(var(--padding-lg) * var(--times-of-padding-long)); --padding-long-lg: calc(var(--padding-lg) * var(--times-of-padding-long));
--padding-long-xl: calc(var(--padding-xl) * var(--times-of-padding-long)); --padding-long-xl: calc(var(--padding-xl) * var(--times-of-padding-long));
--padding-long-2xl: calc(var(--padding-2xl) * var(--times-of-padding-long)); --padding-long-xxl: calc(var(--padding-xxl) * var(--times-of-padding-long));
--padding-long-3xl: calc(var(--padding-3xl) * var(--times-of-padding-long)); --padding-long-xxxl: calc(var(--padding-xxxl) * var(--times-of-padding-long));
--gap-xs: 2px; --gap-xs: 2px;
--gap-sm: 3px; --gap-sm: 3px;
--gap-md: 4px; --gap-md: 4px;
--gap-lg: 5px; --gap-lg: 5px;
--gap-xl: 10px; --gap-xl: 10px;
--gap-2xl: 12px; --gap-xxl: 12px;
--gap-3xl: 14px; --gap-xxxl: 14px;
--gap-none: 0; --gap-none: 0;
--drop-shadow: drop-shadow(0 0 4px rgba(0, 0, 0, 0.14)) --drop-shadow: drop-shadow(0 0 4px rgba(0, 0, 0, 0.14))
@@ -441,6 +441,6 @@
--height-inline-md: calc(var(--font-size-md) * var(--line-height)); --height-inline-md: calc(var(--font-size-md) * var(--line-height));
--height-inline-lg: calc(var(--font-size-lg) * var(--line-height)); --height-inline-lg: calc(var(--font-size-lg) * var(--line-height));
--height-inline-xl: calc(var(--font-size-xl) * var(--line-height)); --height-inline-xl: calc(var(--font-size-xl) * var(--line-height));
--height-inline-2xl: calc(var(--font-size-2xl) * var(--line-height)); --height-inline-xxl: calc(var(--font-size-xxl) * var(--line-height));
--height-inline-3xl: calc(var(--font-size-3xl) * var(--line-height)); --height-inline-xxxl: calc(var(--font-size-xxxl) * var(--line-height));
} }
@@ -19,12 +19,12 @@
width: calc(var(--font-size-xl) / 2); width: calc(var(--font-size-xl) / 2);
} }
.w--dot-2xl { .w--dot-xxl {
width: calc(var(--font-size-2xl) / 2); width: calc(var(--font-size-xxl) / 2);
} }
.w--dot-3xl { .w--dot-xxxl {
width: calc(var(--font-size-3xl) / 2); width: calc(var(--font-size-xxxl) / 2);
} }
} }
@@ -19,7 +19,11 @@
width: calc(var(--font-size-xl) * var(--line-height)); width: calc(var(--font-size-xl) * var(--line-height));
} }
.w--inline-xl { .w--inline-xxl {
width: calc(var(--font-size-2xl) * var(--line-height)); width: calc(var(--font-size-xxl) * var(--line-height));
} }
}
.w--inline-xxxl {
width: calc(var(--font-size-xxxl) * var(--line-height));
}
}
@@ -19,7 +19,11 @@
width: var(--height-item-xl); width: var(--height-item-xl);
} }
.w--item--2xl { .w--item--xxl {
width: var(--height-item-2xl); width: var(--height-item-xxl);
} }
}
.w--item--xxxl {
width: var(--height-item-xxxl);
}
}
@@ -19,9 +19,9 @@ type VariantProps<V extends Record<string, Record<string, string>>> = Partial<{
[K in keyof V]: keyof V[K] | boolean; [K in keyof V]: keyof V[K] | boolean;
}>; }>;
export function createClassRecipe<V extends Record<string, Record<string, string>>>( export function createClassRecipe<
config: VariantsConfig<V>, V extends Record<string, Record<string, string>>,
) { >(config: VariantsConfig<V>) {
return function (props: VariantProps<V> = {}): string { return function (props: VariantProps<V> = {}): string {
const classes: string[] = []; const classes: string[] = [];
@@ -1,3 +1,13 @@
/**
* Use "--" as separator to split prefix and surffix.
*
* If a utility has not "--" separator, all are treated as a prefix.
* @example
* const a = "text--xs px--xs gap";
* const b = "px--none gap--xs";
* const result = merge_class([a,b]);
* // Output: "text--xs px--none gap--xs"
*/
export function mergeClass(...classes: (string[] | string)[]) { export function mergeClass(...classes: (string[] | string)[]) {
const map = new Map<string, string>(); const map = new Map<string, string>();
@@ -2,3 +2,5 @@ declare module "*.css" {
const content: string; const content: string;
export default content; export default content;
} }
declare module "*.json";
+26
View File
@@ -0,0 +1,26 @@
{
// 继承 TS 检查文件,按需覆盖。
"extends": "./tsconfig.json",
"compilerOptions": {
// 前端用 bundler,交给打包器负责,后端用 nodenext。
"moduleResolution": "bundler",
// 指定内置工具库,前端需包含 DOM,后端需包含 esnext。
"lib": ["DOM", "DOM.Iterable", "ESNext"],
// 输出编译后文件,如果用于 TS 检查则为 true。
"noEmit": false,
// 生成 d.ts 声明文件。
"declaration": true,
// 方便调试
"declarationMap": true,
// 输出目录
"outDir": "./dist/",
// 源码根目录,如果用于 TS 检查则不写,默认是 "." 项目根目录。
"rootDir": "./src",
// 方便调试
"sourceMap": true,
// 如果你用了 vite,设为 true,本文件仅生成 d.ts,编译完全交给 vite 。
"emitDeclarationOnly": false
},
// 本配置文件的作用范围,打包不需要包含 src 外部的各种配置文件,例如 vite.config.ts 。
"include": ["src"]
}
+34 -44
View File
@@ -1,54 +1,44 @@
{ {
// 本文件仅供 TS Server 检查语法,不负责编译,编译使用的是另一个文件 tsconfig.build.json
// TS 类型检查专用配置, build 配置继承后按需覆盖。
"compilerOptions": { "compilerOptions": {
// This is a component library, so "ESNext" is a good choice. Also it requires very little down-leveling during transpilation. // 编译后, 输出的语法格式,自从 2026 年后,cjs 模块也能识别 es 模块了,如果需要兼容老项目则调低版本
"target": "esnext", "target": "es2023",
// Include a list of type definitions for build-in JS APIs. // 前端用 esnext ,后端用 nodenext ,node 其实也是用 js 写的一个库,前端是不带这个库的
"lib": ["esnext", "DOM", "DOM.Iterable"],
// Specify the module system for the output files. It's not required for Vite but good to have.
"module": "esnext", "module": "esnext",
// The types defined in "vite/client" are included in global scope. // 所有项目必须开,兼容 es 和 cjs 导入,允许 import React from 'react' ,而非 import * as React 。
"types": ["node", "vite/client"],
// Do not emit compiled output files, vite will take care of the that.
"noEmit": true,
// Vite will handle the resolution of the import paths.
"moduleResolution": "bundler",
// Use the React 17 JSX transform, importing React is no longer required.
"jsx": "react-jsx",
// Skip the type checking for declaration files to improve performance.
"skipLibCheck": true,
// Allow importing modules with ".json" extension.
"resolveJsonModule": true,
// "declarationMap" need to be enabled to let Vite generates source map files.
"declaration": true,
"declarationMap": true,
// Importing .js files is not allowed, enable if needed.
"allowJs": false,
// Fix the mis-match of behaviors between ES import and CommonJS require.
"esModuleInterop": true, "esModuleInterop": true,
// Allow default import from modules with no default export, i.e. you can write `import React from 'react'` instead of `import * as React from 'react'`. // 允许导入 ts,tsx 扩展名,include 里可以省略后缀。
"allowSyntheticDefaultImports": true,
// Enforce the file name casing to be consistent with development environment.
"forceConsistentCasingInFileNames": true,
// Ensure the run-time code does not depend on the TypeScript-only features, such as constant enum.
"isolatedModules": true,
// Allow importing TypeScript modules.
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
// Enfore "type" modifier for type imports. // 允许 js,jsx 扩展名,include 里可以省略后缀。
"verbatimModuleSyntax": true, "allowJs": true,
// Ensure the public class field initialization is transpiled correctly to match the future JS standard. // 启用装饰器,也就是 @XXX 注解。
"useDefineForClassFields": true, "experimentalDecorators": true,
// Type-checking options // 发射装饰器元数据。
"emitDecoratorMetadata": true,
// 转换 jsx 时,使用 17+ 的新语法导入 react 。
"jsx": "react-jsx",
// 可作为子项目,被其他项目引用,但建议使用 workspace dep 模式,不是写 references 。
"composite": false,
// 只加载指定类型的声明包,避免加载无用类型,提升编译速度
"types": ["node", "vite/client"],
// 不输出编译后的文件,也就是 dist 目录下为空, 本文件只做类型检查。
"noEmit": true,
// 开启严格类型检查模式,只需开启这一个,其他的等于都开启了,要注意这只是类型检查,而非语法检查。
"strict": true, "strict": true,
"noFallthroughCasesInSwitch": true, // 让 TS 编译器保留用于注解的 import 语句,不要优化掉,后面 babel 转义器要用。
"noImplicitOverride": true, "verbatimModuleSyntax": true,
"noImplicitReturns": true, // 跳过第三方库的类型检查,加快编译速度,减少30% 。
"noImplicitThis": true, "skipLibCheck": true,
"noPropertyAccessFromIndexSignature": true, // 跳过内置库的类型检查,加快编译速度,分钟级降至秒级。
"noUncheckedIndexedAccess": true, "skipDefaultLibCheck": true,
"noUnusedLocals": false, // 增量编译,加快编译速度,尤其是大项目。
"noUnusedParameters": true "incremental": true
}, },
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], // 本配置文件的作用范围,包含根目录下的一切文件,包括 vite.config.ts 等配置文件
"include": ["**/*.ts",],
// 本配置文件排除的范围。
"exclude": [ "exclude": [
"node_modules", "node_modules",
"dist", "dist",
@@ -1,59 +0,0 @@
import type { Plugin } from "vite";
import { glob } from "glob";
import * as path from "path";
import * as fs from "fs";
/**
*/
export type PluginOption = {
include: string[];
exclude?: string[];
preamble: string;
entry: string;
};
/**
* Per `option` have follow property:
* @param include
* value like ["src/**\/*.{tsx,jsx,ts,js}"]
* @param preamble
* value like `"export * from "`
*/
export function genIndex(...options: PluginOption[]): Plugin {
return {
name: "VITE_PLUGIN_GEN_INDEX",
config() {
options.forEach((opt) => {
const entryToFileArray: string[] = [];
const includeArray = opt.include;
const excludeArray = opt.exclude;
includeArray.forEach((ipath) => {
const files = glob.sync(ipath, { ignore: excludeArray });
files.forEach((file) => {
let entryToFile = path.relative(opt.entry, file);
// console.log(`origin: ${entryToFile}`);
// Fix the bug of path.relative, file in the same dir should start with [ ./ ] not [ ../ ]
if (entryToFile.startsWith("..")) {
entryToFile = entryToFile.substring(1);
// console.log(`after substring: ${entryToFile}`);
}
// Fix the bug of lib, default is output "\" , we need handle by self, replace "\" to "/" for Windows
entryToFile = entryToFile.replace(/\\/g, "/");
// console.log(`after replace: ${entryToFile} \n`);
entryToFileArray.push(
opt.preamble.concat(" ", "'", entryToFile, "';"),
);
});
});
fs.writeFileSync(opt.entry, entryToFileArray.join("\n"), "utf-8");
});
},
};
}
-67
View File
@@ -1,67 +0,0 @@
import { resolve } from "node:path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "unplugin-dts/vite";
import pkg from "./package.json" with { type: "json" };
import { genIndex, PluginOption } from "./vite-plugin/vite-plugin-gen-index.ts";
const genTsOption: PluginOption = {
include: ["src/**/*.{tsx,ts,jsx,js}"],
exclude: ["src/app.tsx", "src/main.tsx", "src/index.ts"],
preamble: "export * from",
entry: "src/index.ts",
};
const genCssOption: PluginOption = {
include: ["src/**/*.css"],
exclude: ["src/index.css"],
preamble: "@import",
entry: "src/index.css",
};
export default defineConfig({
plugins: [
genIndex(genTsOption, genCssOption),
react(),
dts({
outDirs: [
{ dir: "dist", moduleFormat: "esm" },
{ dir: "dist", moduleFormat: "cjs" },
],
bundleTypes: true,
}),
],
build: {
target: "esnext",
// Must write, vite/css-minify cannot recognize some ruler
cssMinify: false,
lib: {
entry: resolve(import.meta.dirname, "src/index.ts"),
name: "ui-react",
formats: ["es", "cjs"],
fileName: `index`,
cssFileName: "index",
},
rolldownOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["react/jsx-runtime", ...Object.keys(pkg.peerDependencies)],
// output: {
// assetFileNames: (assetInfo) => {
// if (assetInfo.name && assetInfo.name.endsWith(".css")) {
// return "index.css";
// }
// return "[name].[hash][extname]";
// },
// // Provide global variables to use in the UMD build
// // for externalized deps
// globals: {
// react: "React",
// "react-dom": "ReactDOM",
// },
// },
},
},
});
+2519
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -0,0 +1,3 @@
packages:
- packages/*
- apps/*