This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HorizontalActionList Component (#511)
* add post action link list * refactoring * use correct icon color * menuButton styling * update snapshots * add unit tests * rename to MessageActionsList * update reference images * fix reference image * fix vertical alignment * update interface to support both links and clickable * use a more generic name * remove stale reference images * add references with new name * add action states for open overflow menu * fix description * revert menuButton color override * update snapshot
- Loading branch information
Showing
19 changed files
with
622 additions
and
6 deletions.
There are no files selected for viewing
Binary file added
BIN
+2.62 KB
config/styleguide-visual/reference/ActionLink_with_compact_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
config/styleguide-visual/reference/HorizontalActionList_basic_click_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.58 KB
config/styleguide-visual/reference/HorizontalActionList_basic_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.7 KB
config/styleguide-visual/reference/HorizontalActionList_basic_hover_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.61 KB
config/styleguide-visual/reference/HorizontalActionList_counts_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.08 KB
config/styleguide-visual/reference/HorizontalActionList_counts_hover_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.33 KB
config/styleguide-visual/reference/HorizontalActionList_no_overflow_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
99 changes: 99 additions & 0 deletions
99
src/components/HorizontalActionsList/HorizontalActionList.md
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,99 @@ | ||
### Examples | ||
|
||
```js { "props": { "data-description": "basic", "data-action-states": "[{\"action\":\"none\"},{\"action\":\"click\",\"selector\":\".y-menu-button\"},{\"action\":\"hover\",\"selector\":\".y-menu-button--item-text\"}]" } } | ||
const Like = require('../Icon/icons/Like').default; | ||
const Reply = require('../Icon/icons/Reply').default; | ||
const Share = require('../Icon/icons/Share').default; | ||
const Flag = require('../Icon/icons/Flag').default; | ||
const Strong = require('../Strong').default; | ||
|
||
const items = [ | ||
{ | ||
key: 'like', | ||
icon: Like, | ||
text: 'Like', | ||
onClick: () => action('clicked like'), | ||
}, | ||
{ | ||
key: 'reply', | ||
icon: Reply, | ||
text: 'Reply', | ||
onClick: () => action('clicked reply'), | ||
}, | ||
{ | ||
key: 'share', | ||
icon: Share, | ||
text: 'Share', | ||
onClick: () => action('clicked share'), | ||
}, | ||
{ | ||
key: 'flag', | ||
icon: Flag, | ||
text: 'Follow in Inbox', | ||
onClick: () => action('clicked follow'), | ||
}, | ||
]; | ||
|
||
<div style={{ maxWidth: '400px', height: '60px' }}> | ||
<HorizontalActionList items={items} maxVisibleItemCount={3} /> | ||
</div>; | ||
``` | ||
|
||
```js { "props": { "data-description": "counts", "data-action-states": "[{\"action\":\"none\"},{\"action\":\"hover\",\"selector\":\".y-clickable\"}]" } } | ||
const Like = require('../Icon/icons/Like').default; | ||
const Reply = require('../Icon/icons/Reply').default; | ||
const Share = require('../Icon/icons/Share').default; | ||
|
||
const items = [ | ||
{ | ||
key: 'like', | ||
icon: Like, | ||
text: 'Like', | ||
unlinkedText: '4', | ||
onClick: () => action('clicked like'), | ||
}, | ||
{ | ||
key: 'reply', | ||
icon: Reply, | ||
text: 'Reply', | ||
unlinkedText: '2', | ||
onClick: () => action('clicked reply'), | ||
}, | ||
{ | ||
key: 'share', | ||
icon: Share, | ||
text: 'Share', | ||
onClick: () => action('clicked share'), | ||
}, | ||
]; | ||
|
||
<div style={{ maxWidth: '400px' }}> | ||
<HorizontalActionList items={items} maxVisibleItemCount={2} /> | ||
</div>; | ||
``` | ||
|
||
```js { "props": { "data-description": "no overflow" } } | ||
const Like = require('../Icon/icons/Like').default; | ||
const Reply = require('../Icon/icons/Reply').default; | ||
const Share = require('../Icon/icons/Share').default; | ||
|
||
const items = [ | ||
{ | ||
key: 'like', | ||
icon: Like, | ||
text: 'Like', | ||
unlinkedText: '8', | ||
onClick: () => action('clicked like'), | ||
}, | ||
{ | ||
key: 'reply', | ||
icon: Reply, | ||
text: 'Reply', | ||
onClick: () => action('clicked reply'), | ||
}, | ||
]; | ||
|
||
<div style={{ maxWidth: '400px' }}> | ||
<HorizontalActionList items={items} maxVisibleItemCount={2} /> | ||
</div> | ||
``` |
21 changes: 21 additions & 0 deletions
21
src/components/HorizontalActionsList/HorizontalActionList.styles.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,21 @@ | ||
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */ | ||
import { mergeStyleSets, ITheme } from 'office-ui-fabric-react/lib/Styling'; | ||
import { memoizeFunction } from 'office-ui-fabric-react/lib/Utilities'; | ||
|
||
export interface HorizontalActionListClassNameProps { | ||
theme: ITheme; | ||
} | ||
|
||
export const getClassNames = memoizeFunction((classNameProps: HorizontalActionListClassNameProps) => { | ||
const { theme } = classNameProps; | ||
|
||
return mergeStyleSets({ | ||
unlinkedText: { | ||
color: theme.semanticColors.link, | ||
paddingLeft: '0.2rem', | ||
}, | ||
menuButton: { | ||
top: '0.1rem', | ||
}, | ||
}); | ||
}); |
76 changes: 76 additions & 0 deletions
76
src/components/HorizontalActionsList/HorizontalActionList.test.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,76 @@ | ||
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */ | ||
import * as React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { HorizontalActionList } from './HorizontalActionList'; | ||
import { HorizontalActionListItem, HorizontalActionListProps } from './HorizontalActionList.types'; | ||
import Reply from '../Icon/icons/Reply'; | ||
import Like from '../Icon/icons/Like'; | ||
import { darkTheme } from '../Customizer'; | ||
|
||
describe('<HorizontalActionList />', () => { | ||
let component: ShallowWrapper<HorizontalActionListProps>; | ||
let items: HorizontalActionListItem[]; | ||
|
||
beforeEach(() => { | ||
items = [ | ||
{ | ||
icon: Like, | ||
text: 'like', | ||
ariaLabel: 'like', | ||
key: 'like', | ||
unlinkedText: '1', | ||
unlinkedTextAriaLabel: '1 person has like this post', | ||
onClick: jest.fn().mockName('likeOnClick'), | ||
}, | ||
{ | ||
icon: Reply, | ||
text: 'reply', | ||
ariaLabel: 'reply', | ||
key: 'reply', | ||
onClick: jest.fn().mockName('replyOnClick'), | ||
}, | ||
]; | ||
}); | ||
|
||
describe('with one item', () => { | ||
beforeEach(() => { | ||
component = shallow(<HorizontalActionList items={items.slice(0, 1)} overflowMenuAriaLabel="more items" />); | ||
}); | ||
|
||
it('matches its snapshot', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('with all items', () => { | ||
beforeEach(() => { | ||
component = shallow(<HorizontalActionList items={items} overflowMenuAriaLabel="more items" />); | ||
}); | ||
|
||
it('matches its snapshot', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('with all items, and maxVisibleItemCount of 1', () => { | ||
beforeEach(() => { | ||
component = shallow( | ||
<HorizontalActionList items={items} maxVisibleItemCount={1} overflowMenuAriaLabel="more items" />, | ||
); | ||
}); | ||
|
||
it('matches its snapshot', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('with a theme', () => { | ||
beforeEach(() => { | ||
component = shallow(<HorizontalActionList items={items} theme={darkTheme} overflowMenuAriaLabel="more items" />); | ||
}); | ||
|
||
it('matches its snapshot', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.