Skip to content

Commit

Permalink
compass: add className option
Browse files Browse the repository at this point in the history
  • Loading branch information
venmax authored Nov 20, 2023
1 parent 5138d7e commit 7cbf826
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/plugins/compass.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ Color of the navigation cone.

Default color of hotspots.

#### `className`

- type: `string`
- updatable: yes

CSS class(es) added to the compass element.

## Methods

#### `setHotspots(hotspots)`
Expand Down
1 change: 1 addition & 0 deletions packages/compass-plugin/src/CompassPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const getConfig = utils.getConfigParser<CompassPluginConfig, ParsedCompassPlugin
navigationColor: 'rgba(255, 0, 0, 0.2)',
hotspots: [],
hotspotColor: 'rgba(0, 0, 0, 0.5)',
className: null
},
{
position: (position, { defValue }) => {
Expand Down
5 changes: 5 additions & 0 deletions packages/compass-plugin/src/components/CompassComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export class CompassComponent extends AbstractComponent {

applyConfig() {
this.container.className = `psv-compass psv-compass--${this.config.position.join('-')}`;

if (this.config.className) {
utils.addClasses(this.container, this.config.className);
}

this.background.innerHTML = this.config.backgroundSvg;

this.container.style.width = this.config.size;
Expand Down
5 changes: 5 additions & 0 deletions packages/compass-plugin/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export type CompassPluginConfig = {
* @default 'rgba(0, 0, 0, 0.5)'
*/
hotspotColor?: string;

/**
* CSS class(es) added to the compass element.
*/
className?: string;
};

export type ParsedCompassPluginConfig = Omit<CompassPluginConfig, 'position'> & {
Expand Down

0 comments on commit 7cbf826

Please sign in to comment.