Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Creation of the initial cards component
Browse files Browse the repository at this point in the history
  • Loading branch information
autumnfound committed May 20, 2021
1 parent be32f7c commit ebdb070
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
13 changes: 13 additions & 0 deletions exampleSite/data/en/cards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
style: vertical
items:
- heading: Test card
content: Esse incididunt ipsum nulla consectetur tempor elit. Mollit adipisicing esse labore consectetur irure ut reprehenderit sit. Quis do cupidatat qui quis nostrud laboris nulla incididunt laborum sit sit qui id cupidatat.
links:
- url: "#"
text: Download now
alt: Link to a the PDF document for X
style: button
- url: "#"
text: Or don't
alt: Link to a form to do Y
style: text
64 changes: 64 additions & 0 deletions layouts/shortcodes/cards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<!-- Allow for alt sources and languages -->
{{ $source := .Get "source" | default "cards" }}
{{ $languageBase := index .Site.Data .Site.Language.Lang }}
<!-- Get the base of the testimonials by checking existence in localized section -->
{{ $base := index .Site.Data $source}}
{{ if and (ne $languageBase nil) (isset $languageBase $source) }}
{{ $base = index $languageBase $source }}
{{ end }}


{{ $containerClass := .Get "containerClass" | default "col-xs-24 col-sm-8" }}
{{ $useMatchHeight := .Get "useMatchHeight" | default "false" }}
{{ $cardStyle := .Get "" | default $base.style | default "vertical" }}

<div class="row">
{{ range $base.items }}
{{ if .fullCardLink }}
<a href="">
{{ end }}
<div class="card-container{{ with $containerClass }} {{ . }}{{ end }}{{ if $useMatchHeight }} match-height-item-by-row{{ end }}">
{{ $glyphSet := false }}
{{ if or (isset . "glyph") (isset . "glyphSrc") }}
{{ $glyphSet = true }}
<div class="glyph-highlight">
<div class="glyph-container">
{{ if .glyph }}
<i class="fa {{ .glyph }}"></i>
{{ else }}
<img class="img margin-auto" src="{{ .glyphSrc }}" />
{{ end }}
</div>
<div class="glyph-bottom"></div>
</div>
{{ end }}
<div class="card-panel panel panel-default{{ if $glyphSet }} with-glyph{{ end }}{{ if $cardStyle "horizontal" }} horizontal-card{{ end }}{{ with .class }} {{ . }}{{ end }}">
{{ if isset . "img" }}
<div class="panel-heading" aria-hidden="true">
<img class="img {{ .imgClass | default "img-responsive margin-auto" }}" src="{{ .imgSrc }}" alt="{{ .imgAlt }}"/>
</div>
{{ end }}
<div class="panel-body">
{{ with .heading }}
<h3 class="fw-700{{ with .headingClass }} {{ . }}{{ end }}">{{ . }}</h3>
{{ end }}
<p>{{ .content }}</p>
</div>
{{ if and (isset . "links") (len .links) }}
<div class="panel-footer text-center">
{{ range .links }}
<a class="{{ if eq .style "button" }}btn {{ .linkClass | default "btn-primary" }}{{ else if eq .style "text" }}{{ .linkClass | default "brand-primary" }}{{ end }}"
href="{{ .url }}"{{ with .title }} title="{{ . }}"{{ end }}>
{{ .text }}
</a>
{{ end }}
</div>
{{ end }}
</div>
</div>
{{ }}
</a>
{{ end }}
{{ end }}
</div>

0 comments on commit ebdb070

Please sign in to comment.