Browse Source

fix favicons

main
matthew 2 years ago
parent
commit
401776bf57
  1. 1
      searching-front/app/core/components/SearchForm/styles.module.css
  2. 9
      searching-front/app/core/components/WebsiteCard/WebsiteCard.tsx
  3. 11
      searching-front/app/core/components/WebsiteCard/styles.module.css

1
searching-front/app/core/components/SearchForm/styles.module.css

@ -29,6 +29,7 @@
} }
.input { .input {
min-width: 10px;
outline: none; outline: none;
border: none; border: none;
flex: 1; flex: 1;

9
searching-front/app/core/components/WebsiteCard/WebsiteCard.tsx

@ -9,12 +9,13 @@ interface Props {
faviconUrl?: string faviconUrl?: string
} }
const WebsiteCard = (props: Props) => { const WebsiteCard = (props: Props) => {
const faviconUrl = props.faviconUrl; const faviconUrl = props.faviconUrl
const [faviconLoaded, setFaviconLoaded] = useState(false) const [faviconLoaded, setFaviconLoaded] = useState(false)
useEffect(() => { useEffect(() => {
if (faviconUrl) { if (faviconUrl) {
const faviconNode = document.createElement("img") const faviconNode = document.createElement("img")
faviconNode.src = faviconUrl; faviconNode.src = faviconUrl
faviconNode.onload = () => { faviconNode.onload = () => {
setFaviconLoaded(true) setFaviconLoaded(true)
} }
@ -27,13 +28,15 @@ const WebsiteCard = (props: Props) => {
return ( return (
<div className={s.root}> <div className={s.root}>
{faviconLoaded &&<img className={(s.favicon)} src={faviconUrl} />}
<a target="_blank" className={s.titleLink} href={url}> <a target="_blank" className={s.titleLink} href={url}>
{props.title} {props.title}
</a> </a>
<div className={s.faviconAndUrlWrapper}>
{faviconLoaded && <img className={s.favicon} src={faviconUrl} />}
<a target="_blank" className={s.miniLink} href={url}> <a target="_blank" className={s.miniLink} href={url}>
{cleanUrlForUi(props.url)} {cleanUrlForUi(props.url)}
</a> </a>
</div>
<div className={s.description}>{props.description}</div> <div className={s.description}>{props.description}</div>
</div> </div>
) )

11
searching-front/app/core/components/WebsiteCard/styles.module.css

@ -45,8 +45,17 @@
top: 16px; top: 16px;
} }
.faviconAndUrlWrapper {
display: flex;
align-items: center;
}
@media only screen and (max-width: 700px) { @media only screen and (max-width: 700px) {
.favicon { .favicon {
left: -16px; position: static;
margin-right: 5px;
}
.faviconAndUrlWrapper{
margin-bottom: 2px;
} }
} }

Loading…
Cancel
Save