Skip to content

Commit 630c41c

Browse files
committed
fix: add initial html and fix styling
1 parent accd883 commit 630c41c

3 files changed

Lines changed: 63 additions & 28 deletions

File tree

plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public String getNoDescriptionHtml() {
9494
return html;
9595
}
9696

97-
public String replaceCssVariables(String html, String ideScript) {
97+
public String replaceCssVariablesAndScript(String html, String ideScript) {
9898
html = replaceCssVariables(html);
9999
html = html.replace("${ideScript}", ideScript);
100100

@@ -114,9 +114,8 @@ public String replaceCssVariables(String html) {
114114
html = html.replace("var(--text-color)",
115115
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR", "#000000"));
116116

117-
// html = html.replace("var(--ide-background-color)",
118-
// getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#FFFFFF"));
119-
html = html.replace("var(--ide-background-color)", "#2F2F2F");
117+
html = html.replace("var(--ide-background-color)",
118+
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START", "#FFFFFF"));
120119

121120
html = html.replace("var(--background-color)",
122121
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END", "#FFFFFF"));

plugin/src/main/java/io/snyk/eclipse/plugin/html/StaticPageHtmlProvider.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package io.snyk.eclipse.plugin.html;
22

3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.nio.charset.StandardCharsets;
6+
37
import org.eclipse.core.runtime.Platform;
48
import org.osgi.framework.Bundle;
59

@@ -149,30 +153,18 @@ public String getInitHtml() {
149153
return replaceCssVariables(html);
150154
}
151155

152-
// TODO update this when we got new design from Andy
153156
public String getSummaryInitHtml() {
154-
155-
var html = """
156-
<!DOCTYPE html>
157-
<html lang="en">
158-
<body>
159-
<div class="container">
160-
<h3 class="summary-header">SUMMARY</h3>
161-
<div class="snx-header">
162-
<div class="summary-row">
163-
<span class="icon">⚠️</span>
164-
<span class="text">312 issues found in your project</span>
165-
</div>
166-
<div class="summary-row">
167-
<span class="icon">⚡</span>
168-
<span class="text">183 issues are fixable</span>
169-
</div>
170-
171-
</div>
172-
</body>
173-
</html>
174-
""".formatted(head);
175-
return replaceCssVariables(html);
157+
String htmlContent = "";
158+
try {
159+
InputStream inputStream = getClass().getResourceAsStream("/ui/html/ScanSummaryInit.html");
160+
if (inputStream != null) {
161+
htmlContent = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
162+
inputStream.close();
163+
}
164+
} catch (IOException e) {
165+
e.printStackTrace();
166+
}
167+
return replaceCssVariables(htmlContent);
176168
}
177169

178170
public String ideScript() {
@@ -195,6 +187,6 @@ public String ideScript() {
195187
}
196188

197189
public String getFormattedSummaryHtml(String summary) {
198-
return replaceCssVariables(summary, ideScript());
190+
return replaceCssVariablesAndScript(summary, ideScript());
199191
}
200192
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
:root { font-size:10px; }
6+
p { font-size:1.3rem; margin: .8rem 0; }
7+
hr { margin: 2rem 0; }
8+
body { background-color:#212121; color: #ddd; font-family: sans-serif; }
9+
.snx-loader { display:inline-block; width: 12px; height: 12px; border: 2px solid rgba(125,125,125,.65); border-bottom-color: transparent; border-radius: 50%; margin-right:.8rem; animation: spin 1s linear infinite;
10+
}
11+
.size-s { width: 12px; height: 12px; border-width:2px }
12+
.size-m { width: 16px; height: 16px; border-width:3px; }
13+
.size-l { width: 24px; height: 24px; border-width:4px; }
14+
15+
@keyframes spin {
16+
from { transform: rotate(0deg); }
17+
to { transform: rotate(360deg); }
18+
}
19+
20+
.snx-h1 { font-size: 2rem; font-weight: 600; margin: .8rem 0; }
21+
.snx-h2 { font-size: 1.6rem; font-weight:400; margin: .4rem 0; }
22+
23+
.snx-status { display:flex; align-items:center; padding: .4rem 1.2rem; background-color: rgba(255,255,255,.1); border-radius: 1rem; }
24+
.is-dimmed { opacity:.75 }
25+
26+
.snx-header { display: flex; gap:1.6rem; }
27+
.snx-message { display: flex; align-items: center }
28+
.snx-highlight { display:inline-block; cursor:pointer; padding:0 .4rem; text-decoration: underline; font-weight:600 }
29+
strong.snx-highlight { text-decoration: none; cursor: unset; }
30+
</style>
31+
</head>
32+
<body>
33+
34+
<div class="snx-header">
35+
<h1 class="snx-title snx-h1">Snyk Security is loading...</h1>
36+
</div>
37+
<div class="snx-summary">
38+
<div class="snx-status">
39+
<span class="snx-loader size-s"></span>
40+
<p class="snx-message">Waiting for the Snyk CLI to be downloaded and the Language Server to be initialized. </p>
41+
</div>
42+
</div>
43+
</body>
44+
</html>

0 commit comments

Comments
 (0)