Skip to content

Commit

Permalink
Feat(#38): Text 컴포넌트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KIMSEI1124 committed Dec 7, 2024
1 parent 7acebec commit 989f615
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/components/Common/Text/Text.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { css } from '@emotion/react';

import type { TextProps } from './Text';

export const getTextSizeStyling = (size: Required<TextProps>['$size']) => {
const style = {
small: css({
fontSize: '10px',
}),
medium: css({
fontSize: '14px',
}),
large: css({
fontSize: '18px',
}),
};
return style[size];
};
11 changes: 7 additions & 4 deletions src/components/Common/Text/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
type TextProps = {
import { getTextSizeStyling } from './Text.styled';

export interface TextProps {
content: string;
};
$size?: 'small' | 'medium' | 'large';
}

function Text({ content }: TextProps) {
function Text({ content, $size = 'medium' }: TextProps) {
return (
<div css={{ width: '100%' }}>
{content.split('\n').map((line, index) => {
return (
<span key={index} css={{ width: '100%', wordBreak: 'break-all' }}>
<span key={index} css={[getTextSizeStyling($size)]}>
{line}
<br />
</span>
Expand Down

0 comments on commit 989f615

Please sign in to comment.