Skip to content

Commit 7cbf826

Browse files
authored
compass: add className option
1 parent 5138d7e commit 7cbf826

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

docs/plugins/compass.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ Color of the navigation cone.
201201

202202
Default color of hotspots.
203203

204+
#### `className`
205+
206+
- type: `string`
207+
- updatable: yes
208+
209+
CSS class(es) added to the compass element.
210+
204211
## Methods
205212

206213
#### `setHotspots(hotspots)`

packages/compass-plugin/src/CompassPlugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const getConfig = utils.getConfigParser<CompassPluginConfig, ParsedCompassPlugin
1515
navigationColor: 'rgba(255, 0, 0, 0.2)',
1616
hotspots: [],
1717
hotspotColor: 'rgba(0, 0, 0, 0.5)',
18+
className: null
1819
},
1920
{
2021
position: (position, { defValue }) => {

packages/compass-plugin/src/components/CompassComponent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ export class CompassComponent extends AbstractComponent {
9191

9292
applyConfig() {
9393
this.container.className = `psv-compass psv-compass--${this.config.position.join('-')}`;
94+
95+
if (this.config.className) {
96+
utils.addClasses(this.container, this.config.className);
97+
}
98+
9499
this.background.innerHTML = this.config.backgroundSvg;
95100

96101
this.container.style.width = this.config.size;

packages/compass-plugin/src/model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export type CompassPluginConfig = {
5353
* @default 'rgba(0, 0, 0, 0.5)'
5454
*/
5555
hotspotColor?: string;
56+
57+
/**
58+
* CSS class(es) added to the compass element.
59+
*/
60+
className?: string;
5661
};
5762

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

0 commit comments

Comments
 (0)