From 0bab962337db6fc6e3c87db39cb84e29d406e142 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 26 Feb 2022 17:05:30 -0500 Subject: [PATCH] Add underlying design component for a dialog --- .../admin/users/UsersContainerV2.tsx | 42 +++++-- .../components/elements/button/Button.tsx | 36 ++++++ .../elements/button/button.module.css | 30 +++++ .../components/elements/button/index.ts | 2 + .../components/elements/dialog/Dialog.tsx | 116 ++++++++++++++++++ .../elements/dialog/dialog.module.css | 7 ++ .../components/elements/dialog/index.ts | 2 + .../components/elements/dropdown/Dropdown.tsx | 2 +- .../elements/dropdown/DropdownButton.tsx | 2 +- .../elements/dropdown/DropdownItem.tsx | 2 +- ...{styles.module.css => dropdown.module.css} | 0 .../components/elements/dropdown/index.ts | 2 +- tailwind.config.js | 8 +- 13 files changed, 233 insertions(+), 18 deletions(-) create mode 100644 resources/scripts/components/elements/button/Button.tsx create mode 100644 resources/scripts/components/elements/button/button.module.css create mode 100644 resources/scripts/components/elements/button/index.ts create mode 100644 resources/scripts/components/elements/dialog/Dialog.tsx create mode 100644 resources/scripts/components/elements/dialog/dialog.module.css create mode 100644 resources/scripts/components/elements/dialog/index.ts rename resources/scripts/components/elements/dropdown/{styles.module.css => dropdown.module.css} (100%) diff --git a/resources/scripts/components/admin/users/UsersContainerV2.tsx b/resources/scripts/components/admin/users/UsersContainerV2.tsx index 4010d301f..537b26c44 100644 --- a/resources/scripts/components/admin/users/UsersContainerV2.tsx +++ b/resources/scripts/components/admin/users/UsersContainerV2.tsx @@ -3,7 +3,16 @@ import http from '@/api/http'; import { User } from '@/api/admin/user'; import { AdminTransformers } from '@/api/admin/transformers'; import { Dropdown } from '@/components/elements/dropdown'; -import { DotsVerticalIcon, LockClosedIcon, PaperAirplaneIcon, PencilIcon, TrashIcon } from '@heroicons/react/solid'; +import { + DotsVerticalIcon, + LockClosedIcon, + PaperAirplaneIcon, + PencilIcon, + PlusIcon, + TrashIcon, +} from '@heroicons/react/solid'; +import { Button } from '@/components/elements/button/index'; +import { Dialog } from '@/components/elements/dialog'; const UsersContainerV2 = () => { const [ users, setUsers ] = useState([]); @@ -11,6 +20,8 @@ const UsersContainerV2 = () => { document.title = 'Admin | Users'; }, []); + const [ visible, setVisible ] = useState(false); + useEffect(() => { http.get('/api/application/users') .then(({ data }) => { @@ -20,8 +31,21 @@ const UsersContainerV2 = () => { }, []); return ( -
- +
+
+ +
+ setVisible(false)}> + + This account will be permanently deleted. + + setVisible(false)}>Cancel + Delete + + +
diff --git a/resources/scripts/components/elements/button/Button.tsx b/resources/scripts/components/elements/button/Button.tsx new file mode 100644 index 000000000..f3238beac --- /dev/null +++ b/resources/scripts/components/elements/button/Button.tsx @@ -0,0 +1,36 @@ +import React, { forwardRef } from 'react'; +import classNames from 'classnames'; +import styles from './button.module.css'; + +export type ButtonProps = JSX.IntrinsicElements['button'] & { + square?: boolean; + small?: boolean; +} + +const Button = forwardRef( + ({ children, square, small, className, ...rest }, ref) => { + return ( + + ); + }, +); + +const TextButton = forwardRef(({ className, ...props }, ref) => ( + // @ts-expect-error +
@@ -59,13 +83,13 @@ const UsersContainerV2 = () => { - + - }>Edit - }>Reset Password - }>Suspend - - } danger>Delete Account + }>Edit + }>Reset Password + }>Suspend + + } onClick={() => setVisible(true)} danger>Delete Account