diff --git a/src/components/Text/index.test.tsx b/src/components/Text/index.test.tsx new file mode 100644 index 0000000..9c3c82e --- /dev/null +++ b/src/components/Text/index.test.tsx @@ -0,0 +1,54 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { render, screen } from '@testing-library/react'; +import { expect } from '@jest/globals'; +import '@testing-library/jest-dom/extend-expect'; + +import { fontSizes, fontColors } from './test-helpers'; + +import Text from './'; + +describe('', () => { + it('should be defined', () => { + render(); + + const element = screen.getByText('test'); + + expect(element).toBeDefined(); + }); + + fontSizes.forEach(fontSize => { + it(`should render with font-size: ${fontSize.value}`, () => { + render(); + + const element = screen.getByText('test'); + + (expect as any)(element).toHaveStyle(`font-size: + ${fontSize.value}`); + }); + }); + + fontColors.forEach(fontColor => { + it(`should render with color: ${fontColor.value}`, () => { + render(); + + const element = screen.getByText('test'); + + (expect as any)(element).toHaveStyle(`color: + ${fontColor.value}`); + }); + }); + + it('should render with font-size: 16px as default', () => { + render(); + + const element = screen.getByText('test'); + + (expect as any)(element).toHaveStyle('font-size: + 16px'); + }); + + it('should render with color: #1A1033 as default', () => { + render(); + + const element = screen.getByText('test'); + + (expect as any)(element).toHaveStyle('color: + #1A1033'); + }); +}); diff --git a/src/components/Text/index.tsx b/src/components/Text/index.tsx new file mode 100644 index 0000000..e1fdac1 --- /dev/null +++ b/src/components/Text/index.tsx @@ -0,0 +1,7 @@ +import * as S from './styles'; + +const Text = (props: TextProps) => { + return {props.label}; +}; + +export default Text; diff --git a/src/components/Text/styles.ts b/src/components/Text/styles.ts new file mode 100644 index 0000000..f4cd837 --- /dev/null +++ b/src/components/Text/styles.ts @@ -0,0 +1,13 @@ +import styled from 'styled-components'; + +export const Text = styled.p` + color: ${({ fontColor }) => + fontColor ? `var(--${fontColor})` : 'var(--purple-dark)'}; + font-size: ${({ fontSize }) => + fontSize ? `var(--font-size-${fontSize})` : 'var(--font-size-normal)'}; + font-weight: ${({ fontWeight }) => (fontWeight ? `${fontWeight}` : 'normal')}; + font-style: ${({ fontStyle }) => (fontStyle ? `${fontStyle}` : 'normal')}; + display: flex; + justify-content: center; + align-items: center; +`; diff --git a/src/components/Text/test-helpers.ts b/src/components/Text/test-helpers.ts new file mode 100644 index 0000000..96398cc --- /dev/null +++ b/src/components/Text/test-helpers.ts @@ -0,0 +1,18 @@ +export const fontSizes: FontSizes[] = [ + { label: 'xsmall', value: '12px' }, + { label: 'small', value: '14px' }, + { label: 'normal', value: '16px' }, + { label: 'medium', value: '18px' }, + { label: 'large', value: '32px' }, + { label: 'xlarge', value: '48px' }, +]; + +export const fontColors: FontColors[] = [ + { label: 'purple', value: '#5D5FEF' }, + { label: 'purple-light', value: '#B2A1D9' }, + { label: 'purple-dark', value: '#1A1033' }, + { label: 'white', value: '#FFFFFF' }, + { label: 'gray', value: '#A6A8AB' }, + { label: 'gray-light', value: '#D1D1D1' }, + { label: 'yellow', value: '#FBB04D' }, +]; diff --git a/src/types/FontColor.d.ts b/src/types/FontColor.d.ts new file mode 100644 index 0000000..962e644 --- /dev/null +++ b/src/types/FontColor.d.ts @@ -0,0 +1,8 @@ +type FontColor = + | 'purple' + | 'purple-light' + | 'purple-dark' + | 'white' + | 'gray' + | 'gray-light' + | 'yellow'; diff --git a/src/types/FontColors.d.ts b/src/types/FontColors.d.ts new file mode 100644 index 0000000..381a6bf --- /dev/null +++ b/src/types/FontColors.d.ts @@ -0,0 +1,4 @@ +type FontColors = { + label: FontColor; + value: string; +}; diff --git a/src/types/FontSize.d.ts b/src/types/FontSize.d.ts new file mode 100644 index 0000000..1b5cbbd --- /dev/null +++ b/src/types/FontSize.d.ts @@ -0,0 +1 @@ +type FontSize = 'normal' | 'small' | 'xsmall' | 'medium' | 'large' | 'xlarge'; diff --git a/src/types/FontSizes.d.ts b/src/types/FontSizes.d.ts new file mode 100644 index 0000000..fb4e764 --- /dev/null +++ b/src/types/FontSizes.d.ts @@ -0,0 +1,4 @@ +type FontSizes = { + label: FontSize; + value: string; +}; diff --git a/src/types/FontStyle.d.ts b/src/types/FontStyle.d.ts new file mode 100644 index 0000000..31008f8 --- /dev/null +++ b/src/types/FontStyle.d.ts @@ -0,0 +1 @@ +type FontStyle = 'normal' | 'italic'; diff --git a/src/types/FontWeight.d.ts b/src/types/FontWeight.d.ts new file mode 100644 index 0000000..1b78e1f --- /dev/null +++ b/src/types/FontWeight.d.ts @@ -0,0 +1 @@ +type FontWeight = 'normal' | 'bold' | 'lighter'; diff --git a/src/types/TextProps.d.ts b/src/types/TextProps.d.ts new file mode 100644 index 0000000..89688ae --- /dev/null +++ b/src/types/TextProps.d.ts @@ -0,0 +1,7 @@ +type TextProps = { + fontSize?: FontSize; + fontWeight?: FontWeight; + fontColor?: FontColor; + label: string; + fontStyle?: FontStyle; +};