Skip to content

Commit db6db8d

Browse files
committed
minor #2309 Show a visible link to the docs of each package (javiereguiluz, Kocal)
This PR was merged into the 2.x branch. Discussion ---------- Show a visible link to the docs of each package | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | #2273 | License | MIT I know that you mentioned that there's a work-in-progress effort to update some things in the current design (#2273 (comment)) but I think we should fix this issue quickly because it's a problem in many long package pages. If you don't like the proposed changes here it's fine; let's iterate over them. Tell me what to fix or change and I'll do it. Thanks! This is how this PR looks at the moment: ![](https://github.com/user-attachments/assets/372918e7-c72e-4d03-8f5a-5e56d8a9c76b) #SymfonyHackday :) Commits ------- 7c2ad1d [Site] Rework "Read the docs" button on packages pages 3bc80c5 Show a visible link to the docs of each package
2 parents 52b64e1 + 7c2ad1d commit db6db8d

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-21
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@
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, .75rem) var(--space-large, 1.5rem);
23+
transform: translateY(50%);
24+
25+
p {
26+
margin-bottom: 0;
27+
}
28+
29+
svg {
30+
font-size: 1.5rem;
31+
}
32+
33+
&:hover {
34+
transform: translateY(50%);
35+
}
36+
}
1837
}
1938
.DocsLink_content {
2039
display: flex;
@@ -58,5 +77,3 @@
5877
margin-bottom: 0;
5978
}
6079
}
61-
62-

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

Lines changed: 8 additions & 1 deletion
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
}
Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
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="mdi:book-open-variant-outline" class="Icon me-2" />
6+
7+
<a href="{{ url }}" class="DocsLink_link"
8+
rel="{{ isExternal ? 'external noopened noreferrer' }}"
9+
>{{ title }}</a>
10+
</p>
11+
{% else %}
12+
<p class="DocsLink_title ubuntu-header">
13+
<a href="{{ url }}" class="DocsLink_link" rel="{{ isExternal ? 'external noopened noreferrer' }}">
14+
{{ title }}
15+
</a>
16+
{% if icon|default %}
17+
<twig:ux:icon name="{{ icon }}" class="Icon DocsLink_arrow"/>
18+
{% elseif isExternal %}
19+
<twig:ux:icon name="arrow-right" style="transform: rotate(-45deg);" class="Icon DocsLink_arrow"/>
20+
{% endif %}
21+
</p>
22+
{% endif %}
23+
24+
{% if text %}
25+
<div class="DocsLink_description">
26+
<p>{{ text }}</p>
27+
</div>
28+
{% endif %}
1629
</div>
1730
</div>

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

Lines changed: 10 additions & 4 deletions
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)