-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor(ActionMenuItem): expose ActionMenuItem as a standalone component #1457
Open
JoannaSikora
wants to merge
4
commits into
main
Choose a base branch
from
feature/move-actionmenuitem
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
abd38ee
refactor(ActionMenuItem): expose ActionMenuItem as a standalone compo…
JoannaSikora 28ee338
refactor(ActionMenuItem): add export to index file
JoannaSikora 20fe36f
refactor(ActionMenuItem): small refactor of imports and names
JoannaSikora 6d271ee
Merge branch 'main' into feature/move-actionmenuitem
JoannaSikora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { ActionMenu } from './ActionMenu'; | ||
export { ActionMenuItem } from './ActionMenuItem'; | ||
export type { IActionMenuOption } from './types'; |
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
40 changes: 40 additions & 0 deletions
40
packages/react-components/src/components/ActionMenuItem/ActionMenuItem.mdx
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,40 @@ | ||
import { Canvas, ArgTypes, Meta, Title } from '@storybook/blocks'; | ||
|
||
import * as ActionMenuItemStories from './ActionMenuItem.stories'; | ||
|
||
<Meta of={ActionMenuItemStories} /> | ||
|
||
<Title>ActionMenuItem</Title> | ||
|
||
[Intro](#Intro) | [Component API](#ComponentAPI) | [Content Spec](#ContentSpec) | ||
|
||
## Intro <a id="Intro" /> | ||
|
||
The Action Menu Item component is designed to be used within menus, such as the ActionMenu or other custom menus. | ||
It represents a single menu option, allowing users to interact with or select actions. | ||
This component typically displays a label and optionally supports additional elements icons or additional context, which can be positioned on either the left or right side of the item. | ||
This makes it a flexible building block for creating intuitive menus. | ||
|
||
<Canvas of={ActionMenuItemStories.Default} sourceState="none" /> | ||
|
||
#### Example implementation | ||
|
||
```jsx | ||
<ActionMenuItem>Simple Option 1</ActionMenuItem> | ||
// OR | ||
<ActionMenuItem leftNode={<Icon icon="chat" />} rightNode={<Icon icon="chevron-down" />}>Complex option 2</ActionMenuItem> | ||
``` | ||
|
||
## Component API <a id="ComponentAPI" /> | ||
|
||
<ArgTypes of={ActionMenuItemStories.Default} sort="requiredFirst" /> | ||
|
||
## Content Spec <a id="ContentSpec" /> | ||
|
||
<a | ||
className="sb-unstyled" | ||
href="https://www.figma.com/file/9FDwjR8lYvincseDkKypC4/Component-Documentations?type=design&node-id=97-20299&mode=design&t=yMPgy8XRD1OTobuX-4" | ||
target="_blank" | ||
> | ||
Go to Figma documentation | ||
</a> |
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
packages/react-components/src/components/ActionMenuItem/ActionMenuItem.stories.css
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,5 @@ | ||
.action-menu-preview { | ||
display: flex; | ||
justify-content: center; | ||
margin-bottom: 200px; | ||
} |
97 changes: 97 additions & 0 deletions
97
packages/react-components/src/components/ActionMenuItem/ActionMenuItem.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,97 @@ | ||
import { ReactElement } from 'react'; | ||
|
||
import { | ||
CloseCircle, | ||
ContentCopy, | ||
MoreHoriz, | ||
} from '@livechat/design-system-icons'; | ||
|
||
import { customHeightForChromatic } from '../../utils/chromatic-story-helpers'; | ||
import noop from '../../utils/noop'; | ||
import { ActionMenu } from '../ActionMenu'; | ||
import { Button } from '../Button'; | ||
import { Icon } from '../Icon'; | ||
|
||
import { ActionMenuItem } from './ActionMenuItem'; | ||
|
||
import './ActionMenuItem.stories.css'; | ||
|
||
export default { | ||
title: 'Components/ActionMenuItem', | ||
component: ActionMenuItem, | ||
parameters: { | ||
chromatic: { delay: 300 }, | ||
}, | ||
}; | ||
|
||
const defaultOptions = [ | ||
{ | ||
key: 'one', | ||
element: <ActionMenuItem>Simple Item 1</ActionMenuItem>, | ||
onClick: noop, | ||
}, | ||
{ | ||
key: 'two', | ||
element: ( | ||
<ActionMenuItem | ||
leftNode={<Icon source={ContentCopy} />} | ||
rightNode={<Icon source={CloseCircle} />} | ||
> | ||
Complex Item 2 | ||
</ActionMenuItem> | ||
), | ||
onClick: noop, | ||
}, | ||
]; | ||
|
||
const warningOptions = [ | ||
{ | ||
key: 'one', | ||
element: <ActionMenuItem kind="warning">Simple Item 1</ActionMenuItem>, | ||
onClick: noop, | ||
}, | ||
{ | ||
key: 'two', | ||
element: ( | ||
<ActionMenuItem | ||
kind="warning" | ||
leftNode={<Icon source={ContentCopy} />} | ||
rightNode={<Icon source={CloseCircle} />} | ||
> | ||
Complex Item 2 | ||
</ActionMenuItem> | ||
), | ||
onClick: noop, | ||
}, | ||
]; | ||
export const Default = (): ReactElement => { | ||
return ( | ||
<div style={{ height: customHeightForChromatic('1000px') }}> | ||
<div className="action-menu-preview"> | ||
<ActionMenu | ||
options={defaultOptions} | ||
triggerRenderer={ | ||
<Button icon={<Icon source={MoreHoriz} kind="primary" />} /> | ||
} | ||
openedOnInit | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const WarningKind = (): ReactElement => { | ||
return ( | ||
<div style={{ height: customHeightForChromatic('1000px') }}> | ||
<div className="action-menu-preview"> | ||
<ActionMenu | ||
options={warningOptions} | ||
triggerRenderer={ | ||
<Button icon={<Icon source={MoreHoriz} kind="primary" />} /> | ||
} | ||
openedOnInit | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages/react-components/src/components/ActionMenuItem/index.ts
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 @@ | ||
export { ActionMenuItem } from './ActionMenuItem'; |
16 changes: 16 additions & 0 deletions
16
packages/react-components/src/components/ActionMenuItem/types.ts
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,16 @@ | ||
import * as React from 'react'; | ||
|
||
export interface ActionMenuItemProps { | ||
/** | ||
* Renders given element on the left of element | ||
*/ | ||
leftNode?: React.ReactNode; | ||
/** | ||
* Renders given element on the right of element | ||
*/ | ||
rightNode?: React.ReactNode; | ||
/** | ||
* Specify the kind of menu item | ||
*/ | ||
kind?: 'warning' | undefined; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add accessibility documentation
Include a section about ARIA attributes, keyboard navigation, and screen reader considerations.