Skip to content

Commit

Permalink
Formatted code (#3572)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 4, 2022
1 parent b74e3ed commit 13f3f64
Show file tree
Hide file tree
Showing 42 changed files with 268 additions and 266 deletions.
22 changes: 12 additions & 10 deletions components/doc/checkbox/apidoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "next/link";
import { CodeHighlight } from "../common/codehighlight";
import { DevelopmentSection } from "../common/developmentsection";
import { DocSectionText } from "../common/docsectiontext";
import Link from 'next/link';
import { CodeHighlight } from '../common/codehighlight';
import { DevelopmentSection } from '../common/developmentsection';
import { DocSectionText } from '../common/docsectiontext';

export function ApiDoc(props) {
return (
Expand Down Expand Up @@ -155,7 +155,9 @@ export function ApiDoc(props) {
</div>

<h3>Styling</h3>
<p>Following is the list of structural style classes, for theming classes visit <Link href="/theming">theming</Link> page.</p>
<p>
Following is the list of structural style classes, for theming classes visit <Link href="/theming">theming</Link> page.
</p>
<div className="doc-tablewrapper">
<table className="doc-table">
<thead>
Expand Down Expand Up @@ -185,8 +187,8 @@ export function ApiDoc(props) {
<DevelopmentSection>
<h4>Screen Reader</h4>
<p>
Checkbox component uses a hidden native checkbox element internally that is only visible to screen readers. Value to describe the component can either be provided via <i>label</i> tag combined with <i>inputId</i> prop or
using <i>aria-labelledby</i>, <i>aria-label</i> props.
Checkbox component uses a hidden native checkbox element internally that is only visible to screen readers. Value to describe the component can either be provided via <i>label</i> tag combined with <i>inputId</i> prop or using{' '}
<i>aria-labelledby</i>, <i>aria-label</i> props.
</p>
<CodeHighlight>
{`
Expand Down Expand Up @@ -225,9 +227,9 @@ export function ApiDoc(props) {
</table>
</div>
</DevelopmentSection>

<h5>Dependencies</h5>
<p>None.</p>
</>
)
}
);
}
12 changes: 6 additions & 6 deletions components/doc/checkbox/basicdoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { Checkbox } from "../../lib/checkbox/Checkbox";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { Checkbox } from '../../lib/checkbox/Checkbox';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function BasicDoc(props) {
const [checked, setChecked] = useState(false);
Expand Down Expand Up @@ -42,9 +42,9 @@ export default function BasicDemo() {
Checkbox is used as a controlled input with <i>checked</i> and <i>onChange</i> properties.
</DocSectionText>
<div className="card flex justify-content-center">
<Checkbox onChange={e => setChecked(e.checked)} checked={checked}></Checkbox>
<Checkbox onChange={(e) => setChecked(e.checked)} checked={checked}></Checkbox>
</div>
<DocSectionCode code={code} />
</>
)
);
}
8 changes: 4 additions & 4 deletions components/doc/checkbox/disableddoc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Checkbox } from "../../lib/checkbox/Checkbox";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { Checkbox } from '../../lib/checkbox/Checkbox';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function DisabledDoc(props) {
const code = {
Expand Down Expand Up @@ -37,5 +37,5 @@ export default function DisabledDemo() {
</div>
<DocSectionCode code={code} />
</>
)
);
}
24 changes: 11 additions & 13 deletions components/doc/checkbox/dynamicdoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { Checkbox } from "../../lib/checkbox/Checkbox";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { Checkbox } from '../../lib/checkbox/Checkbox';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function DynamicDoc(props) {
const categories = [
Expand All @@ -15,10 +15,8 @@ export function DynamicDoc(props) {
const onCategoryChange = (e) => {
let _selectedCategories = [...selectedCategories];

if (e.checked)
_selectedCategories.push(e.value);
else
_selectedCategories = _selectedCategories.filter(category => category.key !== e.value.key);
if (e.checked) _selectedCategories.push(e.value);
else _selectedCategories = _selectedCategories.filter((category) => category.key !== e.value.key);

setSelectedCategories(_selectedCategories);
};
Expand Down Expand Up @@ -121,22 +119,22 @@ export default function DynamicDemo() {

return (
<>
<DocSectionText {...props}>
Checkboxes can be generated using a list of values.
</DocSectionText>
<DocSectionText {...props}>Checkboxes can be generated using a list of values.</DocSectionText>
<div className="card flex justify-content-center">
<div className="flex flex-column gap-3">
{categories.map((category) => {
return (
<div key={category.key} className="flex align-items-center">
<Checkbox inputId={category.key} name="category" value={category} onChange={onCategoryChange} checked={selectedCategories.some((item) => item.key === category.key)} />
<label htmlFor={category.key} className="ml-2">{category.name}</label>
<label htmlFor={category.key} className="ml-2">
{category.name}
</label>
</div>
);
})}
</div>
</div>
<DocSectionCode code={code} />
</>
)
);
}
38 changes: 21 additions & 17 deletions components/doc/checkbox/groupdoc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { useState } from "react";
import { Checkbox } from "../../lib/checkbox/Checkbox";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { Checkbox } from '../../lib/checkbox/Checkbox';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function GroupDoc(props) {
const [ingredients, setIngredients] = useState([]);

const onIngredientsChange = (e) => {
let _ingredients = [...ingredients];

if (e.checked)
_ingredients.push(e.value);
else
_ingredients.splice(_ingredients.indexOf(e.value), 1);
if (e.checked) _ingredients.push(e.value);
else _ingredients.splice(_ingredients.indexOf(e.value), 1);

setIngredients(_ingredients);
}
};

const code = {
basic: `
Expand Down Expand Up @@ -122,30 +120,36 @@ export default function GroupDemo() {

return (
<>
<DocSectionText {...props}>
Multiple checkboxes can be grouped together.
</DocSectionText>
<DocSectionText {...props}>Multiple checkboxes can be grouped together.</DocSectionText>
<div className="card flex justify-content-center">
<div className="flex flex-wrap gap-3">
<div className="flex align-items-center">
<Checkbox inputId="ingredient1" name="pizza" value="Cheese" onChange={onIngredientsChange} checked={ingredients.includes('Cheese')} />
<label htmlFor="ingredient1" className="ml-2">Cheese</label>
<label htmlFor="ingredient1" className="ml-2">
Cheese
</label>
</div>
<div className="flex align-items-center">
<Checkbox inputId="ingredient2" name="pizza" value="Mushroom" onChange={onIngredientsChange} checked={ingredients.includes('Mushroom')} />
<label htmlFor="ingredient2" className="ml-2">Mushroom</label>
<label htmlFor="ingredient2" className="ml-2">
Mushroom
</label>
</div>
<div className="flex align-items-center">
<Checkbox inputId="ingredient3" name="pizza" value="Pepper" onChange={onIngredientsChange} checked={ingredients.includes('Pepper')} />
<label htmlFor="ingredient3" className="ml-2">Pepper</label>
<label htmlFor="ingredient3" className="ml-2">
Pepper
</label>
</div>
<div className="flex align-items-center">
<Checkbox inputId="ingredient4" name="pizza" value="Onion" onChange={onIngredientsChange} checked={ingredients.includes('Onion')} />
<label htmlFor="ingredient4" className="ml-2">Onion</label>
<label htmlFor="ingredient4" className="ml-2">
Onion
</label>
</div>
</div>
</div>
<DocSectionCode code={code} />
</>
)
);
}
8 changes: 4 additions & 4 deletions components/doc/checkbox/importdoc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function ImportDoc(props) {
const code = {
Expand All @@ -13,5 +13,5 @@ import { Checkbox } from 'primereact/checkbox';
<DocSectionText {...props}></DocSectionText>
<DocSectionCode code={code} hideToggleCode hideCodeSandbox />
</>
)
}
);
}
20 changes: 10 additions & 10 deletions components/doc/common/docsectionnav.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export function DocSectionNav(props) {
return (
<div className="w-12rem px-3 hidden xl:block" style={{flexGrow: 0, flexShrink: 0, flexBasis: 'auto'}}>
<ul className="list-none p-0 m-0 sticky" style={{top: '7rem'}}>
{
props.docs.map(doc => (
<li key={doc.label}>
<button className="p-link block p-1 text-color hover:text-primary" onClick={() => document.getElementById(doc.id).parentElement.scrollIntoView({block: 'b', behavior: 'smooth'})}>{doc.label}</button>
</li>
))
}
<div className="w-12rem px-3 hidden xl:block" style={{ flexGrow: 0, flexShrink: 0, flexBasis: 'auto' }}>
<ul className="list-none p-0 m-0 sticky" style={{ top: '7rem' }}>
{props.docs.map((doc) => (
<li key={doc.label}>
<button className="p-link block p-1 text-color hover:text-primary" onClick={() => document.getElementById(doc.id).parentElement.scrollIntoView({ block: 'b', behavior: 'smooth' })}>
{doc.label}
</button>
</li>
))}
</ul>
</div>
)
);
}
8 changes: 4 additions & 4 deletions components/doc/common/docsectiontext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "next/link";
import { useRouter } from "next/router";
import Link from 'next/link';
import { useRouter } from 'next/router';

export function DocSectionText(props) {
const router = useRouter();
Expand All @@ -9,10 +9,10 @@ export function DocSectionText(props) {
<h2 className="doc-section-label">
{props.label}
<Link href={router.basePath + router.pathname + '#' + props.id} target="_self">
<a id={props.id} >#</a>
<a id={props.id}>#</a>
</Link>
</h2>
{props.children && <p class="doc-section-description">{props.children}</p>}
</>
);
}
}
18 changes: 9 additions & 9 deletions components/doc/inputswitch/apidoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "next/link";
import { CodeHighlight } from "../common/codehighlight";
import { DevelopmentSection } from "../common/developmentsection";
import { DocSectionText } from "../common/docsectiontext";
import Link from 'next/link';
import { CodeHighlight } from '../common/codehighlight';
import { DevelopmentSection } from '../common/developmentsection';
import { DocSectionText } from '../common/docsectiontext';

export function ApiDoc(props) {
return (
Expand Down Expand Up @@ -162,8 +162,8 @@ export function ApiDoc(props) {
<DevelopmentSection>
<h4>Screen Reader</h4>
<p>
InputSwitch component uses a hidden native checkbox element with <i>switch</i> role internally that is only visible to screen readers. Value to describe the component can either be provided via <i>label</i> tag combined
with <i>inputId</i> prop or using <i>aria-labelledby</i>, <i>aria-label</i> props.
InputSwitch component uses a hidden native checkbox element with <i>switch</i> role internally that is only visible to screen readers. Value to describe the component can either be provided via <i>label</i> tag combined with{' '}
<i>inputId</i> prop or using <i>aria-labelledby</i>, <i>aria-label</i> props.
</p>
<CodeHighlight>
{`
Expand Down Expand Up @@ -202,9 +202,9 @@ export function ApiDoc(props) {
</table>
</div>
</DevelopmentSection>

<h4>Dependencies</h4>
<p>None.</p>
</>
)
}
);
}
10 changes: 5 additions & 5 deletions components/doc/inputswitch/basicdoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { InputSwitch } from "../../lib/inputswitch/InputSwitch";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { InputSwitch } from '../../lib/inputswitch/InputSwitch';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function BasicDoc(props) {
const [checked, setChecked] = useState(false);
Expand Down Expand Up @@ -46,5 +46,5 @@ export default function BasicDemo() {
</div>
<DocSectionCode code={code} />
</>
)
);
}
10 changes: 5 additions & 5 deletions components/doc/inputswitch/disableddoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { InputSwitch } from "../../lib/inputswitch/InputSwitch";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { InputSwitch } from '../../lib/inputswitch/InputSwitch';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function DisabledDoc(props) {
const code = {
Expand Down Expand Up @@ -40,5 +40,5 @@ export default function DisabledDemo() {
</div>
<DocSectionCode code={code} />
</>
)
);
}
8 changes: 4 additions & 4 deletions components/doc/inputswitch/importdoc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function ImportDoc(props) {
const code = {
Expand All @@ -13,5 +13,5 @@ import { InputSwitch } from 'primereact/inputswitch';
<DocSectionText {...props}></DocSectionText>
<DocSectionCode code={code} hideToggleCode hideCodeSandbox />
</>
)
}
);
}
10 changes: 5 additions & 5 deletions components/doc/inputswitch/preselectiondoc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { InputSwitch } from "../../lib/inputswitch/InputSwitch";
import { DocSectionText } from "../common/docsectiontext";
import { DocSectionCode } from "../common/docsectioncode";
import { useState } from 'react';
import { InputSwitch } from '../../lib/inputswitch/InputSwitch';
import { DocSectionText } from '../common/docsectiontext';
import { DocSectionCode } from '../common/docsectioncode';

export function PreselectionDoc(props) {
const [checked, setChecked] = useState(true);
Expand Down Expand Up @@ -46,5 +46,5 @@ export default function PreselectionDemo() {
</div>
<DocSectionCode code={code} />
</>
)
);
}
Loading

0 comments on commit 13f3f64

Please sign in to comment.