-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip): add keyboard shortcuts to tooltip (#4161)
* feat(keyboard-key): component init * chore(tools): plopfile syntax fix * chore(tools): plopfile syntax fix * chore(tools): plopfile syntax fix * feat(keyboard-key): styled w/ hook unit tests * feat(keyboard-key): added variants and styles * chore(plop): update tsx dependency * chore(keyboard-key): internal exports in core * chore(keyboard-key): typedocs & build * feat(keyboard-key): change to infline-flex style * chore(keyboard-key): added stroy * chore(keyboard-key): linting * fix(keyboard-key): command logic * feat(design-tokens): added new box shadows to support keyboard-keys * chore(ci-cd): added chagesets * fix(keyboard-key): boxShadow stylings * fix(keyboard-key): remove null component wrapper * fix(keyboard-key): aria-hidden * chore(keyboard-key): refactor * chore(keyboard-key): code cleanup * chore(keyboard-key): code cleanup * chore(keyboard-key): typedocs * chore(keyboard-key): fix tests * fix(keyboard-key): aria and diableBrowserShortcuts * fix(keyboard-key): props fix * chore(keyboard-key): playgorund storybook * chore(keyboard-key): formatting fix * chore(keyboard-key): stories update * chore(keyboard-key): formatting fix * chore(keyboard-key): typo * Update .changeset/sweet-mugs-admire.md Co-authored-by: Nora Krantz <[email protected]> * Update .changeset/shaggy-sheep-confess.md Co-authored-by: Nora Krantz <[email protected]> * chore(keyboard-key): address PR comments * feat(keyboard-tooltip): wip * chore(tooltip): update types * chore(tooltip): update types * chore(tooltip): better var naming * chore(tooltip): fail safe check * chore(tooltip): linting * chore(tooltip): linting * chore(tooltip): yarn lock * chore(tooltip): changeset * chore(tooltip): fix spelling * chore(tooltip): uppdate type name * feat(tooltip): add anonymous keybaord action to tooltip * Update packages/paste-core/components/tooltip/src/Tooltip.tsx Co-authored-by: Sarah <[email protected]> * fix(tooltip): update keyboardkey styles * chore(tooltip): formatting * Update packages/paste-core/components/tooltip/src/Tooltip.tsx Co-authored-by: Nora Krantz <[email protected]> --------- Co-authored-by: Nora Krantz <[email protected]> Co-authored-by: Sarah <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
dbd982f
commit a720e5e
Showing
8 changed files
with
471 additions
and
11 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
"@twilio-paste/tooltip": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[Tooltip] added the ability to put keyboard combinations using the KeyboardKey in the tooltip |
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
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
137 changes: 137 additions & 0 deletions
137
packages/paste-core/components/tooltip/stories/keyboard-key.stories.tsx
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,137 @@ | ||
import type { StoryFn } from "@storybook/react"; | ||
import { Anchor } from "@twilio-paste/anchor"; | ||
import { Box } from "@twilio-paste/box"; | ||
import { Button } from "@twilio-paste/button"; | ||
import { CustomizationProvider } from "@twilio-paste/customization"; | ||
import { InformationIcon } from "@twilio-paste/icons/esm/InformationIcon"; | ||
import { Stack } from "@twilio-paste/stack"; | ||
import { Text } from "@twilio-paste/text"; | ||
import { Theme, useTheme } from "@twilio-paste/theme"; | ||
import * as React from "react"; | ||
|
||
import { Tooltip, useTooltipState } from "../src"; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
title: "Components/Tooltip/KeyboardKey", | ||
excludeStories: ["StateHookExample"], | ||
component: Tooltip, | ||
parameters: { | ||
chromatic: { delay: 3000, diffThreshold: 0.2 }, | ||
}, | ||
}; | ||
|
||
export const Default = (): React.ReactNode => { | ||
return ( | ||
<Box as="div" minHeight="400px"> | ||
<Tooltip | ||
visible | ||
actionHeader="Search shortcuts" | ||
keyCombinationsActions={[ | ||
{ name: "Mac", eventKeyCombination: ["Command", "K"] }, | ||
{ name: "Windows", eventKeyCombination: ["Control", "K"] }, | ||
]} | ||
> | ||
<Button aria-keyshortcuts="command+k" variant="primary"> | ||
Click to search | ||
</Button> | ||
</Tooltip> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const CustomizedTooltip: StoryFn = (_args, { parameters: { isTestEnvironment } }) => { | ||
const currentTheme = useTheme(); | ||
return ( | ||
<CustomizationProvider | ||
disableAnimations={isTestEnvironment} | ||
theme={currentTheme} | ||
elements={{ | ||
TOOLTIP: { | ||
backgroundColor: "colorBackgroundErrorWeakest", | ||
borderColor: "colorBorderDestructive", | ||
textAlign: "center", | ||
}, | ||
TOOLTIP_ACTION_TEXT: { | ||
color: "colorTextErrorStrong", | ||
}, | ||
TOOLTIP_HEADER: { | ||
color: "colorTextLinkDestructive", | ||
fontWeight: "fontWeightBold", | ||
}, | ||
TOOLTIP_ACTION_KEY_GROUP: { | ||
backgroundColor: "colorBackgroundStrong", | ||
padding: "space30", | ||
}, | ||
TOOLTIP_ACTION_KEY: { | ||
backgroundColor: "colorBackgroundPrimary", | ||
color: "colorTextInverse", | ||
}, | ||
CUSTOM_TOOLTIP: { | ||
backgroundColor: "colorBackgroundSuccessWeakest", | ||
borderColor: "colorBorderSuccess", | ||
textAlign: "left", | ||
}, | ||
CUSTOM_TOOLTIP_ACTION_TEXT: { | ||
color: "colorTextSuccess", | ||
}, | ||
CUSTOM_TOOLTIP_HEADER: { | ||
color: "colorTextLinkStrongest", | ||
fontWeight: "fontWeightLight", | ||
}, | ||
CUSTOM_TOOLTIP_ACTION_KEY_GROUP: { | ||
backgroundColor: "colorBackgroundInverse", | ||
padding: "space30", | ||
}, | ||
CUSTOM_TOOLTIP_ACTION_KEY: { | ||
backgroundColor: "colorBackgroundBusy", | ||
color: "colorTextInverse", | ||
fontFamily: "fontFamilyCode", | ||
}, | ||
}} | ||
> | ||
<Box as="div" display="flex" columnGap="space80"> | ||
<Box minWidth="200px"> | ||
<Tooltip | ||
visible | ||
actionHeader="Search shortcuts" | ||
keyCombinationsActions={[ | ||
{ name: "Mac", eventKeyCombination: ["Command", "K"] }, | ||
{ name: "Windows", eventKeyCombination: ["Control", "K"] }, | ||
]} | ||
> | ||
<Button aria-keyshortcuts="command+k" variant="primary"> | ||
Click to search | ||
</Button> | ||
</Tooltip> | ||
</Box> | ||
<Box minWidth="600px"> | ||
<Tooltip | ||
element="CUSTOM_TOOLTIP" | ||
visible | ||
actionHeader="Search shortcuts" | ||
keyCombinationsActions={[ | ||
{ name: "Mac", eventKeyCombination: ["Command", "K"] }, | ||
{ name: "Windows", eventKeyCombination: ["Control", "K"] }, | ||
]} | ||
> | ||
<Button aria-keyshortcuts="command+k" variant="primary"> | ||
Click to search | ||
</Button> | ||
</Tooltip> | ||
</Box> | ||
</Box> | ||
</CustomizationProvider> | ||
); | ||
}; | ||
|
||
CustomizedTooltip.storyName = "Customized Tooltip"; | ||
CustomizedTooltip.parameters = { | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
}, | ||
a11y: { | ||
// no need to a11y check customization | ||
disable: true, | ||
}, | ||
}; |
Oops, something went wrong.