Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(QualificationIconStack): Add theme props #2726

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading