Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fixed overlay zIndex is not effective, and extract types of dialog, overlay, fixednav, popup, toast #2954

Merged
merged 22 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
"dd": true
},
{
"version": "2.0.0",
"version": "3.0.0",
"name": "FixedNav",
"type": "component",
"cName": "悬浮导航",
Expand All @@ -323,7 +323,7 @@
"show": true,
"taro": true,
"author": "Ymm0008",
"dd": false
"dd": true
},
{
"version": "3.0.0",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`Cascader > visible true 1`] = `
<div>
<div
class="nut-overlay"
style="--nutui-overlay-zIndex: 1000;"
style="z-index: 1000;"
/>
<div
class="nut-popup nut-popup-round nut-popup-bottom"
Expand Down
7 changes: 5 additions & 2 deletions src/packages/cascader/cascader.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import React, {
import classNames from 'classnames'
import { Loading, Check } from '@nutui/icons-react-taro'
import { ScrollView, View } from '@tarojs/components'
import { Popup, PopupProps } from '@/packages/popup/popup.taro'
import Popup, {
PopupProps,
CloseIconPosition,
} from '@/packages/popup/index.taro'
import { Tabs } from '@/packages/tabs/tabs.taro'
import Tree, { convertListToOptions } from './utils'
import {
Expand Down Expand Up @@ -57,7 +60,7 @@ export interface CascaderProps
optionKey: CascaderOptionKey
format: Record<string, string | number | null>
closeable: boolean
closeIconPosition: string
closeIconPosition: CloseIconPosition
closeIcon: ReactNode
lazy: boolean
onLoad: (node: any, resolve: any) => void
Expand Down
4 changes: 2 additions & 2 deletions src/packages/cascader/cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
} from 'react'
import classNames from 'classnames'
import { Loading, Check } from '@nutui/icons-react'
import { Popup, PopupProps } from '@/packages/popup/popup'
import Popup, { PopupProps, CloseIconPosition } from '@/packages/popup/index'
import { Tabs } from '@/packages/tabs/tabs'
import Tree, { convertListToOptions } from './utils'
import {
Expand Down Expand Up @@ -56,7 +56,7 @@ export interface CascaderProps
optionKey: CascaderOptionKey
format: Record<string, string | number | null>
closeable: boolean
closeIconPosition: string
closeIconPosition: CloseIconPosition
closeIcon: ReactNode
lazy: boolean
onLoad: (node: any, resolve: any) => void
Expand Down
4 changes: 2 additions & 2 deletions src/packages/dialog/confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Dialog } from './dialog'
import { destroyList, DialogConfirmProps, DialogReturnProps } from './config'
import { destroyList, DialogConfirmProps, DialogReturnProps } from './types'
import { render as reactRender, unmount } from '@/utils/render'

function ConfirmDialog(props: DialogConfirmProps) {
Expand Down Expand Up @@ -100,8 +100,8 @@ const confirm = (
const update = (newConfig: DialogConfirmProps) => {
dialogConfig = {
...dialogConfig,
title: config.title, // 避免 newConfig 未传递 title 时,icon 出现多个的问题
...newConfig,
title: config.title, // 避免 newConfig 未传递 title 时,icon 出现多个的问题
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newConfig 中存在 title 时,无法被覆盖,值一直是 config.title

}

dialogConfig = normalizeConfig(dialogConfig)
Expand Down
58 changes: 28 additions & 30 deletions src/packages/dialog/content.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react'
import React, { FunctionComponent, HTMLAttributes } from 'react'
import classNames from 'classnames'
import { ITouchEvent, View } from '@tarojs/components'
import { BasicComponent } from '@/utils/typings'
import { View, ITouchEvent } from '@tarojs/components'
import { ContentProps } from './index.taro'

interface ContentProps extends BasicComponent {
visible: boolean
title: ReactNode
header: ReactNode
footer: ReactNode
close: ReactNode
footerDirection: string
onClick: (event: ITouchEvent) => void
export const defaultContentProps: ContentProps = {
visible: false,
title: '',
header: null,
footer: null,
close: '',
footerDirection: 'horizontal',
onClick: () => {},
}

export const Content: FunctionComponent<
Expand All @@ -24,39 +24,39 @@ export const Content: FunctionComponent<
footer,
close,
footerDirection,
onClick,
children,
} = props
onClick,
} = { ...defaultContentProps, ...props }

const classPrefix = 'nut-dialog'

const renderHeader = () => {
return title ? (
<View className={`${classPrefix}-header`}>{title}</View>
) : null
return title && <View className={`${classPrefix}-header`}>{title}</View>
}

const renderFooter = () => {
return footer ? (
<View
className={classNames(`${classPrefix}-footer`, {
[footerDirection as any]: footerDirection,
})}
>
{footer}
</View>
) : null
return (
footer && (
<View
className={classNames(`${classPrefix}-footer`, {
[footerDirection]: footerDirection,
})}
>
{footer}
</View>
)
)
}

const handleClick = (e: any) => {
const handleClick = (e: ITouchEvent) => {
onClick && onClick(e)
}

return (
<View
className={classNames(`${classPrefix}-outer`, props.className)}
style={props.style}
onClick={(e) => handleClick(e)}
onClick={(e: ITouchEvent) => handleClick(e)}
>
{close}
{header}
Expand All @@ -65,9 +65,7 @@ export const Content: FunctionComponent<
style={{ display: visible ? 'flex' : 'none' }}
>
{renderHeader()}
<View className={`${classPrefix}-content`}>
<>{children}</>
</View>
<View className={`${classPrefix}-content`}>{children}</View>
{renderFooter()}
</View>
</View>
Expand Down
57 changes: 31 additions & 26 deletions src/packages/dialog/content.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react'
import React, { FunctionComponent, HTMLAttributes } from 'react'
import classNames from 'classnames'
import { ContentProps } from './types'

interface ContentProps {
visible: boolean
title: ReactNode
header: ReactNode
footer: ReactNode
close: ReactNode
footerDirection: string
export const defaultContentProps: ContentProps = {
visible: false,
title: '',
header: '',
footer: '',
xiaoyatong marked this conversation as resolved.
Show resolved Hide resolved
close: '',
xiaoyatong marked this conversation as resolved.
Show resolved Hide resolved
footerDirection: 'horizontal',
onClick: () => {},
}

export const Content: FunctionComponent<
Partial<ContentProps> & HTMLAttributes<HTMLDivElement>
Partial<ContentProps> &
Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'content'>
> = (props) => {
const {
visible,
Expand All @@ -20,26 +23,30 @@ export const Content: FunctionComponent<
footer,
close,
footerDirection,
onClick,
children,
} = props
style,
className,
onClick,
} = { ...defaultContentProps, ...props }

const classPrefix = 'nut-dialog'

const renderHeader = () => {
return title ? <div className={`${classPrefix}-header`}>{title}</div> : null
return title && <div className={`${classPrefix}-header`}>{title}</div>
}

const renderFooter = () => {
return footer ? (
<div
className={classNames(`${classPrefix}-footer`, {
[footerDirection as any]: footerDirection,
})}
>
{footer}
</div>
) : null
return (
footer && (
<div
className={classNames(`${classPrefix}-footer`, {
[footerDirection]: footerDirection,
})}
>
{footer}
</div>
)
)
}

const handleClick = (e: any) => {
Expand All @@ -48,8 +55,8 @@ export const Content: FunctionComponent<

return (
<div
className={classNames(`${classPrefix}-outer`, props.className)}
style={props.style}
className={classNames(`${classPrefix}-outer`, className)}
style={style}
onClick={(e) => handleClick(e)}
>
{close}
Expand All @@ -59,9 +66,7 @@ export const Content: FunctionComponent<
style={{ display: visible ? 'flex' : 'none' }}
>
{renderHeader()}
<div className={`${classPrefix}-content`}>
<>{children}</>
</div>
<div className={`${classPrefix}-content`}>{children}</div>
{renderFooter()}
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions src/packages/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
padding: $dialog-padding;
box-sizing: border-box;

&-overlay {
--nutui-overlay-zIndex: 1200;
}

&-outer {
position: fixed;
max-height: 100%;
Expand Down
Loading
Loading