2024-05-08 10:10:23 +07:00
|
|
|
package put
|
2024-05-07 20:51:00 +07:00
|
|
|
|
|
|
|
import "github.com/tigorlazuardi/redmage/views/utils"
|
|
|
|
import "fmt"
|
|
|
|
import "strconv"
|
|
|
|
|
|
|
|
type ResolutionData struct {
|
|
|
|
Error string
|
|
|
|
Value int
|
|
|
|
HXSwapOOB bool
|
|
|
|
}
|
|
|
|
|
|
|
|
templ ResolutionXInput(data ResolutionData) {
|
|
|
|
<label
|
|
|
|
x-data={ fmt.Sprintf(`{error: %t}`, data.Error != "") }
|
|
|
|
id="resolution-x-form"
|
|
|
|
class="form-control"
|
|
|
|
if data.HXSwapOOB {
|
|
|
|
hx-swap-oob="true"
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<div class="label">
|
|
|
|
<span
|
|
|
|
class={ utils.CXX("label-text", true, "text-error", data.Error != "") }
|
|
|
|
:class="{'text-error': error}"
|
|
|
|
>Width</span>
|
|
|
|
</div>
|
|
|
|
<input
|
|
|
|
id="resolution-x-field"
|
|
|
|
x-data={ fmt.Sprintf(`{ init() { $el.setCustomValidity(%q) } }`, data.Error) }
|
|
|
|
name="resolution_x"
|
|
|
|
type="number"
|
|
|
|
min="1"
|
|
|
|
@change="$el.setCustomValidity(''); this.error = false"
|
|
|
|
class={ utils.CXX(
|
2024-05-29 12:05:40 +07:00
|
|
|
"input input-bordered w-full", true,
|
2024-05-07 20:51:00 +07:00
|
|
|
"text-error", data.Error != "",
|
|
|
|
"input-error", data.Error != "",
|
|
|
|
) }
|
|
|
|
:class="{'text-error': error, 'input-error': error}"
|
|
|
|
if data.Value > 0 {
|
|
|
|
value={ strconv.Itoa(data.Value) }
|
|
|
|
}
|
2024-05-07 21:02:10 +07:00
|
|
|
placeholder="e.g. 1920"
|
2024-05-07 20:51:00 +07:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
<div class="label">
|
|
|
|
<span
|
|
|
|
class={ utils.CXX("label-text", true, "text-error", data.Error != "") }
|
|
|
|
:class="{'text-error': error}"
|
|
|
|
>
|
|
|
|
if data.Error != "" {
|
|
|
|
{ data.Error }
|
|
|
|
} else {
|
|
|
|
Your intended device width resolution.
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ ResolutionYInput(data ResolutionData) {
|
|
|
|
<label
|
|
|
|
x-data={ fmt.Sprintf(`{error: %t}`, data.Error != "") }
|
|
|
|
id="resolution-y-form"
|
|
|
|
class="form-control"
|
|
|
|
if data.HXSwapOOB {
|
|
|
|
hx-swap-oob="true"
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<div class="label">
|
|
|
|
<span
|
|
|
|
class={ utils.CXX("label-text", true, "text-error", data.Error != "") }
|
|
|
|
:class="{'text-error': error}"
|
|
|
|
>Height</span>
|
|
|
|
</div>
|
|
|
|
<input
|
|
|
|
id="resolution-y-field"
|
|
|
|
x-data={ fmt.Sprintf(`{ init() { $el.setCustomValidity(%q) } }`, data.Error) }
|
|
|
|
name="resolution_y"
|
|
|
|
type="number"
|
|
|
|
min="1"
|
|
|
|
@change="$el.setCustomValidity(''); this.error = false"
|
|
|
|
class={ utils.CXX(
|
2024-05-29 12:05:40 +07:00
|
|
|
"input input-bordered w-full", true,
|
2024-05-07 20:51:00 +07:00
|
|
|
"text-error", data.Error != "",
|
|
|
|
"input-error", data.Error != "",
|
|
|
|
) }
|
|
|
|
:class="{'text-error': error, 'input-error': error}"
|
|
|
|
if data.Value > 0 {
|
|
|
|
value={ strconv.Itoa(data.Value) }
|
|
|
|
}
|
2024-05-07 21:02:10 +07:00
|
|
|
placeholder="e.g. 1080"
|
2024-05-07 20:51:00 +07:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
<div class="label">
|
|
|
|
<span
|
|
|
|
class={ utils.CXX("label-text", true, "text-error", data.Error != "") }
|
|
|
|
:class="{'text-error': error}"
|
|
|
|
>
|
|
|
|
if data.Error != "" {
|
|
|
|
{ data.Error }
|
|
|
|
} else {
|
|
|
|
Your intended device height resolution.
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
}
|