@paperbits/styles
Advanced tools
Comparing version 0.1.40 to 0.1.41
@@ -38,9 +38,5 @@ import * as ko from "knockout"; | ||
this.applyChanges = this.applyChanges.bind(this); | ||
this.updateFonts = this.updateFonts.bind(this); | ||
this.addFonts = this.addFonts.bind(this); | ||
this.addColor = this.addColor.bind(this); | ||
this.selectColor = this.selectColor.bind(this); | ||
this.removeFont = this.removeFont.bind(this); | ||
this.removeColor = this.removeColor.bind(this); | ||
this.removeStyle = this.removeStyle.bind(this); | ||
this.addFonts = this.addFonts.bind(this); | ||
@@ -56,47 +52,7 @@ this.styles = ko.observable(); | ||
@OnMounted() | ||
public async loadStyles(): Promise<void> { | ||
const styles = await this.styleService.getStyles(); | ||
this.styles(styles); | ||
this.updateFonts(); | ||
this.updateColors(); | ||
this.updateButons(); | ||
this.updateCards(); | ||
const bodyFont = Utils.getObjectAt<FontContract>(styles.globals.body.typography.fontKey, styles); | ||
this.bodyFontDisplayName(bodyFont.displayName); | ||
this.applyChanges(); | ||
} | ||
public updateFonts(): void { | ||
const styles = this.styles(); | ||
const fonts = Object.keys(styles.fonts).map(key => styles.fonts[key]); | ||
this.fonts(fonts); | ||
} | ||
private async updateColors(): Promise<void> { | ||
this.colors([]); | ||
const styles = await this.styleService.getStyles(); | ||
this.styles(styles); | ||
const colors = Object.keys(styles.colors).map(key => styles.colors[key]); | ||
this.colors(colors); | ||
} | ||
private async updateButons(): Promise<void> { | ||
this.buttons([]); | ||
const styles = await this.styleService.getStyles(); | ||
this.styles(styles); | ||
const variations = await this.styleService.getComponentVariations("button"); | ||
this.buttons(variations); | ||
} | ||
private async updateCards(): Promise<void> { | ||
this.cards([]); | ||
const styles = await this.styleService.getStyles(); | ||
this.styles(styles); | ||
const variations = await this.styleService.getComponentVariations("card"); | ||
this.cards(variations); | ||
} | ||
public async addFonts(): Promise<void> { | ||
@@ -111,4 +67,3 @@ const view: IView = { | ||
this.eventManager.dispatchEvent("onStyleChange"); | ||
this.updateFonts(); | ||
this.applyChanges(); | ||
} | ||
@@ -123,9 +78,4 @@ } | ||
public async removeFont(font: FontContract): Promise<void> { | ||
this.styleService.removeStyle(font.key); | ||
this.updateFonts(); | ||
} | ||
public async removeStyle(contract): Promise<void> { | ||
this.styleService.removeStyle(contract.key); | ||
await this.styleService.removeStyle(contract.key); | ||
this.applyChanges(); | ||
@@ -137,12 +87,6 @@ } | ||
this.styleService.addColorVariation(variationName); | ||
const styles = await this.styleService.getStyles(); | ||
this.styles(styles); | ||
this.eventManager.dispatchEvent("onStyleChange"); | ||
this.updateColors(); | ||
} | ||
public async removeColor(color: ColorContract): Promise<void> { | ||
this.styleService.removeStyle(color.key); | ||
await this.styleService.removeStyle(color.key); | ||
this.applyChanges(); | ||
@@ -158,5 +102,5 @@ } | ||
selectedColor: color, | ||
onSelect: (color: ColorContract) => { | ||
this.eventManager.dispatchEvent("onStyleChange"); | ||
this.updateColors(); | ||
onSelect: async (color: ColorContract) => { | ||
await this.styleService.updateStyle(color); | ||
this.applyChanges(); | ||
} | ||
@@ -176,3 +120,2 @@ } | ||
await this.styleService.addComponentVariation(componentName, variationName); | ||
this.applyChanges(); | ||
@@ -186,13 +129,33 @@ } | ||
await this.styleService.addComponentVariation(componentName, variationName); | ||
this.applyChanges(); | ||
} | ||
public applyChanges(): void { | ||
this.updateButons(); | ||
this.updateCards(); | ||
this.updateColors(); | ||
this.updateFonts(); | ||
this.styles.valueHasMutated(); | ||
public async applyChanges(): Promise<void> { | ||
const styles = await this.styleService.getStyles(); | ||
const bodyFont = Utils.getObjectAt<FontContract>(styles.globals.body.typography.fontKey, styles); | ||
if (bodyFont) { | ||
this.bodyFontDisplayName(bodyFont.displayName); | ||
} | ||
else { | ||
this.bodyFontDisplayName("Default"); | ||
} | ||
const fonts = Object.keys(styles.fonts).map(key => styles.fonts[key]); | ||
this.fonts(fonts); | ||
const colors = Object.keys(styles.colors).map(key => styles.colors[key]); | ||
this.colors(colors); | ||
const cardVariations = await this.styleService.getComponentVariations("card"); | ||
this.cards(cardVariations); | ||
const buttonVariations = await this.styleService.getComponentVariations("button"); | ||
this.buttons(buttonVariations); | ||
// this.styles.valueHasMutated(); | ||
this.styles(styles); | ||
} | ||
} |
{ | ||
"name": "@paperbits/styles", | ||
"version": "0.1.40", | ||
"version": "0.1.41", | ||
"description": "Paperbits style editors.", | ||
@@ -19,3 +19,3 @@ "author": "Paperbits", | ||
"dependencies": { | ||
"@paperbits/common": "0.1.40", | ||
"@paperbits/common": "0.1.41", | ||
"cropperjs": "^1.4.0", | ||
@@ -22,0 +22,0 @@ "google-maps": "^3.2.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136705
2478
+ Added@paperbits/common@0.1.41(transitive)
- Removed@paperbits/common@0.1.40(transitive)
Updated@paperbits/common@0.1.41