DEV: enforces style-concatenation linting rule (#8888)

This commit is contained in:
Joffrey JAFFEUX 2020-02-10 08:13:50 +01:00 committed by GitHub
parent f5f4ce90c1
commit 99ad2e408a
6 changed files with 32 additions and 15 deletions

View File

@ -3,6 +3,7 @@ module.exports = {
ignore: ["**/*.raw"], ignore: ["**/*.raw"],
rules: { rules: {
"self-closing-void-elements": true "self-closing-void-elements": true,
"style-concatenation": true
} }
}; };

View File

@ -2,6 +2,9 @@ import ComboBoxComponent from "select-kit/components/combo-box";
export default ComboBoxComponent.extend({ export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["color-palettes"], pluginApiIdentifiers: ["color-palettes"],
classNames: "color-palettes", classNames: ["color-palettes"],
rowComponent: "color-palettes/color-palettes-row"
modifyComponentForRow() {
return "color-palettes/color-palettes-row";
}
}); });

View File

@ -1,14 +1,20 @@
import { escapeExpression } from "discourse/lib/utilities"; import { escapeExpression } from "discourse/lib/utilities";
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row"; import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
import discourseComputed from "discourse-common/utils/decorators"; import { computed } from "@ember/object";
export default SelectKitRowComponent.extend({ export default SelectKitRowComponent.extend({
classNames: ["color-palettes-row"],
layoutName: layoutName:
"select-kit/templates/components/color-palettes/color-palettes-row", "select-kit/templates/components/color-palettes/color-palettes-row",
classNames: "color-palettes-row",
@discourseComputed("computedContent.originalContent.colors") palettes: computed("item.colors.[]", function() {
colors(colors) { return (this.item.colors || [])
return (colors || []).map(color => `#${escapeExpression(color.hex)}`); .map(color => `#${escapeExpression(color.hex)}`)
} .map(
hex => `<span class="palette" style="background-color:${hex}"></span>`
)
.join("")
.htmlSafe();
})
}); });

View File

@ -2,10 +2,8 @@
{{label}} {{label}}
</span> </span>
{{#if colors}} {{#if item.colors}}
<div class="palettes"> <div class="palettes">
{{#each colors as |color|}} {{palettes}}
<span class="palette" style="background-color:{{color}};"></span>
{{/each}}
</div> </div>
{{/if}} {{/if}}

View File

@ -6,6 +6,7 @@ import {
chooseDarker, chooseDarker,
LOREM LOREM
} from "wizard/lib/preview"; } from "wizard/lib/preview";
import { computed } from "@ember/object";
export default createPreviewComponent(305, 165, { export default createPreviewComponent(305, 165, {
logo: null, logo: null,
@ -13,6 +14,10 @@ export default createPreviewComponent(305, 165, {
classNameBindings: ["isSelected"], classNameBindings: ["isSelected"],
canvasStyle: computed("width", "height", function() {
return `width:${this.width}px;height:${this.height}px`.htmlSafe();
}),
@discourseComputed("selectedId", "colorsId") @discourseComputed("selectedId", "colorsId")
isSelected(selectedId, colorsId) { isSelected(selectedId, colorsId) {
return selectedId === colorsId; return selectedId === colorsId;

View File

@ -1,4 +1,8 @@
<div class='preview-area'> <div class="preview-area">
<canvas width={{elementWidth}} height={{elementHeight}} style={{concat "width:" width "; height:" height ";"}}> <canvas
width={{elementWidth}}
height={{elementHeight}}
style={{canvasStyle}}
>
</canvas> </canvas>
</div> </div>