Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 37 additions & 1 deletion .remarkrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,45 @@ function pageDescription() {
};
}

/**
* Framework tabs must use `<FrameworkTabs>`, which takes each tab's label and
* the tab order from `src/utils/frameworks.ts`. A `<Tabs groupId="framework">`
* with its own `values` lets pages drift apart in spelling and order.
*
* A Tabs inside an `mdx-code-block` fence is a code node to remark, so the
* fence's text is searched as well.
*/
const FRAMEWORK_TABS_IN_CODE = /<Tabs\b[^>]*\bgroupId=["']framework["']/;

function frameworkTabs() {
return (tree, file) => {
const report = (node) => {
const message = file.message(
'Use `<FrameworkTabs>` instead of `<Tabs groupId="framework">`. It takes the labels and order from `src/utils/frameworks.ts`, so every page shows the frameworks the same way.',
node
);
message.source = 'ionic-docs';
message.ruleId = 'framework-tabs';
};
const visit = (node) => {
if (node.type === 'code' && node.lang === 'mdx-code-block' && FRAMEWORK_TABS_IN_CODE.test(node.value)) {
report(node);
} else if (
node.type === 'mdxJsxFlowElement' &&
node.name === 'Tabs' &&
node.attributes.some((a) => a.name === 'groupId' && a.value === 'framework')
) {
report(node);
}
node.children?.forEach(visit);
};
visit(tree);
};
}

export default {
// remark-frontmatter parses the frontmatter as YAML, as Docusaurus does.
// Without it, the lint reads it as Markdown, and a `<` in a description
// becomes an unclosed JSX tag.
plugins: [remarkFrontmatter, docLinks, pageDescription],
plugins: [remarkFrontmatter, docLinks, pageDescription, frameworkTabs],
};
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Thanks for your interest in contributing to Ionic's documentation! :tada: Check
- [Authoring Content](#authoring-content)
- [Admonitions](#admonitions)
- [Links and Headings](#links-and-headings)
- [Framework Tabs](#framework-tabs)
- [Playgrounds](#playgrounds)
- [Reference Content](#reference-content)
- [Translation](#translation)
Expand Down Expand Up @@ -241,6 +242,22 @@ Markup inside code samples is exempt, since it's example code rather than part o
npm run lint
```

### Framework Tabs

To show a sample once per framework, use `<FrameworkTabs>`. Give each `<TabItem>` only its `value`, such as `angular`, `react`, or `vue`:

```mdx
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

<FrameworkTabs>
<TabItem value="angular">…</TabItem>
<TabItem value="react">…</TabItem>
</FrameworkTabs>
```

The labels come from `src/utils/frameworks.ts`, and the tabs are sorted alphabetically by label. Picking a framework selects it in every framework tab and playground on the site. A tab outside that list, such as Stencil, needs its own `label`. `npm run lint` fails on a `<Tabs groupId="framework">`.

### Playgrounds

A playground is the interactive example on a component page. It shows a live demo that switches between iOS and Material Design modes, the code for JavaScript, Angular, React and Vue, and a button to open the example in StackBlitz.
Expand Down
24 changes: 5 additions & 19 deletions docs/angular/platform.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Platform
description: 'Ionic Platform service can be used to get information about your current device. With this information you can completely customize your app to fit any device.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

<head>
Expand All @@ -14,14 +14,7 @@ The Platform service can be used to get information about your current device. Y

## Usage {/* #usage */}

<Tabs
groupId="framework"
defaultValue="angular"
values={[
{ value: 'angular', label: 'Angular' },
{ value: 'angular-standalone', label: 'Angular (Standalone)' },
]}
>
<FrameworkTabs defaultValue="angular">
<TabItem value="angular">

```tsx
Expand Down Expand Up @@ -50,7 +43,7 @@ export class MyPage {
```

</TabItem>
</Tabs>
</FrameworkTabs>

## Methods {/* #methods */}

Expand Down Expand Up @@ -92,14 +85,7 @@ Below is a table listing all the possible platform values along with correspondi

The function used to detect a specific platform can be overridden by providing an alternative function in the global [Ionic config](../developing/config.mdx). Each function takes `window` as a parameter and returns a boolean.

<Tabs
groupId="framework"
defaultValue="angular"
values={[
{ value: 'angular', label: 'Angular' },
{ value: 'angular-standalone', label: 'Angular (Standalone)' },
]}
>
<FrameworkTabs defaultValue="angular">
<TabItem value="angular">

```tsx title="app.module.ts"
Expand Down Expand Up @@ -155,7 +141,7 @@ bootstrapApplication(AppComponent, {
```

</TabItem>
</Tabs>
</FrameworkTabs>

```ts
type PlatformConfig = {
Expand Down
13 changes: 3 additions & 10 deletions docs/angular/slides.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Migrating from ion-slides to Swiper.js
description: 'Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider component.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

<head>
Expand Down Expand Up @@ -141,14 +141,7 @@ It is recommended to review the [properties](https://github.com/ionic-team/ionic

We can install the `IonicSlides` module by importing and passing it to the `modules` property of `swiper-container` as an array:

<Tabs
groupId="framework"
defaultValue="angular"
values={[
{ value: 'angular', label: 'Angular' },
{ value: 'angular-standalone', label: 'Angular (Standalone)' },
]}
>
<FrameworkTabs defaultValue="angular">
<TabItem value="angular">

```typescript
Expand Down Expand Up @@ -181,7 +174,7 @@ export class HomePage {
```

</TabItem>
</Tabs>
</FrameworkTabs>

```html
<!-- home.page.html -->
Expand Down
10 changes: 5 additions & 5 deletions docs/api/action-sheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'ion-action-sheet'
description: 'Action Sheets are dialogs that display a set of options above app content and must be manually dismissed. Read to learn about use on iOS and Android devices.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

import Props from '@ionic-internal/component-api/v9/action-sheet/props.mdx';
Expand Down Expand Up @@ -109,7 +109,7 @@ Action Sheets are given a `role` of [`dialog`](https://developer.mozilla.org/en-

It is strongly recommended that every Action Sheet have the `header` property defined, as Ionic will automatically set `aria-labelledby` to point to the header element. However, if you choose not to include a `header`, an alternative is to use the `htmlAttributes` property to provide a descriptive `aria-label` or set a custom `aria-labelledby` value.

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -159,13 +159,13 @@ const actionSheet = await actionSheetController.create({

</TabItem>

</Tabs>
</FrameworkTabs>

#### Action Sheet Buttons Description {/* #action-sheet-buttons-description */}

Buttons containing text will be read by a screen reader. If a button contains only an icon, or a description other than the existing text is desired, a label should be assigned to the button by passing `aria-label` to the `htmlAttributes` property on the button.

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -239,7 +239,7 @@ const actionSheet = await actionSheetController.create({

</TabItem>

</Tabs>
</FrameworkTabs>

## Interfaces {/* #interfaces */}

Expand Down
10 changes: 5 additions & 5 deletions docs/api/alert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'ion-alert'
description: "ion-alert dialog presents or collects information using inputs. Custom alert button messages appear above the app's content and must be manually dismissed."
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

import Props from '@ionic-internal/component-api/v9/alert/props.mdx';
Expand Down Expand Up @@ -127,7 +127,7 @@ If the `header` property is defined for the Alert, the `aria-labelledby` attribu

It is strongly recommended that your Alert have a `message`, as well as either a `header` or `subHeader`, in order to align with the ARIA spec. If you choose not to include a `header` or `subHeader`, an alternative is to provide a descriptive `aria-label` using the `htmlAttributes` property.

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -181,15 +181,15 @@ const alert = await alertController.create({

</TabItem>

</Tabs>
</FrameworkTabs>

All ARIA attributes can be manually overwritten by defining custom values in the `htmlAttributes` property of the Alert.

#### Alert Buttons Description {/* #alert-buttons-description */}

Buttons containing text will be read by a screen reader. If a description other than the existing text is desired, a label can be set on the button by passing `aria-label` to the `htmlAttributes` property on the button.

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -263,7 +263,7 @@ const alert = await alertController.create({

</TabItem>

</Tabs>
</FrameworkTabs>

## Interfaces {/* #interfaces */}

Expand Down
6 changes: 3 additions & 3 deletions docs/api/item.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Slots from '@ionic-internal/component-api/v9/item/slots.mdx';
import Link from '@docusaurus/Link';
import useBaseUrl from '@docusaurus/useBaseUrl';
import BestPracticeFigure from '@components/global/BestPracticeFigure';
import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

<head>
Expand Down Expand Up @@ -286,7 +286,7 @@ import Clickable from '@site/static/usage/v9/item/clickable/index.mdx';

Items support client-side navigation using the `routerLink` property. Setting `routerLink` renders the item as an anchor and navigates to the specified route when tapped. The `routerDirection` property controls the transition animation direction, and `routerAnimation` accepts a custom animation builder.

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -382,7 +382,7 @@ import { IonItem, IonLabel, IonList } from '@ionic/vue';

</TabItem>

</Tabs>
</FrameworkTabs>

## Detail Arrows {/* #detail-arrows */}

Expand Down
8 changes: 4 additions & 4 deletions docs/api/route.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'ion-route'
description: 'The ion-route component takes a component and renders it when the Browser URL matches the URL property. Learn more about the API route component for Ionic Apps.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

import Props from '@ionic-internal/component-api/v9/route/props.mdx';
Expand Down Expand Up @@ -44,7 +44,7 @@ interface NavigationHookOptions {

## Usage {/* #usage */}

<Tabs groupId="framework" defaultValue="javascript" values={[{ value: 'javascript', label: 'Javascript' }, { value: 'stencil', label: 'Stencil' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="javascript">

<TabItem value="javascript">

Expand Down Expand Up @@ -111,7 +111,7 @@ const confirmDiscardChanges = async () => {

</TabItem>

<TabItem value="stencil">
<TabItem value="stencil" label="Stencil">

```typescript
import { Component, h } from '@stencil/core';
Expand Down Expand Up @@ -242,7 +242,7 @@ const confirmDiscardChanges = async () => {

</TabItem>

</Tabs>
</FrameworkTabs>

## Properties {/* #properties */}

Expand Down
6 changes: 3 additions & 3 deletions docs/api/tab-bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'ion-tab-bar'
description: 'The tab bar component contains a set of tab buttons and a tab bar must be provided inside of tabs to communicate. Read more about use and CSS custom properties.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

import Props from '@ionic-internal/component-api/v9/tab-bar/props.mdx';
Expand All @@ -25,7 +25,7 @@ The tab bar is a UI component that contains a set of [tab buttons](./tab-button.

## Usage {/* #usage */}

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -131,7 +131,7 @@ import { call, person, settings } from 'ionicons/icons';

</TabItem>

</Tabs>
</FrameworkTabs>

## Badges in Tab Buttons {/* #badges-in-tab-buttons */}

Expand Down
6 changes: 3 additions & 3 deletions docs/api/tab-button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'ion-tab-button'
description: 'ion-tab-button is placed inside of an ion-tab-bar. It sets the layout of its icon and label, and connects to an ion-tab.'
---

import Tabs from '@theme/Tabs';
import FrameworkTabs from '@site/src/components/global/FrameworkTabs';
import TabItem from '@theme/TabItem';

import Props from '@ionic-internal/component-api/v9/tab-button/props.mdx';
Expand All @@ -23,7 +23,7 @@ Refer to the [tabs documentation](./tabs.mdx) for more details on configuring ta

## Usage {/* #usage */}

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'vue', label: 'Vue' }]}>
<FrameworkTabs defaultValue="angular">

<TabItem value="angular">

Expand Down Expand Up @@ -181,7 +181,7 @@ import { calendar, informationCircle, map, personCircle } from 'ionicons/icons';

</TabItem>

</Tabs>
</FrameworkTabs>

## Properties {/* #properties */}

Expand Down
Loading
Loading