Skip to content

Commit 0b7df25

Browse files
committed
feat(svg-animations): theme switching for animations
1 parent 6c09534 commit 0b7df25

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

packages/micro-journeys/src/bolt-svg-animations/svg-animations.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
import { props, define, hasNativeShadowDomSupport } from '@bolt/core/utils';
1+
import {
2+
props,
3+
define,
4+
hasNativeShadowDomSupport,
5+
withContext,
6+
} from '@bolt/core/utils';
27
import { classMap } from 'lit-html/directives/class-map.js';
38
import { withLitHtml, html, convertSchemaToProps } from '@bolt/core';
49
import * as SVGs from './svg';
510
import styles from './svg-animations.scss';
611
import schema from './svg-animations.schema';
12+
import { BoltInteractivePathwaysContext } from '../interactive-pathways';
713

814
@define
9-
class SVGAnimations extends withLitHtml() {
15+
class SVGAnimations extends withContext(withLitHtml()) {
1016
static is = 'bolt-svg-animations';
1117

1218
static props = {
1319
...convertSchemaToProps(schema),
1420
};
1521

22+
static get consumes() {
23+
return [[BoltInteractivePathwaysContext, 'theme']];
24+
}
25+
1626
constructor(self) {
1727
self = super(self);
1828
self.schema = schema;
@@ -21,18 +31,22 @@ class SVGAnimations extends withLitHtml() {
2131
}
2232

2333
render() {
24-
const { direction, animType, speed, theme } = this.validateProps(
25-
this.props,
26-
);
34+
const props = this.validateProps(this.props);
35+
this.theme = this.context.theme;
2736
const classes = {
2837
'c-bolt-svg-animations': true,
38+
[`t-bolt-${this.theme}`]: this.theme,
2939
};
30-
const SVGTag = SVGs[`${animType}`];
40+
const SVGTag = SVGs[`${props.animType}`];
3141

3242
return html`
3343
${this.addStyles([styles])}
3444
<div class="${classMap(classes)}">
35-
${SVGTag({ speed, theme, direction })}
45+
${SVGTag({
46+
speed: props.speed,
47+
theme: this.theme,
48+
direction: props.direction,
49+
})}
3650
</div>
3751
`;
3852
}

packages/micro-journeys/src/bolt-svg-animations/svg-animations.schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
theme: {
3030
type: 'string',
3131
enum: ['light', 'dark'],
32+
default: '',
3233
description:
3334
'control color scheme of component, not applicable to all animTypes',
3435
},

packages/micro-journeys/src/bolt-svg-animations/svg/connectionBand.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const connectionBand = ({ direction, theme }) => {
1818
backwards; animation-name: connectionArrowScroll; animation-timing-function:
1919
cubic-bezier(0, 0, 1, 1); }
2020
`;
21-
2221
const gradientColors =
2322
theme === 'dark'
2423
? svg`

packages/micro-journeys/src/bolt-svg-animations/svg/tripleConnectionBand.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { html } from '@bolt/core/renderers/renderer-lit-html';
21
import { svg } from 'lit-html';
32

43
export const tripleConnectionBand = ({ speed, direction, theme }) => {

0 commit comments

Comments
 (0)