Skip to content

Commit 3bc80c5

Browse files
javiereguiluzKocal
authored andcommitted
Show a visible link to the docs of each package
1 parent 6008eed commit 3bc80c5

File tree

5 files changed

+66
-19
lines changed

5 files changed

+66
-19
lines changed
Loading

ux.symfony.com/assets/styles/components/_DocsLink.scss

+21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@
1515
opacity: 1;
1616
}
1717

18+
&.DocsLink-sm {
19+
border-radius: var(--border-radius-sm, .5rem);
20+
height: 52px;
21+
opacity: 1;
22+
padding: var(--space-small, .25rem) var(--space-large, 1rem);
23+
transform: translateY(50%);
24+
25+
p {
26+
margin-bottom: 0;
27+
}
28+
29+
svg {
30+
fill: none;
31+
position: relative;
32+
bottom: 2px;
33+
}
34+
35+
&:hover {
36+
transform: translateY(50%);
37+
}
38+
}
1839
}
1940
.DocsLink_content {
2041
display: flex;

ux.symfony.com/src/Twig/Components/DocsLink.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
#[AsTwigComponent]
1818
class DocsLink
1919
{
20+
public string $size = 'md';
2021
public string $url;
2122
public string $title;
22-
public string $text;
23+
public ?string $text = null;
2324

2425
public ?string $icon = null;
2526

@@ -28,4 +29,10 @@ public function isExternal(): bool
2829
{
2930
return !str_starts_with($this->url, 'https://symfony.com');
3031
}
32+
33+
#[ExposeInTemplate]
34+
public function isSmall(): bool
35+
{
36+
return 'sm' === $this->size;
37+
}
3138
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
<div {{ attributes.defaults({class: 'DocsLink'}) }}>
1+
<div {{ attributes.defaults({class: 'DocsLink DocsLink-' ~ size }) }}>
22
<div class="DocsLink_content">
3-
<p class="DocsLink_title ubuntu-header">
4-
<a href="{{ url }}" class="DocsLink_link"
5-
rel="{{ isExternal ? 'external noopened noreferrer' }}"
6-
>{{ title }}</a>
7-
{% if icon|default %}
8-
<twig:ux:icon name="{{ icon }}" class="Icon DocsLink_arrow"/>
9-
{% elseif isExternal %}
10-
<twig:ux:icon name="arrow-right" style="transform: rotate(-45deg);" class="Icon DocsLink_arrow"/>
11-
{% endif %}
12-
</p>
13-
<div class="DocsLink_description">
14-
<p>{{ text }}</p>
15-
</div>
3+
{% if isSmall %}
4+
<p class="d-flex align-items-center">
5+
<twig:ux:icon name="fluent-emoji-flat:open-book" class="Icon me-2" font-size="32"/>
6+
<a href="{{ url }}" class="DocsLink_link"
7+
rel="{{ isExternal ? 'external noopened noreferrer' }}"
8+
>{{ title }}</a>
9+
</p>
10+
{% else %}
11+
<p class="DocsLink_title ubuntu-header">
12+
<a href="{{ url }}" class="DocsLink_link"
13+
rel="{{ isExternal ? 'external noopened noreferrer' }}"
14+
>{{ title }}</a>
15+
{% if icon|default %}
16+
<twig:ux:icon name="{{ icon }}" class="Icon DocsLink_arrow"/>
17+
{% elseif isExternal %}
18+
<twig:ux:icon name="arrow-right" style="transform: rotate(-45deg);" class="Icon DocsLink_arrow"/>
19+
{% endif %}
20+
</p>
21+
{% endif %}
22+
23+
{% if text %}
24+
<div class="DocsLink_description">
25+
<p>{{ text }}</p>
26+
</div>
27+
{% endif %}
1628
</div>
1729
</div>

ux.symfony.com/templates/components/Package/PackageHeader.html.twig

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@
1212
</p>
1313
</div>
1414

15-
{% if command is not defined or command %}
16-
<div class="d-flex justify-content-center">
15+
<div class="d-flex justify-content-center">
16+
{% if command is not defined or command %}
1717
<twig:TerminalCommand
1818
aria-label="Composer command to install {{ package.humanName }}"
1919
command="{{ package.composerRequireCommand }}"
2020
style="--color-accent: {{ package.color }}; transform: translateY(50%);"
2121
/>
22-
</div>
23-
{% endif %}
22+
{% endif %}
2423

24+
<twig:DocsLink
25+
class="ms-3"
26+
size="sm"
27+
title="Read the docs"
28+
url="{{ package.officialDocsUrl }}"
29+
/>
30+
</div>
2531
</div>
2632
</div>

0 commit comments

Comments
 (0)