Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V 3/network button #1314

Merged
merged 23 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c9db2a3
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 8, 2023
797a677
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 15, 2023
5bb31c4
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 15, 2023
9d7d7fb
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 16, 2023
e4751ef
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 16, 2023
c283ab2
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 21, 2023
035cfef
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 23, 2023
44b0366
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 23, 2023
f00815b
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 25, 2023
482e54e
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Aug 30, 2023
bf7059a
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Sep 4, 2023
362f940
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Sep 5, 2023
9b91647
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Sep 5, 2023
83fa048
Merge branch 'V3' of github.com:WalletConnect/web3modal into V3
svenvoskamp Sep 6, 2023
f6cc4a3
network button changes
svenvoskamp Sep 6, 2023
cde78a6
merge main into v-3/network-button
svenvoskamp Sep 6, 2023
3f54d72
remove obsolete code
svenvoskamp Sep 6, 2023
81d7e9f
remove obsolete code
svenvoskamp Sep 6, 2023
a14e54d
remove obsolete code
svenvoskamp Sep 6, 2023
f5aba55
remove obsolete code
svenvoskamp Sep 6, 2023
ee49d30
remove name property
svenvoskamp Sep 7, 2023
0d24aee
add network button type
svenvoskamp Sep 7, 2023
9a443cd
expose disabled property
svenvoskamp Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions apps/gallery/stories/composites/wui-network-button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ export default {
title: 'Composites/wui-network-button',
args: {
imageSrc: networkImageSrc,
variant: 'fill'
disabled: false
},
argTypes: {
variant: {
options: ['fill', 'shade'],
control: { type: 'select' }
disabled: {
control: { type: 'boolean' }
}
}
} as Component

export const Default: Component = {
render: args =>
html`<wui-network-button .imageSrc=${args.imageSrc} variant=${args.variant}>
Ethereum
</wui-network-button>`
html`<wui-network-button ?disabled=${args.disabled} .imageSrc=${args.imageSrc}
>Ethereum</wui-network-button
>`
}
8 changes: 6 additions & 2 deletions packages/scaffold/src/modal/w3m-network-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class W3mNetworkButton extends LitElement {
private unsubscribe: (() => void)[] = []

// -- State & Properties -------------------------------- //
svenvoskamp marked this conversation as resolved.
Show resolved Hide resolved
@property() public variant?: WuiNetworkButton['variant'] = 'fill'
@property({ type: Boolean }) public disabled?: WuiNetworkButton['disabled'] = false

@state() private networkImages = AssetController.state.networkImages

Expand Down Expand Up @@ -44,7 +44,11 @@ export class W3mNetworkButton extends LitElement {
const networkImage = this.networkImages[this.network?.imageId ?? '']

return html`
<wui-network-button imageSrc=${ifDefined(networkImage)} @click=${this.onClick.bind(this)}>
<wui-network-button
.disabled=${Boolean(this.disabled)}
imageSrc=${ifDefined(networkImage)}
@click=${this.onClick.bind(this)}
>
${this.network?.name ?? (this.connected ? 'Unknown Network' : 'Select Network')}
</wui-network-button>
`
Expand Down
7 changes: 3 additions & 4 deletions packages/ui/src/composites/wui-network-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { customElement, property } from 'lit/decorators.js'
import '../../components/wui-image/index.js'
import '../../components/wui-text/index.js'
import { elementStyles, resetStyles } from '../../utils/ThemeUtil.js'
import type { ButtonType } from '../../utils/TypesUtil.js'
import '../wui-icon-box/index.js'
import styles from './styles.js'

Expand All @@ -14,12 +13,12 @@ export class WuiNetworkButton extends LitElement {
// -- State & Properties -------------------------------- //
@property() public imageSrc?: string = undefined

@property() public variant: Exclude<ButtonType, 'accent' | 'fullwidth'> = 'fill'
@property({ type: Boolean }) public disabled = false

// -- Render -------------------------------------------- //
public override render() {
return html`
<button data-variant=${this.variant}>
<button ?disabled=${this.disabled}>
${this.visualTemplate()}
<wui-text variant="paragraph-600" color="inherit">
<slot></slot>
Expand All @@ -38,7 +37,7 @@ export class WuiNetworkButton extends LitElement {
<wui-icon-box
size="sm"
iconColor="inverse-100"
backgroundColor="accent-100"
backgroundColor="fg-100"
icon="networkPlaceholder"
></wui-icon-box>
`
Expand Down
23 changes: 19 additions & 4 deletions packages/ui/src/composites/wui-network-button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,31 @@ export default css`
padding: var(--wui-spacing-2xs) var(--wui-spacing-s) var(--wui-spacing-2xs)
var(--wui-spacing-xs);
border: 1px solid var(--wui-overlay-010);
background-color: var(--wui-overlay-005);
color: var(--wui-color-fg-100);
}

button:disabled {
border: 1px solid var(--wui-overlay-005);
background-color: var(--wui-overlay-015);
color: var(--wui-overlay-015);
}

@media (hover: hover) and (pointer: fine) {
button:hover:enabled {
background-color: var(--wui-overlay-010);
}

button:active:enabled {
background-color: var(--wui-overlay-015);
}
}

wui-image,
wui-icon-box {
border-radius: var(--wui-border-radius-3xl);
width: 24px;
height: 24px;
}

wui-icon-box {
border: 1px solid var(--wui-overlay-010);
outline: 2px solid var(--wui-overlay-005);
}
`
2 changes: 1 addition & 1 deletion packages/wagmi/exports/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ declare global {
interface IntrinsicElements {
'w3m-connect-button': Pick<W3mConnectButton, 'size' | 'label' | 'loadingLabel'>
'w3m-account-button': Pick<W3mAccountButton, 'disabled' | 'balance'>
'w3m-network-button': Pick<W3mNetworkButton, 'variant'>
'w3m-button': Pick<W3mButton, 'size' | 'label' | 'loadingLabel' | 'disabled' | 'balance'>
'w3m-network-button': Pick<W3mNetworkButton, 'disabled'>
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wagmi/exports/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
W3mConnectButton: Pick<W3mConnectButton, 'size' | 'label' | 'loadingLabel'>
W3mAccountButton: Pick<W3mAccountButton, 'disabled' | 'balance'>
W3mNetworkButton: Pick<W3mNetworkButton, 'variant'>
W3mButton: Pick<W3mButton, 'size' | 'label' | 'loadingLabel' | 'disabled' | 'balance'>
W3mNetworkButton: Pick<W3mNetworkButton, 'disabled'>
}
}

Expand Down