popup.helpers.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @file Popup 变体合并 — footer 与关闭按钮可见性纯逻辑
*/
/** @typedef {'default' | 'none' | 'tips'} PopupFooterMode */
/**
* 是否显示底部取消/确认按钮
* @param {PopupFooterMode} footerMode
* @returns {boolean}
*/
export function shouldShowFooter(footerMode) {
return footerMode === 'default' || footerMode === 'tips'
}
/**
* 是否显示标题栏关闭图标(tipsPopup 风格)
* @param {PopupFooterMode} footerMode
* @param {boolean} showCloseIcon
* @returns {boolean}
*/
export function shouldShowCloseIcon(footerMode, showCloseIcon) {
return footerMode === 'none' || showCloseIcon
}
/**
* 是否显示 tips 文案区域
* @param {PopupFooterMode} footerMode
* @param {string} [tips]
* @returns {boolean}
*/
export function shouldShowTips(footerMode, tips) {
return footerMode === 'tips' && Boolean(tips)
}
/**
* slot 区域 class:tips 模式用更高 scroll 区域
* @param {PopupFooterMode} footerMode
* @param {boolean} hasTips
* @returns {'popup-slot' | 'popup-slot-other'}
*/
export function getPopupSlotClass(footerMode, hasTips) {
return footerMode === 'tips' && hasTips ? 'popup-slot-other' : 'popup-slot'
}