Skip to content

Commit

Permalink
feat: create table add comfirm modal (#15)
Browse files Browse the repository at this point in the history
* feat: create table add comfirm modal

* chore(syncpack): format and sync package.json files

Co-authored-by: github-actions[bot] <github-actions@github.com>
  • Loading branch information
nichenqin and github-actions[bot] committed Nov 23, 2022
1 parent 58fffe6 commit 0d108b8
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 51 deletions.
30 changes: 27 additions & 3 deletions apps/web/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
Divider,
Alert,
IconAlertCircle,
openConfirmModal,
Text,
} from '@egodb/ui'
import { createTableCommandInput, type ICreateTableInput } from '@egodb/core'
import { trpc } from '../trpc'
Expand All @@ -39,6 +41,26 @@ export default function App() {
createTable.mutate(values)
})

const closeModal = () => {
form.reset()
createTable.reset()
toggle(false)
}

const openModal = () =>
openConfirmModal({
target: 'body',
title: 'Please confirm your action',
children: <Text size="sm">You have unsaved changes. Do you really want to close the panel?</Text>,
labels: { confirm: 'Confirm', cancel: 'Cancel' },
confirmProps: { color: 'red' },
onConfirm: closeModal,
overlayColor: theme.colorScheme === 'dark' ? theme.colors.dark[9] : theme.colors.gray[2],
overlayOpacity: 0.55,
overlayBlur: 3,
centered: true,
})

return (
<>
<AppShell
Expand Down Expand Up @@ -71,9 +93,11 @@ export default function App() {
<Drawer
opened={opened}
onClose={() => {
form.reset()
createTable.reset()
toggle(false)
if (form.isDirty()) {
openModal()
} else {
closeModal()
}
}}
title="New Table"
padding="xl"
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/emotion.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { CacheProvider, EgoUIProvider, useEmotionCache } from '@egodb/ui'
import { CacheProvider, EgoUIProvider, ModalsProvider, useEmotionCache } from '@egodb/ui'
import { useServerInsertedHTML } from 'next/navigation'

export default function RootStyleRegistry({ children }: { children: React.ReactNode }) {
Expand All @@ -20,7 +20,7 @@ export default function RootStyleRegistry({ children }: { children: React.ReactN
return (
<CacheProvider value={cache}>
<EgoUIProvider withGlobalStyles withNormalizeCSS>
{children}
<ModalsProvider>{children}</ModalsProvider>
</EgoUIProvider>
</CacheProvider>
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"commitizen": "^4.2.5",
"cz-conventional-changelog": "^3.3.0",
"husky": "^8.0.2",
"prettier": "^2.7.1",
"prettier": "^2.8.0",
"syncpack": "^8.3.9",
"turbo": "^1.6.3"
},
Expand Down
1 change: 1 addition & 0 deletions packages/ui/Typography.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Text } from '@mantine/core'
2 changes: 2 additions & 0 deletions packages/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export * from './AppShell'
export * from './Divider'
export * from './Provider'
export * from './Inputs'
export * from './Typography'

export * from './hooks'
export * from './theme'
export * from './Form'
export * from './notification'
export * from './modal'
1 change: 1 addition & 0 deletions packages/ui/modal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ModalsProvider, openConfirmModal } from '@mantine/modals'
11 changes: 6 additions & 5 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"@babel/core": "^7.20.2",
"@emotion/react": "^11.10.5",
"@emotion/server": "^11.10.0",
"@mantine/core": "^5.8.2",
"@mantine/form": "^5.8.2",
"@mantine/hooks": "^5.8.2",
"@mantine/next": "^5.8.2",
"@mantine/notifications": "^5.8.2",
"@mantine/core": "^5.8.3",
"@mantine/form": "^5.8.3",
"@mantine/hooks": "^5.8.3",
"@mantine/modals": "^5.8.3",
"@mantine/next": "^5.8.3",
"@mantine/notifications": "^5.8.3",
"@tabler/icons": "^1.112.0",
"react-dom": "^18.2.0"
},
Expand Down
101 changes: 61 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d108b8

Please sign in to comment.