-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
154 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { DocSectionCode } from '@/components/doc/common/docsectioncode'; | ||
import { DocSectionText } from '@/components/doc/common/docsectiontext'; | ||
import { Button } from '@/components/lib/button/Button'; | ||
import { ConfirmDialog } from '@/components/lib/confirmdialog/ConfirmDialog'; | ||
import { Toast } from '@/components/lib/toast/Toast'; | ||
import { useRef, useState } from 'react'; | ||
|
||
export function ResponsiveDoc(props) { | ||
const [visible, setVisible] = useState(false); | ||
const toast = useRef(null); | ||
|
||
const accept = () => { | ||
toast.current.show({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 }); | ||
}; | ||
|
||
const reject = () => { | ||
toast.current.show({ severity: 'warn', summary: 'Rejected', detail: 'You have rejected', life: 3000 }); | ||
}; | ||
|
||
const code = { | ||
basic: ` | ||
<Toast ref={toast} /> | ||
<ConfirmDialog | ||
group="declarative" | ||
visible={visible} | ||
onHide={() => setVisible(false)} | ||
message="Are you sure you want to proceed?" | ||
header="Confirmation" | ||
icon="pi pi-exclamation-triangle" | ||
accept={accept} | ||
reject={reject} | ||
style={{ width: '50vw' }} | ||
breakpoints={{ '1100px': '75vw', '960px': '100vw' }} | ||
/> | ||
<Button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" /> | ||
`, | ||
javascript: ` | ||
import React, { useState, useRef } from 'react'; | ||
import { ConfirmDialog, confirmDialog } from 'primereact/confirmdialog'; | ||
import { Toast } from 'primereact/toast'; | ||
import { Button } from 'primereact/button'; | ||
export default function DeclarativeDemo() { | ||
const [visible, setVisible] = useState(false); | ||
const toast = useRef(null); | ||
const accept = () => { | ||
toast.current.show({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 }); | ||
} | ||
const reject = () => { | ||
toast.current.show({ severity: 'warn', summary: 'Rejected', detail: 'You have rejected', life: 3000 }); | ||
} | ||
return ( | ||
<> | ||
<Toast ref={toast} /> | ||
<ConfirmDialog | ||
group="declarative" | ||
visible={visible} | ||
onHide={() => setVisible(false)} | ||
message="Are you sure you want to proceed?" | ||
header="Confirmation" | ||
icon="pi pi-exclamation-triangle" | ||
accept={accept} | ||
reject={reject} | ||
style={{ width: '50vw' }} | ||
breakpoints={{ '1100px': '75vw', '960px': '100vw' }} | ||
/> | ||
<div className="card flex justify-content-center"> | ||
<Button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" /> | ||
</div> | ||
</> | ||
) | ||
} | ||
`, | ||
typescript: ` | ||
import React, { useState, useRef } from 'react'; | ||
import { ConfirmDialog, confirmDialog } from 'primereact/confirmdialog'; | ||
import { Toast } from 'primereact/toast'; | ||
import { Button } from 'primefaces/button'; | ||
export default function DeclarativeDemo() { | ||
const [visible, setVisible] = useState<boolean>(false); | ||
const toast = useRef<Toast>(null); | ||
const accept = () => { | ||
toast.current?.show({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 }); | ||
} | ||
const reject = () => { | ||
toast.current?.show({ severity: 'warn', summary: 'Rejected', detail: 'You have rejected', life: 3000 }); | ||
} | ||
return ( | ||
<> | ||
<Toast ref={toast} /> | ||
<ConfirmDialog | ||
group="declarative" | ||
visible={visible} | ||
onHide={() => setVisible(false)} | ||
message="Are you sure you want to proceed?" | ||
header="Confirmation" | ||
icon="pi pi-exclamation-triangle" | ||
accept={accept} | ||
reject={reject} | ||
style={{ width: '50vw' }} | ||
breakpoints={{ '1100px': '75vw', '960px': '100vw' }} | ||
/> | ||
<div className="card flex justify-content-center"> | ||
<Button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" /> | ||
</div> | ||
</> | ||
) | ||
} | ||
` | ||
}; | ||
|
||
return ( | ||
<> | ||
<DocSectionText {...props}> | ||
<p> | ||
ConfirmDialog width can be adjusted per screen size with the breakpoints option where a key defines the max-width for the breakpoint and value for the corresponding width. When no breakpoint matches width defined in style property | ||
is used. | ||
</p> | ||
</DocSectionText> | ||
<Toast ref={toast} /> | ||
<ConfirmDialog | ||
group="declarative" | ||
visible={visible} | ||
onHide={() => setVisible(false)} | ||
message="Are you sure you want to proceed?" | ||
header="Confirmation" | ||
icon="pi pi-exclamation-triangle" | ||
accept={accept} | ||
reject={reject} | ||
style={{ width: '50vw' }} | ||
breakpoints={{ '1100px': '75vw', '960px': '100vw' }} | ||
/> | ||
<div className="card flex justify-content-center"> | ||
<Button onClick={() => setVisible(true)} icon="pi pi-check" label="Confirm" /> | ||
</div> | ||
<DocSectionCode code={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