Skip to content

Commit 3aeb353

Browse files
[#148] Moving from php to twig
1 parent 9eda4eb commit 3aeb353

File tree

4 files changed

+67
-40
lines changed

4 files changed

+67
-40
lines changed

wp-content/themes/wp-starter/blocks/dialog/block.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
},
3535
"viewStyle": "file:./view.css",
3636
"editorStyle": "file:./editor.css",
37-
"viewScript": "file:./view.js",
3837
"acf": {
3938
"mode": "preview"
4039
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{#
2+
Block: Dialog
3+
#}
4+
5+
{% set cbx_id = 'dialog-' ~ random() %}
6+
7+
{% if function('is_admin') == true %}
8+
<input type="checkbox" id="{{ cbx_id }}" class="acfbt-dialog-checkbox">
9+
<label for="{{ cbx_id }}" class="acfbt-dialog-label">Toggle Dialog</label>
10+
{% endif %}
11+
12+
<div
13+
{% if function('is_admin') == false %}
14+
x-data="{
15+
openDialog: false,
16+
17+
// Close the dialog when the user clicks backdrop
18+
handleDialogClick(event) {
19+
(event.target === $refs.dialogRef) && this.handleDialogClose()
20+
},
21+
22+
// Delay close to allow for animation
23+
handleDialogClose() {
24+
if (!this.openDialog) return
25+
this.openDialog = false
26+
$refs.dialogRef.close()
27+
}
28+
}"
29+
{% endif %}
30+
>
31+
32+
<dialog
33+
{{ block_attrs( block ) }}
34+
{% if function('is_admin') == false %}
35+
x-ref="dialogRef"
36+
@keydown.escape.prevent="handleDialogClose()"
37+
@click="handleDialogClick(event)"
38+
{% endif %}
39+
>
40+
{% if function('is_admin') == false %}
41+
<button
42+
class="acf-dialog-close"
43+
@click="handleDialogClose()"
44+
>
45+
<span class="sr-only">Close</span>
46+
</button>
47+
{% endif %}
48+
49+
<div class="inner">
50+
{% if function('is_admin') == true %}
51+
<label for="{{ cbx_id }}" class="acfbt-dialog-close">
52+
<span class="sr-only">Close</span>
53+
</label>
54+
{% endif %}
55+
{{ inner_blocks() }}
56+
</div>
57+
</dialog>
58+
59+
<button
60+
class="btn-default"
61+
{% if function('is_admin') == false %}
62+
@click="$refs.dialogRef.showModal(), openDialog = true"
63+
{% endif %}
64+
>
65+
Open
66+
</button>
67+
</div>

wp-content/themes/wp-starter/blocks/dialog/view.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

wp-content/themes/wp-starter/blocks/dialog/x-render.twig

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)