Skip to content

Commit 9a8c19f

Browse files
Merge pull request #1451 from thechillbasu/feature/add-code-icon-1449
[Feature] Add CodeIcon
2 parents b3e1404 + be4042f commit 9a8c19f

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

src/__testing__/CodeIcon.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { render } from '@testing-library/react';
2+
import { CodeIcon } from '../icons';
3+
4+
describe('CodeIcon', () => {
5+
it('renders without errors', () => {
6+
render(<CodeIcon width={24} height={24} />);
7+
});
8+
9+
it('applies width and height', () => {
10+
const { getByTestId } = render(<CodeIcon width={24} height={24} />);
11+
const svgElement = getByTestId('code-icon-svg');
12+
expect(svgElement.getAttribute('width')).toBe('24');
13+
expect(svgElement.getAttribute('height')).toBe('24');
14+
});
15+
});

src/icons/Code/CodeIcon.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { DEFAULT_HEIGHT, DEFAULT_WIDTH, DEFAULT_FILL_NONE } from '../../constants/constants';
2+
import { IconProps } from '../types';
3+
4+
export const CodeIcon = ({
5+
width = DEFAULT_WIDTH,
6+
height = DEFAULT_HEIGHT,
7+
fill = DEFAULT_FILL_NONE,
8+
...props
9+
}: IconProps): JSX.Element => {
10+
return (
11+
<svg
12+
width={width}
13+
height={height}
14+
xmlns="http://www.w3.org/2000/svg"
15+
viewBox="0 0 24 24"
16+
data-testid="code-icon-svg"
17+
{...props}
18+
>
19+
<path
20+
d="M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"
21+
fill={fill}
22+
/>
23+
</svg>
24+
);
25+
};
26+
27+
export default CodeIcon;

src/icons/Code/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as CodeIcon } from './CodeIcon';

src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export * from './Circle';
3232
export * from './Clone';
3333
export * from './Close';
3434
export * from './Cloud';
35+
export * from './Code';
3536
export * from './CollapseAll';
3637
export * from './Column';
3738
export * from './CompareArrows';

0 commit comments

Comments
 (0)