mm
This commit is contained in:
@@ -1 +1,2 @@
|
||||
registry = https://registry.npmmirror.com/
|
||||
registry=https://registry.npmmirror.com
|
||||
shamefully-hoist = true
|
||||
@@ -1,22 +0,0 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
import { DownloadSvg } from "../src/assets/svg/download-svg";
|
||||
import { Button } from "../src/components/button/button";
|
||||
import { IW } from "./iw";
|
||||
import { OW } from "./ow";
|
||||
|
||||
export const ButtonGallery = () => {
|
||||
return (
|
||||
<OW>
|
||||
<IW>
|
||||
<Button size="xs">xsmall</Button>
|
||||
<Button size="xs" iconSvg={<DownloadSvg />}>
|
||||
xsmall
|
||||
</Button>
|
||||
<Button size="xs" iconSvg={<DownloadSvg />} isIconOnly={true}>
|
||||
xsmall
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
iconSvg={<DownloadSvg />}
|
||||
canLoading={true}
|
||||
isLoading={true}
|
||||
>
|
||||
isLoading
|
||||
</Button>
|
||||
<Button size="xs" iconSvg={<DownloadSvg />} canLoading={true}>
|
||||
canLoading
|
||||
</Button>
|
||||
</IW>
|
||||
<IW>
|
||||
<Button size="sm">small</Button>
|
||||
<Button size="sm" iconSvg={<DownloadSvg />}>
|
||||
下载
|
||||
</Button>
|
||||
<Button size="sm" iconSvg={<DownloadSvg />} isIconOnly={true}>
|
||||
small
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
iconSvg={<DownloadSvg />}
|
||||
canLoading={true}
|
||||
isLoading={true}
|
||||
>
|
||||
isLoading
|
||||
</Button>
|
||||
<Button size="sm" iconSvg={<DownloadSvg />} canLoading={true}>
|
||||
canLoading
|
||||
</Button>
|
||||
</IW>
|
||||
<IW>
|
||||
<Button size="md">medium</Button>
|
||||
<Button size="md" iconSvg={<DownloadSvg />}>
|
||||
medium
|
||||
</Button>
|
||||
<Button size="md" iconSvg={<DownloadSvg />} isIconOnly={true}>
|
||||
medium
|
||||
</Button>
|
||||
<Button
|
||||
size="md"
|
||||
iconSvg={<DownloadSvg />}
|
||||
canLoading={true}
|
||||
isLoading={true}
|
||||
>
|
||||
isLoading
|
||||
</Button>{" "}
|
||||
<Button size="md" iconSvg={<DownloadSvg />} canLoading={true}>
|
||||
canLoading
|
||||
</Button>
|
||||
</IW>
|
||||
<IW>
|
||||
<Button size="lg">large</Button>
|
||||
<Button size="lg" iconSvg={<DownloadSvg />}>
|
||||
large
|
||||
</Button>
|
||||
<Button size="lg" iconSvg={<DownloadSvg />} isIconOnly={true}>
|
||||
large
|
||||
</Button>
|
||||
<Button
|
||||
size="lg"
|
||||
iconSvg={<DownloadSvg />}
|
||||
canLoading={true}
|
||||
isLoading={true}
|
||||
>
|
||||
isLoading
|
||||
</Button>{" "}
|
||||
<Button
|
||||
size="lg"
|
||||
iconSvg={<DownloadSvg />}
|
||||
canLoading={true}
|
||||
>
|
||||
canLoading
|
||||
</Button>
|
||||
</IW>
|
||||
<IW>
|
||||
<Button size="md" variant={"filled"} iconSvg={<DownloadSvg />}>
|
||||
filled
|
||||
</Button>
|
||||
<Button size="md" variant={"outline"} iconSvg={<DownloadSvg />}>
|
||||
outline
|
||||
</Button>
|
||||
<Button size="md" variant={"subtle"} iconSvg={<DownloadSvg />}>
|
||||
subtle
|
||||
</Button>
|
||||
<Button size="md" variant={"ghost"} iconSvg={<DownloadSvg />}>
|
||||
ghost
|
||||
</Button>
|
||||
</IW>
|
||||
</OW>
|
||||
);
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export const IW = ({ children }: { children: ReactNode }) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
gap: "10px",
|
||||
display: "flex",
|
||||
flexWrap: "nowrap",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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>,
|
||||
);
|
||||
@@ -1,102 +0,0 @@
|
||||
import {
|
||||
Button,
|
||||
FileSvg,
|
||||
Menu,
|
||||
MenuCheckItem,
|
||||
MenuDropdown,
|
||||
MenuItem,
|
||||
MenuRadioItem,
|
||||
MenuRadioItemGroup,
|
||||
MenuTrigger,
|
||||
} from "../src";
|
||||
import { IW } from "./iw";
|
||||
import { OW } from "./ow";
|
||||
|
||||
export const MenuGallery = () => {
|
||||
return (
|
||||
<OW>
|
||||
<IW>
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<Button size="sm" variant="ghost">
|
||||
文件
|
||||
</Button>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuItem iconSvg={<FileSvg />}>Open File...</MenuItem>
|
||||
<MenuItem>Open Folder...</MenuItem>
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<MenuItem>Preferences</MenuItem>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuItem>Profile</MenuItem>
|
||||
<MenuItem>Settings</MenuItem>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
<MenuCheckItem>Auto Lint</MenuCheckItem>
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<MenuItem>Ruler</MenuItem>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuRadioItemGroup defaultSelectName="hori">
|
||||
<MenuRadioItem name="hori">Hori</MenuRadioItem>
|
||||
<MenuRadioItem name="verti">Verti</MenuRadioItem>
|
||||
<MenuRadioItem name="both">Hoth</MenuRadioItem>
|
||||
</MenuRadioItemGroup>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
</IW>
|
||||
|
||||
<IW>
|
||||
<Menu size="md">
|
||||
<MenuTrigger>
|
||||
<Button size="md" variant="ghost">
|
||||
文件
|
||||
</Button>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuItem iconSvg={<FileSvg />}>Open File...</MenuItem>
|
||||
<MenuItem>Open Folder...</MenuItem>
|
||||
{/* 子菜单 */}
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<MenuItem>Preferences</MenuItem>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuItem>Profile</MenuItem>
|
||||
<MenuItem>Settings</MenuItem>
|
||||
{/* 子菜单 */}
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<MenuItem>To open 3</MenuItem>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuItem>Profile</MenuItem>
|
||||
<MenuItem>Settings</MenuItem>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
<MenuCheckItem>Auto Lint</MenuCheckItem>
|
||||
<Menu>
|
||||
<MenuTrigger>
|
||||
<MenuItem>Ruler</MenuItem>
|
||||
</MenuTrigger>
|
||||
<MenuDropdown>
|
||||
<MenuRadioItemGroup defaultSelectName="hori">
|
||||
<MenuRadioItem name="hori">Hori</MenuRadioItem>
|
||||
<MenuRadioItem name="verti">Verti</MenuRadioItem>
|
||||
<MenuRadioItem name="both">Hoth</MenuRadioItem>
|
||||
</MenuRadioItemGroup>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
</MenuDropdown>
|
||||
</Menu>
|
||||
</IW>
|
||||
</OW>
|
||||
);
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export const OW = ({ children }: { children: ReactNode }) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
margin: "20px",
|
||||
gap: "20px",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
flexWrap: "nowrap",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
import { Button } from "../src/components/button/button";
|
||||
import { Popover } from "../src/components/popover/popover";
|
||||
import { PopoverDropdown } from "../src/components/popover/popover-dropdown";
|
||||
import { PopoverTrigger } from "../src/components/popover/popover-trigger";
|
||||
import { IW } from "./iw";
|
||||
import { OW } from "./ow";
|
||||
|
||||
export const PopoverGallery = () => {
|
||||
return (
|
||||
<OW>
|
||||
<IW>
|
||||
<Popover>
|
||||
<PopoverTrigger>
|
||||
<Button>Open Popover</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverDropdown>
|
||||
This is Popover Content !
|
||||
</PopoverDropdown>
|
||||
</Popover>
|
||||
</IW>
|
||||
</OW>
|
||||
);
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>vite-project</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/gallery/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
# 代码原则
|
||||
|
||||
## UI 开发应该用函数式组件
|
||||
|
||||
其实函数式组件,就是类组件里的一个 render 方法而已。
|
||||
|
||||
类组件里的各种成员变量,框架已经自动传入 render 的参数里了,非常方便。
|
||||
|
||||
再加上 tsx 和 rsx 的特殊语法解析器,智能提示全齐。
|
||||
|
||||
## 有些技术问题,早就有人开发了改进框架
|
||||
|
||||
有时候自己开发 react ,发现两个不是父子关系的组件,仍然需要通信。
|
||||
|
||||
例如,全选按钮,和列表按钮,不是父子关系。
|
||||
|
||||
这就需要一个所谓的 “全局状态库”,或者说 “配置模式”。
|
||||
|
||||
就像 settings 里的一大堆勾勾清单,使用 profile A,和 profile B,批量改变。
|
||||
|
||||
## 不要强求传入的数据有某种格式,而是兼容标准数据
|
||||
|
||||
例如 svg 格式的,要不要写成一个 component 呢?
|
||||
|
||||
试想一下,系统已经上线运营,你不可能添加任何代码,你只能给文件,系统愿不愿意数据转换,那是另一回事。
|
||||
|
||||
如果我想复用 svg 文件,不仅在 react 框架下用,还要在很多框架下用,我不能弄几套不同的版本,那样太占用空间。
|
||||
|
||||
因此,我必须维持 .svg 的原文件格式,不添加任何 jsx 语法。
|
||||
@@ -1,13 +1,18 @@
|
||||
{
|
||||
"name": "@dg/ui-react",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"license": "MIT",
|
||||
"sideEffects": [
|
||||
"*.css"
|
||||
],
|
||||
"files": [
|
||||
"dist/[^.]*",
|
||||
"types/[^.]*",
|
||||
"docs/[^.]*",
|
||||
"doc/[^.]*"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
@@ -16,42 +21,22 @@
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.cjs"
|
||||
"default": "./dist/index.cjs.js"
|
||||
}
|
||||
},
|
||||
"./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": {
|
||||
"@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": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
"react": "^19.3.1",
|
||||
"react-dom": "^19.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
type CSSProperties,
|
||||
} from "react";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { type CSSProperties } from "react";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { dotSizeRecipe } from "../../styles/recipes/dot-size-recipe";
|
||||
import type { CommonProps } from "../../utils/common-props";
|
||||
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 & {
|
||||
size?: "xs" | "sm" | "md" | "lg";
|
||||
@@ -39,12 +37,16 @@ export const Badge = (props: BadgeProps) => {
|
||||
borderRadius: "9999px",
|
||||
};
|
||||
|
||||
|
||||
|
||||
const indicatorClass = mergeClass(displayRecipe(), dotSizeRecipe({ size }), brandRecipe({ brand: "danger" }), "pointer-events--none", className);
|
||||
const indicatorClass = mergeClass(
|
||||
displayRecipe(),
|
||||
dotSizeRecipe({ size }),
|
||||
brandRecipe({ brand: "danger" }),
|
||||
"pointer-events--none",
|
||||
className,
|
||||
);
|
||||
|
||||
return (
|
||||
<div {...rest} ref={ref} style={wrapperStyle}>
|
||||
<div {...rest} ref={ref} style={wrapperStyle}>
|
||||
{children}
|
||||
<div className={indicatorClass} style={indicatorStyle}>
|
||||
{indicatorContent}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
@import './styles/css/overscroll-behavior.css';
|
||||
@import './styles/css/overflow.css';
|
||||
@import './styles/css/outline.css';
|
||||
@import './styles/css/opacity.css';
|
||||
@import './styles/css/max-width.css';
|
||||
@import './styles/css/max-height.css';
|
||||
@import './styles/css/justify-self.css';
|
||||
|
||||
@@ -1,44 +1,6 @@
|
||||
export * from './utils/use-state-registry.ts';
|
||||
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';
|
||||
import './index.css';
|
||||
export * from './styles/utils/merge-class.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-low-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-checked-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);
|
||||
}
|
||||
|
||||
.rounded--2xl {
|
||||
border-radius: var(--radius-2xl);
|
||||
.rounded--xxl {
|
||||
border-radius: var(--radius-xxl);
|
||||
}
|
||||
|
||||
.rounded--3xl {
|
||||
border-radius: var(--radius-3xl);
|
||||
.rounded--xxxl {
|
||||
border-radius: var(--radius-xxxl);
|
||||
}
|
||||
|
||||
.rounded--4 {
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--2xl {
|
||||
font-size: var(--font-size-2xl);
|
||||
.text--xxl {
|
||||
font-size: var(--font-size-xxl);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--3xl {
|
||||
font-size: var(--font-size-3xl);
|
||||
.text--xxxl {
|
||||
font-size: var(--font-size-xxxl);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,11 @@
|
||||
font-weight: var(--font-weight-xl);
|
||||
}
|
||||
|
||||
.font-weight--2xl {
|
||||
font-weight: var(--font-weight-2xl);
|
||||
.font-weight--xxl {
|
||||
font-weight: var(--font-weight-xxl);
|
||||
}
|
||||
|
||||
.font-weight--3xl {
|
||||
font-weight: var(--font-weight-3xl);
|
||||
.font-weight--xxxl {
|
||||
font-weight: var(--font-weight-xxxl);
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,11 @@
|
||||
gap: var(--gap-lg);
|
||||
}
|
||||
|
||||
.gap--2xl {
|
||||
gap: var(--gap-2xl);
|
||||
.gap--xxl {
|
||||
gap: var(--gap-xxl);
|
||||
}
|
||||
|
||||
.gap--3xl {
|
||||
gap: var(--gap-3xl);
|
||||
.gap--xxxl {
|
||||
gap: var(--gap-xxxl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
height: calc(var(--font-size-xl) / 2);
|
||||
}
|
||||
|
||||
.h--dot-2xl {
|
||||
height: calc(var(--font-size-2xl) / 2);
|
||||
.h--dot-xxl {
|
||||
height: calc(var(--font-size-xxl) / 2);
|
||||
}
|
||||
|
||||
.h--dot-3xl {
|
||||
height: calc(var(--font-size-3xl) / 2);
|
||||
.h--dot-xxxl {
|
||||
height: calc(var(--font-size-xxxl) / 2);
|
||||
}
|
||||
}
|
||||
@@ -39,19 +39,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
.h--inline-2xl {
|
||||
height: calc(var(--font-size-2xl) * var(--line-height));
|
||||
.h--inline-xxl {
|
||||
height: calc(var(--font-size-xxl) * var(--line-height));
|
||||
& svg {
|
||||
height: calc(var(--font-size-2xl) * var(--line-height));
|
||||
width: calc(var(--font-size-2xl) * var(--line-height));
|
||||
height: calc(var(--font-size-xxl) * var(--line-height));
|
||||
width: calc(var(--font-size-xxl) * var(--line-height));
|
||||
}
|
||||
}
|
||||
|
||||
.h--inline-3xl {
|
||||
height: calc(var(--font-size-3xl) * var(--line-height));
|
||||
.h--inline-xxxl {
|
||||
height: calc(var(--font-size-xxxl) * var(--line-height));
|
||||
& svg {
|
||||
height: calc(var(--font-size-3xl) * var(--line-height));
|
||||
width: calc(var(--font-size-3xl) * var(--line-height));
|
||||
height: calc(var(--font-size-xxxl) * 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));
|
||||
}
|
||||
}
|
||||
.h--item-2xl {
|
||||
height: var(--height-item-2xl);
|
||||
.h--item-xxl {
|
||||
height: var(--height-item-xxl);
|
||||
& svg {
|
||||
height: calc(var(--font-size-2xl) * var(--line-height));
|
||||
width: calc(var(--font-size-2xl) * var(--line-height));
|
||||
height: calc(var(--font-size-xxl) * var(--line-height));
|
||||
width: calc(var(--font-size-xxl) * var(--line-height));
|
||||
}
|
||||
}
|
||||
.h--item-3xl {
|
||||
height: var(--height-item-3xl);
|
||||
.h--item-xxxl {
|
||||
height: var(--height-item-xxxl);
|
||||
& svg {
|
||||
height: calc(var(--font-size-3xl) * var(--line-height));
|
||||
width: calc(var(--font-size-3xl) * var(--line-height));
|
||||
height: calc(var(--font-size-xxxl) * var(--line-height));
|
||||
width: calc(var(--font-size-xxxl) * var(--line-height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
.px--long-xl {
|
||||
padding-inline: var(--padding-long-xl);
|
||||
}
|
||||
.px--long-2xl {
|
||||
padding-inline: var(--padding-long-2xl);
|
||||
.px--long-xxl {
|
||||
padding-inline: var(--padding-long-xxl);
|
||||
}
|
||||
.px--long-3xl {
|
||||
padding-inline: var(--padding-long-3xl);
|
||||
.px--long-xxxl {
|
||||
padding-inline: var(--padding-long-xxxl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
.px--xl {
|
||||
padding-inline: var(--padding-xl);
|
||||
}
|
||||
.px--2xl {
|
||||
padding-inline: var(--padding-2xl);
|
||||
.px--xxl {
|
||||
padding-inline: var(--padding-xxl);
|
||||
}
|
||||
.px--3xl {
|
||||
padding-inline: var(--padding-3xl);
|
||||
.px--xxxl {
|
||||
padding-inline: var(--padding-xxxl);
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
@@ -44,11 +44,11 @@
|
||||
.py--xl {
|
||||
padding-block: var(--padding-xl);
|
||||
}
|
||||
.py--2xl {
|
||||
padding-block: var(--padding-2xl);
|
||||
.py--xxl {
|
||||
padding-block: var(--padding-xxl);
|
||||
}
|
||||
.py--3xl {
|
||||
padding-block: var(--padding-3xl);
|
||||
.py--xxxl {
|
||||
padding-block: var(--padding-xxxl);
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
@@ -335,8 +335,8 @@
|
||||
--font-size-md: 14px;
|
||||
--font-size-lg: 15px;
|
||||
--font-size-xl: 16px;
|
||||
--font-size-2xl: 24px;
|
||||
--font-size-3xl: 30px;
|
||||
--font-size-xxl: 24px;
|
||||
--font-size-xxxl: 30px;
|
||||
|
||||
--line-height: 1.33;
|
||||
|
||||
@@ -352,24 +352,24 @@
|
||||
--font-weight-md: var(--font-weight-extranormal);
|
||||
--font-weight-lg: var(--font-weight-semibold);
|
||||
--font-weight-xl: var(--font-weight-semibold);
|
||||
--font-weight-2xl: var(--font-weight-semibold);
|
||||
--font-weight-3xl: var(--font-weight-bold);
|
||||
--font-weight-xxl: var(--font-weight-semibold);
|
||||
--font-weight-xxxl: var(--font-weight-bold);
|
||||
|
||||
--height-item-xs: 20px;
|
||||
--height-item-sm: 24px;
|
||||
--height-item-md: 28px;
|
||||
--height-item-lg: 32px;
|
||||
--height-item-xl: 42px;
|
||||
--height-item-2xl: 56px;
|
||||
--height-item-3xl: 64px;
|
||||
--height-item-xxl: 56px;
|
||||
--height-item-xxxl: 64px;
|
||||
|
||||
--radius-xs: 2px;
|
||||
--radius-sm: 3px;
|
||||
--radius-md: 4px;
|
||||
--radius-lg: 5px;
|
||||
--radius-xl: 8px;
|
||||
--radius-2xl: 12px;
|
||||
--radius-3xl: 16px;
|
||||
--radius-xxl: 12px;
|
||||
--radius-xxxl: 16px;
|
||||
--radius-none: 0;
|
||||
--radius-full: 9999px;
|
||||
|
||||
@@ -378,8 +378,8 @@
|
||||
--padding-md: 6px;
|
||||
--padding-lg: 7px;
|
||||
--padding-xl: 16px;
|
||||
--padding-2xl: 2px;
|
||||
--padding-3xl: 2px;
|
||||
--padding-xxl: 2px;
|
||||
--padding-xxxl: 2px;
|
||||
|
||||
--times-of-padding-long: 2;
|
||||
|
||||
@@ -388,16 +388,16 @@
|
||||
--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-xl: calc(var(--padding-xl) * var(--times-of-padding-long));
|
||||
--padding-long-2xl: calc(var(--padding-2xl) * var(--times-of-padding-long));
|
||||
--padding-long-3xl: calc(var(--padding-3xl) * var(--times-of-padding-long));
|
||||
--padding-long-xxl: calc(var(--padding-xxl) * var(--times-of-padding-long));
|
||||
--padding-long-xxxl: calc(var(--padding-xxxl) * var(--times-of-padding-long));
|
||||
|
||||
--gap-xs: 2px;
|
||||
--gap-sm: 3px;
|
||||
--gap-md: 4px;
|
||||
--gap-lg: 5px;
|
||||
--gap-xl: 10px;
|
||||
--gap-2xl: 12px;
|
||||
--gap-3xl: 14px;
|
||||
--gap-xxl: 12px;
|
||||
--gap-xxxl: 14px;
|
||||
--gap-none: 0;
|
||||
|
||||
--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-lg: calc(var(--font-size-lg) * 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-3xl: calc(var(--font-size-3xl) * var(--line-height));
|
||||
--height-inline-xxl: calc(var(--font-size-xxl) * 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);
|
||||
}
|
||||
|
||||
.w--dot-2xl {
|
||||
width: calc(var(--font-size-2xl) / 2);
|
||||
.w--dot-xxl {
|
||||
width: calc(var(--font-size-xxl) / 2);
|
||||
}
|
||||
|
||||
.w--dot-3xl {
|
||||
width: calc(var(--font-size-3xl) / 2);
|
||||
.w--dot-xxxl {
|
||||
width: calc(var(--font-size-xxxl) / 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,11 @@
|
||||
width: calc(var(--font-size-xl) * var(--line-height));
|
||||
}
|
||||
|
||||
.w--inline-xl {
|
||||
width: calc(var(--font-size-2xl) * var(--line-height));
|
||||
.w--inline-xxl {
|
||||
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);
|
||||
}
|
||||
|
||||
.w--item--2xl {
|
||||
width: var(--height-item-2xl);
|
||||
.w--item--xxl {
|
||||
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;
|
||||
}>;
|
||||
|
||||
export function createClassRecipe<V extends Record<string, Record<string, string>>>(
|
||||
config: VariantsConfig<V>,
|
||||
) {
|
||||
export function createClassRecipe<
|
||||
V extends Record<string, Record<string, string>>,
|
||||
>(config: VariantsConfig<V>) {
|
||||
return function (props: VariantProps<V> = {}): 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)[]) {
|
||||
const map = new Map<string, string>();
|
||||
|
||||
|
||||
@@ -2,3 +2,5 @@ declare module "*.css" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module "*.json";
|
||||
@@ -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"]
|
||||
}
|
||||
@@ -1,54 +1,44 @@
|
||||
{
|
||||
// 本文件仅供 TS Server 检查语法,不负责编译,编译使用的是另一个文件 tsconfig.build.json
|
||||
|
||||
// TS 类型检查专用配置, build 配置继承后按需覆盖。
|
||||
"compilerOptions": {
|
||||
// This is a component library, so "ESNext" is a good choice. Also it requires very little down-leveling during transpilation.
|
||||
"target": "esnext",
|
||||
// Include a list of type definitions for build-in JS APIs.
|
||||
"lib": ["esnext", "DOM", "DOM.Iterable"],
|
||||
// Specify the module system for the output files. It's not required for Vite but good to have.
|
||||
// 编译后, 输出的语法格式,自从 2026 年后,cjs 模块也能识别 es 模块了,如果需要兼容老项目则调低版本
|
||||
"target": "es2023",
|
||||
// 前端用 esnext ,后端用 nodenext ,node 其实也是用 js 写的一个库,前端是不带这个库的
|
||||
"module": "esnext",
|
||||
// The types defined in "vite/client" are included in global scope.
|
||||
"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.
|
||||
// 所有项目必须开,兼容 es 和 cjs 导入,允许 import React from 'react' ,而非 import * as React 。
|
||||
"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'`.
|
||||
"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.
|
||||
// 允许导入 ts,tsx 扩展名,include 里可以省略后缀。
|
||||
"allowImportingTsExtensions": true,
|
||||
// Enfore "type" modifier for type imports.
|
||||
"verbatimModuleSyntax": true,
|
||||
// Ensure the public class field initialization is transpiled correctly to match the future JS standard.
|
||||
"useDefineForClassFields": true,
|
||||
// Type-checking options
|
||||
// 允许 js,jsx 扩展名,include 里可以省略后缀。
|
||||
"allowJs": true,
|
||||
// 启用装饰器,也就是 @XXX 注解。
|
||||
"experimentalDecorators": true,
|
||||
// 发射装饰器元数据。
|
||||
"emitDecoratorMetadata": true,
|
||||
// 转换 jsx 时,使用 17+ 的新语法导入 react 。
|
||||
"jsx": "react-jsx",
|
||||
// 可作为子项目,被其他项目引用,但建议使用 workspace dep 模式,不是写 references 。
|
||||
"composite": false,
|
||||
// 只加载指定类型的声明包,避免加载无用类型,提升编译速度
|
||||
"types": ["node", "vite/client"],
|
||||
// 不输出编译后的文件,也就是 dist 目录下为空, 本文件只做类型检查。
|
||||
"noEmit": true,
|
||||
// 开启严格类型检查模式,只需开启这一个,其他的等于都开启了,要注意这只是类型检查,而非语法检查。
|
||||
"strict": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": true
|
||||
// 让 TS 编译器保留用于注解的 import 语句,不要优化掉,后面 babel 转义器要用。
|
||||
"verbatimModuleSyntax": true,
|
||||
// 跳过第三方库的类型检查,加快编译速度,减少30% 。
|
||||
"skipLibCheck": true,
|
||||
// 跳过内置库的类型检查,加快编译速度,分钟级降至秒级。
|
||||
"skipDefaultLibCheck": true,
|
||||
// 增量编译,加快编译速度,尤其是大项目。
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
||||
// 本配置文件的作用范围,包含根目录下的一切文件,包括 vite.config.ts 等配置文件
|
||||
"include": ["**/*.ts",],
|
||||
// 本配置文件排除的范围。
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"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");
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -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",
|
||||
// },
|
||||
// },
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user