-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
8 changed files
with
212 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/components/layout/header/internal/HeaderWithShadow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use client' | ||
|
||
import clsx from 'clsx' | ||
|
||
import { usePageScrollLocationSelector } from '~/providers/root/page-scroll-info-provider' | ||
|
||
export const HeaderWithShadow: Component = ({ children }) => { | ||
const showShadow = usePageScrollLocationSelector((y) => y > 100) | ||
return ( | ||
<header | ||
className={clsx( | ||
'fixed left-0 right-0 top-0 z-[9] h-[4.5rem] overflow-hidden transition-shadow duration-200', | ||
showShadow && 'shadow-xl shadow-neutral-100 dark:shadow-neutral-800', | ||
)} | ||
> | ||
{children} | ||
</header> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.anchor { | ||
@apply relative inline cursor-alias overflow-hidden text-accent; | ||
} | ||
|
||
.anchor::after { | ||
@apply absolute -bottom-0.5 left-1/2 w-0 -translate-x-1/2 border-b-[1px] border-current text-center transition-[width] duration-500 ease-in-out; | ||
|
||
content: ''; | ||
} | ||
|
||
.anchor:hover::after { | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { memo, useCallback } from 'react' | ||
import Router from 'next/router' | ||
import type { FC } from 'react' | ||
|
||
import { FloatPopover } from '../../float-popover' | ||
import styles from './link.module.css' | ||
|
||
const ExtendIcon = () => ( | ||
<svg | ||
style={{ | ||
transform: `translateY(-2px)`, | ||
marginLeft: `2px`, | ||
}} | ||
xmlns="http://www.w3.org/2000/svg" | ||
x="0px" | ||
y="0px" | ||
viewBox="0 0 100 100" | ||
width="15" | ||
height="15" | ||
className="inline align-middle leading-normal" | ||
> | ||
<path | ||
fill="var(--shizuku-text-color)" | ||
d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" | ||
/> | ||
<polygon | ||
fill="var(--shizuku-text-color)" | ||
points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" | ||
/> | ||
</svg> | ||
) | ||
export const MLink: FC<{ | ||
href: string | ||
title?: string | ||
children?: JSX.Element | JSX.Element[] | ||
}> = memo((props) => { | ||
const handleRedirect = useCallback( | ||
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { | ||
const href = props.href | ||
const locateUrl = new URL(location.href) | ||
|
||
const toUrlParser = new URL(href) | ||
|
||
if ( | ||
toUrlParser.host === locateUrl.host || | ||
(process.env.NODE_ENV === 'development' && | ||
toUrlParser.host === 'innei.ren') | ||
) { | ||
e.preventDefault() | ||
const pathArr = toUrlParser.pathname.split('/').filter(Boolean) | ||
const headPath = pathArr[0] | ||
|
||
switch (headPath) { | ||
case 'posts': | ||
case 'notes': | ||
case 'category': { | ||
Router.push(toUrlParser.pathname) | ||
break | ||
} | ||
default: { | ||
window.open(toUrlParser.pathname) | ||
} | ||
} | ||
} | ||
}, | ||
[props.href], | ||
) | ||
|
||
return ( | ||
<FloatPopover | ||
as="span" | ||
wrapperClassNames="!inline" | ||
TriggerComponent={() => ( | ||
<> | ||
<a | ||
className={styles['anchor']} | ||
href={props.href} | ||
target="_blank" | ||
onClick={handleRedirect} | ||
title={props.title} | ||
> | ||
{props.children} | ||
</a> | ||
|
||
{ExtendIcon} | ||
</> | ||
)} | ||
> | ||
<span>{props.href}</span> | ||
</FloatPopover> | ||
) | ||
}) |
525cbc0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
springtide – ./
springtide-innei.vercel.app
springtide.vercel.app
innei.in
springtide-git-main-innei.vercel.app