From 8fd799df2d6d967d83c6a86e83218cb8a69e49c7 Mon Sep 17 00:00:00 2001 From: Asva Date: Sat, 15 May 2021 23:31:46 +0300 Subject: [PATCH] feat: va-toast docs closes #426 Co-authored-by: Damir Sadykov Co-authored-by: Dmitry Kushnerevich --- .../ui-elements/va-toast/api-options.ts | 25 +++ .../ui-elements/va-toast/page-config.ts | 111 ++++++++++++ .../components/sidebar/navigationRoutes.ts | 4 + packages/docs/src/examples/va-toast/Click.vue | 16 ++ packages/docs/src/examples/va-toast/Close.vue | 18 ++ packages/docs/src/examples/va-toast/Color.vue | 7 + .../docs/src/examples/va-toast/Default.vue | 4 + .../docs/src/examples/va-toast/Offset.vue | 3 + .../docs/src/examples/va-toast/Position.vue | 6 + packages/docs/src/locales/en/en.json | 61 ++++++- packages/docs/src/pages/ui-elements/toast.vue | 20 +++ packages/ui/.eslintrc.js | 1 + .../vuestic-components/va-slider/VaSlider.vue | 1 - .../va-toast/VaToast.demo.vue | 38 +++- .../vuestic-components/va-toast/VaToast.vue | 170 +++++++++--------- .../va-toast/_variables.scss | 1 + .../vuestic-components/va-toast/index.ts | 5 +- .../va-toast/tests/VaToast.spec.ts | 11 ++ 18 files changed, 406 insertions(+), 96 deletions(-) create mode 100644 packages/docs/src/components/page-configs/ui-elements/va-toast/api-options.ts create mode 100644 packages/docs/src/components/page-configs/ui-elements/va-toast/page-config.ts create mode 100644 packages/docs/src/examples/va-toast/Click.vue create mode 100644 packages/docs/src/examples/va-toast/Close.vue create mode 100644 packages/docs/src/examples/va-toast/Color.vue create mode 100644 packages/docs/src/examples/va-toast/Default.vue create mode 100644 packages/docs/src/examples/va-toast/Offset.vue create mode 100644 packages/docs/src/examples/va-toast/Position.vue create mode 100644 packages/docs/src/pages/ui-elements/toast.vue create mode 100644 packages/ui/src/components/vuestic-components/va-toast/tests/VaToast.spec.ts diff --git a/packages/docs/src/components/page-configs/ui-elements/va-toast/api-options.ts b/packages/docs/src/components/page-configs/ui-elements/va-toast/api-options.ts new file mode 100644 index 0000000000..58e36c351a --- /dev/null +++ b/packages/docs/src/components/page-configs/ui-elements/va-toast/api-options.ts @@ -0,0 +1,25 @@ +import { ManualApiOptions } from 'vuestic-ui/src/services/api-docs/ManualApiOptions' + +export default { + props: { + title: { local: true }, + offsetY: { local: true }, + offsetX: { local: true }, + message: { local: true }, + icon: { local: true }, + customClass: { local: true }, + duration: { local: true }, + closeable: { local: true }, + onClose: { local: true }, + onClick: { local: true }, + position: { local: true }, + render: { local: true }, + multiLine: { local: true }, + }, + events: { + }, + methods: { + }, + slots: { + }, +} as ManualApiOptions diff --git a/packages/docs/src/components/page-configs/ui-elements/va-toast/page-config.ts b/packages/docs/src/components/page-configs/ui-elements/va-toast/page-config.ts new file mode 100644 index 0000000000..44c0eca93e --- /dev/null +++ b/packages/docs/src/components/page-configs/ui-elements/va-toast/page-config.ts @@ -0,0 +1,111 @@ +import VaToast from 'vuestic-ui/src/components/vuestic-components/va-toast/VaToast.vue' +import apiOptions from './api-options' +import { BlockType, ApiDocsBlock } from '../../../../types/configTypes' + +export default [ + { + type: BlockType.TITLE, + translationString: 'toast.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.summaryText', + }, + { + type: BlockType.SUBTITLE, + translationString: 'all.examples', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.default.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.default.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Default', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.color.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.color.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Color', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.offset.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.offset.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Offset', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.position.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.position.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Position', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.close.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.close.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Close', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.examples.click.title', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.examples.click.text', + }, + { + type: BlockType.EXAMPLE, + component: 'va-toast/Click', + }, + { + type: BlockType.SUBTITLE, + translationString: 'all.api', + }, + { + type: BlockType.API, + componentOptions: VaToast, + apiOptions, + }, + { + type: BlockType.SUBTITLE, + translationString: 'all.faq', + }, + { + type: BlockType.HEADLINE, + translationString: 'toast.faq.questions[0].question', + }, + { + type: BlockType.PARAGRAPH, + translationString: 'toast.faq.questions[0].answer', + }, +] as ApiDocsBlock[] diff --git a/packages/docs/src/components/sidebar/navigationRoutes.ts b/packages/docs/src/components/sidebar/navigationRoutes.ts index b13aeb3b5e..df1b963d08 100644 --- a/packages/docs/src/components/sidebar/navigationRoutes.ts +++ b/packages/docs/src/components/sidebar/navigationRoutes.ts @@ -275,6 +275,10 @@ export const navigationRoutes: NavigationRoute[] = [ name: 'progress-circle', displayName: 'menu.progressCircle', }, + { + name: 'toast', + displayName: 'menu.toast', + }, // GENERATOR_ADD - uiElements ], }, diff --git a/packages/docs/src/examples/va-toast/Click.vue b/packages/docs/src/examples/va-toast/Click.vue new file mode 100644 index 0000000000..f19d2132b8 --- /dev/null +++ b/packages/docs/src/examples/va-toast/Click.vue @@ -0,0 +1,16 @@ + + + diff --git a/packages/docs/src/examples/va-toast/Close.vue b/packages/docs/src/examples/va-toast/Close.vue new file mode 100644 index 0000000000..5d95ede119 --- /dev/null +++ b/packages/docs/src/examples/va-toast/Close.vue @@ -0,0 +1,18 @@ + + + diff --git a/packages/docs/src/examples/va-toast/Color.vue b/packages/docs/src/examples/va-toast/Color.vue new file mode 100644 index 0000000000..0436f9f8bc --- /dev/null +++ b/packages/docs/src/examples/va-toast/Color.vue @@ -0,0 +1,7 @@ + diff --git a/packages/docs/src/examples/va-toast/Default.vue b/packages/docs/src/examples/va-toast/Default.vue new file mode 100644 index 0000000000..d4caaeb9db --- /dev/null +++ b/packages/docs/src/examples/va-toast/Default.vue @@ -0,0 +1,4 @@ + diff --git a/packages/docs/src/examples/va-toast/Offset.vue b/packages/docs/src/examples/va-toast/Offset.vue new file mode 100644 index 0000000000..b40600102d --- /dev/null +++ b/packages/docs/src/examples/va-toast/Offset.vue @@ -0,0 +1,3 @@ + diff --git a/packages/docs/src/examples/va-toast/Position.vue b/packages/docs/src/examples/va-toast/Position.vue new file mode 100644 index 0000000000..6b622cc99e --- /dev/null +++ b/packages/docs/src/examples/va-toast/Position.vue @@ -0,0 +1,6 @@ + diff --git a/packages/docs/src/locales/en/en.json b/packages/docs/src/locales/en/en.json index 19db4f661c..4a5ab2fcd4 100644 --- a/packages/docs/src/locales/en/en.json +++ b/packages/docs/src/locales/en/en.json @@ -397,6 +397,26 @@ "default": "Insert content (for horizontal only)" } }, + "VaToast": { + "props": { + "title": "Sets the title for the notification", + "offsetY": "Sets the Y offset", + "offsetX": "Sets the X offset", + "message": "Notification message", + "icon": "Sets the close icon", + "customClass": "Applies custom class to the component", + "duration": "Sets the duration of the notification display", + "closeable":"Provides the ability to close the component", + "onClose":"Applies a function to use when pressed a close button", + "onClick":"Applies a function to use when clicked", + "position":"Sets the position of the notification", + "render":"Render function to use a custom content", + "multiLine": "Sets more space for the Toast component" + }, + "events": {}, + "methods": {}, + "slots": {} + }, "VaCard": { "props": { "stripe": "Displays a stripe above a card title.", @@ -1003,7 +1023,8 @@ "colorsConfig": "Colors Config", "cssVariables": "CSS Variables", "sidebarItem": "Sidebar Item", - "navbar": "Navbar" + "navbar": "Navbar", + "toast": "Toast" }, "all": { "examples": "Examples", @@ -1385,6 +1406,44 @@ ] } }, + "toast": { + "title": "Toast", + "summaryText": "Component for sending a notification to the user.", + "examples": { + "default": { + "title": "Basic usage", + "text": "By default, run this component in events by using the `init` method with a setting object." + }, + "color": { + "title": "Color", + "text": "Set different colors using `color` prop. You can either user theme string *HEX* color value." + }, + "offset": { + "title": "Offset", + "text": "Use `offset` property to set the offset of the toast." + }, + "position": { + "title": "Position", + "text": "Use `position` property to set the custom position of the toast. Available are `top-right`, `top-left`, `bottom-right`, `bottom-left`." + }, + "close": { + "title": "Close", + "text": "You can use close method to close the notification and you can set custom onClose event." + }, + "click": { + "title": "Click", + "text": "You can set custom onClick event to handle the click on button." + } + }, + "faq": { + "questions": [ + { + "question": "What is the difference between a component and a service?", + "answer": "The difference is in implementation. The service behaves more flexibly and it is easier to bind it to certain events than to render the whole element. \n Each prop you provide to the component you can provide to the service too by using the setting object." + } + ] + } + }, "modal": { "title": "Modal", "description": "Classic modal overlay which represents a dialog box or other interactive component, such as a dismissible alert, sub-window, etc.", diff --git a/packages/docs/src/pages/ui-elements/toast.vue b/packages/docs/src/pages/ui-elements/toast.vue new file mode 100644 index 0000000000..c7b998f361 --- /dev/null +++ b/packages/docs/src/pages/ui-elements/toast.vue @@ -0,0 +1,20 @@ + + + diff --git a/packages/ui/.eslintrc.js b/packages/ui/.eslintrc.js index 031f9bb6fb..49b74013d6 100644 --- a/packages/ui/.eslintrc.js +++ b/packages/ui/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { curly: ['error', 'all'], indent: ['error', 2, { ignoreComments: true }], 'prefer-arrow-callback': 'error', + 'lines-between-class-members': 'off', 'array-bracket-spacing': ['error', 'never'], '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/ban-ts-comment': 'off', diff --git a/packages/ui/src/components/vuestic-components/va-slider/VaSlider.vue b/packages/ui/src/components/vuestic-components/va-slider/VaSlider.vue index 77ca44cc51..34c77c28bb 100644 --- a/packages/ui/src/components/vuestic-components/va-slider/VaSlider.vue +++ b/packages/ui/src/components/vuestic-components/va-slider/VaSlider.vue @@ -165,7 +165,6 @@ class SliderProps { type: [Number, Array], default: () => [], }) - trackLabel = prop({ type: String, default: '' }) color = prop({ type: String, default: 'primary' }) trackColor = prop({ type: String, default: '' }) diff --git a/packages/ui/src/components/vuestic-components/va-toast/VaToast.demo.vue b/packages/ui/src/components/vuestic-components/va-toast/VaToast.demo.vue index 0a4498fab6..a99aca2852 100644 --- a/packages/ui/src/components/vuestic-components/va-toast/VaToast.demo.vue +++ b/packages/ui/src/components/vuestic-components/va-toast/VaToast.demo.vue @@ -21,12 +21,19 @@ - - - + + + + + + + + + + @@ -62,7 +69,32 @@ export default { message: 'Custom handler (bottom-right)', onClose: () => console.log('Handle onClose'), }, + customMessage: { + message: 'Simple message', + render: (h) => { + return h('div', [ + 'This is a ', + h('span', { style: 'font-weight: bold' }, 'custom'), + ' render message', + ]) + }, + }, + multiLine: { + message: 'Multi-line message', + multiLine: true, + }, + handleId: null, } }, + methods: { + handleToast () { + this.handleId = this.$vaToast.init({ + message: `Toast ${this.handleId} is opened`, // this example is buggy because of lack of reactivity inside the toast data + onClose: () => { + this.handleId = null + }, + }) + }, + }, } diff --git a/packages/ui/src/components/vuestic-components/va-toast/VaToast.vue b/packages/ui/src/components/vuestic-components/va-toast/VaToast.vue index 6fc175c8db..1492b00b75 100644 --- a/packages/ui/src/components/vuestic-components/va-toast/VaToast.vue +++ b/packages/ui/src/components/vuestic-components/va-toast/VaToast.vue @@ -2,35 +2,28 @@