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

Implement hextra/hero-container with optional front-page logo #387

Closed
fmunteanu opened this issue May 8, 2024 · 1 comment · Fixed by #389
Closed

Implement hextra/hero-container with optional front-page logo #387

fmunteanu opened this issue May 8, 2024 · 1 comment · Fixed by #389

Comments

@fmunteanu
Copy link
Contributor

fmunteanu commented May 8, 2024

Feature Description

Hi @imfing,

On Hextra front-page, there is a lot of unused space on the right side of headline, ideal to insert a logo image.

Proposed Solution

I created the following layouts/shortcodes/hextra/hero-container.html shortcode, implementing a container with optional logo image and related link:

{{- $class := .Get "class" -}}
{{- $cols := .Get "cols" | default 2 -}}
{{- $image := .Get "image" -}}
{{- $imageClass := .Get "imageClass" -}}
{{- $imageLink := .Get "imageLink" -}}
{{- $imageLinkExternal := hasPrefix $imageLink "http" -}}
{{- $imageTitle := .Get "imageTitle" -}}
{{- $imageWidth := .Get "imageWidth" | default 350 -}}
{{- $imageHeight := .Get "imageHeight" | default 350 -}}
{{- $style := .Get "style" -}}

{{- $css := printf "--hextra-feature-grid-cols: %v; %s" $cols $style -}}
{{- $href := cond (hasPrefix $imageLink "/") ($imageLink | relURL) $imageLink -}}

<div
  class="{{ $class }} hextra-feature-grid hx-grid sm:max-lg:hx-grid-cols-2 max-sm:hx-grid-cols-1 hx-gap-4 hx-w-max not-prose"
  {{ with $css }}style="{{ . | safeCSS }}"{{ end }}
>
  <div class="grid-col-span-1">
    {{ .Inner }}
  </div>
  {{- with $image }}
  <div class="hx-mx-auto hx-px-6">
    {{ with $href }}<a href="{{ $href }}" {{ with $imageLinkExternal }}target="_blank" rel="noreferrer"{{ end }}>{{ end }}
      <img
        {{ with $imageClass }}class="{{ $imageClass }}"{{ end }} src="{{ $image }}" 
        width="{{ $imageWidth }}" height="{{ $imageHeight }}" {{ with $imageTitle }}alt="{{ $imageTitle }}"{{ end }}
      />
    {{ with $href }}</a>{{ end }}
  </div>
  {{ end -}}
</div>

Code Usage

Based on my tests, an image with 350px height will perfectly align with the existing Hextra badge, headline and subtile group. Example of hextra/hero-container shortcode usage, with image pulled from /static/images directory:

{{< hextra/hero-container
  image="images/logo-services.svg"
  imageLink="https://github.com/axivo/k3s-cluster"
  imageTitle="Kubernetes Services"
>}}
{{< hextra/hero-badge link="https://github.com/axivo/k3s-cluster">}}
  <div class="hx-w-2 hx-h-2 hx-rounded-full hx-bg-primary-400"></div>
  <span>Contribute</span>
  {{< icon name="arrow-circle-right" attributes="height=14" >}}
{{< /hextra/hero-badge >}}

<div class="hx-mt-6 hx-mb-6">
{{< hextra/hero-headline >}}
  <span class="hx-whitespace-nowrap">
    High Availability K3s Cluster
  </span><br class="sm:hx-block hx-hidden" />
  Deployed with Ansible
{{< /hextra/hero-headline >}}
</div>

<div class="hx-mb-12">
{{< hextra/hero-subtitle >}}
  <span class="hx-whitespace-nowrap">
    Documentation and tutorials to deploy, manage and monitor
  </span><br class="sm:hx-block hx-hidden" />
  your Kubernetes cluster and related components, in style.
{{< /hextra/hero-subtitle >}}
</div>

<div class="hx-mb-6">
{{< hextra/hero-button text="Get Started" link="wiki" >}}
</div>
{{< /hextra/hero-container >}}

Implementation Result

Hovering the mouse over logo image will open the related link into a new tab:

image

@fmunteanu fmunteanu changed the title Implement extra/hero-container with optional front-page logo Implement hextra/hero-container with optional front-page logo May 8, 2024
@fmunteanu
Copy link
Contributor Author

@imfing I created #389.

@imfing imfing linked a pull request May 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant