Skip to content

docs(item): add best practices and usage guides #3123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 72 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7d0321a
docs(item): note that items should only be used in lists
liamdebeasi Sep 14, 2023
aedc307
docs(item): remove incorrect outline used from input playground
liamdebeasi Sep 14, 2023
cdce63e
docs(item): create outline for content types and usage guidelines
liamdebeasi Sep 14, 2023
00a9c73
docs(item): add supporting visuals example
liamdebeasi Sep 14, 2023
05ee5c6
docs(item): update visaul example, remove media and icon playgrounds
liamdebeasi Sep 14, 2023
d25e0f4
docs(item): add text best practice draft
liamdebeasi Sep 14, 2023
bbe422b
docs(item): add metadata example
liamdebeasi Sep 15, 2023
9bd8809
lint
liamdebeasi Sep 15, 2023
b02c744
docs(item): add actions docs
liamdebeasi Sep 15, 2023
073cb54
use empty string alt for decorative images
liamdebeasi Sep 15, 2023
e040fc8
remove unneeded file
liamdebeasi Sep 15, 2023
d45dcc7
typo
liamdebeasi Sep 15, 2023
c0f8940
docs(item): add initial control info
liamdebeasi Sep 15, 2023
a0e4a71
docs(item): add playground
liamdebeasi Sep 18, 2023
81cf625
lint
liamdebeasi Sep 18, 2023
a0e5496
docs(item): add playground for text
liamdebeasi Sep 18, 2023
dffa720
couple react fixes
liamdebeasi Sep 18, 2023
ed6fdea
lint
liamdebeasi Sep 18, 2023
4ae34ef
typos
liamdebeasi Sep 18, 2023
f2c4f2d
fix screenshots
liamdebeasi Sep 18, 2023
59af34c
use correct semantics and ensure color contrast
liamdebeasi Sep 18, 2023
4a1b7f8
move basic usage to top
liamdebeasi Sep 18, 2023
427e6aa
pass text as string where possible
liamdebeasi Sep 19, 2023
0bc5327
supporting visuals playground is larger
liamdebeasi Sep 19, 2023
7ded04a
Update docs/api/item.md
liamdebeasi Sep 19, 2023
a6e67f8
Update static/usage/v7/item/content-types/text/angular/example_compon…
liamdebeasi Sep 19, 2023
3e58f37
Update static/usage/v7/item/content-types/text/demo.html
liamdebeasi Sep 19, 2023
2281c83
Update static/usage/v7/item/content-types/text/javascript.md
liamdebeasi Sep 19, 2023
d63328f
Update static/usage/v7/item/content-types/text/vue.md
liamdebeasi Sep 19, 2023
f79d81b
Update docs/api/item.md
liamdebeasi Sep 19, 2023
9d5d252
Update docs/api/item.md
liamdebeasi Sep 19, 2023
9210d5f
Update docs/api/item.md
liamdebeasi Sep 19, 2023
de3e005
clarify using item in separate list
liamdebeasi Sep 19, 2023
db2f997
add correct alt text
liamdebeasi Sep 19, 2023
b1a9c33
clarify do text
liamdebeasi Sep 19, 2023
d0cd106
Update docs/api/item.md
liamdebeasi Sep 20, 2023
d944f10
Update docs/api/item.md
liamdebeasi Sep 20, 2023
b58609c
Update docs/api/item.md
liamdebeasi Sep 20, 2023
543c0a7
remove text playground placeholders
liamdebeasi Sep 20, 2023
8f26d53
use allow terminology instead
liamdebeasi Sep 20, 2023
3316920
remove ?
liamdebeasi Sep 20, 2023
684b880
clarify alignment text
liamdebeasi Sep 20, 2023
579b4b4
fix text wording
liamdebeasi Sep 20, 2023
ba84925
Update docs/api/item.md
liamdebeasi Sep 20, 2023
e2fa31f
Update docs/api/item.md
liamdebeasi Sep 20, 2023
0f6f3f2
improve color contrast for text demo
liamdebeasi Sep 20, 2023
c1c43f6
make borders thicker for actions screenshot
liamdebeasi Sep 20, 2023
326168e
make borders thicker for metadata screenshots
liamdebeasi Sep 20, 2023
008f65b
note and icon colors match on metadata playground
liamdebeasi Sep 20, 2023
ff9dd00
note matches too
liamdebeasi Sep 20, 2023
ecaea65
fix typos
liamdebeasi Sep 20, 2023
3b0efb7
typo
liamdebeasi Sep 20, 2023
8888a48
improve screenshot contrast
liamdebeasi Sep 20, 2023
2025a7a
lint
liamdebeasi Sep 20, 2023
24b7931
Update static/usage/v7/item/content-types/metadata/demo.html
liamdebeasi Sep 20, 2023
99967e0
Update static/usage/v7/item/content-types/metadata/demo.html
liamdebeasi Sep 20, 2023
e96ddc9
Update static/usage/v7/item/content-types/metadata/javascript.md
liamdebeasi Sep 20, 2023
b367c2b
Update static/usage/v7/item/content-types/metadata/javascript.md
liamdebeasi Sep 20, 2023
246ce2b
Update static/usage/v7/item/content-types/metadata/vue.md
liamdebeasi Sep 20, 2023
7512d9c
Update static/usage/v7/item/content-types/metadata/vue.md
liamdebeasi Sep 20, 2023
835ed63
Update static/usage/v7/item/content-types/text/demo.html
liamdebeasi Sep 20, 2023
a7a4657
Update static/usage/v7/item/content-types/text/javascript.md
liamdebeasi Sep 20, 2023
13b1b92
Update static/usage/v7/item/content-types/text/vue.md
liamdebeasi Sep 20, 2023
4f54f99
lint
liamdebeasi Sep 20, 2023
43e86dc
Update static/usage/v7/item/content-types/text/vue.md
liamdebeasi Sep 20, 2023
8e75c43
Update static/usage/v7/item/content-types/metadata/angular/example_co…
liamdebeasi Sep 20, 2023
d163d0e
Update static/usage/v7/item/content-types/metadata/angular/example_co…
liamdebeasi Sep 20, 2023
596ba7c
clarify actions
liamdebeasi Sep 20, 2023
c86c887
add example outside list
liamdebeasi Sep 20, 2023
9d34ccf
add docs
liamdebeasi Sep 20, 2023
8384b6b
Update docs/api/input.md
liamdebeasi Sep 21, 2023
068dd1e
Merge remote-tracking branch 'origin/main' into FW-4149
liamdebeasi Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Material Design offers filled styles for an input. The `fill` property on the in

