Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/core/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,39 @@
import type { Locale } from './locales'
import type { Icon } from './theme'

/**
* Generic options for all plugins.
*
* ## Custom Plugin Positioning
*
* There are two implemented layouting systems in POLAR configured by {@link MapConfiguration.layout}.
*
* If `layout` is set to `'nineRegions'` all plugins are placed in a predefined region grid.
* Use {@link PluginOptions.displayComponent | displayComponent} to control visibility
* and {@link PluginOptions.layoutTag | layoutTag} to specify the target region.
*
* If `layout` is set to `'standard'`, a plugin can be rendered in one of two ways:
* 1. **As part of the IconMenu**: Configure the plugin in the IconMenu's
* {@link IconMenuPluginOptions.menus | `menus`} configuration.
* The IconMenu will handle positioning and rendering the plugin at the designated location.
* 2. **Independent with CSS positioning**: Directly add the plugin with
* {@link addPlugin}. The plugin is responsible for its own positioning
* using CSS (e.g., `position: absolute`) within the map container.
*/
export interface PluginOptions {
/**
* Should the component be visible at all.
* Only relevant if {@link MapConfiguration.layout | layout} is set to `'nineRegions'`.
*
* @defaultValue `false`
*/
displayComponent?: boolean

/**
* The region where the plugin should be rendered.
* Required if {@link MapConfiguration.layout | layout} is set to `'nineRegions'`,
* ignored otherwise.
*/
layoutTag?: keyof typeof NineLayoutTag
}

Expand Down Expand Up @@ -111,7 +142,7 @@
type GetPluginStore<
T extends BundledPluginId,
I extends BundledPluginId,
// TODO: This fixes the type error, but relaxes type-checking for the plugin store too much.

Check warning on line 145 in src/core/types/plugin.ts

View workflow job for this annotation

GitHub Actions / Linting

Unexpected 'todo' comment: 'TODO: This fixes the type error, but...'
// However, it is not clear if Pinia's type system allows for stronger checks at the moment.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
S extends PolarPluginStore<any>,
Expand Down Expand Up @@ -201,6 +232,8 @@
* The component will be rendered by POLAR over the map.
* The position is either to be determined by the plugin if `layout === 'standard'`
* or will be determined by the layout.
*
* @see {@link PluginOptions} for configuration details
*/
component?: Component

Expand Down
Loading