Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions assets/src/components/field/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ const Accordion = props => {
/>
</div>
: null

return(
<div className='tf-accordion'>
<input type='hidden' name={ props.name ?? '' } value={ JSON.stringify(value) } />
<ExpandablePanel
title={ props.title ?? false }
headerLeft={ headerLeft }
behavior={ 'hide' }
behavior={ 'show' }
isOpen={ props.isOpen ?? false }
>
<FieldGroup
{ ...props }
Expand Down
5 changes: 3 additions & 2 deletions example/register/sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
'title' => 'Accordion',
'path' => 'fields/accordion',
'fields'=> [
'accordion' => [ 'json' => true ],
'accordion-with-switch' => [ 'json' => true ]
'accordion' => [ 'json' => true ],
'accordion-open-by-default' => [ 'json' => true ],
'accordion-with-switch' => [ 'json' => true ]
]
],
'alignment_matrix' => [
Expand Down
109 changes: 70 additions & 39 deletions example/templates/fields/accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,93 @@
<h4>Example</h4>

<div class="tangible-settings-row">
<?= $fields->render_field('accordion', [
'label' => 'Accordion',
'type' => 'accordion',
'value' => $fields->fetch_value('accordion'),
'fields' => [
[
'label' => 'Text',
'type' => 'text',
'name' => 'text_name',
],[
'label' => 'Text',
'type' => 'dimensions',
'name' => 'dimension_name',
]
]
]) ?>
<?= $fields->render_field('accordion', [
'label' => 'Accordion',
'type' => 'accordion',
'title' => 'Simple Accordion',
'value' => $fields->fetch_value('accordion'),
'fields' => [
[
'label' => 'Text',
'type' => 'text',
'name' => 'text_name',
],
[
'label' => 'Text',
'type' => 'dimensions',
'name' => 'dimension_name',
]
]
]) ?>
</div>

<div class="tangible-settings-row">
<?php submit_button() ?>
<?php submit_button() ?>
</div>

<h4>Example that is open by default</h4>

<div class="tangible-settings-row">
<?= $fields->render_field('accordion-open-by-default', [
'label' => 'Accordion',
'type' => 'accordion',
'title' => 'Simple Open Accordion',
'isOpen' => true,
'value' => $fields->fetch_value('accordion'),
'fields' => [
[
'label' => 'Text',
'type' => 'text',
'name' => 'text_name',
],
[
'label' => 'Text',
'type' => 'dimensions',
'name' => 'dimension_name',
]
]
]) ?>
</div>

<div class="tangible-settings-row">
<?php submit_button() ?>
</div>

<h4>Example with activation toggle</h4>

The value of the toggle will be saved in the JSON object, using the name "enabled".

<div class="tangible-settings-row">
<?= $fields->render_field('accordion-with-switch', [
'label' => 'Accordion',
'type' => 'accordion',
'value' => $fields->fetch_value('accordion-with-switch'),
'use_switch' => true,
'fields' => [
[
'label' => 'Text',
'type' => 'text',
'name' => 'text_name',
],[
'label' => 'Text',
'type' => 'dimensions',
'name' => 'dimension_name',
]
]
]) ?>
<?= $fields->render_field('accordion-with-switch', [
'label' => 'Accordion',
'type' => 'accordion',
'title' => 'Simple Accordion With a Toggle',
'value' => $fields->fetch_value('accordion-with-switch'),
'use_switch' => true,
'fields' => [
[
'label' => 'Text',
'type' => 'text',
'name' => 'text_name',
],
[
'label' => 'Text',
'type' => 'dimensions',
'name' => 'dimension_name',
]
]
]) ?>
</div>

<div class="tangible-settings-row">
<?php submit_button() ?>
<?php submit_button() ?>
</div>

<h4>Value</h4>

<?php tangible\see(
$fields->fetch_value('accordion'),
$fields->fetch_value('accordion-with-switch')
<?php tangible\see(
$fields->fetch_value('accordion'),
$fields->fetch_value('accordion-with-switch')
); ?>

<h4>Code</h4>
Expand Down Expand Up @@ -89,4 +121,3 @@
]);
</code>
</pre>

Loading