-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eeddb43
commit 910e729
Showing
4 changed files
with
114 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.crossLink { | ||
@apply flex flex-col items-start p-3 gap-2 bg-white dark:bg-black | ||
border border-solid border-neutral-300 dark:border-neutral-900 rounded; | ||
|
||
.header { | ||
@apply flex items-center self-stretch gap-2 | ||
text-xs text-neutral-800 dark:text-neutral-100; | ||
|
||
&.right { | ||
@apply justify-end; | ||
} | ||
|
||
.icon { | ||
@apply h-4 w-4 text-neutral-600 dark:text-neutral-400; | ||
} | ||
} | ||
|
||
.content { | ||
@apply text-sm truncate text-neutral-900 dark:text-white self-stretch; | ||
|
||
&.right { | ||
@apply text-right; | ||
} | ||
} | ||
} |
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,47 @@ | ||
import type { Meta as MetaObj, StoryObj } from '@storybook/react'; | ||
import CrossLink from './index'; | ||
|
||
type Story = StoryObj<typeof CrossLink>; | ||
type Meta = MetaObj<typeof CrossLink>; | ||
|
||
export const Prev: Story = { | ||
args: { | ||
direction: 'left', | ||
text: 'How to install Node.js', | ||
url: 'https://nodejs.dev/en/learn/how-to-install-nodejs/', | ||
}, | ||
}; | ||
|
||
export const Next: Story = { | ||
args: { | ||
direction: 'right', | ||
text: 'How much JavaScript do you need to know to use Node.js?', | ||
url: 'https://nodejs.dev/en/learn/how-much-javascript-do-you-need-to-know-to-use-nodejs/', | ||
}, | ||
}; | ||
|
||
export const PrevDark: Story = { | ||
render: () => ( | ||
<div data-theme="dark" className="w-80 bg-black p-2"> | ||
<CrossLink | ||
direction="left" | ||
text="How to install Node.js" | ||
url="https://nodejs.dev/en/learn/how-to-install-nodejs/" | ||
/> | ||
</div> | ||
), | ||
}; | ||
|
||
export const NextDark: Story = { | ||
render: () => ( | ||
<div data-theme="dark" className="w-80 bg-black p-2"> | ||
<CrossLink | ||
direction="right" | ||
text="How much JavaScript do you need to know to use Node.js?" | ||
url="https://nodejs.dev/en/learn/how-much-javascript-do-you-need-to-know-to-use-nodejs/" | ||
/> | ||
</div> | ||
), | ||
}; | ||
|
||
export default { component: CrossLink } as Meta; |
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,40 @@ | ||
import styles from './index.module.scss'; | ||
import Link from 'next/link'; | ||
import classNames from 'classnames'; | ||
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/solid'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import type { FC } from 'react'; | ||
|
||
type CrossLinkProps = { | ||
direction: 'left' | 'right'; | ||
text: string; | ||
url: string; | ||
}; | ||
|
||
const CrossLink: FC<CrossLinkProps> = ({ direction, text, url }) => { | ||
const contentClasses = classNames(styles['content'], { | ||
[styles['right']]: direction === 'right', | ||
}); | ||
|
||
return ( | ||
<Link className={styles.crossLink} href={url}> | ||
{direction === 'left' && ( | ||
<div className={styles.header}> | ||
<ChevronLeftIcon className={styles.icon} /> | ||
<FormattedMessage id="components.common.crossLink.prev" /> | ||
</div> | ||
)} | ||
|
||
{direction === 'right' && ( | ||
<div className={`${styles.header} ${styles.right}`}> | ||
<FormattedMessage id="components.common.crossLink.next" /> | ||
<ChevronRightIcon className={styles.icon} /> | ||
</div> | ||
)} | ||
|
||
<div className={contentClasses}>{text}</div> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default CrossLink; |
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