Skip to content

Commit e95cf41

Browse files
authored
Merge pull request #1000 from phpDocumentor/backport/1.x/pr-999
[1.x] [BUGFIX] Display value of card-footer,
2 parents 89c2943 + 835b9de commit e95cf41

File tree

5 files changed

+152
-3
lines changed

5 files changed

+152
-3
lines changed

packages/guides-theme-bootstrap/src/Bootstrap/Directives/CardFooterDirective.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
use phpDocumentor\Guides\Bootstrap\Nodes\Card\CardFooterNode;
1717
use phpDocumentor\Guides\Nodes\CollectionNode;
18+
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
1819
use phpDocumentor\Guides\Nodes\InlineCompoundNode;
1920
use phpDocumentor\Guides\Nodes\Node;
2021
use phpDocumentor\Guides\RestructuredText\Directives\SubDirective;
2122
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
2223
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
2324

25+
use function array_merge;
26+
use function explode;
27+
2428
class CardFooterDirective extends SubDirective
2529
{
2630
public function getName(): string
@@ -33,10 +37,33 @@ protected function processSub(
3337
CollectionNode $collectionNode,
3438
Directive $directive,
3539
): Node|null {
40+
$contentItems = [];
41+
$buttonStyle = null;
42+
if ($directive->hasOption('button-style')) {
43+
$buttonStyle = $directive->getOption('button-style')->toString();
44+
if ($buttonStyle === '') {
45+
$buttonStyle = 'btn btn-primary';
46+
}
47+
48+
$buttonStyle = explode(' ', $buttonStyle);
49+
}
50+
51+
if ($directive->getDataNode() !== null) {
52+
$content = $directive->getDataNode();
53+
foreach ($content->getChildren() as $contentItem) {
54+
if ($buttonStyle !== null && $contentItem instanceof AbstractLinkInlineNode) {
55+
$contentItem->setClasses(array_merge($contentItem->getClasses(), $buttonStyle));
56+
}
57+
58+
$contentItems[] = $contentItem;
59+
}
60+
}
61+
3662
return new CardFooterNode(
3763
$this->getName(),
3864
$directive->getData(),
39-
$directive->getDataNode() ?? new InlineCompoundNode(),
65+
new InlineCompoundNode($contentItems),
66+
$collectionNode->getChildren(),
4067
);
4168
}
4269
}

packages/guides/resources/template/html/inline/link.html.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{%- if node.url -%}
2-
<a href="{{- node.url -}}"{% for key, value in attributes %} {{- key -}}="{{- value -}}"{% endfor %}>
2+
<a href="{{- node.url -}}"
3+
{%- for key, value in attributes %} {{- key -}}="{{- value -}}"{% endfor -%}
4+
{%- if node.classes %} class="{{ node.classesString }}"{% endif -%}
5+
>
36
{{- node.value -}}
47
</a>
58
{%- else -%}

