MCPcopy Create free account
hub / github.com/codecombat/codecombat / applyCampaignStyles

Method applyCampaignStyles

app/views/play/CampaignView.js:1776–1797  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1774 }
1775
1776 applyCampaignStyles () {
1777 if (!this.campaign?.loaded) { return }
1778 const backgrounds = this.campaign.get('backgroundImage')
1779 if (backgrounds?.length) {
1780 backgrounds.sort((a, b) => b.width - a.width)
1781 const rules = backgrounds.map((background, i) => {
1782 let rule = `#campaign-view .map-background { background-image: url(/file/${background.image}); }`
1783 if (i) { rule = `@media screen and (max-width: ${background.width}px) { ${rule} }` }
1784 return rule
1785 })
1786 utils.injectCSS(rules.join('\n'))
1787 }
1788 const backgroundColor = this.campaign.get('backgroundColor')
1789 if (backgroundColor) {
1790 const backgroundColorTransparent = this.campaign.get('backgroundColorTransparent')
1791 this.$el.css('background-color', backgroundColor)
1792 for (const pos of ['top', 'right', 'bottom', 'left']) {
1793 this.$el.find(`.${pos}-gradient`).css('background-image', `linear-gradient(to ${pos}, ${backgroundColorTransparent} 0%, ${backgroundColor} 100%)`)
1794 }
1795 }
1796 return this.playAmbientSound()
1797 }
1798
1799 onMouseMovePortals (e) {
1800 if (!this.portalScrollInterval) { return }

Callers 1

afterRenderMethod · 0.95

Calls 2

playAmbientSoundMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected