Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[triple-email-template] default 링크 스타일을 추가하고, 스크롤 포커싱 이슈를 해결합니다. #3517

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/triple-email-document/src/elements/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ const H4Container = styled.h4`
`

export function Heading1View({
id,
value: { text, headline },
}: {
id?: string
value: Heading1Document['value']
}) {
return (
<FluidTable>
<FluidTable id={id}>
<tbody>
<tr>
<Box padding={{ top: 25, bottom: 20, left: 30, right: 30 }}>
Expand All @@ -89,12 +91,14 @@ export function Heading1View({
}

export function Heading2View({
id,
value: { text },
}: {
id?: string
value: Heading2Document['value']
}) {
return (
<FluidTable>
<FluidTable id={id}>
<tbody>
<tr>
<Box padding={{ top: 20, bottom: 20, left: 30, right: 30 }}>
Expand All @@ -107,12 +111,14 @@ export function Heading2View({
}

export function Heading3View({
id,
value: { text },
}: {
id?: string
value: Heading3Document['value']
}) {
return (
<FluidTable>
<FluidTable id={id}>
<tbody>
<tr>
<Box padding={{ top: 20, left: 30, right: 30 }}>
Expand All @@ -125,12 +131,14 @@ export function Heading3View({
}

export function Heading4View({
id,
value: { text },
}: {
id?: string
value: Heading4Document['value']
}) {
return (
<FluidTable>
<FluidTable id={id}>
<tbody>
<tr>
<Box padding={{ top: 20, left: 30, right: 30 }}>
Expand Down
1 change: 1 addition & 0 deletions packages/triple-email-document/src/elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type GetValue<Key extends TripleEmailElementType> = Extract<

const ELEMENTS: {
[key in TripleEmailElementType]: ComponentType<{
id?: string
value: GetValue<key>
}>
} = {
Expand Down
20 changes: 20 additions & 0 deletions packages/triple-email-document/src/elements/links.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ import { render, screen } from '@testing-library/react'

import { ELEMENTS } from '../index'

test('디폴트형 링크 Element를 렌더링합니다.', () => {
const Links = ELEMENTS.links

render(
<Links
value={{
links: [{ id: '', label: 'Default Styled Link', href: 'Test Href' }],
display: 'default',
}}
/>,
)

const anchorElement = screen.getByRole('link')

expect(anchorElement).toHaveAttribute('href', 'Test Href')
expect(anchorElement).toHaveStyleRule('color', '#2987f0')
expect(anchorElement).toHaveStyleRule('text-decoration', 'underline')
expect(anchorElement).toHaveTextContent('Default Styled Link')
})

test('버튼형 링크 Element를 렌더링합니다.', () => {
const Links = ELEMENTS.links

Expand Down
33 changes: 32 additions & 1 deletion packages/triple-email-document/src/elements/links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,31 @@ export interface LinksDocument {
type: 'links'
value: {
links: Link[]
display: 'button' | 'block' | 'largeButton' | 'largeCompactButton'
display:
| 'default'
| 'button'
| 'block'
| 'largeButton'
| 'largeCompactButton'
}
}

const DefaultLink = styled.a`
display: inline-block;
margin-right: 20px;
font-size: 15px;
font-weight: bold;
color: #2987f0;
text-decoration: underline;
overflow-wrap: break-word;
white-space: pre-line;

&:hover {
color: #2987f0;
text-decoration: underline;
}
`

const ButtonLink = styled.a`
padding: 13px 25px;
display: inline-block;
Expand Down Expand Up @@ -77,13 +98,15 @@ declare module 'react' {
}

const LINK_BOXES = {
default: DefaultLinkBox,
button: ButtonBox,
block: BlockBox,
largeButton: LargeBox,
largeCompactButton: LargeBox,
}

const LINK_ELEMENTS = {
default: DefaultLink,
button: ButtonLink,
block: BlockLink,
largeButton: LargeLink,
Expand Down Expand Up @@ -123,6 +146,14 @@ export default function LinksView({
)
}

function DefaultLinkBox({ children }: PropsWithChildren<unknown>) {
return (
<DefaultBox padding={{ top: 10, left: 30, right: 30 }}>
{children}
</DefaultBox>
)
}

function ButtonBox({ children }: PropsWithChildren<unknown>) {
return (
<DefaultBox padding={{ top: 55, left: 30, right: 30 }}>
Expand Down
12 changes: 11 additions & 1 deletion packages/triple-email-document/src/links.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export default {
},
} as Meta

export const StyledDefaultLinkElement: StoryObj = {
name: '디폴트',
args: generateSampleData('default'),
}

export const StyledButtonLinkElement: StoryObj = {
name: '버튼',
args: generateSampleData('button'),
Expand All @@ -50,7 +55,12 @@ export const StyledCompactLargeButtonLinkElement: StoryObj = {
args: generateSampleData('largeCompactButton'),
}

type LinkDisplay = 'button' | 'block' | 'largeButton' | 'largeCompactButton'
type LinkDisplay =
| 'default'
| 'button'
| 'block'
| 'largeButton'
| 'largeCompactButton'

function generateSampleData(type: LinkDisplay) {
return {
Expand Down
Loading