Skip to content
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

Created documentation for SkipToContentLink #2326

Merged
merged 27 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
30562ff
created doc for skip to main content link
smmr-dn Nov 1, 2024
a6b050b
added example
smmr-dn Nov 4, 2024
488a7d3
attempted to fix a11y error
smmr-dn Nov 5, 2024
2a3b768
Merge branch 'main' into uyen/skip-content-doc
smmr-dn Nov 5, 2024
4df97df
revert example changes
smmr-dn Nov 5, 2024
89d4bbb
Merge branch 'uyen/skip-content-doc' of https://github.com/iTwin/iTwi…
smmr-dn Nov 5, 2024
602b8d8
revert example changes
smmr-dn Nov 5, 2024
c054d95
modified examples
smmr-dn Nov 6, 2024
a800e82
description wording
smmr-dn Nov 6, 2024
13d7985
Merge branch 'main' into uyen/skip-content-doc
smmr-dn Nov 6, 2024
c5f6065
changed examples and wording
smmr-dn Nov 7, 2024
fa06deb
Merge branch 'uyen/skip-content-doc' of https://github.com/iTwin/iTwi…
smmr-dn Nov 7, 2024
aa63244
typo
smmr-dn Nov 7, 2024
ccf8a97
more wording
smmr-dn Nov 7, 2024
2e9164e
more wording
smmr-dn Nov 7, 2024
0105931
more explanation in intro
smmr-dn Nov 7, 2024
da92a8c
more explanation in intro
smmr-dn Nov 7, 2024
e05ab6b
removed redundancies
smmr-dn Nov 7, 2024
3428273
Merge branch 'main' into uyen/skip-content-doc
smmr-dn Nov 7, 2024
ef63dc8
Merge branch 'main' into uyen/skip-content-doc
smmr-dn Nov 11, 2024
4a13cc0
make skip link appear from the top
smmr-dn Nov 11, 2024
fc47ca0
Merge branch 'uyen/skip-content-doc' of https://github.com/iTwin/iTwi…
smmr-dn Nov 11, 2024
685c835
Merge branch 'main' into uyen/skip-content-doc
smmr-dn Nov 12, 2024
07c4193
modified demo
smmr-dn Nov 12, 2024
7d3ae03
Merge branch 'uyen/skip-content-doc' of https://github.com/iTwin/iTwi…
smmr-dn Nov 12, 2024
4dc7f2b
renamed id
smmr-dn Nov 12, 2024
693f526
added css comment and used normal button and kbd
smmr-dn Nov 12, 2024
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
31 changes: 31 additions & 0 deletions apps/website/src/content/docs/skiptocontentlink.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Skip to content link
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
description: A skip-to-content link can be used to navigate directly to certain desired contents.
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
thumbnail: #TODO
---

<p>{frontmatter.description}</p>

<Placeholder componentPageName='table--basic' />
mayank99 marked this conversation as resolved.
Show resolved Hide resolved

## Usage

`SkipToContentLink` is designed for screen reader and keyboard users and will only become visible when focused. It provides a shortcut to the main content of the page, bypassing the header and other navigation elements. The `href` prop should be set to the `id` of the main content section, and the value must include the '#' prefix.
mayank99 marked this conversation as resolved.
Show resolved Hide resolved

<LiveExample src='SkipToContentLink.main.jsx' truncate={true}>
<AllExamples.SkipToContentLinkMainExample client:load />
</LiveExample>
mayank99 marked this conversation as resolved.
Show resolved Hide resolved

**Note**: `SkipToContentLink` must be placed inside a `<body>`.

mayank99 marked this conversation as resolved.
Show resolved Hide resolved
### Custom Text

The link component accepts custom text through its `children` prop, allowing for localization. If no custom text is provided, the default text displayed is "Skip to main content".

<LiveExample src='SkipToContentLink.customText.jsx' truncate={true}>
<AllExamples.SkipToContentLinkCustomTextExample client:load />
</LiveExample>

## Props

<PropsTable path='@itwin/itwinui-react/esm/core/SkipToContentLink/SkipToContentLink.d.ts' />
6 changes: 6 additions & 0 deletions examples/SkipToContentLink.customText.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.main-content {
border: solid 1px var(--iui-color-border);
height: 300px;
padding: 11px 12px;
margin-top: 10px;
}
31 changes: 31 additions & 0 deletions examples/SkipToContentLink.customText.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { SkipToContentLink, Text, Kbd, Anchor } from '@itwin/itwinui-react';

export default () => {
return (
<>
<SkipToContentLink href='#main-content'>
Go to main content
</SkipToContentLink>
<Text variant='body'>
This is not the main content. Press&nbsp;
<Kbd>tab</Kbd>&nbsp;to see skip-to-content-link component. You might
need to click on the top of the page or the URL first. Press&nbsp;
<Kbd>&crarr;</Kbd>
&nbsp;after focusing on skip-to-content-link to skip to the main content
below. <Anchor href='#'>This link will be skipped.</Anchor> <br />
</Text>
<div className='main-content' id='main-content'>
<Text variant='body'>
This is the main content. Focus will be directed here from the
skip-to-content-link component.&nbsp;
<Anchor href='#'>Tab again to focus on this link.</Anchor>
&nbsp;
</Text>
</div>
</>
);
};
6 changes: 6 additions & 0 deletions examples/SkipToContentLink.main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.main-content {
border: solid 1px var(--iui-color-border);
height: 300px;
padding: 11px 12px;
margin: 10px;
}
29 changes: 29 additions & 0 deletions examples/SkipToContentLink.main.jsx
mayank99 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { SkipToContentLink, Text, Kbd, Anchor } from '@itwin/itwinui-react';

export default () => {
return (
<>
<SkipToContentLink href='#main-content' />
<Text variant='body'>
This is not the main content. Press&nbsp;
<Kbd>tab</Kbd>&nbsp;to see skip-to-content-link component. You might
need to click on the top of the page or the URL first. Press&nbsp;
<Kbd>&crarr;</Kbd>
&nbsp;after focusing on skip-to-content-link to skip to the main content
below. <Anchor href='#'>This link will be skipped.</Anchor> <br />
</Text>
<div className='main-content' id='main-content'>
<Text variant='body'>
This is the main content. Focus will be directed here from the
skip-to-content-link component.&nbsp;
<Anchor href='#'>Tab again to focus on this link.</Anchor>
&nbsp;
</Text>
</div>
</>
);
};
14 changes: 14 additions & 0 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,20 @@ export { SideNavigationSubmenuExample };

// ----------------------------------------------------------------------------

import { default as SkipToContentLinkMainExampleRaw } from './SkipToContentLink.main';
const SkipToContentLinkMainExample = withThemeProvider(
SkipToContentLinkMainExampleRaw,
);
export { SkipToContentLinkMainExample };

import { default as SkipToContentLinkCustomTextExampleRaw } from './SkipToContentLink.customText';
const SkipToContentLinkCustomTextExample = withThemeProvider(
SkipToContentLinkCustomTextExampleRaw,
);
export { SkipToContentLinkCustomTextExample };

// ----------------------------------------------------------------------------

import { default as SliderMainExampleRaw } from './Slider.main';
const SliderMainExample = withThemeProvider(SliderMainExampleRaw);
export { SliderMainExample };
Expand Down
Loading