-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet-ext: button connected to component
* implement figma button component to reuse in dapp status and (later) for account selector
- Loading branch information
1 parent
288f2bd
commit 3e8a8ab
Showing
6 changed files
with
118 additions
and
145 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
48 changes: 48 additions & 0 deletions
48
apps/wallet/src/ui/app/shared/ButtonConnectedTo.stories.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,48 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { type Meta, type StoryObj } from '@storybook/react'; | ||
|
||
import Icon, { SuiIcons } from '../components/icon'; | ||
import { ButtonConnectedTo } from './ButtonConnectedTo'; | ||
|
||
export default { | ||
component: ButtonConnectedTo, | ||
} as Meta<typeof ButtonConnectedTo>; | ||
|
||
export const Default: StoryObj<typeof ButtonConnectedTo> = { | ||
args: { | ||
text: 'Button', | ||
}, | ||
}; | ||
|
||
export const LightGrey: StoryObj<typeof ButtonConnectedTo> = { | ||
args: { | ||
text: 'Button', | ||
bgOnHover: 'grey', | ||
}, | ||
}; | ||
|
||
export const Disabled: StoryObj<typeof ButtonConnectedTo> = { | ||
args: { | ||
text: 'Button', | ||
bgOnHover: 'grey', | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const LongText: StoryObj<typeof ButtonConnectedTo> = { | ||
render: (props) => { | ||
return ( | ||
<div className="w-28"> | ||
<ButtonConnectedTo {...props} /> | ||
</div> | ||
); | ||
}, | ||
args: { | ||
text: 'Button with very long text', | ||
bgOnHover: 'grey', | ||
iconBefore: <Icon icon={SuiIcons.Add} />, | ||
iconAfter: <Icon icon={SuiIcons.Add} />, | ||
}, | ||
}; |
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,51 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import { type ComponentProps, forwardRef, type ReactNode } from 'react'; | ||
|
||
const styles = cva( | ||
[ | ||
'cursor-pointer outline-0 flex flex-row items-center py-1 px-2 gap-1 rounded-2xl', | ||
'transition text-body-small font-medium border border-solid max-w-full min-w-0', | ||
'border-transparent bg-transparent', | ||
'hover:text-hero hover:bg-sui-light hover:border-sui', | ||
'focus:text-hero focus:bg-sui-light focus:border-sui', | ||
'active:text-steel active:bg-gray-45 active:border-transparent', | ||
'disabled:text-gray-60 disabled:bg-transparent disabled:border-transparent', | ||
], | ||
{ | ||
variants: { | ||
bgOnHover: { | ||
blueLight: ['text-hero'], | ||
grey: ['text-steel-dark'], | ||
}, | ||
}, | ||
defaultVariants: { | ||
bgOnHover: 'blueLight', | ||
}, | ||
} | ||
); | ||
|
||
export interface ButtonConnectedToProps | ||
extends VariantProps<typeof styles>, | ||
Omit<ComponentProps<'button'>, 'ref' | 'className'> { | ||
iconBefore?: ReactNode; | ||
text?: string; | ||
iconAfter?: ReactNode; | ||
} | ||
|
||
export const ButtonConnectedTo = forwardRef< | ||
HTMLButtonElement, | ||
ButtonConnectedToProps | ||
>(({ bgOnHover, iconBefore, iconAfter, text, ...rest }, ref) => { | ||
return ( | ||
<button {...rest} ref={ref} className={styles({ bgOnHover })}> | ||
{iconBefore} | ||
<span className="truncate">{text}</span> | ||
{iconAfter} | ||
</button> | ||
); | ||
}); | ||
|
||
ButtonConnectedTo.displayName = 'ButtonConnectedTo'; |
49 changes: 1 addition & 48 deletions
49
apps/wallet/src/ui/app/shared/dapp-status/DappStatus.module.scss
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
Oops, something went wrong.