From 5770e6c0681d7a3cc8216ed2524a33adcfa33a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=2E=E6=A0=8B?= <103579791+pe-3@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:06:55 +0800 Subject: [PATCH] feat(react): add mobile mode in tiny react alert (#550) * feat(react): add mobile mode in tiny react alert * feat(react): adjust indent spaces to 2 --- packages/react/src/alert/package.json | 3 +- packages/react/src/alert/src/index.ts | 2 + packages/react/src/alert/src/mobile.jsx | 93 +++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 packages/react/src/alert/src/mobile.jsx diff --git a/packages/react/src/alert/package.json b/packages/react/src/alert/package.json index b88dfae91..89d9d73e0 100644 --- a/packages/react/src/alert/package.json +++ b/packages/react/src/alert/package.json @@ -13,6 +13,7 @@ "@opentiny/vue-renderless": "workspace:~", "@opentiny/react-common": "workspace:~", "@opentiny/react-icon": "workspace:~", - "@opentiny/vue-theme": "workspace:~" + "@opentiny/vue-theme": "workspace:~", + "@opentiny/vue-theme-mobile": "workspace:~" } } \ No newline at end of file diff --git a/packages/react/src/alert/src/index.ts b/packages/react/src/alert/src/index.ts index 4023bcdd1..a401d7893 100644 --- a/packages/react/src/alert/src/index.ts +++ b/packages/react/src/alert/src/index.ts @@ -1,4 +1,5 @@ import pc from './pc.jsx' +import mobile from './mobile.jsx' import mobileFirst from './mobile-first.jsx' export default function (props) { @@ -8,6 +9,7 @@ export default function (props) { const S = ({ pc, + mobile, 'mobile-first': mobileFirst })[tiny_mode] diff --git a/packages/react/src/alert/src/mobile.jsx b/packages/react/src/alert/src/mobile.jsx new file mode 100644 index 000000000..cfea48d0e --- /dev/null +++ b/packages/react/src/alert/src/mobile.jsx @@ -0,0 +1,93 @@ +import { renderless, api } from '@opentiny/vue-renderless/alert/vue' +import { IconClose, IconSuccess, IconError, IconHelp, IconWarning, IconChevronDown } from '@opentiny/react-icon' +import { + vc, + If, + Component, + Slot, + useSetup, + useVm, +} from '@opentiny/react-common' +import '@opentiny/vue-theme-mobile/alert/index.less' + +const $constants = { + ICON_MAP: { + success: IconSuccess, + error: IconError, + info: IconHelp, + warning: IconWarning + }, + TITLE_MAP: { + success: 'ui.alert.success', + error: 'ui.alert.error', + info: 'ui.alert.info', + warning: 'ui.alert.warning' + }, + CONTENT_MAXHEUGHT: 252 +} + +export default function Alert(props) { + const { + type = 'success', + size = 'normal', + showIcon = true, + closable = true, + closeText, + _constants = $constants, + description = '' + } = props; + + const defaultProps = Object.assign({ + type, + size, + showIcon, + closable, + _constants + }, props); + + const { + ref, + current: vm, + parent + } = useVm() + + const { + state, + handleClose + } = useSetup({ + props: defaultProps, + renderless, + api, + vm, + parent, + constants: _constants, + }) + + return (
+ +
+ +
+ {description} +
+ + + + + {closeText} + +
+
+
) +} \ No newline at end of file