Skip to content

Commit

Permalink
Adding maskId (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
robmadole committed Feb 24, 2022
1 parent ac63cd4 commit 9f83d49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface FontAwesomeIconProps extends BackwardCompatibleOmit<SVGAttribut
forwardedRef?: ((e: any) => void) | React.MutableRefObject<any> | null
icon: IconProp
mask?: IconProp
maskId?: string
className?: string
color?: string
spin?: boolean
Expand Down
9 changes: 7 additions & 2 deletions src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default function FontAwesomeIcon({ forwardedRef, ...props }) {
symbol,
className,
title,
titleId
titleId,
maskId
} = props

const iconLookup = normalizeIconArgs(iconArgs)
Expand All @@ -37,7 +38,8 @@ export default function FontAwesomeIcon({ forwardedRef, ...props }) {
...mask,
symbol,
title,
titleId
titleId,
maskId
})

if (!renderedIcon) {
Expand Down Expand Up @@ -79,6 +81,8 @@ FontAwesomeIcon.propTypes = {
PropTypes.string
]),

maskId: PropTypes.string,

fixedWidth: PropTypes.bool,

inverse: PropTypes.bool,
Expand Down Expand Up @@ -141,6 +145,7 @@ FontAwesomeIcon.defaultProps = {
border: false,
className: '',
mask: null,
maskId: null,
fixedWidth: false,
inverse: false,
flip: null,
Expand Down
11 changes: 10 additions & 1 deletion src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,22 @@ describe('using transform', () => {
})
})

describe('mask', () => {
describe.only('mask', () => {
test('will add icon', () => {
const vm = mount({ icon: faCoffee, mask: faCircle })

expect(vm.children.length).toBe(2)
expect(vm.children[1].props.hasOwnProperty('clipPath')).toBeTruthy() // eslint-disable-line no-prototype-builtins
})

test('will use maskId', () => {
const vm = mount({ icon: faCoffee, mask: faCircle, maskId: 'circle-mask' })

expect(vm.children[0].children[0].props.id).toEqual('clip-circle-mask')
expect(vm.children[0].children[1].props.id).toEqual('mask-circle-mask')
expect(vm.children[1].props.mask).toEqual('url(#mask-circle-mask)')
expect(vm.children[1].props.clipPath).toEqual('url(#clip-circle-mask)')
})
})

describe('symbol', () => {
Expand Down

0 comments on commit 9f83d49

Please sign in to comment.