Skip to content

Commit 9062095

Browse files
authored
figma-inspector: added em dash to the sanitizers (#8320)
1 parent e56e606 commit 9062095

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

tools/figma-inspector/backend/utils/export-variables.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function formatStructName(name: string): string {
4040
.replace(/,\s*/g, "-") // Replace commas (and following spaces) with hyphens
4141
.replace(/\+/g, "-") // Replace + with hyphens (add this line)
4242
.replace(/\:/g, "-") // Replace : with ""
43+
.replace(//g, "-") // Replace em dash hyphens
4344
.replace(/([a-z])([A-Z])/g, "$1-$2") // Add hyphens between camelCase
4445
.replace(/\s+/g, "-") // Convert spaces to hyphens
4546
.replace(/--+/g, "-") // Normalize multiple consecutive hyphens to single
@@ -65,6 +66,7 @@ export function sanitizePropertyName(name: string): string {
6566
.replace(/&/g, "and") // Replace &
6667
.replace(/\(/g, "_") // Replace ( with _
6768
.replace(/\)/g, "_") // Replace ) with _
69+
.replace(//g, "_") // Replace em dash with underscore
6870
.replace(/[^a-zA-Z0-9_]/g, "_") // Replace other invalid chars (including -, +, :, etc.) with _
6971
.replace(/__+/g, "_"); // Collapse multiple underscores
7072

tools/figma-inspector/src/main.tsx

+41-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getColorTheme, subscribeColorTheme } from "./utils/bolt-utils";
66
import CodeSnippet from "./components/snippet/CodeSnippet";
77
import { ExportType, useInspectorStore } from "./utils/store";
88
import DialogFrame from "./components/DialogFrame.js";
9-
import { Button, Checkbox, DropdownMenu, Text } from "figma-kit";
9+
import { Text, Button, Checkbox, DropdownMenu } from "figma-kit";
1010
import "./main.css";
1111

1212
export const App = () => {
@@ -102,40 +102,63 @@ export const App = () => {
102102
/>
103103
</DialogFrame.Content>
104104
<DialogFrame.Footer>
105-
<div className="border border-secondary border-[var(--figma-color-bg-brand)]">
106-
<Text className="text-[var(--figma-color-bg-brand)]">
107-
Welcome to Figma
108-
</Text>
109-
</div>
105+
<Checkbox.Root>
106+
<Checkbox.Input
107+
checked={useVariables}
108+
onChange={(e) => setUseVariables(e.target.checked)}
109+
/>
110+
<Checkbox.Label>Use Figma Variables</Checkbox.Label>
111+
</Checkbox.Root>
112+
110113
<DropdownMenu.Root>
111114
<DropdownMenu.Trigger asChild>
112-
<Button>Export</Button>
115+
<Button
116+
variant={
117+
exportsAreCurrent ? "secondary" : "primary"
118+
}
119+
style={{
120+
visibility: useVariables
121+
? "visible"
122+
: "hidden",
123+
}}
124+
>
125+
Export
126+
</Button>
113127
</DropdownMenu.Trigger>
114-
<DropdownMenu.Content style={{}}>
128+
<DropdownMenu.Content>
115129
<DropdownMenu.Item
116130
onClick={() =>
117131
exportFiles(ExportType.SeparateFiles)
118132
}
119133
>
120-
Separate Files…
134+
Separate Files Per Collection
121135
</DropdownMenu.Item>
122136
<DropdownMenu.Item
123137
onClick={() =>
124138
exportFiles(ExportType.SingleFile)
125139
}
126140
>
127-
Single File…
141+
Singl Design-Tokens File…
128142
</DropdownMenu.Item>
129143
</DropdownMenu.Content>
130144
</DropdownMenu.Root>
131-
132-
<Checkbox.Root>
133-
<Checkbox.Input
134-
checked={useVariables}
135-
onChange={(e) => setUseVariables(e.target.checked)}
136-
/>
137-
<Checkbox.Label>Use Figma Variables</Checkbox.Label>
138-
</Checkbox.Root>
145+
<Text
146+
style={{
147+
color: exportsAreCurrent
148+
? "var(--figma-color-text-disabled)"
149+
: "var(--figma-color-text-primary",
150+
}}
151+
>
152+
{useVariables ? (
153+
exportsAreCurrent ? (
154+
<em>Exports are current</em>
155+
) : (
156+
"Either variables have changed or no export found"
157+
)
158+
) : (
159+
""
160+
)}
161+
</Text>
139162
</DialogFrame.Footer>
140163
</DialogFrame>
141164
</>

0 commit comments

Comments
 (0)