diff --git a/docs/presentation.md b/docs/presentation.md index 8b023696..2398a5e1 100644 --- a/docs/presentation.md +++ b/docs/presentation.md @@ -36,3 +36,16 @@ - Do not forget to subscribe from events when component is destroyed or if needed [collection](./collection-files.md) is changed. - 💡 `events` in base class [`StatefulVue`](./../src/presentation/components/Shared/StatefulVue.ts) makes lifecycling easier - 📖 See [Application state | Application layer](./presentation.md#application-state) where the state is implemented using using state pattern. + +## Modals + +- [Dialog.vue](./../src/presentation/components/Shared/Dialog.vue) is a shared component that can be used to show modal windows +- Simply wrap the content inside of its slot and call `.show()` method on its reference. +- Example: + + ```html + +
Hello world
+
+
Show dialog
+ ``` diff --git a/src/presentation/components/Code/CodeButtons/TheCodeButtons.vue b/src/presentation/components/Code/CodeButtons/TheCodeButtons.vue index a200f332..fb90bff6 100644 --- a/src/presentation/components/Code/CodeButtons/TheCodeButtons.vue +++ b/src/presentation/components/Code/CodeButtons/TheCodeButtons.vue @@ -17,17 +17,9 @@ v-on:click="copyCodeAsync" icon-prefix="fas" icon-name="copy"> - - - + + + @@ -36,6 +28,7 @@ import { Component } from 'vue-property-decorator'; import { StatefulVue } from '@/presentation/components/Shared/StatefulVue'; import { SaveFileDialog, FileType } from '@/infrastructure/SaveFileDialog'; import { Clipboard } from '@/infrastructure/Clipboard'; +import Dialog from '@/presentation/components/Shared/Dialog.vue'; import IconButton from './IconButton.vue'; import MacOsInstructions from './MacOsInstructions.vue'; import { Environment } from '@/application/Environment/Environment'; @@ -51,11 +44,10 @@ import { IApplicationContext } from '@/application/Context/IApplicationContext'; components: { IconButton, MacOsInstructions, + Dialog, }, }) export default class TheCodeButtons extends StatefulVue { - public readonly macOsModalName = 'macos-instructions'; - public readonly isDesktopVersion = Environment.CurrentEnvironment.isDesktop; public canRun = false; public hasCode = false; @@ -70,7 +62,7 @@ export default class TheCodeButtons extends StatefulVue { const context = await this.getCurrentContextAsync(); saveCode(this.fileName, context.state); if (this.isMacOsCollection) { - this.$modal.show(this.macOsModalName); + (this.$refs.instructionsDialog as any).show(); } } public async executeCodeAsync() { @@ -134,9 +126,6 @@ async function executeCodeAsync(context: IApplicationContext) { diff --git a/src/presentation/components/Shared/Dialog.vue b/src/presentation/components/Shared/Dialog.vue new file mode 100644 index 00000000..7f8a0b90 --- /dev/null +++ b/src/presentation/components/Shared/Dialog.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/presentation/components/TheFooter/TheFooter.vue b/src/presentation/components/TheFooter/TheFooter.vue index 7b5a8ab3..f718d6bc 100644 --- a/src/presentation/components/TheFooter/TheFooter.vue +++ b/src/presentation/components/TheFooter/TheFooter.vue @@ -31,18 +31,13 @@ - - - + + + @@ -50,17 +45,17 @@ import { Component, Vue } from 'vue-property-decorator'; import { Environment } from '@/application/Environment/Environment'; import PrivacyPolicy from './PrivacyPolicy.vue'; +import Dialog from '@/presentation/components/Shared/Dialog.vue'; import DownloadUrlList from './DownloadUrlList.vue'; import { IApplication } from '@/domain/IApplication'; import { ApplicationFactory } from '@/application/ApplicationFactory'; @Component({ components: { - PrivacyPolicy, DownloadUrlList, + Dialog, PrivacyPolicy, DownloadUrlList, }, }) export default class TheFooter extends Vue { - public readonly modalName = 'privacy-policy'; public readonly isDesktop = Environment.CurrentEnvironment.isDesktop; public version: string = '';