-
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
744 additions
and
14 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
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
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
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
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(() => ({ | ||
isActive: this.isActive(), | ||
})); | ||
} | ||
|
||
getStyleActionParam(param) { | ||
return `border-${this.props.direction ? this.props.direction + "-" : ""}${param}`; | ||
} | ||
isActive() { | ||
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.isActive"> | ||
<BuilderSelectItem styleActionValue="'solid'" class="'o_we_fake_img_item o_we_border_preview'" style="'border-style: solid;'">Solid</BuilderSelectItem> | ||
<BuilderSelectItem styleActionValue="'dashed'" class="'o_we_fake_img_item o_we_border_preview'" style="'border-style: dashed;'">Dashed</BuilderSelectItem> | ||
<BuilderSelectItem styleActionValue="'dotted'" class="'o_we_fake_img_item o_we_border_preview'" style="'border-style: dotted;'">Dotted</BuilderSelectItem> | ||
<BuilderSelectItem styleActionValue="'double'" class="'o_we_fake_img_item o_we_border_preview'" style="'border-style: double; border-left: none; border-right: none;'">Double</BuilderSelectItem> | ||
</BuilderSelect> | ||
<BuilderColorPicker styleAction="getStyleActionParam('color')" t-if="state.isActive"/> | ||
</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); |
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="html_builder.SeparatorOption"> | ||
<t t-set="applyTo" t-value="'hr'" /> | ||
<t t-set="label">Border</t> | ||
<GlobalBorderOption label="label" 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.