Skip to content

Commit 75439de

Browse files
committed
remove redundant styles
1 parent af2c983 commit 75439de

3 files changed

Lines changed: 8 additions & 164 deletions

File tree

_includes/scripts/lib/copy-to-clipboard.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
(function() {
2-
// This script is built on clipboard.js, cf: https://clipboardjs.com/
3-
// 1. find all code blocks defined under snippet class
42
var snippets = document.querySelectorAll('pre');
53
[].forEach.call(snippets, function(snippet) {
64
if (snippet.closest('.snippet') !== null) {
@@ -20,12 +18,13 @@
2018
showTooltip(e.trigger, fallbackMessage(e.action));
2119
});
2220

23-
// 2. add event listener for all created copy button
2421
var btns = document.querySelectorAll('.btn');
2522
for (var i = 0; i < btns.length; i++) {
2623
btns[i].addEventListener('mouseleave', clearTooltip);
2724
btns[i].addEventListener('blur', clearTooltip);
28-
btns[i].addEventListener('mouseenter', showToolhint);
25+
btns[i].addEventListener('mouseenter', function(e) {
26+
showTooltip(e.currentTarget, "copy to clipboard")
27+
}, false);
2928
}
3029

3130
function clearTooltip(e) {
@@ -38,11 +37,6 @@
3837
elem.setAttribute('aria-label', msg);
3938
}
4039

41-
function showToolhint(e) {
42-
e.currentTarget.setAttribute('class', 'btn tooltipped tooltipped-s');
43-
e.currentTarget.setAttribute('aria-label', 'copy to clipboard');
44-
}
45-
4640
function fallbackMessage(action) {
4741
var actionMsg = '';
4842
var actionKey = (action === 'cut' ? 'X' : 'C');

_posts/2019-10-02-copy-to-clipboard.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

_sass/additional/_copy-to-clipboard.scss

Lines changed: 5 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*styles related to tooltips, borrowed from https://clipboardjs.com/bower_components/primer-css/css/primer.css*/
21
.tooltipped {
32
position: relative
43
}
@@ -8,7 +7,8 @@
87
z-index: 1000000;
98
display: none;
109
padding: 5px 8px;
11-
font: normal normal 11px/1.5 Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
10+
font: arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
11+
font-size: map-get($base, font-size-sm);
1212
color: #fff;
1313
text-align: center;
1414
text-decoration: none;
@@ -41,122 +41,26 @@
4141
text-decoration: none
4242
}
4343

44-
.tooltipped-multiline:hover:after, .tooltipped-multiline:active:after, .tooltipped-multiline:focus:after {
45-
display: table-cell
46-
}
47-
48-
.tooltipped-s:after, .tooltipped-se:after, .tooltipped-sw:after {
44+
.tooltipped-s:after {
4945
top: 100%;
5046
right: 50%;
5147
margin-top: 5px
5248
}
5349

54-
.tooltipped-s:before, .tooltipped-se:before, .tooltipped-sw:before {
50+
.tooltipped-s:before {
5551
top: auto;
5652
right: 50%;
5753
bottom: -5px;
5854
margin-right: -5px;
5955
border-bottom-color: rgba(0, 0, 0, .8)
6056
}
6157

62-
.tooltipped-se:after {
63-
right: auto;
64-
left: 50%;
65-
margin-left: -15px
66-
}
67-
68-
.tooltipped-sw:after {
69-
margin-right: -15px
70-
}
71-
72-
.tooltipped-n:after, .tooltipped-ne:after, .tooltipped-nw:after {
73-
right: 50%;
74-
bottom: 100%;
75-
margin-bottom: 5px
76-
}
77-
78-
.tooltipped-n:before, .tooltipped-ne:before, .tooltipped-nw:before {
79-
top: -5px;
80-
right: 50%;
81-
bottom: auto;
82-
margin-right: -5px;
83-
border-top-color: rgba(0, 0, 0, .8)
84-
}
85-
86-
.tooltipped-ne:after {
87-
right: auto;
88-
left: 50%;
89-
margin-left: -15px
90-
}
91-
92-
.tooltipped-nw:after {
93-
margin-right: -15px
94-
}
95-
96-
.tooltipped-s:after, .tooltipped-n:after {
58+
.tooltipped-s:after {
9759
-webkit-transform: translateX(50%);
9860
-ms-transform: translateX(50%);
9961
transform: translateX(50%)
10062
}
10163

102-
.tooltipped-w:after {
103-
right: 100%;
104-
bottom: 50%;
105-
margin-right: 5px;
106-
-webkit-transform: translateY(50%);
107-
-ms-transform: translateY(50%);
108-
transform: translateY(50%)
109-
}
110-
111-
.tooltipped-w:before {
112-
top: 50%;
113-
bottom: 50%;
114-
left: -5px;
115-
margin-top: -5px;
116-
border-left-color: rgba(0, 0, 0, .8)
117-
}
118-
119-
.tooltipped-e:after {
120-
bottom: 50%;
121-
left: 100%;
122-
margin-left: 5px;
123-
-webkit-transform: translateY(50%);
124-
-ms-transform: translateY(50%);
125-
transform: translateY(50%)
126-
}
127-
128-
.tooltipped-e:before {
129-
top: 50%;
130-
right: -5px;
131-
bottom: 50%;
132-
margin-top: -5px;
133-
border-right-color: rgba(0, 0, 0, .8)
134-
}
135-
136-
.tooltipped-multiline:after {
137-
width: -webkit-max-content;
138-
width: -moz-max-content;
139-
width: max-content;
140-
max-width: 250px;
141-
word-break: break-word;
142-
word-wrap: normal;
143-
white-space: pre-line;
144-
border-collapse: separate
145-
}
146-
147-
.tooltipped-multiline.tooltipped-s:after, .tooltipped-multiline.tooltipped-n:after {
148-
right: auto;
149-
left: 50%;
150-
-webkit-transform: translateX(-50%);
151-
-ms-transform: translateX(-50%);
152-
transform: translateX(-50%)
153-
}
154-
155-
.tooltipped-multiline.tooltipped-w:after, .tooltipped-multiline.tooltipped-e:after {
156-
right: 100%
157-
}
158-
159-
/*styles related to snippet copy to clipboard, borrowed from https://clipboardjs.com/assets/styles/main.css*/
16064
.clippy {
16165
margin-top: -3px;
16266
position: relative;

0 commit comments

Comments
 (0)