-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
|
||
interface FillableFlagProps { | ||
maskId: string | ||
percent: number | ||
} | ||
|
||
const FillableFlag = ({ maskId, percent }: FillableFlagProps) => { | ||
const fillWidth = (percent / 100) * 120 | ||
return ( | ||
<svg width="120" height="43" viewBox="0 0 120 43" fill="none" xmlns="http://www.w3.org/2000/svg" role="img"> | ||
<defs> | ||
<mask id={`mask-${maskId}`}> | ||
<rect x="0" y="0" width={`${fillWidth}`} height="43" fill="white" /> | ||
</mask> | ||
</defs> | ||
<path | ||
d="M10.7443 41.822L0.558603 21.375L10.7443 0.928009L119.5 0.928009L119.5 41.822L10.7443 41.822Z" | ||
stroke="black" | ||
fill="black" | ||
mask={`url(#mask-${maskId})`} | ||
/> | ||
<path | ||
d="M10.7443 41.822L0.558603 21.375L10.7443 0.928009L119.5 0.928009L119.5 41.822L10.7443 41.822Z" | ||
stroke="black" | ||
/> | ||
</svg> | ||
) | ||
} | ||
|
||
export default React.memo(FillableFlag) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import FillableFlag from '@/features/fba/components/viz/FillableFlag' | ||
|
||
describe('FillableFlag', () => { | ||
it('should render', () => { | ||
const maskId = 'test' | ||
const { getByRole } = render(<FillableFlag maskId={maskId} percent={50} />) | ||
const element = getByRole('img') | ||
expect(element).toBeInTheDocument() | ||
}) | ||
it("should use maskId in svg mask element's id", () => { | ||
const maskId = 'test' | ||
const result = render(<FillableFlag maskId={maskId} percent={50} />) | ||
const element = result.container.querySelector(`#mask-${maskId}`) | ||
expect(element).toBeInTheDocument() | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.