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

Add code snippets for usage via CSS variables #1924

Closed
wants to merge 4 commits into from
Closed
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
46 changes: 38 additions & 8 deletions docs/layouts/icons/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ <h2 class="fs-3">Download</h2>
<p>Download the SVG to use or edit.</p>
<a href="{{ $svgPath }}" class="btn btn-bd-primary mb-4" download>Download SVG</a>

<h2 class="fs-3">Icon font</h2>
<p>Using the web font? Copy, paste, and go.</p>

<div class="mb-4">
{{ $iconFontSnippet := printf `<i class="bi bi-%s"></i>` .File.TranslationBaseName -}}
{{- highlight $iconFontSnippet "html" "" }}
</div>

<h2 class="fs-3">Code point</h2>
<div class="mb-4">
{{ $codepoints := getJSON "font/bootstrap-icons.json" -}}
Expand All @@ -138,6 +130,44 @@ <h2 class="fs-3">Code point</h2>
</ul>
</div>

<h2 class="fs-3">Icon font</h2>
<p>Using the web font? Copy, paste, and go.</p>

<div class="mb-4">
{{ $iconFontSnippet := printf `<i class="bi bi-%s"></i>` .File.TranslationBaseName -}}
{{- highlight $iconFontSnippet "html" "" }}
</div>

<p>Don’t want or can’t modify HTML? No problem, you can also use CSS variables! Define via:</p>

{{ $iconCSSDefSnippet := printf `--bi-%s: "\%s";` .File.TranslationBaseName $hexCodepoint -}}
{{- highlight $iconCSSDefSnippet "css" "" }}

<p>
<small class="text-body-secondary">
<i class="bi bi-lightbulb"></i>
<strong>Tip:</strong> Use on <code>:root</code> to make available on the whole page.
</small>
</p>

<p>Then apply like:</p>

{{ $iconCSSUseSnippet := printf `content: var(--bi-%s);` .File.TranslationBaseName -}}
{{- highlight $iconCSSUseSnippet "css" "" }}

<details class="mb-4">
<summary>See Example</summary>
{{ $iconCSSExampleSnippet := printf `:root {
%s
}

.card > footer > a::after {
%s
font-family: bootstrap-icons;
}` $iconCSSDefSnippet $iconCSSUseSnippet -}}
{{- highlight $iconCSSExampleSnippet "css" "" }}
</details>

<h2 class="fs-3">Copy HTML</h2>
<p>Paste the SVG right into your project's code.</p>

Expand Down
Loading