Skip to content

Commit

Permalink
get rid of boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Aug 4, 2023
1 parent 1c4ddbe commit 6f9be4f
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 53 deletions.
16 changes: 16 additions & 0 deletions packages/web-app-pdf-viewer/src/PdfViewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<object class="pdf-viewer oc-width-1-1 oc-height-1-1" :data="url" type="application/pdf" />
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
props: {
url: {
type: String,
required: true
}
}
})
</script>
13 changes: 0 additions & 13 deletions packages/web-app-pdf-viewer/src/components/ErrorScreen.vue

This file was deleted.

14 changes: 0 additions & 14 deletions packages/web-app-pdf-viewer/src/components/LoadingScreen.vue

This file was deleted.

10 changes: 8 additions & 2 deletions packages/web-app-pdf-viewer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import translations from '../l10n/translations.json'
import App from './App.vue'
import { AppWrapperRoute } from 'web-pkg/src/components/AppTemplates/AppWrapperRoute'
import PdfViewer from './PdfViewer.vue'

// just a dummy function to trick gettext tools
function $gettext(msg) {
Expand All @@ -9,7 +10,12 @@ function $gettext(msg) {
const routes = [
{
path: '/:driveAliasAndItem(.*)?',
component: App,
component: AppWrapperRoute(PdfViewer, {
applicationId: 'pdf-viewer',
urlForResourceOptions: {
disposition: 'inline'
}
}),
name: 'pdf-viewer',
meta: {
authContext: 'hybrid',
Expand Down
22 changes: 0 additions & 22 deletions packages/web-app-text-editor/src/App.vue

This file was deleted.

7 changes: 5 additions & 2 deletions packages/web-app-text-editor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import App from './App.vue'
import translations from '../l10n/translations.json'
import TextEditor from './TextEditor.vue'
import { AppWrapperRoute } from 'web-pkg/src/components/AppTemplates/AppWrapperRoute'

// just a dummy function to trick gettext tools
function $gettext(msg) {
Expand All @@ -11,7 +12,9 @@ const appId = 'text-editor'
const routes = [
{
path: '/:driveAliasAndItem(.*)?',
component: App,
component: AppWrapperRoute(TextEditor, {
applicationId: appId
}),
name: 'text-editor',
meta: {
authContext: 'hybrid',
Expand Down
25 changes: 25 additions & 0 deletions packages/web-pkg/src/components/AppTemplates/AppWrapperRoute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineComponent, h } from 'vue'
import AppWrapper, { AppWrapperSlotArgs } from './AppWrapper.vue'
import { UrlForResourceOptions } from 'web-pkg/src/composables'

export function AppWrapperRoute(
fileEditor: ReturnType<typeof defineComponent>,
options: { applicationId: string; urlForResourceOptions?: UrlForResourceOptions }
) {
return defineComponent({
render() {
return h(AppWrapper, options, {
default: (slotArgs: AppWrapperSlotArgs) => {
const { currentContent, ...restArgs } = slotArgs
return h(fileEditor, {
currentContent: currentContent.value,
'onUpdate:currentContent': (value) => {
currentContent.value = value
},
...restArgs
})
}
})
}
})
}

0 comments on commit 6f9be4f

Please sign in to comment.