-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.tsx
More file actions
179 lines (169 loc) · 4.58 KB
/
code.tsx
File metadata and controls
179 lines (169 loc) · 4.58 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
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
/// <reference types="@figma/widget-typings" />
const { widget } = figma;
const { useSyncedState, usePropertyMenu, AutoLayout, Text: WidgetText } = widget;
// Role presets
const rolePresets = {
'design': {
text: 'Design',
color: '#8b5cf6'
},
'copywriting': {
text: 'Copywriting',
color: '#06b6d4'
}
} as const;
// Status presets with enhanced colors and styling
const statusPresets = {
'in-progress': {
text: '🚧 In Progress',
backgroundColor: '#FFC700',
textColor: '#642000',
borderColor: '#e4b404'
},
'review': {
text: '🔍 Ready for Review',
backgroundColor: '#0060D0',
textColor: '#ffffff',
borderColor: '#2e6dd2'
},
'approved': {
text: '✅ Approved',
backgroundColor: '#437C16',
textColor: '#ffffff',
borderColor: '#396c12'
},
'not-started': {
text: 'Not Started',
backgroundColor: '#C2C1BB',
textColor: '#000000',
borderColor: '#a5aab2'
}
} as const;
type RoleKey = keyof typeof rolePresets;
type StatusKey = keyof typeof statusPresets;
function DesignStatusChip() {
// Synced state for the current role and status
const [currentRole, setCurrentRole] = useSyncedState('currentRole', 'design' as RoleKey);
const [currentStatus, setCurrentStatus] = useSyncedState('currentStatus', 'in-progress' as StatusKey);
// Property menu for changing role and status
usePropertyMenu(
[
{
itemType: 'dropdown',
propertyName: 'role',
tooltip: 'Change role',
selectedOption: currentRole,
options: [
{ option: 'design', label: 'Design' },
{ option: 'copywriting', label: 'Copywriting' }
]
},
{
itemType: 'separator'
},
{
itemType: 'dropdown',
propertyName: 'status',
tooltip: 'Change status',
selectedOption: currentStatus,
options: [
{ option: 'not-started', label: 'Not Started' },
{ option: 'in-progress', label: 'In Progress' },
{ option: 'review', label: 'Ready for Review' },
{ option: 'approved', label: 'Approved' }
]
}
],
(event) => {
if (event.propertyName === 'role') {
setCurrentRole(event.propertyValue as RoleKey);
} else if (event.propertyName === 'status') {
setCurrentStatus(event.propertyValue as StatusKey);
}
}
);
// Get current presets
const rolePreset = rolePresets[currentRole];
const statusPreset = statusPresets[currentStatus];
return (
<AutoLayout
direction="horizontal"
horizontalAlignItems="center"
verticalAlignItems="center"
padding={0}
cornerRadius={20}
fill={statusPreset.backgroundColor}
stroke={statusPreset.borderColor}
strokeWidth={1}
spacing={0}
width="hug-contents"
height={36}
effect={[
{
type: 'drop-shadow',
color: '#00000015',
offset: { x: 0, y: 2 },
blur: 8,
spread: 0
},
{
type: 'drop-shadow',
color: '#00000008',
offset: { x: 0, y: 1 },
blur: 3,
spread: 0
}
]}
>
{/* Left Half - Role */}
<AutoLayout
direction="horizontal"
horizontalAlignItems="center"
verticalAlignItems="center"
padding={{ left: 16, right: 12, bottom:10, top: 10 }}
cornerRadius={{ topLeft: 20, topRight: 0, bottomLeft: 20, bottomRight: 0 }}
fill={{
type: 'solid',
color: { r: 1, g: 1, b: 1, a: 0.2 }
}}
spacing={0}
width="hug-contents"
height="fill-parent"
>
<WidgetText
fontSize={13}
fontWeight={600}
fill={statusPreset.textColor}
fontFamily="Inter"
>
{rolePreset.text}
</WidgetText>
</AutoLayout>
{/* Right Half - Status */}
<AutoLayout
direction="horizontal"
horizontalAlignItems="center"
verticalAlignItems="center"
padding={{ left: 12, right: 16, bottom:10, top: 10 }}
cornerRadius={{ topLeft: 0, topRight: 20, bottomLeft: 0, bottomRight: 20 }}
fill={{
type: 'solid',
color: { r: 0, g: 0, b: 0, a: 0 }
}}
spacing={0}
width="hug-contents"
height="fill-parent"
>
<WidgetText
fontSize={13}
fontWeight={600}
fill={statusPreset.textColor}
fontFamily="Inter"
>
{statusPreset.text}
</WidgetText>
</AutoLayout>
</AutoLayout>
);
}
widget.register(DesignStatusChip);