infra: add linting and formatting for js projects (#230)
* wip * wip * wip * format * wip(mobile): lint and format * cleanup * nits * nits * idiomatic react * nit * format all root files
This commit was merged in pull request #230.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, Text, TextInput, View } from "react-native";
|
||||
import { toast } from "sonner-native";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { toUserMessage } from "@/lib/errors";
|
||||
import { editTextParticleContent } from "@/lib/firestore-particles";
|
||||
import { particlePath, toFirestoreDocPath } from "@/lib/particle-path";
|
||||
import { useSuspendPlayback } from "@/hooks/use-suspend-playback";
|
||||
import { BottomSheet } from "@/components/BottomSheet";
|
||||
import { useState } from 'react';
|
||||
import { Pressable, Text, TextInput, View } from 'react-native';
|
||||
import { toast } from 'sonner-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { toUserMessage } from '@/lib/errors';
|
||||
import { editTextParticleContent } from '@/lib/firestore-particles';
|
||||
import { particlePath, toFirestoreDocPath } from '@/lib/particle-path';
|
||||
import { useSuspendPlayback } from '@/hooks/use-suspend-playback';
|
||||
import { BottomSheet } from '@/components/BottomSheet';
|
||||
|
||||
interface EditParticleSheetProps {
|
||||
open: boolean;
|
||||
@@ -25,17 +25,20 @@ export function EditParticleSheet({
|
||||
particleId,
|
||||
currentContent,
|
||||
}: EditParticleSheetProps) {
|
||||
useSuspendPlayback(open, "edit-particle");
|
||||
useSuspendPlayback(open, 'edit-particle');
|
||||
|
||||
const [content, setContent] = useState(currentContent);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Reset the editor each time the sheet opens fresh.
|
||||
const [prevOpen, setPrevOpen] = useState(open);
|
||||
if (open !== prevOpen) {
|
||||
setPrevOpen(open);
|
||||
if (open) {
|
||||
setContent(currentContent);
|
||||
setSaving(false);
|
||||
}
|
||||
}, [open, currentContent]);
|
||||
}
|
||||
|
||||
const trimmed = content.trim();
|
||||
const canSave = !saving && trimmed.length > 0 && trimmed !== currentContent;
|
||||
@@ -65,11 +68,11 @@ export function EditParticleSheet({
|
||||
<Pressable onPress={handleSave} disabled={!canSave} hitSlop={12}>
|
||||
<Text
|
||||
className={cn(
|
||||
"text-base font-semibold",
|
||||
canSave ? "text-white" : "text-white/30",
|
||||
'text-base font-semibold',
|
||||
canSave ? 'text-white' : 'text-white/30',
|
||||
)}
|
||||
>
|
||||
{saving ? "Saving..." : "Save"}
|
||||
{saving ? 'Saving...' : 'Save'}
|
||||
</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user