Skip to content

Commit a64a48d

Browse files
committed
feat: add translation links and styling to PostLayout
1 parent d616876 commit a64a48d

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/layouts/PostLayout.styles.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ export const PostContents = styled(TextBlock).attrs({
5454
as: 'article'
5555
})``
5656

57+
export const TranslateBar = styled.div`
58+
display: flex;
59+
justify-content: center;
60+
gap: 0.75rem;
61+
margin: 1.5rem 0;
62+
`
63+
64+
export const TranslateLink = styled.a`
65+
font-size: ${$theme.fontSize.copy2}rem;
66+
color: ${$theme.color.copyLight};
67+
font-weight: ${$theme.fontWeight.semiBold};
68+
text-decoration: none;
69+
border: 1.5px solid ${$theme.color.copyLight};
70+
border-radius: 999px;
71+
padding: 0.25em 0.9em;
72+
transition: ${$theme.transition.default};
73+
74+
&:hover {
75+
color: ${$theme.color.copy};
76+
border-color: ${$theme.color.copy};
77+
background-color: ${$theme.color.copy}0D;
78+
}
79+
`
80+
5781
export const PostFooter = styled.footer`
5882
display: grid;
5983
grid-template-columns: max-content 1fr max-content;

src/layouts/PostLayout.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ export const PostLayout: React.FC<PostLayoutProps> = ({
3737
</S.PostOccurrence>
3838
)}
3939
<S.PostDate>{formatRFC7231(date)}</S.PostDate>
40+
<S.TranslateBar>
41+
<S.TranslateLink
42+
href={`https://translate.google.com/translate?hl=es&sl=auto&u=${typeof window !== 'undefined' ? window.location.href : ''}`}
43+
target="_blank"
44+
rel="noopener noreferrer"
45+
>
46+
Traducir
47+
</S.TranslateLink>
48+
<S.TranslateLink
49+
href={`https://translate.google.com/translate?hl=ht&sl=auto&u=${typeof window !== 'undefined' ? window.location.href : ''}`}
50+
target="_blank"
51+
rel="noopener noreferrer"
52+
>
53+
Tradwi
54+
</S.TranslateLink>
55+
<S.TranslateLink
56+
href={`https://translate.google.com/translate?u=${typeof window !== 'undefined' ? window.location.href : ''}`}
57+
target="_blank"
58+
rel="noopener noreferrer"
59+
>
60+
Translate
61+
</S.TranslateLink>
62+
</S.TranslateBar>
4063
<S.PostContents dangerouslySetInnerHTML={{ __html: contents }} />
4164
<S.PostFooter>
4265
{previousSlug && (

0 commit comments

Comments
 (0)