| 1 |
<templates xml:space="preserve"> |
| 2 |
<t t-name="html_editor.GradientPicker"> |
| 3 |
<div class="d-flex flex-column"> |
| 4 |
|
| 5 |
<div class="align-items-center d-flex justify-content-between my-2 o_type_row"> |
| 6 |
Type |
| 7 |
<span class="d-flex justify-content-between"> |
| 8 |
<button t-attf-class="btn btn-sm btn-light {{ this.state.type === 'linear' ? 'active' : ''}}" t-on-click="() => this.selectType('linear')"> Linear </button> |
| 9 |
<button t-attf-class="btn btn-sm btn-light {{ this.state.type === 'radial' ? 'active' : ''}}" t-on-click="() => this.selectType('radial')"> Radial </button> |
| 10 |
</span> |
| 11 |
</div> |
| 12 |
|
| 13 |
<div t-if="this.state.type === 'linear'" class="d-flex align-items-center justify-content-between mb-1"> |
| 14 |
Angle |
| 15 |
<span class="d-flex justify-content-between align-items-center"> |
| 16 |
<div class="d-flex justify-content-center align-items-center my-auto me-2 position-relative gradient-angle-knob" |
| 17 |
t-ref="gradientAngleKnob" |
| 18 |
t-attf-style="--angle: #{this.state.angle}deg;" |
| 19 |
t-on-mousedown="onKnobMouseDown"> |
| 20 |
<div class="position-absolute gradient-angle-thumb"></div> |
| 21 |
</div> |
| 22 |
<div class="o_color_gradient_input d-flex align-items-center"> |
| 23 |
<input |
| 24 |
name="angle" |
| 25 |
type="number" |
| 26 |
min="0" |
| 27 |
max="360" |
| 28 |
t-att-value="this.state.angle" |
| 29 |
t-on-change="onAngleChange" |
| 30 |
/> |
| 31 |
<label class="flex-grow-0 ms-1 mb-0">deg</label> |
| 32 |
</div> |
| 33 |
</span> |
| 34 |
</div> |
| 35 |
<div t-else="" class="d-flex flex-column gap-1 mb-1"> |
| 36 |
Size |
| 37 |
<div class="d-flex align-items-center justify-content-between"> |
| 38 |
<button t-on-click="() => this.onSizeChange('closest-side')" t-attf-class="btn btn-light p-0 {{ this.state.size === 'closest-side' ? `active` : ''}}" title="Extend to the closest side"> |
| 39 |
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="45" viewBox="0 0 16 20" fill="none"> |
| 40 |
<rect x="1.5" y="3.5" width="13" height="13" stroke="#AAAAAD"></rect> |
| 41 |
<path d="M3 4H9V8C9 8.55228 8.55228 9 8 9H4C3.44772 9 3 8.55228 3 8V4Z" fill="#8C8C92"></path> |
| 42 |
<path d="M6 11C7.65685 11 9 9.65685 9 8C9 6.34315 7.65685 5 6 5C4.34315 5 3 6.34315 3 8C3 9.65685 4.34315 11 6 11Z" fill="#74747B"></path> |
| 43 |
<path d="M6 10C7.10457 10 8 9.10457 8 8C8 6.89543 7.10457 6 6 6C4.89543 6 4 6.89543 4 8C4 9.10457 4.89543 10 6 10Z" fill="white"></path> |
| 44 |
<rect x="2" y="3" width="12" height="1" fill="white"></rect> |
| 45 |
</svg> |
| 46 |
</button> |
| 47 |
<button t-on-click="() => this.onSizeChange('closest-corner')" t-attf-class="btn btn-light p-0 {{ this.state.size === 'closest-corner' ? `active` : ''}}" title="Extend to the closest corner"> |
| 48 |
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="45" viewBox="0 0 16 20" fill="none"> |
| 49 |
<rect x="1.5" y="3.5" width="13" height="13" stroke="#AAAAAD"></rect> |
| 50 |
<path d="M2 4H9V7C9 9.20914 7.20914 11 5 11H2V4Z" fill="#8C8C92"></path> |
| 51 |
<path d="M6 11C7.65685 11 9 9.65685 9 8C9 6.34315 7.65685 5 6 5C4.34315 5 3 6.34315 3 8C3 9.65685 4.34315 11 6 11Z" fill="#74747B"></path> |
| 52 |
<path d="M6 10C7.10457 10 8 9.10457 8 8C8 6.89543 7.10457 6 6 6C4.89543 6 4 6.89543 4 8C4 9.10457 4.89543 10 6 10Z" fill="white"></path> |
| 53 |
<rect x="1" y="3" width="8" height="1" fill="white"></rect> |
| 54 |
<rect x="1" y="11" width="8" height="1" transform="rotate(-90 1 11)" fill="white"></rect> |
| 55 |
</svg> |
| 56 |
</button> |
| 57 |
<button t-on-click="() => this.onSizeChange('farthest-side')" t-attf-class="btn btn-light p-0 {{ this.state.size === 'farthest-side' ? `active` : ''}}" title="Extend to the farthest side"> |
| 58 |
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="45" viewBox="0 0 16 20" fill="none"> |
| 59 |
<rect x="1.5" y="3.5" width="13" height="13" stroke="#AAAAAD"></rect> |
| 60 |
<path d="M7 12C10.3137 12 14 10.2091 14 8C14 5.79086 10.3137 4 7 4C3.68629 4 2 5.79086 2 8C2 10.2091 3.68629 12 7 12Z" fill="#8C8C92"></path> |
| 61 |
<path d="M6 11C7.65685 11 9 9.65685 9 8C9 6.34315 7.65685 5 6 5C4.34315 5 3 6.34315 3 8C3 9.65685 4.34315 11 6 11Z" fill="#74747B"></path> |
| 62 |
<path d="M6 10C7.10457 10 8 9.10457 8 8C8 6.89543 7.10457 6 6 6C4.89543 6 4 6.89543 4 8C4 9.10457 4.89543 10 6 10Z" fill="white"></path> |
| 63 |
<rect x="14" y="4" width="1" height="12" fill="white"></rect> |
| 64 |
</svg> |
| 65 |
</button> |
| 66 |
<button t-on-click="() => this.onSizeChange('farthest-corner')" t-attf-class="btn btn-light p-0 {{ this.state.size === 'farthest-corner' ? `active` : ''}}" title="Extend to the farthest corner"> |
| 67 |
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="45" viewBox="0 0 16 20" fill="none"> |
| 68 |
<rect x="1.5" y="3.5" width="13" height="13" stroke="#AAAAAD"></rect> |
| 69 |
<path d="M2 4H14V10C14 13.3137 11.3137 16 8 16H2V4Z" fill="#8C8C92"></path> |
| 70 |
<path d="M6 11C7.65685 11 9 9.65685 9 8C9 6.34315 7.65685 5 6 5C4.34315 5 3 6.34315 3 8C3 9.65685 4.34315 11 6 11Z" fill="#74747B"></path> |
| 71 |
<path d="M6 10C7.10457 10 8 9.10457 8 8C8 6.89543 7.10457 6 6 6C4.89543 6 4 6.89543 4 8C4 9.10457 4.89543 10 6 10Z" fill="white"></path> |
| 72 |
<rect x="15" y="17" width="7" height="0.999999" transform="rotate(-180 15 17)" fill="white"></rect> |
| 73 |
<rect x="15" y="10" width="7" height="1" transform="rotate(90 15 10)" fill="white"></rect> |
| 74 |
</svg> |
| 75 |
</button> |
| 76 |
</div> |
| 77 |
<div class="d-flex align-items-center justify-content-between"> |
| 78 |
Position X |
| 79 |
<span class="o_color_gradient_input"> |
| 80 |
<input |
| 81 |
name="positionX" |
| 82 |
type="number" |
| 83 |
min="0" |
| 84 |
max="100" |
| 85 |
t-att-value="this.positions['x']" |
| 86 |
t-on-change="(ev) => this.onPositionChange('x', ev)" |
| 87 |
/> |
| 88 |
</span> |
| 89 |
</div> |
| 90 |
<div class="d-flex align-items-center justify-content-between"> |
| 91 |
Position Y |
| 92 |
<span class="o_color_gradient_input"> |
| 93 |
<input |
| 94 |
name="positionY" |
| 95 |
type="number" |
| 96 |
min="0" |
| 97 |
max="100" |
| 98 |
t-att-value="this.positions['y']" |
| 99 |
t-on-change="(ev) => this.onPositionChange('y', ev)" |
| 100 |
/> |
| 101 |
</span> |
| 102 |
</div> |
| 103 |
</div> |
| 104 |
|
| 105 |
<div class="custom-gradient-configurator"> |
| 106 |
<div class="gradient-checkers"></div> |
| 107 |
<div class="gradient-preview" t-attf-style="background-image: #{this.cssGradients.preview};" |
| 108 |
t-on-click="this.onGradientPreviewClick" > |
| 109 |
</div> |
| 110 |
<style><t t-out="this.cssGradients.sliderThumbStyle" /></style> |
| 111 |
<div class="gradient-colors"> |
| 112 |
<div t-foreach="this.colors" t-as="color" t-key="color_index"> |
| 113 |
<input type="range" min="0" max="100" t-att-value="color.percentage" |
| 114 |
t-att-class="{'active': this.state.currentColorIndex === color_index}" |
| 115 |
t-attf-name="custom gradient percentage color #{color_index+1}" |
| 116 |
t-on-click="() => this.state.currentColorIndex = color_index" |
| 117 |
t-on-change="(ev) => this.onColorPercentageChange(color_index, ev)" /> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
<div class="gradient-color-bin"> |
| 121 |
<t t-if="this.colors.length > 2"> |
| 122 |
<a t-on-click="() => this.removeColor(this.state.currentColorIndex)" |
| 123 |
t-attf-style="left: #{this.colors[this.state.currentColorIndex].percentage}%" |
| 124 |
type="button" class="btn btn-sm btn-light"><i class="fa fa-fw fa-trash" role="img"/></a> |
| 125 |
</t> |
| 126 |
</div> |
| 127 |
</div> |
| 128 |
|
| 129 |
<ColorPicker |
| 130 |
onColorSelect.bind="onColorChange" |
| 131 |
onColorPreview.bind="onColorPreview" |
| 132 |
setOnCloseCallback.bind="props.setOnCloseCallback" |
| 133 |
setOperationCallbacks.bind="props.setOperationCallbacks" |
| 134 |
defaultColor="this.currentColorHex" |
| 135 |
selectedColor="this.currentColorHex" |
| 136 |
noTransparency="props.noTransparency" |
| 137 |
/> |
| 138 |
</div> |
| 139 |
</t> |
| 140 |
</templates> |