-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
812caff
commit 5b0c435
Showing
4 changed files
with
95 additions
and
4 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
70 changes: 70 additions & 0 deletions
70
packages/@docs/demos/src/demos/modals/Modals.demo.textInput.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,70 @@ | ||
import { Button, Text } from '@mantine/core'; | ||
import { modals } from '@mantine/modals'; | ||
import { notifications } from '@mantine/notifications'; | ||
import { MantineDemo } from '@mantinex/demo'; | ||
|
||
const code = ` | ||
import { Button, Text } from '@mantine/core'; | ||
import { modals } from '@mantine/modals'; | ||
function Demo() { | ||
const openModal = () => | ||
modals.openTextInputModal({ | ||
modalId: 'test-id', | ||
title: 'Please enter your name', | ||
children: ( | ||
<Text size="sm"> | ||
Children are rendered above the input field. | ||
</Text> | ||
), | ||
bottomSection: ( | ||
<Text size="sm"> | ||
But you can still render content below it. | ||
</Text> | ||
), | ||
onCancel: () => console.log('Cancel'), | ||
onConfirm: (value) => console.log(\`Confirm with value \${value}\`), | ||
}); | ||
return <Button onClick={openModal}>Open text input modal</Button>; | ||
} | ||
`; | ||
|
||
function Demo() { | ||
const openModal = () => | ||
modals.openTextInputModal({ | ||
modalId: 'test-id', | ||
title: 'Please enter your name', | ||
topSection: ( | ||
<Text size="sm"> | ||
Top section is rendered here. | ||
</Text> | ||
), | ||
bottomSection: ( | ||
<Text size="sm"> | ||
Bottom section is rendered here. | ||
</Text> | ||
), | ||
onCancel: () => | ||
notifications.show({ | ||
title: 'Canceled', | ||
message: 'TextInput modal was canceled', | ||
color: 'gray', | ||
}), | ||
onConfirm: (value) => | ||
notifications.show({ | ||
title: 'Confirmed', | ||
message: `TextInputModal was confirmed with input ${value}`, | ||
color: 'teal', | ||
}), | ||
}); | ||
|
||
return <Button onClick={openModal}>Open text input modal</Button>; | ||
} | ||
|
||
export const textInput: MantineDemo = { | ||
type: 'code', | ||
centered: true, | ||
component: Demo, | ||
code, | ||
}; |
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