forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[explorer] Add link component (MystenLabs#5395)
- Loading branch information
1 parent
f5e4fcf
commit 11b99a7
Showing
4 changed files
with
58 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
||
import { ButtonOrLink, type ButtonOrLinkProps } from './utils/ButtonOrLink'; | ||
|
||
const linkStyles = cva( | ||
[ | ||
// TODO: Remove when CSS reset is applied. | ||
'cursor-pointer no-underline bg-transparent p-0 border-none', | ||
], | ||
{ | ||
variants: { | ||
variant: { | ||
text: 'text-body font-semibold text-sui-grey-75 hover:text-sui-grey-90 active:text-sui-grey-100', | ||
mono: 'font-mono text-bodySmall font-medium text-sui-dark', | ||
}, | ||
uppercase: { | ||
true: 'uppercase', | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
export interface LinkProps | ||
extends ButtonOrLinkProps, | ||
VariantProps<typeof linkStyles> {} | ||
|
||
export function Link({ variant, ...props }: LinkProps) { | ||
return <ButtonOrLink className={linkStyles({ variant })} {...props} />; | ||
} |
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,24 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { type Meta, type StoryObj } from '@storybook/react'; | ||
|
||
import { Link, type LinkProps } from '../Link'; | ||
|
||
export default { | ||
component: Link, | ||
} as Meta; | ||
|
||
export const Text: StoryObj<LinkProps> = { | ||
args: { | ||
variant: 'text', | ||
children: 'View more', | ||
}, | ||
}; | ||
|
||
export const Mono: StoryObj<LinkProps> = { | ||
args: { | ||
variant: 'mono', | ||
children: '0x0000000000000000000000000000000000000002', | ||
}, | ||
}; |
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