Files
freeCodeCamp/client/src/templates/Introduction/components/CertificationCard.js

70 lines
1.9 KiB
JavaScript
Raw Normal View History

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import ScrollableAnchor from 'react-scrollable-anchor';
import { useTranslation } from 'react-i18next';
import ClaimCertSteps from './ClaimCertSteps';
feat(client): migrate icons to TS (#42453) * migrate files and update tests fix: use more memory for gatsby develop (#42433) feat(client): remove whitespace from calculated values (#42400) * feat(client?): remove whitespace for calculated values * feat(client): remove whitespace from styledeclaration * do not automatically strip Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: include all properties of CSSStyleDeclaration * fix test for getPropVal Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> fix: get showUpcomingChange from env.json (#42440) fix(client): display legacy certs like current ones (#42038) * fix: display legacy certs like the current ones * fix: link projects in legacy certs to project pages * fix: update tests to changed legacy cert display * fix: update tests for removed legacy certs forms * fix: display legacy certs like the current ones * fix: submit projects for cert on projects pages * fix: remove legacy certs form submitting handling * fix: move claiming cert setup before both tests * fix: remove legacy cert update props and actions * fix: remove legacy cert updates from api * fix: correct merge conflict fix(curriculum): rework Project Euler 98 (#42423) * fix: rework challenge to use argument in function * fix: add solution * fix: use MathJax to improve math notation fix(curriculum): rework Project Euler 56 (#42364) * fix: rework challenge to use argument in function * fix: add solution * fix: use MathJax to improve look of math notation fix(curriculum): correct small english typo (#42447) chore: group together monaco-editor and plugin (#42443) This should get renovate to create PRs where both are modified. fix(deps): update dependency algoliasearch to v4.9.2 (#42432) Co-authored-by: Renovate Bot <bot@renovateapp.com> migrate files and update tests Algorithm moved to TSX first ten files renamed to tsx first 10 migration complete first 20 files renamed migrate some files. rename all test index.tsx forced to ignore ts issues rename and migrate all files update tests * remove missed propType declarations * kebab-caseify * fi xlinting Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Parth Parth <thecodingaviator@users.noreply.github.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
2021-06-25 20:11:27 +05:30
import Caret from '../../../assets/icons/caret';
const propTypes = {
certSlug: PropTypes.string,
i18nCertText: PropTypes.string,
superBlock: PropTypes.string
};
const CertificationCard = ({ certSlug, superBlock, i18nCertText }) => {
const { t } = useTranslation();
const [isExpanded, setIsExpanded] = useState(true);
const handleBlockClick = () => {
setIsExpanded(!isExpanded);
};
const {
expand: expandText,
collapse: collapseText,
steps: stepsText
} = t('intro:misc-text');
return (
<ScrollableAnchor id='claim-cert-block'>
<div className={`block ${isExpanded ? 'open' : ''}`}>
<div className='block-title-wrapper'>
<a className='block-link' href='#claim-cert-block'>
<h3 className='big-block-title'>
{t('certification-card.title')}
<span className='block-link-icon'>#</span>
</h3>
</a>
</div>
<div className='block-description'>
{t('certification-card.intro', { i18nCertText })}
</div>
<button
aria-expanded={isExpanded}
className='map-title'
onClick={handleBlockClick}
>
<Caret />
<h4 className='course-title'>
{`${
isExpanded ? collapseText : expandText
} ${stepsText.toLowerCase()}`}
</h4>
</button>
{isExpanded && (
<ClaimCertSteps
certSlug={certSlug}
i18nCertText={i18nCertText}
superBlock={superBlock}
/>
)}
</div>
</ScrollableAnchor>
);
};
CertificationCard.displayName = 'CertStatus';
CertificationCard.propTypes = propTypes;
export default CertificationCard;