-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a22ec3d
commit 10123ff
Showing
4 changed files
with
126 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/settings-ui/src/user-packs/dialogs/CreateWidgetPackDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogDescription, | ||
DialogFooter, | ||
Dialog, | ||
TextField, | ||
Button, | ||
} from '@glzr/components'; | ||
import { createForm, Field } from 'smorf'; | ||
|
||
export type CreateWidgetPackForm = { | ||
name: string; | ||
}; | ||
|
||
export interface CreateWidgetPackDialogProps { | ||
onSubmit: (pack: CreateWidgetPackForm) => void; | ||
} | ||
|
||
export function CreateWidgetPackDialog( | ||
props: CreateWidgetPackDialogProps, | ||
) { | ||
const packForm = createForm<CreateWidgetPackForm>({ | ||
name: '', | ||
}); | ||
|
||
return ( | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Create Widget Pack</DialogTitle> | ||
<DialogDescription> | ||
Enter a name for your new widget pack. | ||
</DialogDescription> | ||
</DialogHeader> | ||
|
||
<div class="p-4"> | ||
<Field of={packForm} path="name"> | ||
{inputProps => ( | ||
<TextField | ||
id="name" | ||
label="Pack Name" | ||
placeholder="Enter pack name..." | ||
{...inputProps()} | ||
/> | ||
)} | ||
</Field> | ||
</div> | ||
|
||
<DialogFooter> | ||
<Dialog.CloseButton> | ||
<Button variant="outline">Cancel</Button> | ||
</Dialog.CloseButton> | ||
|
||
<Dialog.CloseButton onClick={() => props.onSubmit(packForm.value)}> | ||
<Button disabled={!packForm.value.name.trim()}>Create</Button> | ||
</Dialog.CloseButton> | ||
</DialogFooter> | ||
</DialogContent> | ||
); | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/settings-ui/src/user-packs/dialogs/DeleteWidgetPackDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
AlertDialogContent, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogClose, | ||
AlertDialogAction, | ||
} from '@glzr/components'; | ||
|
||
import { WidgetPack } from '~/common'; | ||
|
||
export interface DeleteWidgetPackDialogProps { | ||
pack: WidgetPack; | ||
onDelete: (packId: string) => void; | ||
} | ||
|
||
export function DeleteWidgetPackDialog( | ||
props: DeleteWidgetPackDialogProps, | ||
) { | ||
return ( | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>Delete Widget Pack</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
Are you sure you want to delete "{props.pack.name}"? This action | ||
cannot be undone. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogClose>Cancel</AlertDialogClose> | ||
<AlertDialogAction | ||
onClick={() => props.onDelete(props.pack.id)} | ||
class="bg-red-500 hover:bg-red-600" | ||
> | ||
Delete | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
); | ||
} |