From 95f8cbf59cb48786a8c924632eeaa7a7aed54540 Mon Sep 17 00:00:00 2001 From: "Min Ji, Choi" <30827184+mmindy@users.noreply.github.com> Date: Wed, 4 Nov 2020 13:05:32 +0900 Subject: [PATCH] =?UTF-8?q?[#703][3.0]=20MessageBox=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20(#704)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ########## - MessageBox 2.0 버전 마이그레이션 및 기능 개선 - 기타 스타일 및 불필요 코드 수정 - docs 샘플 페이지 생성 - message, notification 코드 개선 Co-authored-by: mjchoi --- docs/router/index.js | 7 + docs/views/messageBox/api/messageBox.md | 57 ++++ docs/views/messageBox/example/Default.vue | 211 ++++++++++++ docs/views/messageBox/props.js | 15 + docs/views/notification/props.js | 2 +- src/components/message/Message.vue | 70 ++-- src/components/message/index.js | 10 +- src/components/messageBox/MessageBox.vue | 339 +++++++++++++++++++ src/components/messageBox/index.js | 17 + src/components/notification/Notification.vue | 38 +-- src/components/notification/index.js | 9 +- src/main.js | 3 +- 12 files changed, 713 insertions(+), 65 deletions(-) create mode 100644 docs/views/messageBox/api/messageBox.md create mode 100644 docs/views/messageBox/example/Default.vue create mode 100644 docs/views/messageBox/props.js create mode 100644 src/components/messageBox/MessageBox.vue create mode 100644 src/components/messageBox/index.js diff --git a/docs/router/index.js b/docs/router/index.js index 634f3d312..24aba7a46 100644 --- a/docs/router/index.js +++ b/docs/router/index.js @@ -13,6 +13,7 @@ import iconProps from 'docs/views/icon/props'; import datePickerProps from 'docs/views/datePicker/props'; import calendarProps from 'docs/views/calendar/props'; import messageProps from 'docs/views/message/props'; +import messageBoxProps from 'docs/views/messageBox/props'; import notificationProps from 'docs/views/notification/props'; const routes = [ @@ -148,6 +149,12 @@ const routes = [ component: PageView, props: messageProps, }, + { + path: '/messageBox', + name: 'MessageBox', + component: PageView, + props: messageBoxProps, + }, { path: '/notification', name: 'Notification', diff --git a/docs/views/messageBox/api/messageBox.md b/docs/views/messageBox/api/messageBox.md new file mode 100644 index 000000000..d253b6588 --- /dev/null +++ b/docs/views/messageBox/api/messageBox.md @@ -0,0 +1,57 @@ +### Desc +$messagebox 는 `app.config.globalProperties`에 등록되어 있어, 각 컴포넌트에서 아래처럼 사용 가능 +```vue + + +``` +```js +// 메시지만 입력 시, +ctx.$messagebox('message'); + +// 옵션과 사용 시, +ctx.$messagebox({ + message: 'message', + // options +}); +``` + +### Props + +| 이름 | 디폴트 | 타입 | 설명 | 종류 | +| --- | ---- | ----- | ---- | --- | +| type | '' | String | 메시지 스타일. type입력 시 좌측 상단에 타입에 맞는 아이콘 노출됨 | 'info', 'success', 'warning', 'error' | +| message | '' | String | 메시지 창에 띄울 문구 | | +| title | '' | String | 메시지 상단 타이틀 문구 | | +| iconClass | '' | String | 메시지 창 좌측에 띄울 EVUI 아이콘 명 | | +| onClose | null | Function | 메시지 창이 닫힌 후 동작. 매개변수로 클릭한 버튼 타입을 받음(ok, cancel). 닫기 버튼 및 모달 레이어 클릭으로 닫을 시 cancel | | +| showClose | true | Boolean | 닫기 버튼 노출 여부 | true, false | +| showConfirmBtn | true | Boolean | 확인 버튼 노출 여부 | true, false | +| showCancelBtn | true | Boolean | 취소 버튼 노출 여부 | true, false | +| confirmBtnText | 'OK' | String | 확인 버튼 문구 | | +| cancelBtnText | 'Cancel' | String | 취소 버튼 문구 | | +| closeOnClickModal | true | Boolean | 모달 레이어 클릭 시 메시지 창 닫기 여부 | true, false | +| lockScroll | true | Boolean | 메시지 창 노출 시 스크롤 사라짐 여부 | true, false | +| useHTML | false | Boolean | 메시지 창 문구에 HTML 사용 여부. 사용 시 message 속성에 함께 작성 | | diff --git a/docs/views/messageBox/example/Default.vue b/docs/views/messageBox/example/Default.vue new file mode 100644 index 000000000..d3afacd70 --- /dev/null +++ b/docs/views/messageBox/example/Default.vue @@ -0,0 +1,211 @@ + + + + + diff --git a/docs/views/messageBox/props.js b/docs/views/messageBox/props.js new file mode 100644 index 000000000..c3e6dd359 --- /dev/null +++ b/docs/views/messageBox/props.js @@ -0,0 +1,15 @@ +import { parseComponent } from 'vue-template-compiler'; +import mdText from '!!raw-loader!./api/messageBox.md'; +import Default from './example/Default'; +import DefaultRaw from '!!raw-loader!./example/Default'; + +export default { + mdText, + components: { + Default: { + description: '사용자 작업에 대한 확인 정보창을 표시할 수 있습니다. (버튼 클릭 시 메시지 창을 확인할 수 있습니다.)', + component: Default, + parsedData: parseComponent(DefaultRaw), + }, + }, +}; diff --git a/docs/views/notification/props.js b/docs/views/notification/props.js index ad8f8d418..e7acb70cb 100644 --- a/docs/views/notification/props.js +++ b/docs/views/notification/props.js @@ -7,7 +7,7 @@ export default { mdText, components: { Default: { - description: '사용자 동작에 대한 알림을 표시할 수 있습니다. (버튼 클릭 시 메시지 창을 확인할 수 있습니다.)', + description: '어플리케이션의 공지 알람을 표시할 수 있습니다. (버튼 클릭 시 메시지 창을 확인할 수 있습니다.)', component: Default, parsedData: parseComponent(DefaultRaw), }, diff --git a/src/components/message/Message.vue b/src/components/message/Message.vue index d37c6e823..2f375e53e 100644 --- a/src/components/message/Message.vue +++ b/src/components/message/Message.vue @@ -1,20 +1,21 @@ + + diff --git a/src/components/messageBox/index.js b/src/components/messageBox/index.js new file mode 100644 index 000000000..47400c0e3 --- /dev/null +++ b/src/components/messageBox/index.js @@ -0,0 +1,17 @@ +import { defineComponent, h, render } from 'vue'; +import Component from './MessageBox.vue'; + +const componentObj = defineComponent(Component); + +const messageBox = (options = {}) => { + const container = document.createElement('div'); + const unmount = () => render(null, container); + const msgOption = (typeof options === 'string') ? { message: options, unmount } : { ...options, unmount }; + const instance = h( + componentObj, + msgOption, + ); + render(instance, container); +}; + +export default messageBox; diff --git a/src/components/notification/Notification.vue b/src/components/notification/Notification.vue index 55994b332..2af4580bb 100644 --- a/src/components/notification/Notification.vue +++ b/src/components/notification/Notification.vue @@ -16,18 +16,15 @@ @mouseleave="startTimer" @click="clickMsg" > - - - -
+ + +

-

-

- {{ title }} -

-

{{ message }}

@@ -58,8 +48,8 @@ class="ev-notification-close" @click="closeMsg" > - - + +
@@ -180,7 +170,7 @@ export default {