Skip to content

Commit

Permalink
Apply PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Feb 6, 2020
1 parent 8f91d27 commit 0b69a51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
11 changes: 1 addition & 10 deletions packages/component/src/Attachment/FileAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@ import PropTypes from 'prop-types';
import React from 'react';

import FileContent from './FileContent';
import useStyleSet from '../hooks/useStyleSet';

const FileAttachment = ({
activity: { attachments = [], channelData: { attachmentSizes = [] } = {} } = {},
attachment
}) => {
const [{ fileAttachment: fileAttachmentStyleSet }] = useStyleSet();
const attachmentIndex = attachments.indexOf(attachment);
const size = attachmentSizes[attachmentIndex];

return (
<FileContent
className={fileAttachmentStyleSet + ''}
fileName={attachment.name}
href={attachment.contentUrl}
size={size}
/>
);
return <FileContent fileName={attachment.name} href={attachment.contentUrl} size={size} />;
};

FileAttachment.propTypes = {
Expand Down
29 changes: 12 additions & 17 deletions packages/component/src/Attachment/FileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,20 @@ const FileContent = ({ className, href, fileName, size }) => {
aria-hidden={true}
className={classNames('webchat__fileContent', ROOT_CSS + '', fileContentStyleSet + '', (className || '') + '')}
>
<ScreenReaderText text={alt} />
{href ? (
<React.Fragment>
<ScreenReaderText text={alt} />
<a
aria-hidden={true}
className="webchat__fileContent__buttonLink"
href={href}
rel="noopener noreferrer"
target="_blank"
>
{/* Although nested, Chrome v75 does not respect the above aria-hidden and makes the below aria-hidden in FileContentBadge necessary */}
<FileContentBadge downloadIcon={true} fileName={fileName} size={size} />
</a>
</React.Fragment>
<a
aria-hidden={true}
className="webchat__fileContent__buttonLink"
href={href}
rel="noopener noreferrer"
target="_blank"
>
{/* Although nested, Chrome v75 does not respect the above aria-hidden and makes the below aria-hidden in FileContentBadge necessary */}
<FileContentBadge downloadIcon={true} fileName={fileName} size={size} />
</a>
) : (
<React.Fragment>
<ScreenReaderText text={alt} />
<FileContentBadge downloadIcon={false} fileName={fileName} size={size} />
</React.Fragment>
<FileContentBadge downloadIcon={false} fileName={fileName} size={size} />
)}
</div>
);
Expand Down
3 changes: 0 additions & 3 deletions packages/component/src/Styles/StyleSet/FileAttachment.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/component/src/Styles/createStyleSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import createConnectivityNotification from './StyleSet/ConnectivityNotification'
import createDictationInterimsStyle from './StyleSet/DictationInterims';
import createErrorBoxStyle from './StyleSet/ErrorBox';
import createErrorNotificationStyle from './StyleSet/ErrorNotification';
import createFileAttachmentStyle from './StyleSet/FileAttachment';
import createFileContentStyle from './StyleSet/FileContent';
import createMicrophoneButtonStyle from './StyleSet/MicrophoneButton';
import createRootStyle from './StyleSet/Root';
Expand Down Expand Up @@ -181,7 +180,6 @@ export default function createStyleSet(options) {
dictationInterims: createDictationInterimsStyle(options),
errorBox: createErrorBoxStyle(options),
errorNotification: createErrorNotificationStyle(options),
fileAttachment: createFileAttachmentStyle(options),
fileContent: createFileContentStyle(options),
microphoneButton: createMicrophoneButtonStyle(options),
options: {
Expand Down

0 comments on commit 0b69a51

Please sign in to comment.