Skip to content
15 changes: 2 additions & 13 deletions src/components/DocumentCard/DocumentCard.Props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DocumentCardActivity } from './DocumentCardActivity';
import { DocumentCardActions } from './DocumentCardActions';
import { PersonaInitialsColor } from '../../Persona';
import { ImageFit } from '../../Image';
import { IButtonProps } from '../../Button';

export interface IDocumentCardProps extends React.Props<DocumentCard> {
/**
Expand Down Expand Up @@ -145,22 +146,10 @@ export interface IDocumentCardActionsProps extends React.Props<DocumentCardActio
/**
* The actions available for this document.
*/
actions: IDocumentCardAction[];
actions: IButtonProps[];
Copy link
Member

@dzearing dzearing Aug 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of changing the type here, maybe you should leave the previous and deprecate it.

add "buttons" to the contract as an optional.

Then you are not breaking existing people. We need to avoid breaks as much as possible.

Or maybe don't change it, extend action definition as needed.

Copy link
Contributor

@cliffkoh cliffkoh Aug 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this actually only breaks people who imports IDocumentCardAction.. anyone who specifies actions: { ... } without importing the type will not be broken...

We could of course leave IDocumentCardAction in and while I don't think you can deprecate an interface, you could possibly deprecate both properties and indicate the entire interface is deprecated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok maybe it's ok :)

Approved


/**
* The number of views this document has received.
*/
views?: Number;
}

export interface IDocumentCardAction {
/**
* The icon for this action.
*/
icon: string;

/**
* Function to run when clicking the action.
*/
onClick?: (ev?: any) => void;
}
18 changes: 8 additions & 10 deletions src/components/DocumentCard/DocumentCardActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ export class DocumentCardActions extends React.Component<IDocumentCardActionsPro
return (
<div className='ms-DocumentCardActions'>

{ actions && actions.map((action, index) => (
<div className='ms-DocumentCardActions-action' key={ index }>
<Button
buttonType={ ButtonType.icon }
icon={ action.icon }
onClick={ action.onClick }
rootProps={ { title:'' } }
description='' />
</div>
)) }
{ actions && actions.map((action, index) => {
action.buttonType = ButtonType.icon;
return (
<div className='ms-DocumentCardActions-action' key={ index }>
<Button { ...action } />
</div>
);
}) }

{ views && (
<div className='ms-DocumentCardActions-views'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,37 @@ export class DocumentCardCompleteExample extends React.Component<any, any> {
}
/>
<DocumentCardActions
actions={
[
{ icon: 'share', onClick: (ev: any) => {
console.log('You clicked the share action.');
ev.preventDefault();
ev.stopPropagation();
}
actions={
[
{
icon: 'share',
onClick: (ev: any) => {
console.log('You clicked the share action.');
ev.preventDefault();
ev.stopPropagation();
},
{ icon: 'pinLeft', onClick: (ev: any) => {
console.log('You clicked the pin action.');
ev.preventDefault();
ev.stopPropagation();
}
ariaLabel: 'share action'
},
{
icon: 'pinLeft',
onClick: (ev: any) => {
console.log('You clicked the pin action.');
ev.preventDefault();
ev.stopPropagation();
},
{ icon: 'bell', onClick: (ev: any) => {
console.log('You clicked the bell action.');
ev.preventDefault();
ev.stopPropagation();
}
ariaLabel: 'pin left action'
},
{
icon: 'bell',
onClick: (ev: any) => {
console.log('You clicked the bell action.');
ev.preventDefault();
ev.stopPropagation();
},
]
}
ariaLabel: 'bell action'
},
]
}
views={ 432 }
/>
</DocumentCard>
Expand Down