-
Notifications
You must be signed in to change notification settings - Fork 1
/
stripe_checkout.antlers.html
65 lines (58 loc) · 2.41 KB
/
stripe_checkout.antlers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<div x-data="{
target: 'value',
targetContainer: null,
value: '{{ old ?? mode }}',
init() {
// if we're using the alpine driver, the target needs to be the actual
// field's handle (i.e. the target passed to the component)
if (this.$el.dataset.js === 'alpine') {
this.target = this.$el.dataset.target;
if (this.$el.dataset.targetContainer) {
this.targetContainer = this.$el.dataset.targetContainer;
}
}
this.$watch('value', (newValue, oldValue) => {
this.updateTarget(newValue);
});
this.updateTarget(this.value);
},
updateTarget(value) {
if(this.targetContainer) {
this.$data[this.targetContainer][this.target] = value;
}
else {
this.$data[this.target] = value;
}
}
}"
data-js="{{ js_driver }}"
data-target-container=""
data-target="{{ handle }}">
{{ if mode_choice === 'yes' }}
<div class="space-x-2">
<button :class="{
'ring-red-500' : value === 'payment'
}"
class="rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
type="button"
@click.prevent="value='payment'">
{{ 'statamic-stripe-checkout-fieldtype::fieldtype.config.mode.options.payment' | trans }}
</button>
<button :class="{
'ring-red-500' : value === 'subscription'
}"
class="rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
type="button"
@click.prevent="value='subscription'">
{{ 'statamic-stripe-checkout-fieldtype::fieldtype.config.mode.options.subscription' | trans }}
</button>
</div>
{{ /if }}
<input id="{{ handle }}"
type="hidden"
name="{{ handle }}"
value="{{ old ?? mode }}"
x-ref="value"
{{ if js_driver }}{{ js_attributes }}{{ else }}x-model="value" {{ /if }}
{{ if validate|contains:required }}required{{ /if }}>
</div>