-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsidepanel.html
203 lines (184 loc) · 4.86 KB
/
sidepanel.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SVG Copilot - Convert SVG to PNG in Real-Time</title>
<style>
:root {
--bg-color: #ffffff;
--text-color: #000000;
--border-color: #cccccc;
--button-bg: #000000;
--button-text: #ffffff;
--button-hover: #333333;
--muted-text: #666666;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #1e1e1e;
--text-color: #ffffff;
--border-color: #555555;
--button-bg: #ffffff;
--button-text: #000000;
--button-hover: #cccccc;
--muted-text: #aaaaaa;
}
}
body,
html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
"Helvetica Neue", sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
display: flex;
flex-direction: column;
}
.container {
flex-grow: 1;
display: flex;
flex-direction: column;
padding: 20px;
box-sizing: border-box;
max-height: 100vh;
width: 100%;
max-width: 100%;
}
h1 {
font-size: 24px;
margin: 0 0 5px 0;
text-align: center;
}
.slogan {
font-size: 14px;
color: var(--muted-text);
margin: 0 0 15px 0;
}
h2 {
font-size: 18px;
margin: 10px 0 5px 0;
}
p {
margin: 0 0 5px 0;
}
.input-section {
flex: 0 0 auto;
margin-bottom: 10px;
width: 100%;
}
.output-section {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
width: 100%;
}
.output-row{
display: flex;
flex-direction: row;
justify-content: space-between;
background-color: whitesmoke;
}
textarea {
width: 100%;
height: 100px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid var(--border-color);
border-radius: 4px;
resize: none;
background-color: var(--bg-color);
color: var(--text-color);
box-sizing: border-box;
}
#preview {
flex-grow: 1;
border: 1px solid var(--border-color);
border-radius: 4px;
margin-bottom: 16px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: auto;
background-color: var(--bg-color);
width: 100%;
}
#preview canvas {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
/* 小巧的右上角按钮 */
#copyBtnPreview {
flex-direction: row;
position: absolute;
margin-top: 8px;
right: 28px;
width: 48px;
background-color: var(--button-bg);
color: var(--button-text);
border: none;
padding: 4px 10px;
border-radius: 4px; /* 圆角按钮 */
font-size: 12px;
display: none;
cursor: pointer;
z-index: 10; /* 确保按钮在最上方 */
}
#copyBtnPreview:hover {
background-color: var(--button-hover);
}
button {
background-color: var(--button-bg);
color: var(--button-text);
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
width: 100%;
}
button:hover {
background-color: var(--button-hover);
}
.footer {
text-align: center;
padding: 10px 0;
font-size: 12px;
color: var(--muted-text);
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h2>SVG Copilot</h2>
<p class="slogan">Immersive & Real-time conversion of SVG to PNG with preview and download!</p>
<div class="input-section">
<h2>Input</h2>
<p>Paste your SVG code or file here:</p>
<textarea id="svgInput" placeholder='Input code such as "<svg>...</svg>",You can also drag the SVG file to here.'></textarea>
</div>
<div class="output-section">
<h2>Output</h2>
<div id="output-row">
<p>PNG Preview:</p>
<!-- 新增的小按钮,默认隐藏 -->
<button id="copyBtnPreview">Copy</button>
</div>
<div id="preview"></div>
<button id="downloadBtn">Save as PNG</button>
</div>
</div>
<div class="footer">Powered by @银海</div>
<script src="sidepanel.js"></script>
</body>
</html>