-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.html
More file actions
79 lines (72 loc) · 2.38 KB
/
Copy pathui.html
File metadata and controls
79 lines (72 loc) · 2.38 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image to Figma Design(Beta)</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
width: 300px;
}
h2 {
font-size: 24px;
margin-bottom: 20px;
}
input[type="file"] {
margin: 10px 0;
}
button {
background-color: #007bff;
color: white;
border: none;
padding: 10px 15px;
cursor: pointer;
width: 100%;
border-radius: 4px;
}
button:hover {
background-color: #0056b3;
}
img {
max-width: 100%;
margin: 10px 0;
}
</style>
</head>
<body>
<h2>Image to Figma Design</h2>
<input type="file" id="imageInput" accept="image/png" />
<button id="create">Create Design</button>
<button id="change">Change Image</button>
<div id="output"></div>
<script>
document.getElementById('create').onclick = () => {
const imageInput = document.getElementById('imageInput');
const outputDiv = document.getElementById('output');
if (imageInput.files.length === 0) {
outputDiv.innerHTML = "<p>Please select a PNG image file.</p>";
return;
}
const file = imageInput.files[0];
const reader = new FileReader();
reader.onload = function(event) {
const imgElement = document.createElement('img');
imgElement.src = event.target.result;
outputDiv.innerHTML = ''; // Clear previous output
outputDiv.appendChild(imgElement);
// Log the base64 data
console.log("Base64 Image Data:", event.target.result);
// Send the image data to Figma
parent.postMessage({ pluginMessage: { type: 'create-image', base64: event.target.result } }, '*');
};
reader.readAsDataURL(file);
};
document.getElementById('change').onclick = () => {
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = ''; // Clear previous output
};
</script>
</body>
</html>