-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1d9994a
commit 9462ec9
Showing
5 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// import type { SVGAttributes } from 'react'; | ||
import { IconName } from '@virtuslab/tetrisly-icons'; | ||
|
||
import type { BaseProps } from '@/types/BaseProps'; | ||
|
||
export type IconProps = { | ||
name: IconName; | ||
color?: BaseProps['color']; | ||
custom?: BaseProps; | ||
}; |
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,39 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { icons } from '@virtuslab/tetrisly-icons'; | ||
|
||
import { Icon } from './Icon'; | ||
|
||
import { TetDocs } from '@/docs-components/TetDocs'; | ||
|
||
const meta = { | ||
title: 'Foundations / Icon', | ||
component: Icon, | ||
tags: ['autodocs'], | ||
args: { | ||
name: '20-tetrisly', | ||
color: '$color-raspberry-0', | ||
}, | ||
argTypes: { | ||
name: { | ||
options: Object.keys(icons), | ||
defaultValue: undefined, | ||
control: { type: 'select' }, | ||
}, | ||
}, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'A clean, consistent, and pixel-perfect icon library crafted especially for modern UI design.', | ||
}, | ||
page: () => ( | ||
<TetDocs docs="https://docs.tetrisly.com/foundations/overview/icons" /> | ||
), | ||
}, | ||
}, | ||
} satisfies Meta<typeof Icon>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
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,22 @@ | ||
import { Icon } from './Icon'; | ||
import { render } from '../../tests/render'; | ||
|
||
const getIcon = (jsx: JSX.Element) => { | ||
const { getByTestId } = render(jsx); | ||
|
||
return getByTestId('icon'); | ||
}; | ||
|
||
describe('Loader', () => { | ||
it('should render the component', () => { | ||
const icon = getIcon(<Icon name="20-tetrisly" />); | ||
|
||
expect(icon).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render star with $color-raspberry-0 color', () => { | ||
const icon = getIcon(<Icon name="20-star" color="$color-raspberry-0" />); | ||
|
||
expect(icon).toHaveStyle('color: rgb(192, 48, 96);'); | ||
}); | ||
}); |
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,15 @@ | ||
import { Icon as SVGIcon } from '@virtuslab/tetrisly-icons'; | ||
import { styled, system } from '@xstyled/styled-components'; | ||
import { FC } from 'react'; | ||
|
||
import type { IconProps } from './Icon.props'; | ||
|
||
import type { MarginProps } from '@/types/MarginProps'; | ||
|
||
const SVG = styled(SVGIcon)` | ||
${system} | ||
`; | ||
|
||
export const Icon: FC<IconProps & MarginProps> = ({ custom, ...rest }) => ( | ||
<SVG data-testid="icon" {...rest} {...custom} /> | ||
); |
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,2 @@ | ||
export { Icon } from './Icon'; | ||
export type { IconProps } from './Icon.props'; |