Skip to content

Commit

Permalink
feat: create StatsInfoButton component
Browse files Browse the repository at this point in the history
For #348.

Came out of phetsims/qa#869.
  • Loading branch information
liammulh committed Jan 4, 2023
1 parent 701ff47 commit 23746ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
30 changes: 30 additions & 0 deletions src/client/components/StatsInfoButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2022, University of Colorado Boulder

/**
*
*
* @author Liam Mulhall <[email protected]>
*/

import infoCircle from '../img/info-circle.svg';

const StatsInfoButton = ( { statsString } ) => {
const buttonStyle = {
marginRight: '6px',
padding: '0'
};
return (
<button
onClick={() => window.alert( statsString )}
style={buttonStyle}
type='button'
className='btn btn-light'
data-bs-toggle='tooltip'
data-bs-placement='top'
title={statsString}>
<img src={infoCircle} alt='info icon'/>
</button>
);
};

export default StatsInfoButton;
20 changes: 2 additions & 18 deletions src/client/jsx/getTranslationReportRows.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import { Link } from 'react-router-dom';
import getMinutesElapsed from '../../common/getMinutesElapsed.js';
import publicConfig from '../../common/publicConfig.js';
import StatsInfoButton from '../components/StatsInfoButton.jsx';
import getSortedTranslationReportRows from './getSortedTranslationReportRows.jsx';
import infoCircle from '../img/info-circle.svg';

/**
* Return an array of translation report table rows, i.e. return an array of JSX. These rows are put into the
Expand Down Expand Up @@ -87,28 +87,12 @@ const getTranslationReportRows = (
Sim-Specific Strings: ${simSpecificStatsString}
Shared Strings: ${sharedStatsString}
Common Strings: ${commonStatsString}`;
const buttonStyle = {
marginRight: '6px',
padding: '0'
};
const statsInfoJsx = (
<button
onClick={() => window.alert( statsString )}
style={buttonStyle}
type='button'
className='btn btn-light'
data-bs-toggle='tooltip'
data-bs-placement='top'
title={statsString}>
<img src={infoCircle} alt='info icon'/>
</button>
);
if ( Object.keys( translationReportJsx ).includes( reportObject.simName ) ) {
translationReportJsx[ reportObject.simName ] = (
<tr key={reportObject.simName}>
<td><Link to={`/translate/${locale}/${reportObject.simName}`}>{reportObject.simTitle}</Link>{pendingUpdate}</td>
<td>
{statsInfoJsx}
<StatsInfoButton statsString={statsString}/>
{reportObject.percentTotal}% ({reportObject.totalTranslatedStrings} of {reportObject.totalStrings})
</td>
</tr>
Expand Down

0 comments on commit 23746ab

Please sign in to comment.