refactor(themes/signpost): make link self-contained component
This commit is contained in:
parent
7b16d859d4
commit
ee1daec03c
2 changed files with 33 additions and 22 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import type SectionType from './../types/section';
|
||||
import Link from './Link';
|
||||
|
||||
type Props = {
|
||||
sections: SectionType[];
|
||||
|
|
@ -14,28 +15,7 @@ const Grid = ({ sections }: Props) => (
|
|||
<ul>
|
||||
{section.items.map((item) => (
|
||||
<li key={item.name} className="my-2">
|
||||
<a
|
||||
href={item.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="
|
||||
block
|
||||
w-full
|
||||
text-center
|
||||
py-2
|
||||
border-2
|
||||
border-gray-400
|
||||
rounded
|
||||
hover:bg-gray-900
|
||||
hover:border-gray-900
|
||||
hover:text-white
|
||||
transition
|
||||
focus:ring-2
|
||||
focus:ring-gray-600 text-gray-800
|
||||
"
|
||||
>
|
||||
{item.name}
|
||||
</a>
|
||||
<Link url={item.url} title={item.name} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
|
|||
31
themes/signpost/components/Link.tsx
Normal file
31
themes/signpost/components/Link.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
type Props = {
|
||||
url: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
const Link = ({ url, title }: Props) => (
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="
|
||||
block
|
||||
w-full
|
||||
text-center
|
||||
py-2
|
||||
border-2
|
||||
border-gray-400
|
||||
rounded
|
||||
hover:bg-gray-900
|
||||
hover:border-gray-900
|
||||
hover:text-white
|
||||
transition
|
||||
focus:ring-2
|
||||
focus:ring-gray-600 text-gray-800
|
||||
"
|
||||
>
|
||||
{title}
|
||||
</a>
|
||||
);
|
||||
|
||||
export default Link;
|
||||
Reference in a new issue