1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-12-01 02:27:17 +01:00

Inline source repository SVGs

This commit is contained in:
squidfunk 2016-12-28 14:47:53 +01:00
parent 113ba5fd8b
commit 6364de1a2d
19 changed files with 95 additions and 54 deletions

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 959 B

After

Width:  |  Height:  |  Size: 959 B

View File

Before

Width:  |  Height:  |  Size: 742 B

After

Width:  |  Height:  |  Size: 742 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@
{% include "partials/fonts.html" %} {% include "partials/fonts.html" %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-7b7465c8b1.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-de7f9d2ca0.css">
{% if config.extra.palette %} {% if config.extra.palette %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-535e87ca3f.palette.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-535e87ca3f.palette.css">
{% endif %} {% endif %}
@ -54,6 +54,7 @@
{% else %} {% else %}
<body> <body>
{% endif %} {% endif %}
{% include "partials/svgs.html" %}
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer"> <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search"> <input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label> <label class="md-overlay" data-md-component="overlay" for="drawer"></label>
@ -109,7 +110,7 @@
<script src="https://cdn.mathjax.org/{{ path }}"></script> <script src="https://cdn.mathjax.org/{{ path }}"></script>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<script src="{{ base_url }}/assets/javascripts/application-cd89c74ae5.js"></script> <script src="{{ base_url }}/assets/javascripts/application-983f149ca4.js"></script>
<script> <script>
/* Configuration for application */ /* Configuration for application */
var config = { var config = {

View File

@ -1,18 +1,19 @@
{% set platform = config.extra.repo_icon or config.repo_url %} {% set platform = config.repo_url %}
{% if "github" in platform %} {% if "github" in platform %}
{% set repo_type = "github" %} {% set repo_type = "github" %}
{% set repo_icon = "md-source--github" %}
{% elif "gitlab" in platform %} {% elif "gitlab" in platform %}
{% set repo_type = "gitlab" %} {% set repo_type = "gitlab" %}
{% set repo_icon = "md-source--gitlab" %}
{% elif "bitbucket" in platform %} {% elif "bitbucket" in platform %}
{% set repo_type = "bitbucket" %} {% set repo_type = "bitbucket" %}
{% set repo_icon = "md-source--bitbucket" %}
{% else %} {% else %}
{% set repo_type = "" %} {% set repo_type = "" %}
{% set repo_icon = "" %}
{% endif %} {% endif %}
<a href="{{ config.repo_url }}" title="Go to repository" class="md-source {{ repo_icon }}" data-md-source="{{ repo_type }}"> <a href="{{ config.repo_url }}" title="Go to repository" class="md-source" data-md-source="{{ repo_type }}">
{% if repo_type %}
<svg class="md-source__icon">
<use xlink:href="#{{ repo_type }}" x="12" y="12" width="24" height="24"></use>
</svg>
{% endif %}
<div class="md-source__repository"> <div class="md-source__repository">
{{ config.repo_name }} {{ config.repo_name }}
</div> </div>

View File

@ -0,0 +1,10 @@
<div class="md-svg">
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github-da331b3ec4.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab-81ba4a278f.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket-850dc5f8b2.svg" %}
{% endif %}
</div>

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="352" height="448" <svg xmlns="http://www.w3.org/2000/svg" width="352" height="448"
viewBox="0 0 352 448"> viewBox="0 0 352 448" id="bitbucket">
<path d="M203.75 214.75q2 15.75-12.625 25.25t-27.875 <path d="M203.75 214.75q2 15.75-12.625 25.25t-27.875
1.5q-9.75-4.25-13.375-14.5t-0.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875 1.5q-9.75-4.25-13.375-14.5t-0.125-20.5 13-14.5q9-4.5 18.125-3t16 8.875
6.875 16.875zM231.5 209.5q-3.5-26.75-28.25-41t-49.25-3.25q-15.75 6.875 16.875zM231.5 209.5q-3.5-26.75-28.25-41t-49.25-3.25q-15.75

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" <svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
viewBox="0 0 416 448"> viewBox="0 0 416 448" id="github">
<path d="M160 304q0 10-3.125 20.5t-10.75 19-18.125 <path d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75 18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" <svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"
viewBox="0 0 500 500"> viewBox="0 0 500 500" id="gitlab">
<g transform="translate(156.197863, 1.160267)"> <g transform="translate(156.197863, 1.160267)">
<path d="M93.667,473.347L93.667,473.347l90.684-279.097H2.983L93.667, <path d="M93.667,473.347L93.667,473.347l90.684-279.097H2.983L93.667,
473.347L93.667,473.347z" /> 473.347L93.667,473.347z" />

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -44,7 +44,7 @@ export default class Repository {
* @param {Array.<string>} facts - Facts to be rendered * @param {Array.<string>} facts - Facts to be rendered
*/ */
initialize(facts) { initialize(facts) {
this.el_.children[0].appendChild( this.el_.children[this.el_.children.length - 1].appendChild(
<ul class="md-source__facts"> <ul class="md-source__facts">
{facts.map(fact => <li class="md-source__fact">{fact}</li>)} {facts.map(fact => <li class="md-source__fact">{fact}</li>)}
</ul> </ul>

View File

@ -65,6 +65,11 @@ hr {
border: 0; border: 0;
} }
// Inline SVG container
.md-svg {
display: none;
}
// Template-wide grid // Template-wide grid
.md-grid { .md-grid {
max-width: 120.0rem; max-width: 120.0rem;

View File

@ -72,53 +72,34 @@
} }
// Necessary for vertical alignment // Necessary for vertical alignment
&::before { &::after {
display: inline-block; display: inline-block;
height: 4.8rem; height: 4.8rem;
content: ""; content: "";
vertical-align: middle; vertical-align: middle;
} }
// Repository is hosted on platform // Repository platform icon
&--bitbucket, &__icon {
&--github, display: inline-block;
&--gitlab {
// Platform icon
&::before {
width: 4.8rem; width: 4.8rem;
background-repeat: no-repeat; height: 4.8rem;
background-position: center; content: "";
background-size: $md-icon-size $md-icon-size; vertical-align: middle;
} fill: $md-color-white;
// Adjust repository information for platform icon // Correct alignment, if icon is present
.md-source__repository { + .md-source__repository {
margin-left: -4.4rem; margin-left: -4.4rem;
padding-left: 4.0rem; padding-left: 4.0rem;
} }
} }
// Code is hosted on BitBucket
&--bitbucket::before {
background-image: url("../images/icons/bitbucket-white.svg");
}
// Code is hosted on GitHub
&--github::before {
background-image: url("../images/icons/github-white.svg");
}
// Code is hosted on GitLab
&--gitlab::before {
background-image: url("../images/icons/gitlab-white.svg");
}
// Repository name // Repository name
&__repository { &__repository {
display: inline-block; display: inline-block;
max-width: 100%; max-width: 100%;
margin-left: 0.8rem; margin-left: 1.2rem;
font-weight: 700; font-weight: 700;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;

View File

@ -112,6 +112,9 @@
<body> <body>
{% endif %} {% endif %}
<!-- Inline SVGs -->
{% include "partials/svgs.html" %}
<!-- State toggles --> <!-- State toggles -->
<input class="md-toggle" data-md-toggle="drawer" <input class="md-toggle" data-md-toggle="drawer"
type="checkbox" id="drawer" /> type="checkbox" id="drawer" />

View File

@ -24,24 +24,26 @@
Check whether the repository is hosted on one of the supported code hosting Check whether the repository is hosted on one of the supported code hosting
platforms (Github, Gitlab or Bitbucket) to show icon. platforms (Github, Gitlab or Bitbucket) to show icon.
--> -->
{% set platform = config.extra.repo_icon or config.repo_url %} {% set platform = config.repo_url %}
{% if "github" in platform %} {% if "github" in platform %}
{% set repo_type = "github" %} {% set repo_type = "github" %}
{% set repo_icon = "md-source--github" %} <!-- TODO: remove this in favor of type -->
{% elif "gitlab" in platform %} {% elif "gitlab" in platform %}
{% set repo_type = "gitlab" %} {% set repo_type = "gitlab" %}
{% set repo_icon = "md-source--gitlab" %}
{% elif "bitbucket" in platform %} {% elif "bitbucket" in platform %}
{% set repo_type = "bitbucket" %} {% set repo_type = "bitbucket" %}
{% set repo_icon = "md-source--bitbucket" %}
{% else %} {% else %}
{% set repo_type = "" %} {% set repo_type = "" %}
{% set repo_icon = "" %}
{% endif %} {% endif %}
<!-- Repository containing source --> <!-- Repository containing source -->
<a href="{{ config.repo_url }}" title="Go to repository" <a href="{{ config.repo_url }}" title="Go to repository" class="md-source"
class="md-source {{ repo_icon }}" data-md-source="{{ repo_type }}"> <!-- use <> for custom / private repo --> data-md-source="{{ repo_type }}">
{% if repo_type %}
<svg class="md-source__icon">
<use xlink:href="#{{ repo_type }}" x="12" y="12"
width="24" height="24"></use>
</svg>
{% endif %}
<div class="md-source__repository"> <div class="md-source__repository">
{{ config.repo_name }} {{ config.repo_name }}
</div> </div>

38
src/partials/svgs.html Normal file
View File

@ -0,0 +1,38 @@
<!--
Copyright (c) 2016 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Hidden container for inline SVGs -->
<div class="md-svg">
<!--
Check whether the repository is hosted on one of the supported code hosting
platforms (Github, Gitlab or Bitbucket) to show icon.
-->
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket.svg" %}
{% endif %}
</div>