-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
743 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
addons/html_builder/static/src/builder/builder_components/global_builder_options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { GlobalBorderOption } from "@html_builder/builder/options/global_border_option"; | ||
|
||
export const globalBuilderOptions = { | ||
GlobalBorderOption, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
addons/html_builder/static/src/builder/components/option_container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
addons/html_builder/static/src/builder/options/global_border_option.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component } from "@odoo/owl"; | ||
import { defaultBuilderComponents } from "../builder_components/default_builder_components"; | ||
import { useDomState } from "../builder_components/utils"; | ||
|
||
export class GlobalBorderOption extends Component { | ||
static template = "html_builder.snippet_options_border_line"; | ||
static components = { ...defaultBuilderComponents }; | ||
static props = { | ||
label: { type: String }, | ||
direction: { type: String, optional: true }, | ||
applyTo: { type: String }, | ||
}; | ||
setup() { | ||
this.state = useDomState(() => ({ | ||
hasBorder: this.hasBorder(), | ||
})); | ||
} | ||
getStyleActionParam(param) { | ||
return `border-${this.props.direction ? this.props.direction + "-" : ""}${param}`; | ||
} | ||
hasBorder() { | ||
const getAction = this.env.editor.shared.builderActions.getAction; | ||
const editingElement = this.env.getEditingElement().querySelector(this.props.applyTo); | ||
const styleActionValue = getAction("styleAction").getValue({ | ||
editingElement, | ||
param: this.getStyleActionParam("width"), | ||
}); | ||
return !!parseInt(styleActionValue.match(/\d+/g)[0]); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
addons/html_builder/static/src/builder/options/global_border_option.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="html_builder.snippet_options_border_line"> | ||
<BuilderRow label="props.label" applyTo="props.applyTo"> | ||
<BuilderNumberInput styleAction="getStyleActionParam('width')" unit="'px'"></BuilderNumberInput> | ||
<BuilderSelect styleAction="getStyleActionParam('style')" t-if="state.hasBorder"> | ||
<BuilderSelectItem title="'Solid'" styleActionValue="'solid'"><div class="o_we_border_preview" style="border-style: solid;"/></BuilderSelectItem> | ||
<BuilderSelectItem title="'Dashed'" styleActionValue="'dashed'"><div class="o_we_border_preview" style="border-style: dashed;"/></BuilderSelectItem> | ||
<BuilderSelectItem title="'Dotted'" styleActionValue="'dotted'"><div class="o_we_border_preview" style="border-style: dotted;"/></BuilderSelectItem> | ||
<BuilderSelectItem title="'Double'" styleActionValue="'double'"><div class="o_we_border_preview" style="border-style: double; border-left: none; border-right: none;"/></BuilderSelectItem> | ||
</BuilderSelect> | ||
<BuilderColorPicker styleAction="getStyleActionParam('color')" t-if="state.hasBorder"/> | ||
</BuilderRow> | ||
</t> | ||
</templates> |
15 changes: 15 additions & 0 deletions
15
addons/html_builder/static/src/builder/options/separator_option.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Plugin } from "@html_editor/plugin"; | ||
import { registry } from "@web/core/registry"; | ||
|
||
class SeparatorOptionPlugin extends Plugin { | ||
static id = "SeparatorOption"; | ||
resources = { | ||
builder_options: [ | ||
{ | ||
template: "html_builder.SeparatorOption", | ||
selector: ".s_hr", | ||
}, | ||
], | ||
}; | ||
} | ||
registry.category("website-plugins").add(SeparatorOptionPlugin.id, SeparatorOptionPlugin); |
24 changes: 24 additions & 0 deletions
24
addons/html_builder/static/src/builder/options/separator_option.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="html_builder.SeparatorOption"> | ||
<t t-set="applyTo" t-value="'hr'" /> | ||
<GlobalBorderOption label.translate="Border" direction="'top'" applyTo="applyTo"/> | ||
<BuilderRow label.translate="Width"> | ||
<BuilderSelect applyTo="applyTo"> | ||
<BuilderSelectItem classAction="'w-25'">25%</BuilderSelectItem> | ||
<BuilderSelectItem classAction="'w-50'">50%</BuilderSelectItem> | ||
<BuilderSelectItem classAction="'w-75'">75%</BuilderSelectItem> | ||
<BuilderSelectItem classAction="'w-100'" id="'so_width_100'">100%</BuilderSelectItem> | ||
</BuilderSelect> | ||
</BuilderRow> | ||
<BuilderRow label.translate="Alignment" dependencies="'!so_width_100'"> | ||
<BuilderButtonGroup applyTo="'hr'"> | ||
<BuilderButton icon="'fa-align-left'" title.translate="'Left'" classAction="'me-auto'"></BuilderButton> | ||
<BuilderButton icon="'fa-align-center'" title.translate="'Center'" classAction="'mx-auto'"></BuilderButton> | ||
<BuilderButton icon="'fa-align-right'" title.translate="'Right'" classAction="'ms-auto'"></BuilderButton> | ||
</BuilderButtonGroup> | ||
</BuilderRow> | ||
</t> | ||
|
||
</templates> |
Oops, something went wrong.