Files
PromptArch/fix_device_buttons.py

47 lines
2.2 KiB
Python

#!/usr/bin/env python3
fp = '/home/uroma/promptarch/components/AIAssist.tsx'
with open(fp, 'r') as f:
content = f.read()
changes = 0
# Fix 1: viewMode === preview -> viewMode === "preview"
old = 'viewMode === preview && ('
new = 'viewMode === "preview" && ('
if old in content:
content = content.replace(old, new, 1)
changes += 1
print('Fix 1: viewMode quote restored')
# Fix 2: className=flex -> className="flex"
old = 'className=flex items-center gap-1 mt-1.5'
new = 'className="flex items-center gap-1 mt-1.5"'
if old in content:
content = content.replace(old, new, 1)
changes += 1
print('Fix 2: className quote restored')
# Fix 3: Restore quotes in the device button className
# The issue is the className prop lost its opening quote and the string content lost quotes
old_btn_class = '''className={cn(
px-2 py-1 text-[9px] font-black uppercase rounded-md transition-all border,
deviceSize === size
? bg-blue-500 text-white border-blue-500 shadow-md
: text-blue-300/50 border-transparent hover:text-blue-200 hover:bg-blue-900/30
)}'''
new_btn_class = '''className={cn(
"px-2 py-1 text-[9px] font-black uppercase rounded-md transition-all border",
deviceSize === size
? "bg-blue-500 text-white border-blue-500 shadow-md"
: "text-blue-300/50 border-transparent hover:text-blue-200 hover:bg-blue-900/30"
)}'''
if old_btn_class in content:
content = content.replace(old_btn_class, new_btn_class, 1)
changes += 1
print('Fix 3: Button className quotes restored')
with open(fp, 'w') as f:
f.write(content)
print(f'Applied {changes}/3 fixes')