-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(react-keytips): improve keytips docs (#258)
- Loading branch information
1 parent
9c9ff0c
commit 61dab23
Showing
12 changed files
with
124 additions
and
75 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-contrib-react-keytips-6f2b6da6-c466-46c7-be8f-9bd0a56bb1b4.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "docs(react-keytips): improve keytips docs", | ||
"packageName": "@fluentui-contrib/react-keytips", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
By default Keytips are shown for all target elements that have keytip attached via | ||
`useKeytipRef`, except disabled elements. | ||
When multiple Keytips start with the same character, typing that character will filter the visible keytips. | ||
You can also use `positioning` to set an offset from the target element, or control [other positioning options](https://react.fluentui.dev/?path=/docs/concepts-developer-positioning-components--docs). | ||
|
||
```tsx | ||
export const DefaultStory = () => { | ||
const normalKeytip = useKeytipRef({ | ||
keySequences: ['b1'], | ||
content: 'B1', | ||
onExecute, | ||
}); | ||
|
||
const keytipWithOffset = useKeytipRef({ | ||
keySequences: ['b4'], | ||
positioning: { offset: { crossAxis: -50, mainAxis: 5 } }, | ||
content: 'B4', | ||
onExecute, | ||
}); | ||
|
||
return ( | ||
<> | ||
<Button ref={normalKeytip}>Normal Keytip</Button> | ||
<Button ref={keytipWithOffset}>Keytip with offset</Button> | ||
</> | ||
); | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
If a `Keytip` triggers dynamic content that includes its own keytips, you must add the `dynamic` prop to the `useKeytipRef` for the relevant component. Additionally, the child keytips should include the parents key sequence in their key sequences. | ||
|
||
Take the case below; clicking Button 1 and Button 2 will update the text of Button3. Triggering the keytip for Button 1 or Button 2 will then also change the keytip sequence of Button 3, because it can be both a child of Button 1 or Button 2. For this to work fully, Button 1 and Button 2 should have `dynamic: true`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Keytips with Overflow require `dynamic` prop to be passed with `useKeytipRef`. You can also register | ||
a `persisted` keytip, that can be accessed from the top level as a shortcut. A shortcut to a normal Button | ||
will trigger the Button, shortcut to a MenuButton will open a menu. In this example, firing `B` and `C` | ||
will show this functionality. | ||
|
||
```tsx | ||
const subMenuRef = useKeytipRef<HTMLDivElement>({ | ||
keySequences: ['a', 'b'], | ||
content: 'B', | ||
dynamic: true, | ||
persited: true, | ||
onExecute, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { | ||
ExecuteKeytipEventHandler, | ||
useKeytipRef, | ||
} from '@fluentui-contrib/react-keytips'; | ||
|
||
const onExecute: ExecuteKeytipEventHandler = (_, { targetElement }) => { | ||
if (targetElement) targetElement.click(); | ||
}; | ||
|
||
export const DefaultStory = () => { | ||
const normalButton = useKeytipRef({ | ||
keySequences: ['b1'], | ||
content: 'B1', | ||
onExecute, | ||
}); | ||
|
||
return <Button ref={normalButton}>Delayed Start of Keytip Mode</Button>; | ||
}; | ||
|
||
DefaultStory.parameters = { | ||
docs: { | ||
description: { | ||
story: [ | ||
`By default Keytips are shown for all target elements that have keytip attached via | ||
\`useKeytipRef\`, except disabled elements.`, | ||
`When multiple Keytips start with the same character, typing that character will filter the visible keytips.`, | ||
].join('\n'), | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters