-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a49657
commit b5db9a5
Showing
34 changed files
with
201 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Backdrop 遮罩层 | ||
|
||
将用户的焦点缩小到屏幕上的特定元素。 | ||
|
||
使用 `import { IBackdrop } from "@/components";` | ||
|
||
源码 `/src/components/widgets/backdrop` | ||
|
||
## 何时使用 | ||
|
||
* 使内容变暗或阻止浮层元素后面的指针事件。 | ||
|
||
* 背景发出应用程序内状态更改的信号,可用于创建加载程序、对话框等。 | ||
|
||
## 代码演示 | ||
|
||
### 基本用法 | ||
|
||
下面的演示显示了一个基本背景,并在背景中呈现UI元素来指示加载状态。单击开关后,您可以单击页面上的任意位置将其关闭。 | ||
|
||
<code src='@examples/backdrop/basic' /> | ||
|
||
### 锁定主体滚动 | ||
|
||
渲染覆盖层时是否阻止`<body/>`滚动。适用于`iOS`。 | ||
|
||
> 如果您需要更高级的解决方案,`react-remove-scroll`是一个不错的选择。 | ||
{/* <code src='@examples/overlay/advanced' /> */} | ||
|
||
## 常见问题 | ||
|
||
### 兄弟节点覆盖问题 | ||
|
||
在可滚动上下文中使用锚定位和覆盖层时,最好使覆盖层成为浮动元素的同级元素,而不是父容器。这将确保浮动元素不会被覆盖层包含,从而允许其定位在其边界之外,从而防止滚动问题。它还允许叠加层独立地设置动画。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Dialog 对话框 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Snackbar 通知条 |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Theming 主题 | ||
|
||
使用 CSS 变量进行主题化。 | ||
|
||
## 约定 | ||
|
||
{/* CSS 色阶变量必须在没有颜色空间函数的情况下定义 */} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { IFlex, ISpinner, ISwitch } from '@/components'; | ||
import { IBackdrop } from '@/components/widgets/backdrop'; | ||
import { useToggle } from '@/hooks'; | ||
import { iPropagation } from '@/utils'; | ||
|
||
const App: React.FC = () => { | ||
const [open, { toggle, off }] = useToggle(); | ||
|
||
return ( | ||
<IFlex> | ||
<ISwitch | ||
onChange={({ target }) => toggle((target as HTMLInputElement).checked)} | ||
/> | ||
<IBackdrop | ||
open={open} | ||
onClick={(event) => { | ||
iPropagation(event); | ||
off(); | ||
}} | ||
> | ||
<ISpinner /> | ||
</IBackdrop> | ||
</IFlex> | ||
); | ||
}; | ||
|
||
export default App; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.wrap { | ||
display: grid; | ||
place-items: center; | ||
z-index: var(--z-index-float); | ||
background-color: var(--bg-color-mask); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import classNames from 'classnames'; | ||
import { AnimatePresence } from 'framer-motion'; | ||
|
||
import { FloatingPortal } from '@floating-ui/react'; | ||
|
||
import { container } from '@/init'; | ||
import type { ReactCFC } from '@/models'; | ||
import { iFindElement } from '@/utils'; | ||
|
||
import { IOverlay } from '../overlay'; | ||
import type { IBackdropProps } from './models'; | ||
|
||
import * as styles from './index.scss'; | ||
|
||
export const IBackdrop: ReactCFC<IBackdropProps> = ({ | ||
open, | ||
children, | ||
className, | ||
root = container, | ||
...others | ||
}) => ( | ||
<FloatingPortal root={iFindElement(root)}> | ||
<AnimatePresence> | ||
{open && ( | ||
<IOverlay className={classNames(styles.wrap, className)} {...others}> | ||
{children} | ||
</IOverlay> | ||
)} | ||
</AnimatePresence> | ||
</FloatingPortal> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ReactTargetFunc } from '@/models'; | ||
|
||
import type { IOverlayProps } from '../../overlay'; | ||
|
||
export interface IBackdropProps extends IOverlayProps { | ||
open?: boolean; | ||
/** | ||
* 浮层默认渲染到 root 上,也可以使用此方法指定根节点。 | ||
*/ | ||
root?: ReactTargetFunc; | ||
} |
Oops, something went wrong.