Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a visible link to the docs of each package #2309

Merged
merged 2 commits into from
Dec 7, 2024
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
21 changes: 19 additions & 2 deletions ux.symfony.com/assets/styles/components/_DocsLink.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
opacity: 1;
}

&.DocsLink-sm {
border-radius: var(--border-radius-sm, .5rem);
height: 52px;
opacity: 1;
padding: var(--space-small, .75rem) var(--space-large, 1.5rem);
transform: translateY(50%);

p {
margin-bottom: 0;
}

svg {
font-size: 1.5rem;
}

&:hover {
transform: translateY(50%);
}
}
}
.DocsLink_content {
display: flex;
Expand Down Expand Up @@ -58,5 +77,3 @@
margin-bottom: 0;
}
}


9 changes: 8 additions & 1 deletion ux.symfony.com/src/Twig/Components/DocsLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#[AsTwigComponent]
class DocsLink
{
public string $size = 'md';
public string $url;
public string $title;
public string $text;
public ?string $text = null;

public ?string $icon = null;

Expand All @@ -28,4 +29,10 @@ public function isExternal(): bool
{
return !str_starts_with($this->url, 'https://symfony.com');
}

#[ExposeInTemplate]
public function isSmall(): bool
{
return 'sm' === $this->size;
}
}
41 changes: 27 additions & 14 deletions ux.symfony.com/templates/components/DocsLink.html.twig
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
<div {{ attributes.defaults({class: 'DocsLink'}) }}>
<div {{ attributes.defaults({class: 'DocsLink DocsLink-' ~ size}) }}>
<div class="DocsLink_content">
<p class="DocsLink_title ubuntu-header">
<a href="{{ url }}" class="DocsLink_link"
rel="{{ isExternal ? 'external noopened noreferrer' }}"
>{{ title }}</a>
{% if icon|default %}
<twig:ux:icon name="{{ icon }}" class="Icon DocsLink_arrow"/>
{% elseif isExternal %}
<twig:ux:icon name="arrow-right" style="transform: rotate(-45deg);" class="Icon DocsLink_arrow"/>
{% endif %}
</p>
<div class="DocsLink_description">
<p>{{ text }}</p>
</div>
{% if isSmall %}
<p class="d-flex align-items-center">
<twig:ux:icon name="mdi:book-open-variant-outline" class="Icon me-2" />

<a href="{{ url }}" class="DocsLink_link"
rel="{{ isExternal ? 'external noopened noreferrer' }}"
>{{ title }}</a>
</p>
{% else %}
<p class="DocsLink_title ubuntu-header">
<a href="{{ url }}" class="DocsLink_link" rel="{{ isExternal ? 'external noopened noreferrer' }}">
{{ title }}
</a>
{% if icon|default %}
<twig:ux:icon name="{{ icon }}" class="Icon DocsLink_arrow"/>
{% elseif isExternal %}
<twig:ux:icon name="arrow-right" style="transform: rotate(-45deg);" class="Icon DocsLink_arrow"/>
{% endif %}
</p>
{% endif %}

{% if text %}
<div class="DocsLink_description">
<p>{{ text }}</p>
</div>
{% endif %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
</p>
</div>

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

<twig:DocsLink
class="ms-3"
size="sm"
title="Read the docs"
url="{{ package.officialDocsUrl }}"
/>
</div>
</div>
</div>
Loading