Skip to content

Commit fd5865e

Browse files
committed
[Site] Moving the live demos above code + adding a longer description to each
1 parent 4681469 commit fd5865e

File tree

7 files changed

+61
-8
lines changed

7 files changed

+61
-8
lines changed

ux.symfony.com/src/Form/RegistrationForm.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2121
new NotBlank(message: 'Please enter an email!'),
2222
new Email(),
2323
],
24-
'help' => 'Type an invalid email and watch as it auto-validates when you leave the field!',
2524
])
2625
->add('password', PasswordType::class, [
2726
'constraints' => [

ux.symfony.com/src/Model/LiveDemo.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public function __construct(
99
private string $name,
1010
private string $description,
1111
private string $route,
12+
private string $longDescription,
1213
) {
1314
}
1415

@@ -27,6 +28,11 @@ public function getDescription(): string
2728
return $this->description;
2829
}
2930

31+
public function getLongDescription(): string
32+
{
33+
return $this->longDescription;
34+
}
35+
3036
public function getRoute(): string
3137
{
3238
return $this->route;

ux.symfony.com/src/Service/LiveDemoRepository.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,69 @@ public function findAll(): array
1717
name: 'Auto-Validating Form',
1818
description: 'Create a form that validates each field in-real-time as the user enters data!',
1919
route: 'app_live_components_demo_auto_validating_form',
20+
longDescription: <<<EOF
21+
Enter a bad email or leave the password empty, and see how the
22+
form validates in real time!
23+
<br>
24+
This renders a normal Symfony form but with extras added on top,
25+
all generated from Symfony & Twig.
26+
EOF
27+
2028
),
2129
new LiveDemo(
2230
'form-collection-type',
2331
name: 'Embedded CollectionType Form',
2432
description: 'Create embedded forms with functional "add" and "remove" buttons all in Twig.',
2533
route: 'app_live_components_demo_form_collection_type',
34+
longDescription: <<<EOF
35+
Unlock the potential of Symfony's <a href="https://symfony.com/doc/current/reference/forms/types/collection.html"><code>CollectionType</code></a> while
36+
writing zero JavaScript.
37+
<br>
38+
This demo shows off adding and removing items entirely in PHP & Twig.
39+
EOF
2640
),
2741
new LiveDemo(
2842
'dependent-form-fields',
2943
name: 'Dependent Form Fields',
3044
description: 'After selecting the first field, automatically reload the options for a second field.',
3145
route: 'app_live_components_demo_dependent_form_fields',
46+
longDescription: <<<EOF
47+
Say goodbye to the hassle of dependent form fields with Live Components.
48+
<br>
49+
Whip up a <a href="https://symfony.com/doc/current/form/dynamic_form_modification.html#form-events-submitted-data">form with dynamic events</a>and then head out for a well-deserved lunch.
50+
EOF
3251
),
3352
new LiveDemo(
3453
'voting',
3554
name: 'Up & Down Voting',
3655
description: 'Save up & down votes live in pure Twig & PHP.',
3756
route: 'app_live_components_demo_voting',
57+
longDescription: <<<EOF
58+
With each row as its own component, it's easy to add up & down voting + keep track of which items have been voted on.
59+
<br>
60+
This uses a <a href="https://symfony.com/bundles/ux-live-component/current/index.html#actions">LiveAction</a> to save everything with Ajax.
61+
EOF
3862
),
3963
new LiveDemo(
4064
'inline_edit',
4165
name: 'Inline Editing',
4266
description: 'Activate an inline editing form with validation.',
4367
route: 'app_live_components_demo_inline_edit',
68+
longDescription: <<<EOF
69+
Inline editing? Simple. Use LiveComponents to track if you're in "edit" mode, let
70+
the user update any fields on your entity, and save through a <code>LiveAction</code>.
71+
EOF
4472
),
4573
new LiveDemo(
4674
'chartjs_updating',
4775
name: 'Auto-Updating Chart',
4876
description: 'Render & Update a Chart.js chart in real-time.',
4977
route: 'app_live_components_demo_chartjs',
78+
longDescription: <<<EOF
79+
What do you get with Live Components + UX Chart.js + UX Autocomplete?
80+
<br>
81+
An auto-updating chart that you will ❤️.
82+
EOF
5083
),
5184
];
5285
}

ux.symfony.com/src/Twig/RegistrationFormComponent.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ protected function instantiateForm(): FormInterface
2727
return $this->createForm(RegistrationForm::class);
2828
}
2929

30+
public function hasValidationErrors(): bool
31+
{
32+
return $this->getFormInstance()->isSubmitted() && !$this->getFormInstance()->isValid();
33+
}
34+
3035
#[LiveAction]
3136
public function saveRegistration()
3237
{

ux.symfony.com/templates/components/registration_form.html.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
{{ form_row(form.password) }}
1515
{{ form_row(form.terms) }}
1616

17-
<button type="submit" class="btn btn-primary">Register</button>
17+
<button
18+
type="submit"
19+
class="btn btn-primary {{ this.hasValidationErrors ? 'disabled' : '' }}"
20+
>Register</button>
1821

1922
{{ form_rest(form) }}
2023
</form>

ux.symfony.com/templates/liveDemoBase.html.twig

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717

1818
<div class="container-fluid container-xxl px-5 pt-5">
1919

20+
<section style="color: rgb(100 116 139); font-size: 14px; line-height: 1.75rem;" class="mb-2">
21+
{{ demo.longDescription|raw }}
22+
</section>
23+
24+
<div class="mb-3" style="position: relative;">
25+
<div class="p-4 markdown-container rainbow-gradient" id="demo">
26+
{% block demo_content %}{% endblock %}
27+
</div>
28+
29+
<div class="arrow-2 mb-3 d-sm-block" style="position:absolute; bottom: 0; left: 0; transform: scaleX(-1) translateY(70px) translateX(20px)"></div>
30+
</div>
31+
2032
{% block code_block_full %}
2133
<div class="arrow mb-3 d-none d-md-block"></div>
2234

@@ -29,10 +41,5 @@
2941
</div>
3042
</div>
3143
{% endblock %}
32-
33-
<div class="p-4 markdown-container rainbow-gradient mt-5" id="demo" style="position: relative;">
34-
<div class="arrow-2 mb-3 d-sm-block" style="position:absolute; top:-55px; right: -25px;"></div>
35-
{% block demo_content %}{% endblock %}
36-
</div>
3744
</div>
3845
{% endblock %}

ux.symfony.com/templates/liveDemoTabsBase.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'liveDemoBase.html.twig' %}
22

33
{% block code_block_full %}
4-
<div class="row mb-5">
4+
<div class="row" style="margin-top: 60px;">
55
<div class="terminal-code">
66
<ul class="nav nav-tabs">
77
<li class="nav-item" role="presentation">

0 commit comments

Comments
 (0)