Skip to content

Commit

Permalink
Fix #3881: Dialog Doc Enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
habubey committed Jan 6, 2023
1 parent 9004970 commit 7417b32
Show file tree
Hide file tree
Showing 7 changed files with 453 additions and 169 deletions.
145 changes: 30 additions & 115 deletions components/doc/dialog/basicdoc.js

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions components/doc/dialog/footerdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { useState } from 'react';
import { Button } from '../../lib/button/Button';
import { Dialog } from '../../lib/dialog/Dialog';
import { DocSectionCode } from '../common/docsectioncode';
import { DocSectionText } from '../common/docsectiontext';

export function FooterDoc(props) {
const [displayBasic, setDisplayBasic] = useState(false);

const dialogFuncMap = {
displayBasic: setDisplayBasic
};

const onClick = (name, position) => {
dialogFuncMap[`${name}`](true);

if (position) {
setPosition(position);
}
};

const onHide = (name) => {
dialogFuncMap[`${name}`](false);
};

const renderFooter = (name) => {
return (
<div>
<Button label="No" icon="pi pi-times" onClick={() => onHide(name)} className="p-button-text" />
<Button label="Yes" icon="pi pi-check" onClick={() => onHide(name)} autoFocus />
</div>
);
};

const code = {
basic: `
<Button label="Show" icon="pi pi-external-link" onClick={() => onClick('displayBasic')} />
<Dialog header="Header" visible={displayBasic} style={{ width: '50vw' }} footer={renderFooter('displayBasic')} onHide={() => onHide('displayBasic')}>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</Dialog>
`,
javascript: `
import React, { useState } from "react";
import { Button } from 'primereact/button';
import { Dialog } from 'primereact/dialog';
export default function FooterDoc() {
const [displayBasic, setDisplayBasic] = useState(false);
const dialogFuncMap = {
displayBasic: setDisplayBasic,
};
const onClick = (name, position) => {
dialogFuncMap[\`\${name}\`](true);
if (position) {
setPosition(position);
}
};
const onHide = (name) => {
dialogFuncMap[\`\${name}\`](false);
};
const renderFooter = (name) => {
return (
<div>
<Button label="No" icon="pi pi-times" onClick={() => onHide(name)} className="p-button-text" />
<Button label="Yes" icon="pi pi-check" onClick={() => onHide(name)} autoFocus />
</div>
);
};
return (
<div className="card flex justify-content-center ">
<Button label="Show" icon="pi pi-external-link" onClick={() => onClick('displayBasic')} className="mr-2" />
<Dialog header="Header" visible={displayBasic} style={{ width: '50vw' }} footer={renderFooter('displayBasic')} onHide={() => onHide('displayBasic')}>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</Dialog>
</div>
)
}
`,
typescript: `
import React, { useState } from "react";
import { Button } from 'primereact/button';
import { Dialog } from 'primereact/dialog';
export default function FooterDoc() {
const [displayBasic, setDisplayBasic] = useState(false);
const dialogFuncMap = {
displayBasic: setDisplayBasic,
};
const onClick = (name, position) => {
dialogFuncMap[\`\${name}\`](true);
if (position) {
setPosition(position);
}
};
const onHide = (name) => {
dialogFuncMap[\`\${name}\`](false);
};
const renderFooter = (name) => {
return (
<div>
<Button label="No" icon="pi pi-times" onClick={() => onHide(name)} className="p-button-text" />
<Button label="Yes" icon="pi pi-check" onClick={() => onHide(name)} autoFocus />
</div>
);
};
return (
<div className="card flex justify-content-center ">
<Button label="Show" icon="pi pi-external-link" onClick={() => onClick('displayBasic')} className="mr-2" />
<Dialog header="Header" visible={displayBasic} style={{ width: '50vw' }} footer={renderFooter('displayBasic')} onHide={() => onHide('displayBasic')}>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</Dialog>
</div>
)
}
`
};

return (
<>
<DocSectionText {...props}>
{/* TO DO: Add demo content. */}
<p></p>
</DocSectionText>
<div className="card flex justify-content-center ">
<Button label="Show" icon="pi pi-external-link" onClick={() => onClick('displayBasic')} className="mr-2" />
<Dialog header="Header" visible={displayBasic} style={{ width: '50vw' }} footer={renderFooter('displayBasic')} onHide={() => onHide('displayBasic')}>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</Dialog>
</div>
<DocSectionCode code={code} />
</>
);
}
Loading

0 comments on commit 7417b32

Please sign in to comment.