Skip to content

Commit

Permalink
Merge pull request #351 from maykinmedia/feature/347-add-better-toolt…
Browse files Browse the repository at this point in the history
…ip-behind-the-(i)-icons

Add improved tooltip to info icons
  • Loading branch information
joeribekker authored Jan 11, 2022
2 parents 9945353 + 8bf42c8 commit 63e8cc4
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 9 deletions.
72 changes: 70 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
"homepage": "https://maykinmedia.nl",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"ckeditor5": "^30.0.0",
"flag-icon-css": "^4.1.6",
"flatpickr": "^4.6.9",
"microscope-sass": "latest",
"pretty-checkbox": "^3.0.3",
"reseter.css": "^2.0.0",
"showdown": "^1.9.1",
"text-diff": "^1.0.1"
"text-diff": "^1.0.1",
"tippy.js": "^6.3.7"
},
"devDependencies": {
"@babel/core": "latest",
Expand All @@ -48,8 +50,8 @@
"@ckeditor/ckeditor5-list": "^30.0.0",
"@ckeditor/ckeditor5-markdown-gfm": "^30.0.0",
"@ckeditor/ckeditor5-paragraph": "^30.0.0",
"@ckeditor/ckeditor5-theme-lark": "^30.0.0",
"@ckeditor/ckeditor5-table": "^30.0.0",
"@ckeditor/ckeditor5-theme-lark": "^30.0.0",
"arrayify": "^1.0.0",
"autoprefixer": "^9.0.0",
"babel-loader": "latest",
Expand Down
1 change: 1 addition & 0 deletions src/sdg/js/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ import "./catalog";
import "./diff";
import "./general";
import "./product";
import "./tooltip";
25 changes: 25 additions & 0 deletions src/sdg/js/components/tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {dom} from '@fortawesome/fontawesome-svg-core'
import tippy from "tippy.js";


class InfoTooltip {

constructor(node) {
this.node = node;
const text = this.node.firstChild.textContent;
this.node.firstChild.remove();
tippy(this.node, {
content: text,
placement: "right",
animation: "scale",
theme: "sdg",
});
}
}

const iconsDoneRendering = () => {
const infoIcons = document.querySelectorAll("svg.fa-info-circle[title]");
[...infoIcons].forEach(icon => new InfoTooltip(icon));
};

dom.i2svg({callback: iconsDoneRendering});
1 change: 1 addition & 0 deletions src/sdg/scss/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
@import 'diff';
@import 'reference';
@import 'flags';
@import 'tooltip';
12 changes: 12 additions & 0 deletions src/sdg/scss/components/_tooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import 'tippy.js/dist/tippy.css';
@import 'tippy.js/animations/scale.css';
@import 'colors';


.tippy-box {
background-color: $color_primary_darker;
}

.tippy-arrow {
color: $color_primary_darker;
}
2 changes: 1 addition & 1 deletion src/sdg/templates/account/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{% block head_title %}{% endblock head_title %} | SDG invoervoorziening{% endblock title %}
{% block main_container %}{% endblock %}
{% block extra_css %}
<script defer src="{% static 'bundles/fontawesome.js' %}"></script>
<script src="{% static 'bundles/fontawesome.js' %}"></script>
{% endblock %}

{% block outer_content %}
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

{% block extrahead %}
{{ block.super }}
<script src="{% static 'bundles/fontawesome.js' %}"></script>
<script defer src="{% static 'bundles/sdg-js.js' %}"></script>
<script defer src="{% static 'bundles/fontawesome.js' %}"></script>
{% endblock %}

{% block branding %}
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/core/base_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block title %}{% block head_title %}{% endblock head_title %} | SDG{% endblock title %}

{% block extra_css %}
<script defer src="{% static 'bundles/fontawesome.js' %}"></script>
<script src="{% static 'bundles/fontawesome.js' %}"></script>
{% endblock %}

{% block outer_content %}
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@

{% block extra_js %}
{% endblock %}
<script src="{% static 'bundles/sdg-js.js' %}"></script>
<script defer src="{% static 'bundles/sdg-js.js' %}"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/sdg/templates/producten/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
{% block title %}SDG | {% trans "Producten" %}{% endblock %}
{% block notifications %}{% endblock %}
{% block extra_css %}
<script defer src="{% static 'bundles/fontawesome.js' %}"></script>
<script src="{% static 'bundles/fontawesome.js' %}"></script>
{% endblock %}

0 comments on commit 63e8cc4

Please sign in to comment.