forked from bernaferrari/FigmaToCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericSolidColorSection.svelte
More file actions
66 lines (57 loc) · 1.92 KB
/
Copy pathGenericSolidColorSection.svelte
File metadata and controls
66 lines (57 loc) · 1.92 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
<script>
import { createEventDispatcher } from "svelte";
import { onDestroy } from "svelte";
import SimpleItemColor from "./TailwindItemColor.svelte";
import TailwindItemColor from "./TailwindItemColor.svelte";
import FlutterItemColor from "./FlutterItemColor.svelte";
const dispatch = createEventDispatcher();
const clipboard = data => dispatch("clipboard", { text: data });
export let sectionStyle;
export let type;
let colorsData = [];
$: colorsObservable = colorsData;
function handleMessage(event) {
console.log("handleMessage solidSection got", event.data);
if (!event.data.pluginMessage) {
return;
}
if (event.data.pluginMessage.type === "colors") {
colorsData = event.data.pluginMessage.data;
}
}
addEventListener("message", handleMessage);
onDestroy(() => {
removeEventListener("message", handleMessage);
});
</script>
{#if colorsObservable.length > 0}
<div
class="flex flex-col space-y-2 items-center w-full p-2 mb-2 {sectionStyle}">
<div class="flex flex-wrap w-full">
<div class="{type === 'flutter' ? 'w-1/2' : 'w-1/3'} p-1">
<div
class="flex items-center justify-center w-full h-full bg-gray-200
rounded-lg">
<p class="text-xl font-semibold">Colors</p>
</div>
</div>
{#each colorsObservable as item}
{#if type === 'html' || type === 'swiftui'}
<div class="w-1/3 p-1">
<SimpleItemColor {...item} on:clipboard={clipboard(item.exported)} />
</div>
{/if}
{#if type === 'tailwind'}
<div class="w-1/3 p-1">
<TailwindItemColor {...item} on:clipboard={clipboard(item.exported)} />
</div>
{/if}
{#if type === 'flutter'}
<div class="w-1/2 p-1">
<FlutterItemColor {...item} on:clipboard={clipboard(item.exported)} />
</div>
{/if}
{/each}
</div>
</div>
{/if}