tests/Integration/tests/bootstrap/bootstrap-card-group/expected/index.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,74 @@ <h1>Document Title</h1>
7777
</div>
7878
</div>
7979
</div>
80+
<div class="section" id="cards-with-buttons-in-the-footer">
81+
<h2>Cards with buttons in the footer</h2>
82+
<div class="row card-group row-cols-1 row-cols-md-3 g-4">
83+
<div class="col">
84+
<div class="card h-100">
85+
<div class="card-body">
86+
<h3 class="card-title">Primary Buttons</h3>
87+
<div class="card-text">
88+
89+
<p>The Page Management Guide introduces TYPO3&#039;s Page Tree and explains how pages are created and managed.</p>
90+
91+
</div>
92+
</div>
93+
<div class="card-footer">
94+
<a href="https://example.org/" class="btn btn-primary">12-dev</a> <a href="https://example.org/" class="btn btn-primary">11.5</a> <a href="https://example.org/" class="btn btn-primary">10.4</a>
95+
</div>
96+
</div>
97+
</div><div class="col">
98+
<div class="card h-100">
99+
<div class="card-body">
100+
<h3 class="card-title">Secondary Buttons</h3>
101+
<div class="card-text">
102+
103+
<p>The Page Management Guide introduces TYPO3&#039;s Page Tree and explains how pages are created and managed.</p>
104+
105+
</div>
106+
</div>
107+
<div class="card-footer">
108+
<a href="https://example.org/" class="btn btn-secondary">12-dev</a> <a href="https://example.org/" class="btn btn-secondary">11.5</a> <a href="https://example.org/" class="btn btn-secondary">10.4</a>
109+
</div>
110+
</div>
111+
</div><div class="col">
112+
<div class="card h-100">
113+
<div class="card-body">
114+
<h3 class="card-title">Link Buttons</h3>
115+
<div class="card-text">
116+
117+
<p>The Page Management Guide introduces TYPO3&#039;s Page Tree and explains how pages are created and managed.</p>
118+
119+
</div>
120+
</div>
121+
<div class="card-footer">
122+
<a href="https://example.org/" class="btn btn-link">12-dev</a> <a href="https://example.org/" class="btn btn-link">11.5</a> <a href="https://example.org/" class="btn btn-link">10.4</a>
123+
</div>
124+
</div>
125+
</div><div class="col">
126+
<div class="card h-100">
127+
<div class="card-body">
128+
<h3 class="card-title">Card with footer values</h3>
129+
<div class="card-text">
130+
131+
<p>Button-style only has effect on content</p>
132+
133+
</div>
134+
</div>
135+
<div class="card-footer">
136+
137+
138+
139+
<ul>
140+
<li><a href="https://example.org/">12-dev</a></li>
141+
<li><a href="https://example.org/">11.5</a></li>
142+
<li><a href="https://example.org/">10.4</a></li>
143+
</ul>
144+
145+
</div>
146+
</div>
147+
</div></div>
148+
</div>
80149
</div>
81150
<!-- content end -->

tests/Integration/tests/bootstrap/bootstrap-card-group/input/index.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,45 @@ Document Title
5757
sed diam voluptua.
5858

5959
.. card-footer:: :ref:`Read more <start>`
60+
61+
Cards with buttons in the footer
62+
================================
63+
64+
.. card-grid::
65+
:columns: 1
66+
:columns-md: 3
67+
:gap: 4
68+
:card-height: 100
69+
70+
.. card:: Primary Buttons
71+
72+
The Page Management Guide introduces TYPO3's Page Tree and explains how pages are created and managed.
73+
74+
.. card-footer:: `12-dev <https://example.org/>`__ `11.5 <https://example.org/>`__ `10.4 <https://example.org/>`__
75+
:button-style: btn btn-primary
76+
77+
78+
.. card:: Secondary Buttons
79+
80+
The Page Management Guide introduces TYPO3's Page Tree and explains how pages are created and managed.
81+
82+
.. card-footer:: `12-dev <https://example.org/>`__ `11.5 <https://example.org/>`__ `10.4 <https://example.org/>`__
83+
:button-style: btn btn-secondary
84+
85+
.. card:: Link Buttons
86+
87+
The Page Management Guide introduces TYPO3's Page Tree and explains how pages are created and managed.
88+
89+
.. card-footer:: `12-dev <https://example.org/>`__ `11.5 <https://example.org/>`__ `10.4 <https://example.org/>`__
90+
:button-style: btn btn-link
91+
92+
.. card:: Card with footer values
93+
94+
Button-style only has effect on content
95+
96+
.. card-footer::
97+
:button-style: btn btn-primary
98+
99+
* `12-dev <https://example.org/>`__
100+
* `11.5 <https://example.org/>`__
101+
* `10.4 <https://example.org/>`__

tests/Integration/tests/bootstrap/bootstrap-cards/expected/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ <h3 class="card-title"><a href="#start">Linked Card Header</a></h3>
3636
</div>
3737
<div class="card-footer">
3838

39-
</div>
39+
40+
41+
<ul>
42+
<li><a href="https://docs.typo3.org/m/typo3/tutorial-editors/main/en-us/Pages/Index.html">12-dev</a></li>
43+
<li><a href="https://docs.typo3.org/m/typo3/tutorial-editors/11.5/en-us/Pages/Index.html">11.5</a></li>
44+
<li><a href="https://docs.typo3.org/m/typo3/tutorial-editors/10.4/en-us/Pages/Index.html">10.4</a></li>
45+
</ul>
46+
47+
</div>
4048
</div>
4149
<div class="card w-50">
4250
<div class="card-header">

0 commit comments

Comments
 (0)