Skip to content

Commit

Permalink
feat(QualificationIconStack): Add theme props
Browse files Browse the repository at this point in the history
Now works both for theme and qualification
  • Loading branch information
JF-Cozy committed Dec 10, 2024
1 parent 9c26d28 commit 61081a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
5 changes: 4 additions & 1 deletion react/QualificationIconStack/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import QualificationIconStack from 'cozy-ui/transpiled/react/QualificationIconSt
;

<>
<QualificationIconStack className="u-mr-1" />
<QualificationIconStack className="u-mr-1" qualification="isp_invoice" />
<QualificationIconStack className="u-mr-1" qualification="phone_invoice" />
<QualificationIconStack qualification="family_record_book" />
<QualificationIconStack className="u-mr-1" qualification="family_record_book" />
<QualificationIconStack className="u-mr-1" theme="identity" />
<QualificationIconStack theme="transport" />
</>
```
35 changes: 28 additions & 7 deletions react/QualificationIconStack/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import BankCheckIcon from '../Icons/BankCheck'
import BenefitIcon from '../Icons/Benefit'
import BillIcon from '../Icons/Bill'
import CarIcon from '../Icons/Car'
import ChessIcon from '../Icons/Chess'
import ChildIcon from '../Icons/Child'
import DotsIcon from '../Icons/Dots'
import EmailIcon from '../Icons/Email'
import EuroIcon from '../Icons/Euro'
import ExchangeIcon from '../Icons/Exchange'
Expand Down Expand Up @@ -51,13 +53,15 @@ function FileDuotoneWhite(props) {
)
}

const qualificationIcon = {
const IconByLabel = {
'bank-check': BankCheckIcon,
bank: BankIcon,
benefit: BenefitIcon,
bill: BillIcon,
car: CarIcon,
chess: ChessIcon,
child: ChildIcon,
dots: DotsIcon,
email: EmailIcon,
euro: EuroIcon,
exchange: ExchangeIcon,
Expand All @@ -84,8 +88,25 @@ const qualificationIcon = {
work: WorkIcon
}

const QualificationIconStack = ({ qualification, ...props }) => {
const QualificationIcon = qualificationIcon[getIconByLabel(qualification)]
const themeIconByLabel = {
identity: 'people',
family: 'team',
work_study: 'work',
health: 'heart',
home: 'home',
transport: 'car',
activity: 'chess',
finance: 'bank',
invoice: 'bill',
others: 'dots'
}

const QualificationIconStack = ({ theme, qualification, ...props }) => {
const ForegroundIcon = qualification
? IconByLabel[getIconByLabel(qualification)]
: theme
? IconByLabel[themeIconByLabel[theme]]
: null

return (
<IconStack
Expand All @@ -96,16 +117,16 @@ const QualificationIconStack = ({ qualification, ...props }) => {
<Icon icon={FileDuotoneIcon} color="#E049BF" size={32} />
</>
}
foregroundIcon={
<Icon icon={QualificationIcon} color="#E049BF" size={16} />
}
foregroundIcon={<Icon icon={ForegroundIcon} color="#E049BF" size={16} />}
/>
)
}

QualificationIconStack.propTypes = {
/** The name of the qualification (isp\_invoice, family\_record\_book, etc.) */
qualification: PropTypes.string.isRequired
qualification: PropTypes.string,
/** The name of the qualification theme (indentity, family, etc.) */
theme: PropTypes.string
}

export default QualificationIconStack

0 comments on commit 61081a1

Please sign in to comment.