Since the `fill` styles visually defines the input container, inputs that use `fill` should not be used in `ion-item`.

Filled inputs can be used on iOS by setting Input's `mode` to `md`.

import Fill from '@site/static/usage/v7/input/fill/index.md';

<Fill />
Expand Down
161 changes: 142 additions & 19 deletions docs/api/item.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/api/textarea.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Material Design offers filled styles for a textarea. The `fill` property on the

Since the `fill` styles visually defines the textarea container, textareas that use `fill` should not be used in `ion-item`.

Filled textareas can be used on iOS by setting Textarea's `mode` to `md`.

import Fill from '@site/static/usage/v7/textarea/fill/index.md';

<Fill />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.best-practice__do_dont {
display: grid;

grid-template-columns: 1fr 1fr;

gap: 12px;
}

/* Collapse to 1 column per row on smaller viewports */
@media (max-width: 996px) {
.best-practice__do_dont {
grid-template-columns: 1fr;
}
}

.best-practice__container figcaption {
text-align: start;
}

.best-practice__do p,
.best-practice__dont p,
.best-practice__caution p {
padding: 8px 16px;
}

.best-practice__image-wrapper {
border-radius: 8px 8px 0px 0px;

overflow: hidden;
}

.best-practice__dont-text,
.best-practice__do-text,
.best-practice__caution-text {
padding: 12px 16px;

font-weight: 600;

border-radius: 0px 0px 8px 8px;
}

.best-practice__do .best-practice__image-wrapper {
border: 1px solid var(--c-blue-10);
}

.best-practice__dont .best-practice__image-wrapper {
border: 1px solid var(--c-red-10);
}

