-
Notifications
You must be signed in to change notification settings - Fork 5
Feat(initial view) #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LivMoeser
wants to merge
20
commits into
next
Choose a base branch
from
feat(initialView)
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat(initial view) #909
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b54e416
feat(initialView): add initial view plugin
LivMoeser aea2ee3
Merge branch 'next' of https://github.com/Dataport/polar into next
LivMoeser 396b606
feat(initialView): change to one-button application
LivMoeser 004ab9d
Merge branch 'next' of https://github.com/Dataport/polar into next
LivMoeser af11964
fix(initialView): move comment to variable in types.ts
JoselinGuevaraHoppe 6b517b4
fix(initialView): get startCenter and startResolution via core config…
JoselinGuevaraHoppe b823a80
fix(initialView): rename "initialViewStore" according ro camelCase
JoselinGuevaraHoppe 236bc0c
fix(initialView): inline function
JoselinGuevaraHoppe 949c299
fix(initialView): delete unused value
JoselinGuevaraHoppe 56b870a
fix(initialView): rename "returnToInitialView" to "initialView"
JoselinGuevaraHoppe e67cbc4
fix(initialView): comment @aplha in store
JoselinGuevaraHoppe 922d69b
fix(initialView): comment @internal in store
JoselinGuevaraHoppe 38d6aac
feat(initialView): add tests to store
LivMoeser f96fb95
Merge branch 'feat(initialView)' of https://github.com/Dataport/polar…
LivMoeser 29e7076
fix(initialView): fix comment @alpha in store
JoselinGuevaraHoppe 8a226bc
feat(core): remove readonly restriction
JoselinGuevaraHoppe c477d2c
fix(initialView): change returnToInitialView to reference to coreStor…
JoselinGuevaraHoppe ee1a583
fix: move plugin "initialView" to iconMenu
JoselinGuevaraHoppe 0399d64
fix(initialView): add tooltip-position to store
LivMoeser 80ca013
Merge branch 'feat(initialView)' of https://github.com/Dataport/polar…
LivMoeser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/plugins/initialView/components/ReturnToInitialView.ce.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <template> | ||
| <PolarIconButton | ||
| :hint="$t(($) => $.label.return, { ns: PluginId })" | ||
| icon="kern-icon--home" | ||
| tooltip-position="left" | ||
| @click="onClick" | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import PolarIconButton from '@/components/PolarIconButton.ce.vue' | ||
|
|
||
| import { useInitialViewStore } from '../store' | ||
| import { PluginId } from '../types' | ||
|
|
||
| const InitialViewStore = useInitialViewStore() | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
|
|
||
| function onClick() { | ||
| InitialViewStore.returnToInitialView() | ||
| } | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* eslint-disable tsdoc/syntax */ | ||
| /** | ||
| * @module @polar/polar/plugins/returnToInitialView | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| */ | ||
| /* eslint-enable tsdoc/syntax */ | ||
|
|
||
| import type { PluginContainer, PolarPluginStore } from '@/core' | ||
| import type { InitialViewPluginOptions } from './types' | ||
|
|
||
| import component from './components/ReturnToInitialView.ce.vue' | ||
| import locales from './locales' | ||
| import { useInitialViewStore } from './store' | ||
| import { PluginId } from './types' | ||
|
|
||
| /** | ||
| * Creates a plugin which offers a button to return to the map's start view. | ||
| * | ||
| * @returns Plugin for use with {@link addPlugin}. | ||
| */ | ||
| export default function pluginInitialView( | ||
| options: InitialViewPluginOptions = {} | ||
| ): PluginContainer { | ||
| return { | ||
| id: PluginId, | ||
| component, | ||
| locales, | ||
| storeModule: useInitialViewStore as PolarPluginStore, | ||
| options, | ||
| } | ||
| } | ||
|
|
||
| export * from './types' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* eslint-disable tsdoc/syntax */ | ||
| /** | ||
| * @module locales/plugins/returnToInitialView | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| */ | ||
| /* eslint-enable tsdoc/syntax */ | ||
|
|
||
| import type { Locale } from '@/core' | ||
|
|
||
| export const resourcesDe = { | ||
| title: 'Zur Startansicht', | ||
| label: { | ||
| return: 'Zurück zur Startansicht', | ||
| }, | ||
| } as const | ||
|
|
||
| export const resourcesEn = { | ||
| title: 'Return to Start View', | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| label: { | ||
| return: 'Return to start view', | ||
| }, | ||
| } as const | ||
|
|
||
| const locales: Locale[] = [ | ||
| { | ||
| type: 'de', | ||
| resources: resourcesDe, | ||
| }, | ||
| { | ||
| type: 'en', | ||
| resources: resourcesEn, | ||
| }, | ||
| ] | ||
|
|
||
| export default locales | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { defineStore } from 'pinia' | ||
| import { ref } from 'vue' | ||
|
|
||
| import { useCoreStore } from '@/core/stores' | ||
|
|
||
| export const useInitialViewStore = defineStore('plugins/initialView', () => { | ||
| const coreStore = useCoreStore() | ||
|
|
||
| const viewCenter = coreStore.map.getView().getCenter() as | ||
| [number, number] | undefined | ||
| const viewResolution = coreStore.map.getView().getResolution() | ||
|
|
||
| const initialCenter = coreStore.configuration.returnToInitialView | ||
| ?.startCenter ?? | ||
| viewCenter ?? [0, 0] | ||
|
|
||
| const initialResolution = | ||
| coreStore.configuration.returnToInitialView?.startResolution ?? | ||
| viewResolution ?? | ||
| 1 | ||
|
|
||
| const startCenter = ref(initialCenter) | ||
| const startResolution = ref(initialResolution) | ||
|
|
||
| function returnToInitialView() { | ||
| coreStore.map.getView().setCenter(startCenter.value) | ||
| coreStore.map.getView().setResolution(startResolution.value) | ||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| function setupPlugin() { | ||
| const options = coreStore.configuration.returnToInitialView | ||
| if (options?.startCenter) { | ||
| startCenter.value = options.startCenter | ||
| } | ||
| if (options?.startResolution) { | ||
| startResolution.value = options.startResolution | ||
| } | ||
| } | ||
|
|
||
| function teardownPlugin() {} | ||
|
|
||
| return { | ||
| startCenter, | ||
| startResolution, | ||
| returnToInitialView, | ||
|
dopenguin marked this conversation as resolved.
|
||
| setupPlugin, | ||
| teardownPlugin, | ||
|
dopenguin marked this conversation as resolved.
|
||
| } | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * Defines if the geoLocation button is rendered independent or as part of the | ||
| * icon menu. | ||
| * @defaultValue `'independent'` | ||
| */ | ||
|
|
||
|
dopenguin marked this conversation as resolved.
Outdated
|
||
| import type { PluginOptions } from '@/core' | ||
|
|
||
| export const PluginId = 'initialView' as const | ||
|
|
||
| export interface InitialViewPluginOptions extends PluginOptions { | ||
| renderType?: 'independent' | 'iconMenu' | ||
| startCenter?: [number, number] | ||
| startResolution?: number | ||
| } | ||
|
dopenguin marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.