mm
This commit is contained in:
@@ -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?
|
||||
@@ -0,0 +1 @@
|
||||
registry = https://registry.npmmirror.com/
|
||||
@@ -0,0 +1,22 @@
|
||||
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,
|
||||
},
|
||||
},
|
||||
])
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ButtonGallery } from "./button-gallery";
|
||||
import { Theme } from "../src/components/theme/theme";
|
||||
import { PopoverGallery } from "./popover-gallery";
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<div className="app">
|
||||
<Theme>
|
||||
<ButtonGallery />
|
||||
<PopoverGallery />
|
||||
</Theme>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { DownloadSvg } from "../src/assets/svg/DownloadSvg";
|
||||
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 />}>
|
||||
small
|
||||
</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>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export const IW = ({ children }: { children: ReactNode }) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
gap: "10px",
|
||||
display: "flex",
|
||||
flexWrap: "nowrap",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
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>,
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
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>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
<!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>
|
||||
@@ -0,0 +1,37 @@
|
||||
block,flex,inline-block,inline-flex 有什么区别?
|
||||
|
||||
# 内联元素
|
||||
|
||||
inline 或 inline- 前缀,就是内联元素的意思,内联元素的 width 和 height 是不起效果的。
|
||||
但是 inline-block 可以正常设置 width 和 height。
|
||||
|
||||
inline,顾名思义,就是和【inline 文本】一个地位,大多数时候,你可能想要【一行元素】而不是【一行文本】。
|
||||
|
||||
text-align,可以将文本居中,因此也能让 inline- 的元素居中。
|
||||
|
||||
inline 的换行行为,就是越界才换行。
|
||||
|
||||
# 易错点
|
||||
|
||||
span 是一个 inline 元素,里面不应该使用 svg 这种 block 元素。
|
||||
有些人的 span 里面只有一个 svg 元素,因此他们没发现问题所在。
|
||||
如果你尝试,把【文本】和【svg】放进同一个 span 元素里,你就会发现 text-align:center 无法使两者居中,【svg】不受 text-align 的影响。
|
||||
你开始疑问,emoj 表情包里面肯定是有 svg 的,他是怎么放进一行话中的?
|
||||
你查了下发现,对话框用的是 div,表情用的是 i,文本用的是 span。
|
||||
|
||||
# 块级元素
|
||||
|
||||
flex,block,自身作为子元素,要求换行,跟 inline 元素相反。
|
||||
两个子元素,一个 flex,一个 block,每个独占一行。
|
||||
|
||||
父元素 【align-items: center】 才能使块元素居中。
|
||||
|
||||
block,自身作为父元素,允许子元素换行,换不换,看子元素自己意愿。
|
||||
flex,自身作为父元素,不允许子元素换行。
|
||||
另外要注意,flex-wrap 的 默认值是 nowrap,但是可以修改成 wrap,模拟 inline 的越界换行。
|
||||
|
||||
# 网格元素
|
||||
|
||||
grid,与 justify-items,和 align-items 相关,每一个 cell 单元格,就是一个 item。
|
||||
|
||||
# 大部分情况是用不到 inline 的
|
||||
@@ -0,0 +1,21 @@
|
||||
# isValidElement 不通过
|
||||
|
||||
通常是 SvgComponent 的属性使用了短横线,而不是驼峰。
|
||||
|
||||
# 弹框在页面左上角
|
||||
|
||||
mergeProps 里面的 function 函数合并出问题了。
|
||||
|
||||
# 点击无反应
|
||||
|
||||
没做 【isMounted && 】的判断。
|
||||
|
||||
setIsOpen(!isOpen),而不是 setIsOpen(true)。
|
||||
|
||||
# hover 不亮
|
||||
|
||||
brandRecipe 可能漏了,css 变量没有提供。
|
||||
|
||||
# FloatingArrow 箭头位置不对
|
||||
|
||||
arrow() 需要位于 offset,shift,flip 之后。
|
||||
@@ -0,0 +1,21 @@
|
||||
当你没有【对应格式】的【编辑器】来给你解析时,始终确保【原生文本】是【人类可读的】。
|
||||
就像【任何格式】的文件,都可以用txt来浏览。
|
||||
|
||||
md 的语法是有缺陷的,【前标签】和【后标签】相互夹起来,而不是用【换行】这种容易被误解的方式,否则一旦有人删除空行,就会导致排版问题。
|
||||
|
||||
【前后标签】方案,适配 style 应用,你可以 【div + class】,或者直接创造一个新标签,
|
||||
例如【<b></b>】。
|
||||
|
||||
为了人类可读,始终不建议标签上直接写【style 属性】而是使用【class 属性】,因为这些不是内容,只是告诉渲染器如何渲染,我非常支持【废除 style 属性】。
|
||||
|
||||
css 文件应该支持 atom 解构赋值,多条样式写好了,封装成一个 atom,就不要反反复复写了。
|
||||
|
||||
【class属性】应取消按【特征值】大小覆盖的逻辑,而是始终【后面覆盖前面】。
|
||||
|
||||
|
||||
为了解决这个问题,我自己写了【基于前缀】的【class 替换】逻辑 【cpm】,旧的直接去掉,换新的上。
|
||||
|
||||
如果后面覆盖前面,那么旧的根本不用去掉,直接在末尾加新的即可,也不用开发者学习,要去掉哪些【旧前缀】?
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
最大问题就是,checkbox,icon,indicator,这三者会拉长长度。
|
||||
|
||||
一个 20 条 item,要有一个具有 checkbox,剩下的全部都得加宽。
|
||||
|
||||
【blender】的方案是,有 checkbox 的,就不要 icon,并始终保留 indicator 的位置。
|
||||
|
||||
通常一个【3d viewport】需要做选择,【显示曲线】或【显示面】等。
|
||||
有 icon 可以极其方便用户,一看便知道。
|
||||
不过此处,不是用 checkbox 来选中状态,而是用【背景色】。
|
||||
但是我希望,这个 viewport 的独立菜单中,也可以看到这个 checkbox。
|
||||
这时候,checkbox 和 icon 是必须同时显示,才能让用户通过 icon 识别。
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
不需要判空的,只有原始 string,number这类型。
|
||||
|
||||
- 带 【?】号的
|
||||
- 带【 | undefind 】交叉类型的
|
||||
- 非原始类型,例如 Array [],Map,对象 {}, 等
|
||||
|
||||
上面全部都是要判空的。
|
||||
@@ -0,0 +1,3 @@
|
||||
如果只是,以便靠左,一边靠右,那就不要用浮动。
|
||||
|
||||
使用浮动 float 的情况,只有文档内,图片需要【文字环绕】的情况。
|
||||
@@ -0,0 +1,15 @@
|
||||
例如,一个表格,当在平板电脑上时,是否需要放大?
|
||||
如果是手机模式,按理说表格应该尽可能,自动拉扯,以便占满屏幕。
|
||||
|
||||
一个桌面网页,在手机上被浏览,往往会【触发换行】。
|
||||
不换行,是反操作体验的,没人希望,每一行内容都要手动滚动。
|
||||
|
||||
因此,一些导航栏,需要监控是否超出屏幕,用一些特殊方法,提供一个菜单,覆盖默认换行行为。
|
||||
|
||||
始终考虑【超出屏幕】就是【面向响应式】设计。
|
||||
|
||||
每个组件的【长度】是不一样的,一旦下一个换行,前一个的末尾,会不会留有空白?
|
||||
|
||||
导航栏,这个组件本身,可以全部替换成菜单。
|
||||
|
||||
标签栏,就会有【长度】问题,但【wps-sheet】和【excel】的方案,【...按钮】省略按钮,和【菜单按钮】悬浮在【最右侧】,不提供滚动条,而是提供2个【箭头按钮】,拖动时悬浮在【...按钮】上,自动滚动。
|
||||
@@ -0,0 +1,26 @@
|
||||
先说一个结论, ts 的 typeof 只能判断原始类型, 例如, string, numnber 这些。
|
||||
|
||||
你自己 用 type 定义了 2 个自定义类型,是无法用 typeof 判断的,这导致非常麻烦的问题。
|
||||
|
||||
如果不是 ts,而是强类型语言,就是简单的 typeof 就解决的事情。
|
||||
|
||||
所以,编译时,是永远无法检查出来的,只有运行时报错。
|
||||
|
||||
你只要确定【兼容】,就直接用 AS 强制转换,不用管其他的。
|
||||
|
||||
其他开发者乱传入参数,那就让他们运行时报错,我们不搞什么动态校验。
|
||||
|
||||
``````
|
||||
export function mergeProps(classMergeFn?: ClassMergeFn | AnyProps, ...propsList: AnyProps[]): AnyProps {
|
||||
|
||||
// 始终提供默认值,否则后面大量判空
|
||||
let _classMergeFn = defaultClassMergeFn;
|
||||
let _propsList = propsList;
|
||||
|
||||
if (typeof classMergeFn === "function") {
|
||||
_classMergeFn = classMergeFn as ClassMergeFn
|
||||
} else if (classMergeFn != undefined) {
|
||||
_propsList = [classMergeFn as AnyProps, ...propsList]
|
||||
}
|
||||
}
|
||||
``````
|
||||
@@ -0,0 +1,41 @@
|
||||
# 顺序问题
|
||||
|
||||
我最初以为,&:focus 和 &:active 是像 switch 一样的分支判断,但其实不是。
|
||||
|
||||
focus 状态同时也会激活 active 状态。
|
||||
|
||||
你必须把 &:focus 放在 &:active 的前面,这样子才不会让 active 覆盖了 focus。
|
||||
|
||||
# 如何区分鼠标和键盘焦点
|
||||
|
||||
:focus,鼠标,触控,键盘都有。
|
||||
|
||||
:focus-visable,仅键盘焦点。
|
||||
|
||||
:focus:not(:focus-visible),从三者中排除键盘焦点,剩下就是鼠标,触控焦点。
|
||||
|
||||
# 如何消除焦点边框
|
||||
|
||||
|
||||
.reset {
|
||||
|
||||
/* 鼠标与触控焦点,必须在 :focus-visible 之后 */
|
||||
button:focus:not(:focus-visible),
|
||||
div:focus:not(:focus-visible) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* 单独设置键盘焦点,必须在 :focus:not(:focus-visible) 之前 */
|
||||
button:focus-visible,
|
||||
div:focus-visible {
|
||||
outline: 2px solid var(--focus-outline-color);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# 如何用色
|
||||
|
||||
有背景色的,hover 深,active 浅,例如,filled,subtle。
|
||||
无背景色的,hover 浅,active 深,例如,outline,ghost。
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "@dg/ui-react",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"sideEffects": [
|
||||
"*.css"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"./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"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export const BoldSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M7 5h6a3.5 3.5 0 0 1 0 7H7zm6 7h1a3.5 3.5 0 0 1 0 7H7v-7"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
export const CheckIndicatorSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const ChevronRightSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="m9 6l6 6l-6 6"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const CloseSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M18 6L6 18M6 6l12 12"
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
export const CutSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12.14 9.342L7.37 2.329a.75.75 0 1 0-1.24.844l5.13 7.545l-2.395 3.743a4 4 0 1 0 1.178.943l2.135-3.337l2.065 3.036a4 4 0 1 0 1.261-.813l-2.447-3.597l.002-.002zM4.5 18a2.5 2.5 0 1 1 5 0a2.5 2.5 0 0 1-5 0m10 0a2.5 2.5 0 1 1 5 0a2.5 2.5 0 0 1-5 0m-.562-8.684l3.943-6.162a.75.75 0 1 0-1.263-.808L13.02 7.968z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
export const DownloadSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 24 24" {...props}>
|
||||
|
||||
<path fill="currentColor" d="M20,15.5c.55,0,1,.45,1,1v2c0,1.66-1.34,3-3,3H6c-1.66,0-3-1.34-3-3v-2c0-.55.45-1,1-1s1,.45,1,1v2c0,.55.45,1,1,1h12c.55,0,1-.45,1-1v-2c0-.55.45-1,1-1M12,2.5c.55,0,1,.45,1,1v9.59l3.29-3.29c.4-.38,1.03-.37,1.41.02.37.39.37,1,0,1.39l-5,5s-.06.06-.09.08l.09-.08c-.18.18-.42.28-.67.29h-.03s-.03,0-.03,0h-.05s.09,0,.09,0c-.22,0-.44-.07-.62-.21-.03-.02-.06-.05-.09-.08l-5-5c-.38-.4-.37-1.03.02-1.41.39-.37,1-.37,1.39,0l3.29,3.29V3.5c0-.55.45-1,1-1" />
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
export const FileSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
>
|
||||
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
||||
<path d="M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2" />
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
export const KeySvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M7 14q-.825 0-1.412-.587T5 12t.588-1.412T7 10t1.413.588T9 12t-.587 1.413T7 14m0 4q-2.5 0-4.25-1.75T1 12t1.75-4.25T7 6q1.675 0 3.038.825T12.2 9h8.375q.2 0 .388.075t.337.225l2 2q.15.15.212.325t.063.375t-.063.375t-.212.325l-3.175 3.175q-.125.125-.3.2t-.35.1t-.35-.025t-.325-.175L17.5 15l-1.425 1.075q-.125.1-.275.15t-.3.05t-.313-.05t-.287-.15L13.375 15H12.2q-.8 1.35-2.163 2.175T7 18m0-2q1.4 0 2.463-.85T10.875 13H14l1.45 1.025v.013v-.013L17.5 12.5l1.775 1.375L21.15 12h-.012h.012l-1-1v-.012V11h-9.275q-.35-1.3-1.412-2.15T7 8Q5.35 8 4.175 9.175T3 12t1.175 2.825T7 16"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
export const MeshSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
>
|
||||
<path d="M3 9h18M3 15h18M8 4c.485.445 3.5 3.312 3.5 8c0 .663-.07 4.848-3.5 8m7-16a17 17 0 0 1 2.004 8c0 1.51-.201 4.628-2.004 8" />
|
||||
<path d="M18.778 20H5.222A2.22 2.22 0 0 1 3 17.778V6.222C3 4.995 3.995 4 5.222 4h13.556C20.005 4 21 4.995 21 6.222v11.556A2.22 2.22 0 0 1 18.778 20" />
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const MoonSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M12 3h.393a7.5 7.5 0 0 0 7.92 12.446A9 9 0 1 1 12 2.992z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
export const PasteSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12.753 2c1.158 0 2.111.875 2.234 2h1.763a2.25 2.25 0 0 1 2.245 2.096L19 6.25a.75.75 0 0 1-.647.742L18.249 7a.75.75 0 0 1-.742-.647L17.5 6.25a.75.75 0 0 0-.648-.743L16.75 5.5h-2.132a2.24 2.24 0 0 1-1.865.993H9.247a2.24 2.24 0 0 1-1.865-.992L5.25 5.5a.75.75 0 0 0-.743.648L4.5 6.25v13.505c0 .38.282.693.648.743l.102.007h3a.75.75 0 0 1 .743.647l.007.102a.75.75 0 0 1-.75.75h-3a2.25 2.25 0 0 1-2.245-2.095L3 19.755V6.25a2.25 2.25 0 0 1 2.096-2.245L5.25 4h1.763a2.247 2.247 0 0 1 2.234-2zm5.997 6a2.25 2.25 0 0 1 2.245 2.096l.005.154v9.5a2.25 2.25 0 0 1-2.096 2.245L18.75 22h-6.5a2.25 2.25 0 0 1-2.245-2.096L10 19.75v-9.5a2.25 2.25 0 0 1 2.096-2.245L12.25 8zm0 1.5h-6.5a.75.75 0 0 0-.743.648l-.007.102v9.5c0 .38.282.694.648.743l.102.007h6.5a.75.75 0 0 0 .743-.648l.007-.102v-9.5a.75.75 0 0 0-.648-.743zm-5.997-6H9.247a.747.747 0 0 0 0 1.493h3.506a.747.747 0 1 0 0-1.493"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const RulerSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M5 4h14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-7a1 1 0 0 0-1 1v7a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1M4 8h2m-2 4h3m-3 4h2M8 4v2m4-2v3m4-3v2"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
export const SearchSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M9.5 16q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l5.6 5.6q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-5.6-5.6q-.75.6-1.725.95T9.5 16m0-2q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
export const SettingSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
fillRule="evenodd"
|
||||
d="M12.563 3.2h-1.126l-.645 2.578l-.647.2a6.3 6.3 0 0 0-1.091.452l-.599.317l-2.28-1.368l-.796.797l1.368 2.28l-.317.598a6.3 6.3 0 0 0-.453 1.091l-.199.647l-2.578.645v1.126l2.578.645l.2.647q.173.568.452 1.091l.317.599l-1.368 2.28l.797.796l2.28-1.368l.598.317q.523.278 1.091.453l.647.199l.645 2.578h1.126l.645-2.578l.647-.2a6.3 6.3 0 0 0 1.091-.452l.599-.317l2.28 1.368l.796-.797l-1.368-2.28l.317-.598q.278-.523.453-1.091l.199-.647l2.578-.645v-1.126l-2.578-.645l-.2-.647a6.3 6.3 0 0 0-.452-1.091l-.317-.599l1.368-2.28l-.797-.796l-2.28 1.368l-.598-.317a6.3 6.3 0 0 0-1.091-.453l-.647-.199zm2.945 2.17l1.833-1.1a1 1 0 0 1 1.221.15l1.018 1.018a1 1 0 0 1 .15 1.221l-1.1 1.833q.33.62.54 1.3l2.073.519a1 1 0 0 1 .757.97v1.438a1 1 0 0 1-.757.97l-2.073.519q-.21.68-.54 1.3l1.1 1.833a1 1 0 0 1-.15 1.221l-1.018 1.018a1 1 0 0 1-1.221.15l-1.833-1.1q-.62.33-1.3.54l-.519 2.073a1 1 0 0 1-.97.757h-1.438a1 1 0 0 1-.97-.757l-.519-2.073a7.5 7.5 0 0 1-1.3-.54l-1.833 1.1a1 1 0 0 1-1.221-.15L4.42 18.562a1 1 0 0 1-.15-1.221l1.1-1.833a7.5 7.5 0 0 1-.54-1.3l-2.073-.519A1 1 0 0 1 2 12.72v-1.438a1 1 0 0 1 .757-.97l2.073-.519q.21-.68.54-1.3L4.27 6.66a1 1 0 0 1 .15-1.221L5.438 4.42a1 1 0 0 1 1.221-.15l1.833 1.1q.62-.33 1.3-.54l.519-2.073A1 1 0 0 1 11.28 2h1.438a1 1 0 0 1 .97.757l.519 2.073q.68.21 1.3.54zM12 14.8a2.8 2.8 0 1 0 0-5.6a2.8 2.8 0 0 0 0 5.6m0 1.2a4 4 0 1 1 0-8a4 4 0 0 1 0 8"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
export const SpinnerSvg = (props: React.SVGProps<SVGSVGElement>) => {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
|
||||
opacity="0.25"
|
||||
/>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
|
||||
>
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
dur="0.75s"
|
||||
repeatCount="indefinite"
|
||||
type="rotate"
|
||||
values="0 12 12;360 12 12"
|
||||
/>
|
||||
</path>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
export const SunSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M8 12a4 4 0 1 0 8 0a4 4 0 1 0-8 0m-5 0h1m8-9v1m8 8h1m-9 8v1M5.6 5.6l.7.7m12.1-.7l-.7.7m0 11.4l.7.7m-12.1-.7l-.7.7"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
export const UserSvg = (props: React.SVGProps<SVGSVGElement>) => {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="1.5"
|
||||
d="M19.618 21.25c0-3.602-4.016-6.53-7.618-6.53s-7.618 2.928-7.618 6.53M12 11.456a4.353 4.353 0 1 0 0-8.706a4.353 4.353 0 0 0 0 8.706"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
export const VolumeHighSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M15 8a5 5 0 0 1 0 8m2.7-11a9 9 0 0 1 0 14M6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2l3.5-4.5A.8.8 0 0 1 11 5v14a.8.8 0 0 1-1.5.5z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const VolumeLowSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M15 8a5 5 0 0 1 0 8m-9-1H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2l3.5-4.5A.8.8 0 0 1 11 5v14a.8.8 0 0 1-1.5.5z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
export const VolumeMuteSvg = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2l3.5-4.5A.8.8 0 0 1 11 5v14a.8.8 0 0 1-1.5.5zm10-5l4 4m0-4l-4 4"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
type CSSProperties,
|
||||
} from "react";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { dotSizeRecipe } from "../../styles/recipes/dot-size-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { brandRecipe } from "../../styles/recipes/brand-recipe";
|
||||
|
||||
export type BadgeProps = CommonProps & {
|
||||
size?: "xs" | "sm" | "md" | "lg";
|
||||
} & {
|
||||
isDot?: boolean;
|
||||
indicatorContent?: string;
|
||||
};
|
||||
|
||||
export const Badge = (props: BadgeProps) => {
|
||||
const {
|
||||
indicatorContent = "",
|
||||
isDot = false,
|
||||
size = "md",
|
||||
children,
|
||||
className = "",
|
||||
ref,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const wrapperStyle: CSSProperties = {
|
||||
position: "relative",
|
||||
height: "fit",
|
||||
width: "fit",
|
||||
};
|
||||
|
||||
const indicatorStyle: CSSProperties = {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
right: 0,
|
||||
transform: "translate(50%,-50%)",
|
||||
borderRadius: "9999px",
|
||||
};
|
||||
|
||||
|
||||
|
||||
const indicatorClass = mergeClass(displayRecipe(), dotSizeRecipe({ size }), brandRecipe({ brand: "danger" }), "pointer-events--none", className);
|
||||
|
||||
return (
|
||||
<div {...rest} ref={ref} style={wrapperStyle}>
|
||||
{children}
|
||||
<div className={indicatorClass} style={indicatorStyle}>
|
||||
{indicatorContent}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
import React, { useState, type CSSProperties, type ReactNode } from "react";
|
||||
import { SpinnerSvg } from "../../assets/svg/SpinnerSvg";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { itemSizeRecipe } from "../../styles/recipes/item-size-recipe";
|
||||
import { variantRecipe } from "../../styles/recipes/variant-recipe";
|
||||
import { brandRecipe } from "../../styles/recipes/brand-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
|
||||
export type ButtonProps = CommonProps & {
|
||||
size?: "xs" | "sm" | "md" | "lg";
|
||||
variant?: "filled" | "outline" | "subtle" | "ghost";
|
||||
shape?: "rounded" | "square" | "circle";
|
||||
brand?: "success" | "danger" | "info" | "warning" | "default";
|
||||
width?: string;
|
||||
} & {
|
||||
isIconOnly?: boolean;
|
||||
isHideIcon?: boolean;
|
||||
} & {
|
||||
canLoading?: boolean;
|
||||
isLoading?: boolean;
|
||||
} & {
|
||||
iconSvg?: ReactNode;
|
||||
loadingIconSvg?: ReactNode;
|
||||
onClick?: (e?: React.MouseEvent<Element, MouseEvent>) => void;
|
||||
};
|
||||
|
||||
export const Button = (props: ButtonProps) => {
|
||||
const {
|
||||
size = "md",
|
||||
variant = "filled",
|
||||
shape = "rounded",
|
||||
brand,
|
||||
// ===========================
|
||||
style,
|
||||
width,
|
||||
// ===========================
|
||||
isIconOnly = false,
|
||||
isHideIcon = false,
|
||||
// ===========================
|
||||
canLoading = false,
|
||||
isLoading,
|
||||
// ===========================
|
||||
isDisabled = false,
|
||||
// =========================
|
||||
className = "",
|
||||
children,
|
||||
// ==========================
|
||||
iconSvg,
|
||||
loadingIconSvg = <SpinnerSvg />,
|
||||
ref,
|
||||
onClick,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const [innerIsLoading, setInnerIsIsLoading] = useState<{
|
||||
state: boolean;
|
||||
class: string;
|
||||
}>({ state: false, class: "" });
|
||||
|
||||
const brandFinal =
|
||||
brand != undefined ? brand : variant == "filled" ? "info" : "default";
|
||||
|
||||
// ====================================================================================
|
||||
|
||||
const rootClass = mergeClass(
|
||||
displayRecipe(),
|
||||
itemSizeRecipe({ size, shape, isIconOnly, isLongPadding: true }),
|
||||
variantRecipe({ variant, isDisabled }),
|
||||
brandRecipe({ brand: brandFinal }),
|
||||
className,
|
||||
);
|
||||
|
||||
let rootStyle: CSSProperties = {
|
||||
transitionDuration: "all 5s ease-in-out",
|
||||
width: width,
|
||||
...style,
|
||||
};
|
||||
|
||||
let loadingClass = mergeClass("");
|
||||
|
||||
// =========================================================================================
|
||||
|
||||
function clickHandler(e: React.MouseEvent<Element, MouseEvent>) {
|
||||
if (canLoading && isLoading == undefined) {
|
||||
}
|
||||
onClick?.(e);
|
||||
}
|
||||
|
||||
// =========================================================================================
|
||||
|
||||
const icon = <Icon size={size}>{iconSvg}</Icon>;
|
||||
const loadingIcon = (
|
||||
<Icon size={size} className={loadingClass}>
|
||||
{loadingIconSvg}
|
||||
</Icon>
|
||||
);
|
||||
|
||||
return (
|
||||
<button
|
||||
{...rest}
|
||||
ref={ref}
|
||||
className={rootClass}
|
||||
style={rootStyle}
|
||||
onClick={clickHandler}
|
||||
>
|
||||
{canLoading && isLoading && loadingIcon}
|
||||
{!isHideIcon && iconSvg && icon}
|
||||
{!isIconOnly && children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
Button.displayName = "Button";
|
||||
@@ -0,0 +1,36 @@
|
||||
import { useState, type ComponentPropsWithRef } from "react";
|
||||
import { CheckIndicatorSvg } from "../../assets/svg/CheckIndicatorSvg";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { inlineSizeRecipe } from "../../styles/recipes/inline-size-recipe";
|
||||
|
||||
export type CheckboxProps = CommonProps & {
|
||||
size?: "sm" | "md",
|
||||
defaultCheck?: boolean,
|
||||
onChange?: (preCheck?: boolean, nextCheck?: boolean) => void,
|
||||
controllerCheck?: boolean
|
||||
};
|
||||
|
||||
export const Checkbox = (props: CheckboxProps) => {
|
||||
const { defaultCheck = false, ref, onChange, size = "sm", className = "" } = props
|
||||
|
||||
const [isCheck, setIsCheck] = useState<boolean>(defaultCheck)
|
||||
|
||||
const rootClass = mergeClass(inlineSizeRecipe({ size, shape: "rounded", isIconOnly: true }), className)
|
||||
|
||||
const inputClass = mergeClass("sr-only")
|
||||
|
||||
const indicatorClass = mergeClass(inlineSizeRecipe({ size, shape: "rounded" }))
|
||||
|
||||
function clickHandler() {
|
||||
const preValue = isCheck
|
||||
setIsCheck(!isCheck)
|
||||
onChange?.(preValue, isCheck)
|
||||
}
|
||||
|
||||
return <div className={rootClass} onClick={clickHandler} >
|
||||
<input className={inputClass} type="checkbox" ref={ref} />
|
||||
{isCheck && <CheckIndicatorSvg className={indicatorClass} />}
|
||||
</div>
|
||||
}
|
||||
Checkbox.displayName = "Checkbox"
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
import { Slot } from "../../utils/slot";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { inlineSizeRecipe } from "../../styles/recipes/inline-size-recipe";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
|
||||
export type IconProps = CommonProps & {
|
||||
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
|
||||
shape?: "square" | "circle" | "rounded";
|
||||
} & {
|
||||
onClick?: (e?: React.MouseEvent) => void
|
||||
};
|
||||
|
||||
export const Icon = (props: IconProps) => {
|
||||
const { size = "md", className = "", children, shape = "square", ref, ...rest } = props;
|
||||
|
||||
const rootClass = mergeClass(inlineSizeRecipe({ size, shape, isIconOnly: "true" }), className);
|
||||
|
||||
return (
|
||||
<Slot {...rest} ref={ref} className={rootClass}>{children}</Slot>
|
||||
);
|
||||
};
|
||||
|
||||
Icon.displayName = "Icon";
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
import { useMenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { useListItem, useMergeRefs } from "@floating-ui/react";
|
||||
import { useMenuContext } from "./use-menu-context";
|
||||
import React, { useState, type CSSProperties } from "react";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { Checkbox } from "../checkbox/checkbox";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { itemSizeRecipe } from "../../styles/recipes/item-size-recipe";
|
||||
import { variantRecipe } from "../../styles/recipes/variant-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { containerRecipe } from "../../styles/recipes/container-recipe";
|
||||
|
||||
export type MenuCheckItemProps = CommonProps & {
|
||||
iconSvg?: React.ReactNode;
|
||||
hotkey?: string;
|
||||
check?: boolean
|
||||
onChange?: (preCheck?: boolean, nextCheck?: boolean) => void
|
||||
};
|
||||
|
||||
export const MenuCheckItem = (props: MenuCheckItemProps) => {
|
||||
const { ref, children, iconSvg = <div></div>, style, hotkey, isDisabled = false, onChange, ...rest } = props;
|
||||
|
||||
const [isCheck, setIsCheck] = useState<boolean>(false)
|
||||
|
||||
// =============== Menu Context ====================================================================
|
||||
|
||||
const menuContext = useMenuContext();
|
||||
const { size = "sm" } = menuContext!
|
||||
|
||||
// =============== Menu Floating Context ====================================================================
|
||||
|
||||
const menuFloatingContext = useMenuFloatingContext();
|
||||
const { getItemProps, activeIndex, isOpen, } = menuFloatingContext!
|
||||
|
||||
const item = useListItem();
|
||||
const isActive = item.index === activeIndex;
|
||||
|
||||
// ================== Style =================================================================
|
||||
|
||||
const rootClass = mergeClass(displayRecipe({ justifyContent: "between", }), containerRecipe({ hasFocusOutline: "false" }),
|
||||
itemSizeRecipe({ size, shape: "rounded" }),
|
||||
variantRecipe({ variant: "ghost", isDisabled }))
|
||||
|
||||
const rootStyle: CSSProperties = {
|
||||
width: "100%",
|
||||
...style
|
||||
}
|
||||
|
||||
const startSectionClass = displayRecipe()
|
||||
|
||||
const endSectionClass = displayRecipe()
|
||||
|
||||
function handleOnClick() {
|
||||
const preCheck = isCheck
|
||||
setIsCheck(!isCheck)
|
||||
onChange?.(preCheck, isCheck)
|
||||
}
|
||||
|
||||
return <button {...rest} ref={useMergeRefs([ref, item.ref])}
|
||||
className={rootClass}
|
||||
role="menuitem"
|
||||
tabIndex={isActive ? 0 : -1}
|
||||
disabled={isDisabled}
|
||||
{...getItemProps({
|
||||
style: rootStyle,
|
||||
onClick: handleOnClick
|
||||
})
|
||||
}
|
||||
>
|
||||
|
||||
<Checkbox size={size} defaultCheck={isCheck} />
|
||||
|
||||
<div className={startSectionClass}>
|
||||
<Icon size={size}>{iconSvg}</Icon>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
<div className={endSectionClass}>
|
||||
{hotkey && <div>{hotkey}</div>}
|
||||
<Icon size={size}><div></div></Icon>
|
||||
</div>
|
||||
</button >
|
||||
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { ComponentPropsWithoutRef, CSSProperties } from "react";
|
||||
import {
|
||||
FloatingFocusManager,
|
||||
FloatingList,
|
||||
FloatingPortal,
|
||||
} from "@floating-ui/react";
|
||||
import { useMenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { useMenuContext } from "./use-menu-context";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { containerRecipe } from "../../styles/recipes/container-recipe"
|
||||
import { useThemeContext } from "../theme/use-theme-context";
|
||||
|
||||
|
||||
export type MenuDropdownProps = ComponentPropsWithoutRef<"div"> & {
|
||||
modal?: boolean;
|
||||
};
|
||||
|
||||
export const MenuDropdown = (props: MenuDropdownProps) => {
|
||||
const { modal = true, className = "", children, ...rest } = props;
|
||||
|
||||
const { size } = useMenuContext()!
|
||||
const { refs, elementsRef, context, floatingStyles, getFloatingProps, isNested, isOpen } = useMenuFloatingContext()!;
|
||||
|
||||
// ==============================================================================================================
|
||||
|
||||
const { themeBaseClass, themeClass } = useThemeContext()!
|
||||
|
||||
// ===============================================================================================================
|
||||
|
||||
const rootClass = mergeClass(themeBaseClass, themeClass, containerRecipe(), className);
|
||||
|
||||
const padding = size == "sm" ? "4px" : (size == "md" ? "8px" : undefined);
|
||||
const borderRadius = size == "sm" ? "4px" : (size == "md" ? "8px" : undefined);
|
||||
|
||||
const rootStyle: CSSProperties = {
|
||||
...floatingStyles,
|
||||
borderRadius: borderRadius,
|
||||
padding: padding,
|
||||
// invisable the outline
|
||||
outline: 0,
|
||||
background: "var(--base-bg)"
|
||||
|
||||
}
|
||||
|
||||
return <FloatingList elementsRef={elementsRef}>
|
||||
{isOpen && <FloatingPortal >
|
||||
<FloatingFocusManager context={context} modal={modal} >
|
||||
<div {...rest} className={rootClass} style={rootStyle} ref={refs.setFloating} {...getFloatingProps()} >
|
||||
{children}
|
||||
</div>
|
||||
</FloatingFocusManager>
|
||||
</FloatingPortal>
|
||||
}
|
||||
</FloatingList >
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
import { useMenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { useListItem, useMergeRefs } from "@floating-ui/react";
|
||||
import React, { type CSSProperties } from "react";
|
||||
import { Icon } from "../icon/icon";
|
||||
import { ChevronRightSvg } from "../../assets/svg/ChevronRightSvg";
|
||||
import { useMenuTriggerContext } from "./use-menu-trigger-context";
|
||||
import { useMenuContext } from "./use-menu-context";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { itemSizeRecipe } from "../../styles/recipes/item-size-recipe";
|
||||
import { variantRecipe } from "../../styles/recipes/variant-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { containerRecipe } from "../../styles/recipes/container-recipe";
|
||||
|
||||
export type MenuItemProps = CommonProps & {
|
||||
onClick?: (e?: React.MouseEvent) => void;
|
||||
iconSvg?: React.ReactNode;
|
||||
indicatorSvg?: React.ReactNode;
|
||||
hotkey?: string;
|
||||
};
|
||||
|
||||
export const MenuItem = (props: MenuItemProps) => {
|
||||
const {
|
||||
ref,
|
||||
children,
|
||||
iconSvg = <div></div>,
|
||||
indicatorSvg = <ChevronRightSvg />,
|
||||
onClick,
|
||||
style,
|
||||
hotkey,
|
||||
isDisabled = false,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
// =============== Menu Context ====================================================================
|
||||
|
||||
const { size = "sm" } = useMenuContext()!;
|
||||
|
||||
// =============== Menu Floating Context ====================================================================
|
||||
|
||||
const menuFloatingContext = useMenuFloatingContext();
|
||||
const { getItemProps, activeIndex, isOpen } = menuFloatingContext!;
|
||||
|
||||
const item = useListItem();
|
||||
const isActive = item.index === activeIndex;
|
||||
|
||||
// =============== Menu Trigger Context ====================================================================
|
||||
|
||||
const menuTriggerContext = useMenuTriggerContext();
|
||||
|
||||
const isTrigger = !!menuTriggerContext;
|
||||
|
||||
// ================== Style =================================================================
|
||||
|
||||
const rootClass = mergeClass(
|
||||
displayRecipe({ justifyContent: "between" }),
|
||||
containerRecipe({ hasFocusOutline: "false" }),
|
||||
itemSizeRecipe({ size, shape: "rounded" }),
|
||||
variantRecipe({ variant: "ghost", isDisabled }),
|
||||
);
|
||||
|
||||
const rootStyle: CSSProperties = {
|
||||
width: "100%",
|
||||
...style,
|
||||
};
|
||||
|
||||
const startSectionClass = displayRecipe();
|
||||
|
||||
const endSectionClass = displayRecipe();
|
||||
|
||||
return (
|
||||
<button
|
||||
{...rest}
|
||||
ref={useMergeRefs([ref, item.ref])}
|
||||
className={rootClass}
|
||||
role="menuitem"
|
||||
tabIndex={isActive ? 0 : -1}
|
||||
disabled={isDisabled}
|
||||
{...getItemProps({
|
||||
style: rootStyle,
|
||||
onClick: (e) => {
|
||||
onClick?.(e);
|
||||
},
|
||||
})}
|
||||
>
|
||||
<div className={startSectionClass}>
|
||||
<Icon size={size}>{iconSvg}</Icon>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
<div className={endSectionClass}>
|
||||
{hotkey && <div>{hotkey}</div>}
|
||||
{isTrigger && isOpen && (
|
||||
<Icon size={size} style={{ rotate: "90deg" }}>
|
||||
{indicatorSvg}
|
||||
</Icon>
|
||||
)}
|
||||
{isTrigger && !isOpen && <Icon size={size}>{indicatorSvg}</Icon>}
|
||||
{!isTrigger && (
|
||||
<Icon size={size}>
|
||||
<div></div>
|
||||
</Icon>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useState } from "react";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { MenuRadioItemGroupContext } from "./use-menu-radio-item-group-context";
|
||||
import { useMenuContext } from "./use-menu-context";
|
||||
|
||||
export type MenuRadioItemGroupProps = CommonProps & {
|
||||
size?: "sm" | "md";
|
||||
defaultSelectName?: string
|
||||
};
|
||||
|
||||
export const MenuRadioItemGroup = (props: MenuRadioItemGroupProps) => {
|
||||
const { size = "sm", defaultSelectName = "", ...rest } = props
|
||||
|
||||
const [selectName, setSelectName] = useState<string>(defaultSelectName);
|
||||
|
||||
const { size: menuSize } = useMenuContext()!
|
||||
|
||||
const currentSize = menuSize ?? size
|
||||
|
||||
return <MenuRadioItemGroupContext value={{ size: currentSize, selectName, setSelectName }}>
|
||||
<div {...rest} ></div>
|
||||
</MenuRadioItemGroupContext>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useRef } from "react";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { useMenuRadioItemGroupContext } from "./use-menu-radio-item-group-context";
|
||||
|
||||
export type MenuRadioItemProps = CommonProps & {
|
||||
name: string;
|
||||
iconSvg?: React.ReactNode;
|
||||
hotkey?: string;
|
||||
onChange?: (preCheck?: boolean, nextCheck?: boolean) => void
|
||||
};
|
||||
|
||||
export const MenuRadioItem = (props: MenuRadioItemProps) => {
|
||||
const { name, children, className, hotkey, onChange, ref, iconSvg, style } = props
|
||||
|
||||
const { selectName, setSelectName } = useMenuRadioItemGroupContext()!
|
||||
const isSelect = name === selectName
|
||||
|
||||
return <div></div>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { ComponentPropsWithoutRef } from "react";
|
||||
|
||||
import { useMenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { Slot } from "../../utils/slot";
|
||||
import { MenuTriggerContext } from "./use-menu-trigger-context";
|
||||
|
||||
export type MenuTriggerProps = ComponentPropsWithoutRef<"div">;
|
||||
|
||||
export const MenuTrigger = (props: MenuTriggerProps) => {
|
||||
const { children } = props;
|
||||
|
||||
const menuFloatingContext = useMenuFloatingContext();
|
||||
const { refs, setIsOpen, getReferenceProps } = menuFloatingContext!;
|
||||
|
||||
return (
|
||||
<MenuTriggerContext.Provider value={{ isTrigger: true }}>
|
||||
<Slot className={"reset"} ref={refs.setReference} {...getReferenceProps(
|
||||
{ onClick: () => { setIsOpen(true) } }
|
||||
)}>
|
||||
{children}
|
||||
</Slot>
|
||||
</MenuTriggerContext.Provider>
|
||||
)
|
||||
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
import {
|
||||
FloatingNode,
|
||||
FloatingTree,
|
||||
} from "@floating-ui/react";
|
||||
import type { ComponentPropsWithoutRef } from "react";
|
||||
import { useMenuFloating } from "./use-menu-floating";
|
||||
import { MenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { MenuContext } from "./use-menu-context";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
|
||||
export type MenuProps = ComponentPropsWithoutRef<"div"> & {
|
||||
size?: "sm" | "md";
|
||||
};
|
||||
|
||||
export const Menu = (props: MenuProps) => {
|
||||
const { size = "sm", className = "", children, ...rest } = props;
|
||||
|
||||
|
||||
const menuFloatingContextValue = useMenuFloating();
|
||||
const { isNested, nodeId } = menuFloatingContextValue!
|
||||
|
||||
// ==========================================================================================
|
||||
|
||||
const rootClass = mergeClass("position--relative",className)
|
||||
|
||||
// ==========================================================================================
|
||||
|
||||
if (!isNested) {
|
||||
return (
|
||||
<MenuContext.Provider value={{ size }}>
|
||||
<MenuFloatingContext.Provider value={menuFloatingContextValue}>
|
||||
<FloatingTree>
|
||||
<FloatingNode id={nodeId}>
|
||||
<div {...rest} className={rootClass}>
|
||||
{children}
|
||||
</div>
|
||||
</FloatingNode>
|
||||
</FloatingTree>
|
||||
</MenuFloatingContext.Provider>
|
||||
</MenuContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuContext.Provider value={{ size }}>
|
||||
<MenuFloatingContext.Provider value={menuFloatingContextValue}>
|
||||
<FloatingNode id={nodeId}>
|
||||
<div {...rest} className={rootClass} >
|
||||
{children}
|
||||
</div>
|
||||
</FloatingNode>
|
||||
</MenuFloatingContext.Provider>
|
||||
</MenuContext.Provider>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
export type MenuContextValue = { size?: "sm" | "md" } | null;
|
||||
|
||||
export const MenuContext = createContext<MenuContextValue>(null);
|
||||
|
||||
export function useMenuContext() {
|
||||
const menuContext = useContext(MenuContext);
|
||||
|
||||
return menuContext;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { useMenuFloating } from "./use-menu-floating";
|
||||
|
||||
export type MenuFloatingContextValue = ReturnType<
|
||||
typeof useMenuFloating
|
||||
> | null;
|
||||
|
||||
export const MenuFloatingContext =
|
||||
createContext<MenuFloatingContextValue>(null);
|
||||
|
||||
export function useMenuFloatingContext() {
|
||||
const menuFloatingContext = useContext(MenuFloatingContext);
|
||||
|
||||
return menuFloatingContext;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import {
|
||||
autoUpdate,
|
||||
flip,
|
||||
offset,
|
||||
safePolygon,
|
||||
shift,
|
||||
useClick,
|
||||
useDismiss,
|
||||
useFloating,
|
||||
useFloatingNodeId,
|
||||
useFloatingParentNodeId,
|
||||
useHover,
|
||||
useInteractions,
|
||||
useListNavigation,
|
||||
useRole,
|
||||
} from "@floating-ui/react";
|
||||
import { useRef, useState } from "react";
|
||||
|
||||
export function useMenuFloating() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
||||
const [selectedIndex, setSelectedIndex] = useState<number | null>(null);
|
||||
|
||||
const nodeId = useFloatingNodeId();
|
||||
const parentId = useFloatingParentNodeId();
|
||||
const isNested = parentId != null;
|
||||
|
||||
const elementsRef = useRef<Array<HTMLElement | null>>([]);
|
||||
|
||||
const { refs, floatingStyles, context } = useFloating({
|
||||
nodeId,
|
||||
placement: isNested ? "right-start" : "bottom-start",
|
||||
open: isOpen,
|
||||
onOpenChange: setIsOpen,
|
||||
whileElementsMounted: autoUpdate,
|
||||
middleware: [
|
||||
offset({
|
||||
mainAxis: isNested ? 0 : 4,
|
||||
alignmentAxis: isNested ? -4 : 0,
|
||||
}),
|
||||
flip(),
|
||||
shift(),
|
||||
],
|
||||
});
|
||||
|
||||
const hover = useHover(context, {
|
||||
enabled: isNested,
|
||||
delay: { open: 75 },
|
||||
handleClose: safePolygon({ blockPointerEvents: true }),
|
||||
});
|
||||
|
||||
const click = useClick(context, {
|
||||
event: "mousedown",
|
||||
toggle: !isNested,
|
||||
ignoreMouse: isNested,
|
||||
});
|
||||
|
||||
const role = useRole(context, { role: "menu" });
|
||||
|
||||
const dismiss = useDismiss(context, { bubbles: true });
|
||||
|
||||
const listNav = useListNavigation(context, {
|
||||
listRef: elementsRef,
|
||||
activeIndex,
|
||||
selectedIndex,
|
||||
nested: isNested,
|
||||
onNavigate: setActiveIndex,
|
||||
});
|
||||
|
||||
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(
|
||||
[hover, click, dismiss, role, listNav],
|
||||
);
|
||||
|
||||
return {
|
||||
nodeId,
|
||||
parentId,
|
||||
isNested,
|
||||
refs,
|
||||
floatingStyles,
|
||||
context,
|
||||
getReferenceProps,
|
||||
getFloatingProps,
|
||||
getItemProps,
|
||||
elementsRef,
|
||||
selectedIndex,
|
||||
setSelectedIndex,
|
||||
activeIndex,
|
||||
isOpen,
|
||||
setIsOpen
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
export type MenuRadioItemGroupContextValue = {
|
||||
size: "sm" | "md"
|
||||
selectName: string;
|
||||
setSelectName: React.Dispatch<React.SetStateAction<string>>;
|
||||
} | null;
|
||||
|
||||
export const MenuRadioItemGroupContext = createContext<MenuRadioItemGroupContextValue>(null)
|
||||
|
||||
export function useMenuRadioItemGroupContext() {
|
||||
return useContext(MenuRadioItemGroupContext)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
export type MenuTriggerContextValue = { isTrigger?: boolean } | null;
|
||||
|
||||
export const MenuTriggerContext = createContext<MenuTriggerContextValue>(null);
|
||||
|
||||
export function useMenuTriggerContext() {
|
||||
return useContext(MenuTriggerContext);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { CSSProperties } from "react";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { usePopoverContext } from "./use-popover-context";
|
||||
import {
|
||||
FloatingArrow,
|
||||
FloatingFocusManager,
|
||||
FloatingPortal,
|
||||
} from "@floating-ui/react";
|
||||
import { useThemeContext } from "../theme/use-theme-context";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { variantRecipe } from "../../styles/recipes/variant-recipe";
|
||||
import { brandRecipe } from "../../styles/recipes/brand-recipe";
|
||||
import { containerRecipe } from "../../styles/recipes/container-recipe";
|
||||
|
||||
export type PopoverDropdownProps = CommonProps;
|
||||
|
||||
export const PopoverDropdown = (props: PopoverDropdownProps) => {
|
||||
const { children, className = "", style, ...rest } = props;
|
||||
|
||||
const {
|
||||
refs,
|
||||
floatingStyles,
|
||||
getFloatingProps,
|
||||
context,
|
||||
arrowRef,
|
||||
isMounted,
|
||||
transitionStyles,
|
||||
arrowWidth,
|
||||
arrowHeight,
|
||||
} = usePopoverContext()!;
|
||||
|
||||
const { themeClass, themeBaseClass } = useThemeContext()!;
|
||||
|
||||
const rootClass = mergeClass(
|
||||
"text--md",
|
||||
containerRecipe({
|
||||
boxShadow: true,
|
||||
rounded: 8,
|
||||
padding: 12,
|
||||
background: "base",
|
||||
hasFocusOutline: "false",
|
||||
}),
|
||||
brandRecipe(),
|
||||
themeBaseClass,
|
||||
themeClass,
|
||||
className,
|
||||
);
|
||||
|
||||
const rootStyle: CSSProperties = {
|
||||
...transitionStyles,
|
||||
...floatingStyles,
|
||||
...style,
|
||||
};
|
||||
|
||||
const arrowStyle: CSSProperties = {
|
||||
fill: "var(--base-background)",
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMounted && (
|
||||
<FloatingPortal>
|
||||
<FloatingFocusManager context={context} modal={false}>
|
||||
<div
|
||||
className={rootClass}
|
||||
ref={refs.setFloating}
|
||||
style={rootStyle}
|
||||
{...getFloatingProps({ ...rest })}
|
||||
>
|
||||
{children}
|
||||
<FloatingArrow
|
||||
ref={arrowRef}
|
||||
context={context}
|
||||
width={arrowWidth}
|
||||
height={arrowHeight}
|
||||
style={arrowStyle}
|
||||
></FloatingArrow>
|
||||
</div>
|
||||
</FloatingFocusManager>
|
||||
</FloatingPortal>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { CommonProps } from "../../utils/CommonProps"
|
||||
import { Slot } from "../../utils/slot";
|
||||
import { usePopoverContext } from "./use-popover-context";
|
||||
|
||||
export type PopoverTriggerProps = CommonProps
|
||||
|
||||
export const PopoverTrigger = (props: PopoverTriggerProps) => {
|
||||
const { children, ...rest } = props;
|
||||
|
||||
const { refs, getReferenceProps, setIsOpen, isOpen } = usePopoverContext()!
|
||||
|
||||
return <Slot ref={refs.setReference} {...getReferenceProps(
|
||||
{ ...rest, onClick: () => { setIsOpen(!isOpen) } }
|
||||
)}>
|
||||
{children}
|
||||
</Slot>
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { CommonProps } from "../../utils/CommonProps"
|
||||
import { PopoverContext } from "./use-popover-context"
|
||||
import { usePopoverFloating } from "./use-popover-floating"
|
||||
|
||||
export type PopoverProps = CommonProps & {
|
||||
|
||||
}
|
||||
|
||||
export const Popover = (props: PopoverProps) => {
|
||||
const { children } = props
|
||||
const popoverFloatingContext = usePopoverFloating()
|
||||
|
||||
return <PopoverContext.Provider value={popoverFloatingContext}>
|
||||
<div>{children}</div>
|
||||
</PopoverContext.Provider>
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { usePopoverFloating } from "./use-popover-floating";
|
||||
|
||||
export type PopoverContextValue = ReturnType<
|
||||
typeof usePopoverFloating
|
||||
> | null;
|
||||
|
||||
export const PopoverContext =
|
||||
createContext<PopoverContextValue>(null);
|
||||
|
||||
export function usePopoverContext() {
|
||||
const popoverContext = useContext(PopoverContext);
|
||||
|
||||
return popoverContext;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { arrow, autoUpdate, flip, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, useTransitionStyles } from "@floating-ui/react";
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
|
||||
export function usePopoverFloating() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const arrowRef = useRef(null);
|
||||
|
||||
// 拉扯 svg 图像,让三角变得,更尖更长,或者更宽更扁
|
||||
const arrowWidth = 16
|
||||
const arrowHeight = 8
|
||||
|
||||
const { refs, floatingStyles, context, middlewareData } = useFloating({
|
||||
placement: "top-start",
|
||||
open: isOpen,
|
||||
onOpenChange: setIsOpen,
|
||||
whileElementsMounted: autoUpdate,
|
||||
middleware: [
|
||||
offset(arrowHeight),
|
||||
flip({ padding: 8 }),
|
||||
// 偏移完成后,再留 8px 空白,而不是紧贴着父容器
|
||||
shift({ padding: 8 }),
|
||||
arrow({
|
||||
element: arrowRef,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// 这两个是未经 useFloating 变换前的坐标
|
||||
// 也就是 arrow 悬浮,左对齐 floating,两者水平中线重合
|
||||
const arrowX = middlewareData.arrow?.x ?? 0;
|
||||
const arrowY = middlewareData.arrow?.y ?? 0;
|
||||
|
||||
// 变换中心的起始坐标就是 floating 的左上角
|
||||
const transformX = arrowX + arrowWidth / 2;
|
||||
const transformY = arrowY + arrowHeight;
|
||||
|
||||
// style 用于内容框,而不是 FloatingArrow
|
||||
const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {
|
||||
duration: 150,
|
||||
initial: {
|
||||
opacity: 0,
|
||||
transform: "scale(0)"
|
||||
},
|
||||
close: {
|
||||
opacity: 0
|
||||
},
|
||||
common: ({ side }) => ({
|
||||
transitionTimingFunction: "ease",
|
||||
transformOrigin: {
|
||||
top: `${transformX}px calc(100% + ${arrowHeight}px)`,
|
||||
bottom: `${transformX}px ${-arrowHeight}px`,
|
||||
left: `calc(100% + ${arrowHeight}px) ${transformY}px`,
|
||||
right: `${-arrowHeight}px ${transformY}px`
|
||||
}[side]
|
||||
})
|
||||
})
|
||||
|
||||
const click = useClick(context);
|
||||
const dismiss = useDismiss(context);
|
||||
const role = useRole(context);
|
||||
|
||||
const { getReferenceProps, getFloatingProps } = useInteractions([
|
||||
click,
|
||||
dismiss,
|
||||
role,
|
||||
]);
|
||||
|
||||
return useMemo(() => ({
|
||||
isOpen,
|
||||
setIsOpen,
|
||||
/* only use at {isMounted && <FloatingPortal/>} */
|
||||
isMounted,
|
||||
arrowRef,
|
||||
arrowHeight,
|
||||
arrowWidth,
|
||||
refs,
|
||||
floatingStyles,
|
||||
transitionStyles,
|
||||
context,
|
||||
getReferenceProps,
|
||||
getFloatingProps
|
||||
}), [isOpen, setIsOpen, isMounted, refs, arrowHeight, arrowWidth, arrowRef, floatingStyles, transitionStyles, context, getReferenceProps, getFloatingProps])
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
export const Slider = () => {
|
||||
const sliderStyle: CSSProperties = {
|
||||
display: "flex",
|
||||
flexWrap: "nowrap",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
userSelect: "none",
|
||||
};
|
||||
|
||||
const sliderThumbStyle: CSSProperties = {
|
||||
height: "16px",
|
||||
width: "16px",
|
||||
};
|
||||
|
||||
const sliderRailStyle: CSSProperties = {
|
||||
height: "6px",
|
||||
width: "auto",
|
||||
};
|
||||
|
||||
return <div></div>
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
import { Icon } from "../icon/icon";
|
||||
import { CloseSvg } from "../../assets/svg/CloseSvg";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { itemSizeRecipe } from "../../styles/recipes/item-size-recipe";
|
||||
import { brandRecipe } from "../../styles/recipes/brand-recipe";
|
||||
import { variantRecipe } from "../../styles/recipes/variant-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
|
||||
export type TagProps = CommonProps & {
|
||||
size?: "xs" | "sm";
|
||||
variant?: "filled" | "outline";
|
||||
brand?: "success" | "danger" | "info" | "warning" | "default";
|
||||
color?: string;
|
||||
background?: string;
|
||||
borderColor?: string;
|
||||
} & {
|
||||
isClosable?: boolean;
|
||||
onClose?: () => void;
|
||||
};
|
||||
|
||||
export const Tag = (props: TagProps) => {
|
||||
const {
|
||||
className = "",
|
||||
children,
|
||||
size = "xs",
|
||||
brand = "info",
|
||||
color,
|
||||
background,
|
||||
borderColor,
|
||||
onClose,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const rootClass = mergeClass(
|
||||
displayRecipe(),
|
||||
variantRecipe({ variant: "filled", isUnclickable: true }),
|
||||
itemSizeRecipe({ size, shape: 'rounded' }),
|
||||
className,
|
||||
);
|
||||
|
||||
const closeIconClase = mergeClass(
|
||||
variantRecipe({ variant: "ghost" }),
|
||||
brandRecipe({ brand: "default" }),
|
||||
"cursor--pointer"
|
||||
);
|
||||
|
||||
return (
|
||||
<div {...rest} className={rootClass} style={{ color: color, background: background, borderColor: borderColor }}>
|
||||
{children}
|
||||
<Icon
|
||||
className={closeIconClase}
|
||||
size={size}
|
||||
shape={"circle"}
|
||||
onClick={onClose}
|
||||
>
|
||||
<CloseSvg />
|
||||
</Icon>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { ThemeContext } from "./use-theme-context";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
|
||||
export type ThemeProps = CommonProps & {
|
||||
theme?: "theme--light" | "theme--dark" | string;
|
||||
};
|
||||
|
||||
export const Theme = (props: ThemeProps) => {
|
||||
const { children, className = "", theme = "theme--light" } = props;
|
||||
|
||||
const [themeClass, setThemeClass] = useState<string>(theme);
|
||||
|
||||
const themeBaseClass = "theme-base";
|
||||
|
||||
const rootClass = mergeClass(themeBaseClass, theme, className);
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider
|
||||
value={{ themeBaseClass, themeClass, setThemeClass }}
|
||||
>
|
||||
<div className={rootClass}>{children}</div>
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
export type ThemeContextValue = {
|
||||
themeBaseClass: string;
|
||||
themeClass: string;
|
||||
setThemeClass: (v: string) => void;
|
||||
} | null;
|
||||
|
||||
export const ThemeContext = createContext<ThemeContextValue>(null);
|
||||
|
||||
export function useThemeContext() {
|
||||
const themeContext = useContext(ThemeContext);
|
||||
return themeContext;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
@import './styles/css/z-index.css';
|
||||
@import './styles/css/width-item.css';
|
||||
@import './styles/css/width-inline.css';
|
||||
@import './styles/css/width-dot.css';
|
||||
@import './styles/css/white-space.css';
|
||||
@import './styles/css/visibility.css';
|
||||
@import './styles/css/variant.css';
|
||||
@import './styles/css/variant-unclickable.css';
|
||||
@import './styles/css/variant-disabled.css';
|
||||
@import './styles/css/user-select.css';
|
||||
@import './styles/css/transition.css';
|
||||
@import './styles/css/theme.css';
|
||||
@import './styles/css/theme-base.css';
|
||||
@import './styles/css/text-align.css';
|
||||
@import './styles/css/screen-reader.css';
|
||||
@import './styles/css/position.css';
|
||||
@import './styles/css/pointer-events.css';
|
||||
@import './styles/css/padding.css';
|
||||
@import './styles/css/padding-long.css';
|
||||
@import './styles/css/overscroll-behavior.css';
|
||||
@import './styles/css/overflow.css';
|
||||
@import './styles/css/outline.css';
|
||||
@import './styles/css/max-width.css';
|
||||
@import './styles/css/max-height.css';
|
||||
@import './styles/css/justify-self.css';
|
||||
@import './styles/css/justify-items.css';
|
||||
@import './styles/css/justify-content.css';
|
||||
@import './styles/css/height-item.css';
|
||||
@import './styles/css/height-inline.css';
|
||||
@import './styles/css/height-dot.css';
|
||||
@import './styles/css/gap.css';
|
||||
@import './styles/css/font-weight.css';
|
||||
@import './styles/css/font-size.css';
|
||||
@import './styles/css/font-family.css';
|
||||
@import './styles/css/flex-wrap.css';
|
||||
@import './styles/css/flex-shrink.css';
|
||||
@import './styles/css/flex-direction.css';
|
||||
@import './styles/css/drop-shadow.css';
|
||||
@import './styles/css/display.css';
|
||||
@import './styles/css/cursor.css';
|
||||
@import './styles/css/color.css';
|
||||
@import './styles/css/break-before.css';
|
||||
@import './styles/css/break-after.css';
|
||||
@import './styles/css/brand.css';
|
||||
@import './styles/css/box-sizing.css';
|
||||
@import './styles/css/box-shadow.css';
|
||||
@import './styles/css/box-inside.css';
|
||||
@import './styles/css/box-decoration.css';
|
||||
@import './styles/css/border.css';
|
||||
@import './styles/css/border-radius.css';
|
||||
@import './styles/css/background.css';
|
||||
@import './styles/css/animation.css';
|
||||
@import './styles/css/align-self.css';
|
||||
@import './styles/css/align-items.css';
|
||||
@import './styles/css/align-content.css';
|
||||
@@ -0,0 +1,59 @@
|
||||
export * from './utils/state-registry.ts';
|
||||
export * from './utils/slot.tsx';
|
||||
export * from './utils/merge-props.ts';
|
||||
export * from './utils/CommonProps.ts';
|
||||
export * from './utils/camelToKebab.ts';
|
||||
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/menu/use-menu-radio-item-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/checkbox/checkbox.tsx';
|
||||
export * from './components/button/button.tsx';
|
||||
export * from './components/badge/badge.tsx';
|
||||
export * from './assets/svg/VolumeMuteSvg.tsx';
|
||||
export * from './assets/svg/VolumeLowSvg.tsx';
|
||||
export * from './assets/svg/VolumeHighSvg.tsx';
|
||||
export * from './assets/svg/UserSvg.tsx';
|
||||
export * from './assets/svg/SunSvg.tsx';
|
||||
export * from './assets/svg/SpinnerSvg.tsx';
|
||||
export * from './assets/svg/SettingSvg.tsx';
|
||||
export * from './assets/svg/SearchSvg.tsx';
|
||||
export * from './assets/svg/Ruler.tsx';
|
||||
export * from './assets/svg/PasteSvg.tsx';
|
||||
export * from './assets/svg/MoonSvg.tsx';
|
||||
export * from './assets/svg/MeshSvg.tsx';
|
||||
export * from './assets/svg/KeySvg.tsx';
|
||||
export * from './assets/svg/FileSvg.tsx';
|
||||
export * from './assets/svg/DownloadSvg.tsx';
|
||||
export * from './assets/svg/CutSvg.tsx';
|
||||
export * from './assets/svg/CloseSvg.tsx';
|
||||
export * from './assets/svg/ChevronRightSvg.tsx';
|
||||
export * from './assets/svg/CheckIndicatorSvg.tsx';
|
||||
export * from './assets/svg/BoldSvg.tsx';
|
||||
@@ -0,0 +1,37 @@
|
||||
@layer utility {
|
||||
.align-content--normal {
|
||||
align-content: normal;
|
||||
}
|
||||
|
||||
.align-content--center {
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.align-content--start {
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
.align-content--end {
|
||||
align-content: flex-end;
|
||||
}
|
||||
|
||||
.align-content--between {
|
||||
align-content: space-between;
|
||||
}
|
||||
|
||||
.align-content--around {
|
||||
align-content: space-around;
|
||||
}
|
||||
|
||||
.align-content--evenly {
|
||||
align-content: space-evenly;
|
||||
}
|
||||
|
||||
.align-content--baseline {
|
||||
align-content: baseline;
|
||||
}
|
||||
|
||||
.align-content--stretch {
|
||||
align-content: stretch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
@layer utility {
|
||||
.items--start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.items--end {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.items-end--safe {
|
||||
align-items: safe flex-end;
|
||||
}
|
||||
|
||||
.items--center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.items--center-safe {
|
||||
align-items: safe center;
|
||||
}
|
||||
|
||||
.items--baseline {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.items--baseline-last {
|
||||
align-items: last baseline;
|
||||
}
|
||||
|
||||
.items--stretch {
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
@layer utility {
|
||||
.align-self--auto {
|
||||
align-self: auto;
|
||||
}
|
||||
|
||||
.align-self--start {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.align-self--end {
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.align-self--end-safe {
|
||||
align-self: safe flex-end;
|
||||
}
|
||||
|
||||
.align-self--center {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.align-self--center-safe {
|
||||
align-self: safe center;
|
||||
}
|
||||
|
||||
.align-self--stretch {
|
||||
align-self: stretch;
|
||||
}
|
||||
|
||||
.align-self--baseline {
|
||||
align-self: baseline;
|
||||
}
|
||||
|
||||
.align-self--baseline-last {
|
||||
align-self: last baseline;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
@layer utility {
|
||||
|
||||
.animate--fade-in-down {
|
||||
animation: var(--animate-fade-in-down);
|
||||
|
||||
@keyframes fade-in-down {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
.animate--fade-out-down {
|
||||
animation: var(--animate-fade-out-down);
|
||||
}
|
||||
|
||||
@keyframes fade-out-down {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 100%, 0);
|
||||
}
|
||||
}
|
||||
.animate--fade-in-up {
|
||||
animation: var(--animate-fade-in-up);
|
||||
}
|
||||
|
||||
@keyframes fade-in-up {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 100%, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
.animate--fade-out-up {
|
||||
animation: var(--animate-fade-out-up);
|
||||
}
|
||||
|
||||
@keyframes fade-out-up {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, -100%, 0);
|
||||
}
|
||||
}
|
||||
.animate--spin {
|
||||
animation: var(--animate-spin);
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
.animate--ping {
|
||||
animation: var(--animate-ping);
|
||||
|
||||
@keyframes ping {
|
||||
75%,
|
||||
100% {
|
||||
transform: scale(2);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.animate--pulse {
|
||||
animation: var(--animate-pulse);
|
||||
|
||||
@keyframes pulse {
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
.animate--bounce {
|
||||
animation: var(--animate-bounce); /* bounce 1s infinite */
|
||||
|
||||
@keyframes bounce {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(-25%);
|
||||
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
|
||||
}
|
||||
50% {
|
||||
transform: none;
|
||||
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
.animate--none {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.background--base {
|
||||
background: var(--base-background);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
@layer utility {
|
||||
.rounded--full {
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.rounded--none {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.rounded--xs {
|
||||
border-radius: var(--radius-xs);
|
||||
}
|
||||
|
||||
.rounded--sm {
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.rounded--md {
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.rounded--lg {
|
||||
border-radius: var(--radius-lg);
|
||||
}
|
||||
|
||||
.rounded--xl {
|
||||
border-radius: var(--radius-xl);
|
||||
}
|
||||
|
||||
.rounded--2xl {
|
||||
border-radius: var(--radius-2xl);
|
||||
}
|
||||
|
||||
.rounded--3xl {
|
||||
border-radius: var(--radius-3xl);
|
||||
}
|
||||
|
||||
.rounded--4 {
|
||||
border-radius: var(--radius-4);
|
||||
}
|
||||
|
||||
.rounded--8 {
|
||||
border-radius: var(--radius-8);
|
||||
}
|
||||
|
||||
.rounded--12 {
|
||||
border-radius: var(--radius-12);
|
||||
}
|
||||
|
||||
.rounded--16 {
|
||||
border-radius: var(--radius-16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@layer utility {
|
||||
.border--1 {
|
||||
border: var(--border-1);
|
||||
border-color: var(--brand-background-high-active);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@layer utility {
|
||||
.box-decoration--clone {
|
||||
box-decoration-break: clone;
|
||||
}
|
||||
|
||||
.box-decoration--slice {
|
||||
box-decoration-break: slice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@layer utility {
|
||||
.break-inside--auto {
|
||||
break-inside: auto;
|
||||
}
|
||||
|
||||
.break-inside--avoid {
|
||||
break-inside: avoid;
|
||||
}
|
||||
|
||||
.break-inside--avoid-page {
|
||||
break-inside: avoid-page;
|
||||
}
|
||||
|
||||
.break-inside--avoid-column {
|
||||
break-inside: avoid-column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.box-shadow {
|
||||
box-shadow: var(--box-shadow);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@layer utility {
|
||||
.box-sizing--border {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.box-sizing--content {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
@layer utility {
|
||||
|
||||
.brand--default {
|
||||
--brand-background-high: var(--default-background-high);
|
||||
--brand-background-high-hover: var(--default-background-high-hover);
|
||||
--brand-background-high-active: var(--default-background-high-active);
|
||||
--brand-background-low: var(--default-background-low);
|
||||
--brand-background-low-hover: var(--default-background-low-hover);
|
||||
--brand-background-low-active: var(--default-background-low-active);
|
||||
}
|
||||
|
||||
.brand--info {
|
||||
--brand-background-high: var(--info-background-high);
|
||||
--brand-background-high-hover: var(--info-background-high-hover);
|
||||
--brand-background-high-active: var(--info-background-high-active);
|
||||
--brand-background-low: var(--info-background-low);
|
||||
--brand-background-low-hover: var(--info-background-low-hover);
|
||||
--brand-background-low-active: var(--info-background-low-active);
|
||||
}
|
||||
|
||||
.brand--danger {
|
||||
--brand-background-high: var(--danger-background-high);
|
||||
--brand-background-high-hover: var(--danger-background-high-hover);
|
||||
--brand-background-high-active: var(--danger-background-high-active);
|
||||
--brand-background-low: var(--danger-background-low);
|
||||
--brand-background-low-hover: var(--danger-background-low-hover);
|
||||
--brand-background-low-active: var(--danger-background-low-active);
|
||||
}
|
||||
|
||||
.brand--success {
|
||||
--brand-background-high: var(--success-background-high);
|
||||
--brand-background-high-hover: var(--success-background-high-hover);
|
||||
--brand-background-high-active: var(--success-background-high-active);
|
||||
--brand-background-low: var(--success-background-low);
|
||||
--brand-background-low-hover: var(--success-background-low-hover);
|
||||
--brand-background-low-active: var(--success-background-low-active);
|
||||
}
|
||||
|
||||
.brand--warning {
|
||||
--brand-background-high: var(--warning-background-high);
|
||||
--brand-background-high-hover: var(--warning-background-high-hover);
|
||||
--brand-background-high-active: var(--warning-background-high-active);
|
||||
--brand-background-low: var(--warning-background-low);
|
||||
--brand-background-low-hover: var(--warning-background-low-hover);
|
||||
--brand-background-low-active: var(--warning-background-low-active);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
@layer utility {
|
||||
.break-after--auto {
|
||||
break-after: auto;
|
||||
}
|
||||
|
||||
.break-after--avoid {
|
||||
break-after: avoid;
|
||||
}
|
||||
|
||||
.break-after--all {
|
||||
break-after: all;
|
||||
}
|
||||
|
||||
.break-after--avoid-page {
|
||||
break-after: avoid-page;
|
||||
}
|
||||
|
||||
.break-after--page {
|
||||
break-after: page;
|
||||
}
|
||||
|
||||
.break-after--left {
|
||||
break-after: left;
|
||||
}
|
||||
|
||||
.break-after--right {
|
||||
break-after: right;
|
||||
}
|
||||
|
||||
.break-after--column {
|
||||
break-after: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
@layer utility {
|
||||
.break-before--auto {
|
||||
break-before: auto;
|
||||
}
|
||||
|
||||
.break-before--avoid {
|
||||
break-before: avoid;
|
||||
}
|
||||
|
||||
.break-before--all {
|
||||
break-before: all;
|
||||
}
|
||||
|
||||
.break-before--avoid-page {
|
||||
break-before: avoid-page;
|
||||
}
|
||||
|
||||
.break-before--page {
|
||||
break-before: page;
|
||||
}
|
||||
|
||||
.break-before--left {
|
||||
break-before: left;
|
||||
}
|
||||
|
||||
.break-before--right {
|
||||
break-before: right;
|
||||
}
|
||||
|
||||
.break-before--column {
|
||||
break-before: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.color--white {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
@layer utility {
|
||||
/* ===== 基础光标 ===== */
|
||||
.cursor--auto {
|
||||
cursor: auto;
|
||||
}
|
||||
.cursor--default {
|
||||
cursor: default;
|
||||
}
|
||||
.cursor--pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.cursor--wait {
|
||||
cursor: wait;
|
||||
}
|
||||
.cursor--text {
|
||||
cursor: text;
|
||||
}
|
||||
.cursor--move {
|
||||
cursor: move;
|
||||
}
|
||||
.cursor--help {
|
||||
cursor: help;
|
||||
}
|
||||
.cursor--not-allowed {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ===== 拖拽 / 抓取 ===== */
|
||||
.cursor--grab {
|
||||
cursor: grab;
|
||||
}
|
||||
.cursor--grabbing {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* ===== 调整大小(通用 & 方向)===== */
|
||||
.cursor--resize {
|
||||
cursor: resize;
|
||||
}
|
||||
.cursor--ew-resize {
|
||||
cursor: ew-resize;
|
||||
}
|
||||
.cursor--ns-resize {
|
||||
cursor: ns-resize;
|
||||
}
|
||||
.cursor--nesw-resize {
|
||||
cursor: nesw-resize;
|
||||
}
|
||||
.cursor--nwse-resize {
|
||||
cursor: nwse-resize;
|
||||
}
|
||||
.cursor--col-resize {
|
||||
cursor: col-resize;
|
||||
}
|
||||
.cursor--row-resize {
|
||||
cursor: row-resize;
|
||||
}
|
||||
|
||||
.cursor--n-resize {
|
||||
cursor: n-resize;
|
||||
}
|
||||
.cursor--e-resize {
|
||||
cursor: e-resize;
|
||||
}
|
||||
.cursor--s-resize {
|
||||
cursor: s-resize;
|
||||
}
|
||||
.cursor--w-resize {
|
||||
cursor: w-resize;
|
||||
}
|
||||
.cursor--ne-resize {
|
||||
cursor: ne-resize;
|
||||
}
|
||||
.cursor--nw-resize {
|
||||
cursor: nw-resize;
|
||||
}
|
||||
.cursor--se-resize {
|
||||
cursor: se-resize;
|
||||
}
|
||||
.cursor--sw-resize {
|
||||
cursor: sw-resize;
|
||||
}
|
||||
|
||||
/* ===== 视觉反馈 ===== */
|
||||
.cursor--crosshair {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.cursor--progress {
|
||||
cursor: progress;
|
||||
}
|
||||
.cursor--no-drop {
|
||||
cursor: no-drop;
|
||||
}
|
||||
.cursor--vertical-text {
|
||||
cursor: vertical-text;
|
||||
}
|
||||
|
||||
/* ===== 现代 / 扩展光标 ===== */
|
||||
.cursor--zoom-in {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
.cursor--zoom-out {
|
||||
cursor: zoom-out;
|
||||
}
|
||||
.cursor--alias {
|
||||
cursor: alias;
|
||||
}
|
||||
.cursor--copy {
|
||||
cursor: copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
@layer utility {
|
||||
/* 基础 display */
|
||||
.display--inline {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.display--block {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.display--inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.display--flow-root {
|
||||
display: flow-root;
|
||||
}
|
||||
|
||||
.display--contents {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.display--none {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Flex */
|
||||
.display--flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.display--inline-flex {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* Grid */
|
||||
.display--grid {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.display--inline-grid {
|
||||
display: inline-grid;
|
||||
}
|
||||
|
||||
/* Table */
|
||||
.display--table {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.display--inline-table {
|
||||
display: inline-table;
|
||||
}
|
||||
|
||||
.display--table-caption {
|
||||
display: table-caption;
|
||||
}
|
||||
|
||||
.display--table-cell {
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.display--table-column {
|
||||
display: table-column;
|
||||
}
|
||||
|
||||
.display--table-column-group {
|
||||
display: table-column-group;
|
||||
}
|
||||
|
||||
.display--table-footer-group {
|
||||
display: table-footer-group;
|
||||
}
|
||||
|
||||
.display--table-header-group {
|
||||
display: table-header-group;
|
||||
}
|
||||
|
||||
.display--table-row-group {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
.display--table-row {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
/* List */
|
||||
.display--list-item {
|
||||
display: list-item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.drop-shadow{
|
||||
filter: var(--drop-shadow);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@layer utility {
|
||||
.flex-direction--row {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.flex-direction--row-reverse {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.flex-direction--col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.flex-direction--col-reverse {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@layer utility {
|
||||
.flex-shrink--1 {
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.flex-shrink--0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
@layer utility {
|
||||
.flex--nowrap {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.flex--wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.flex--wrap-reverse {
|
||||
flex-wrap: wrap-reverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@layer utility {
|
||||
.font-family--sans {
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
.font-family--serif {
|
||||
font-family: var(--font-serif);
|
||||
}
|
||||
.font-family--mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
@layer utility {
|
||||
.text--xs {
|
||||
font-size: var(--font-size-xs);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--sm {
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--md {
|
||||
font-size: var(--font-size-md);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--lg {
|
||||
font-size: var(--font-size-lg);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--xl {
|
||||
font-size: var(--font-size-xl);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--2xl {
|
||||
font-size: var(--font-size-2xl);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
.text--3xl {
|
||||
font-size: var(--font-size-3xl);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
@layer utility {
|
||||
.font-weight--light {
|
||||
font-weight: var(--font-weight-light);
|
||||
}
|
||||
|
||||
.font-weight--normal {
|
||||
font-weight: var(--font-weight-normal);
|
||||
}
|
||||
|
||||
.font-weight--extranormal {
|
||||
font-weight: var(--font-weight-extranormal);
|
||||
}
|
||||
|
||||
.font-weight--semibold {
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.font-weight--bold {
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.font-weight--extrabold {
|
||||
font-weight: var(--font-weight-extrabold);
|
||||
}
|
||||
|
||||
/* ================== */
|
||||
|
||||
.font-weight--xs {
|
||||
font-weight: var(--font-weight-xs);
|
||||
}
|
||||
|
||||
.font-weight--sm {
|
||||
font-weight: var(--font-weight-sm);
|
||||
}
|
||||
|
||||
.font-weight--md {
|
||||
font-weight: var(--font-weight-md);
|
||||
}
|
||||
|
||||
.font-weight--lg {
|
||||
font-weight: var(--font-weight-lg);
|
||||
}
|
||||
|
||||
.font-weight--xl {
|
||||
font-weight: var(--font-weight-xl);
|
||||
}
|
||||
|
||||
.font-weight--2xl {
|
||||
font-weight: var(--font-weight-2xl);
|
||||
}
|
||||
|
||||
.font-weight--3xl {
|
||||
font-weight: var(--font-weight-3xl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@layer utility {
|
||||
|
||||
.gap-none {
|
||||
gap: none;
|
||||
}
|
||||
|
||||
.gap--xs {
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.gap--sm {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.gap--md {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.gap--lg {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.gap--xl {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.gap--2xl {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.gap--3xl {
|
||||
gap: 14px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@layer utility {
|
||||
.h--dot-xs {
|
||||
height: calc(var(--font-size-xs) / 2);
|
||||
}
|
||||
|
||||
.h--dot-sm {
|
||||
height: calc(var(--font-size-sm) / 2);
|
||||
}
|
||||
|
||||
.h--dot-md {
|
||||
height: calc(var(--font-size-md) / 2);
|
||||
}
|
||||
|
||||
.h--dot-lg {
|
||||
height: calc(var(--font-size-lg) / 2);
|
||||
}
|
||||
|
||||
.h--dot-xl {
|
||||
height: calc(var(--font-size-xl) / 2);
|
||||
}
|
||||
|
||||
.h--dot-2xl {
|
||||
height: calc(var(--font-size-2xl) / 2);
|
||||
}
|
||||
|
||||
.h--dot-3xl {
|
||||
height: calc(var(--font-size-3xl) / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
@layer utility {
|
||||
.h--inline-xs {
|
||||
height: calc(var(--font-size-xs) * var(--line-height));
|
||||
}
|
||||
|
||||
.h--inline-sm {
|
||||
height: calc(var(--font-size-sm) * var(--line-height));
|
||||
}
|
||||
|
||||
.h--inline-md {
|
||||
height: calc(var(--font-size-md) * var(--line-height));
|
||||
}
|
||||
|
||||
.h--inline-lg {
|
||||
height: calc(var(--font-size-lg) * var(--line-height));
|
||||
}
|
||||
|
||||
.h--inline-xl {
|
||||
height: calc(var(--font-size-xl) * var(--line-height));
|
||||
}
|
||||
|
||||
.h--inline-2xl {
|
||||
height: calc(var(--font-size-2xl) * var(--line-height));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
@layer utility {
|
||||
.h--item-xs {
|
||||
height: var(--height-item-xs);
|
||||
}
|
||||
.h--item-sm {
|
||||
height: var(--height-item-sm);
|
||||
}
|
||||
.h--item-md {
|
||||
height: var(--height-item-md);
|
||||
}
|
||||
.h--item-lg {
|
||||
height: var(--height-item-lg);
|
||||
}
|
||||
.h--item-xl {
|
||||
height: var(--height-item-xl);
|
||||
}
|
||||
.h--item-2xl {
|
||||
height: var(--height-item-2xl);
|
||||
}
|
||||
.h--item-3xl {
|
||||
height: var(--height-item-3xl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
@layer utility {
|
||||
.justify--start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.justify--end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.justify--end-safe {
|
||||
justify-content: safe flex-end;
|
||||
}
|
||||
|
||||
.justify--center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.justify--center-safe {
|
||||
justify-content: safe center;
|
||||
}
|
||||
|
||||
.justify--between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.justify--around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.justify--evenly {
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.justify--stretch {
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.justify--baseline {
|
||||
justify-content: baseline;
|
||||
}
|
||||
|
||||
.justify--normal {
|
||||
justify-content: normal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@layer utility {
|
||||
.justify-items--start {
|
||||
justify-items: start;
|
||||
}
|
||||
|
||||
.justify-items--end {
|
||||
justify-items: end;
|
||||
}
|
||||
|
||||
.justify-items--end-safe {
|
||||
justify-items: safe end;
|
||||
}
|
||||
|
||||
.justify-items--center {
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
.justify-items--center-safe {
|
||||
justify-items: safe center;
|
||||
}
|
||||
|
||||
.justify-items--stretch {
|
||||
justify-items: stretch;
|
||||
}
|
||||
|
||||
.justify-items--normal {
|
||||
justify-items: normal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@layer utility {
|
||||
.justify-self--auto {
|
||||
justify-self: auto;
|
||||
}
|
||||
|
||||
.justify-self--start {
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
.justify-self--center {
|
||||
justify-self: center;
|
||||
}
|
||||
|
||||
.justify-self--center-safe {
|
||||
justify-self: safe center;
|
||||
}
|
||||
|
||||
.justify-self--end {
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
.justify-self--end-safe {
|
||||
justify-self: safe end;
|
||||
}
|
||||
|
||||
.justify-self--stretch {
|
||||
justify-self: stretch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.max-h--max-content {
|
||||
max-height: max-content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@layer utility {
|
||||
.max-w--max-content {
|
||||
max-width: max-content;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user