.best-practice__caution .best-practice__image-wrapper {
border: 1px solid var(--c-yellow-10);
}

.best-practice__dont-text {
color: var(--c-red-100);
background: var(--c-red-10);
}
.best-practice__do-text {
color: var(--c-blue-100);
background: var(--c-blue-10);
}

.best-practice__caution-text {
/* --c-yellow-100 does not have enough contrast
* placed on top of --c-yellow-10, so we manually
* choose a darker text color here.
*/
color: #7e5e17;
background: var(--c-yellow-10);
}
82 changes: 82 additions & 0 deletions src/components/global/BestPracticeFigure/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';

import './best-practice-figure.css';

/**
Usage:

import BestPracticeFigure from '@components/global/BestPracticeFigure';

<BestPracticeFigure
text="..."
doText="..."
dontText="..."
doImage={<img alt="..." src={useBaseUrl(...)} />}
dontImage={<img alt="..." src={useBaseUrl(...)} />}
/>

All images must have alt text for screen readers.

Custom HTML can also be passed to any of the text properties by using curly braces:

text={<>My text with a <a href="#">link</a></>}

Markdown such as backticks will not be processed when using curly braces.
The <code> tag can be used instead:

text={<>The <code>button</code> property</>}

This component also supports a caution option. Typically you should use
either a "Don't" image or a "Caution" image but not both.

<BestPracticeFigure
text="..."
doText="..."
cautionText="..."
doImage={<img alt="..." src={useBaseUrl(...)} />}
cautionImage={<img alt="..." src={useBaseUrl(...)} />}
/>

@prop text - Text that describes the figure as a whole
@prop doText - Text that describes a best practice
@prop dontText - Text that describes an anti-pattern
@prop cautionText - Text that describes something that could be an anti-pattern based on use case
@prop doImage - Image associated with doText
@prop dontImage - Image associated with dontText
@prop cautionImage - Image associated with cautionText
*/

export default function BestPracticeFigure({ text, doText, dontText, cautionText, doImage, dontImage, cautionImage }) {
return (
<div className="best-practice__container">
<p>{text}</p>
<div className="best-practice__do_dont">
<figure className="best-practice__do">
<div className="best-practice__image-wrapper">{doImage}</div>
<figcaption>
<div className="best-practice__do-text">Do</div>
<p>{doText}</p>
</figcaption>
</figure>
{dontText && dontImage && (
<figure className="best-practice__dont">
<div className="best-practice__image-wrapper">{dontImage}</div>
<figcaption>
<div className="best-practice__dont-text">Don't</div>
<p>{dontText}</p>
</figcaption>
</figure>
)}
{cautionText && cautionImage && (
<figure className="best-practice__caution">
<div className="best-practice__image-wrapper">{cautionImage}</div>
<figcaption>
<div className="best-practice__caution-text">Caution</div>
<p>{cautionText}</p>
</figcaption>
</figure>
)}
</div>
</div>
);
}
Binary file added static/img/item/actions-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/actions-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/controls-count-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/controls-count-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/controls-metadata-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/controls-metadata-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/controls-metadata-list-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/long-text-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/long-text-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/metadata-relevant-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/metadata-relevant-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/visuals-do.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/item/visuals-dont.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions static/usage/v7/item/content-types/actions/angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
```html
<ion-header>
<ion-toolbar>
<ion-title>Example</ion-title>
</ion-toolbar>
</ion-header>
<ion-content color="light">
<ion-list [inset]="true">
<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Rick Astley</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Leeroy Jenkins</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Ionitron</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Wall-E</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Cortana</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>Bender</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item [button]="true">
<ion-avatar aria-hidden="true" slot="start">
<img alt="" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
</ion-avatar>
<ion-label>BB-8</ion-label>
</ion-item>
<ion-item-options slot="end">
<ion-item-option color="warning">
<ion-icon slot="icon-only" name="pin"></ion-icon>
</ion-item-option>
<ion-item-option color="tertiary">
<ion-icon slot="icon-only" name="share"></ion-icon>
</ion-item-option>
<ion-item-option color="danger" expandable="true">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>
</ion-content>
```
Loading