Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/tiny-planets-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/dapp-kit-core': minor
---

Expose a styleable "trigger" part for more custom styling needs on the connect button
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"pnpm": {
"overrides": {
"axios": "^1.13.5",
"markdown-it@>=13.0.0 <14.1.1": ">=14.1.1",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

audit CI was failing

"hono@<4.11.10": ">=4.11.10",
"minimatch": ">=10.2.1"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { StorybookConfig } from '@storybook/web-components-vite';

import { join, dirname } from 'path';
import { dirname } from 'path';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storybook was broken

import { fileURLToPath } from 'url';

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
return dirname(fileURLToPath(import.meta.resolve(value + '/package.json')));
}

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [getAbsolutePath('@storybook/addon-essentials')],
framework: {
name: getAbsolutePath('@storybook/web-components-vite'),
options: {},
Expand Down
2 changes: 0 additions & 2 deletions packages/dapp-kit-next/packages/dapp-kit-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
},
"devDependencies": {
"@mysten/sui": "workspace:^",
"@storybook/addon-essentials": "^8.6.14",
"@storybook/blocks": "^8.6.14",
"@storybook/web-components": "^10.1.11",
"@storybook/web-components-vite": "^10.1.11",
"storybook": "^10.1.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ export const WithCustomTheme: StoryObj<DAppKitConnectButton> = {
`,
};

export const WithCustomTriggerPart: StoryObj<DAppKitConnectButton> = {
render: () => html`
<style>
.custom-part-demo::part(trigger) {
height: 56px;
padding: 12px 32px;
border-radius: 999px;
background-color: #e63946;
color: #f1faee;
font-size: 18px;
letter-spacing: 0.5px;
}
</style>
<mysten-dapp-kit-connect-button class="custom-part-demo" .instance=${dAppKit}>
Connect
</mysten-dapp-kit-connect-button>
`,
};

export const WithRandomSort: StoryObj<DAppKitConnectButton> = {
args: {
modalOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import type { AccountSelectedEvent } from './internal/connected-account-menu-ite
* @cssprop --font-sans - Font family used for text content.
* @cssprop --font-weight-medium - Medium font weight for text (typically used for buttons and interactive elements).
* @cssprop --font-weight-semibold - Semibold font weight for text (typically used for headings or emphasized text).
*
* @csspart trigger - The underlying button element. Use `::part(trigger)` to customize sizing, padding, border-radius, etc.
*/
@customElement('mysten-dapp-kit-connect-button')
export class DAppKitConnectButton extends ScopedRegistryHost(LitElement) {
Expand Down Expand Up @@ -80,6 +82,7 @@ export class DAppKitConnectButton extends ScopedRegistryHost(LitElement) {

return connection.account
? html`<connected-account-menu
exportparts="trigger"
.connection=${connection}
.client=${client}
@account-selected=${(event: AccountSelectedEvent) => {
Expand All @@ -92,7 +95,7 @@ export class DAppKitConnectButton extends ScopedRegistryHost(LitElement) {
this.instance.connectWallet({ wallet: connection.wallet });
}}
></connected-account-menu>`
: html`<internal-button @click=${this.#openModal}>
: html`<internal-button exportparts="trigger" @click=${this.#openModal}>
<slot>Connect Wallet</slot>
</internal-button>
<mysten-dapp-kit-connect-modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Button extends LitElement {
return this.href
? html`
<a
part="trigger"
href=${this.href}
?disabled=${this.disabled}
target="_blank"
Expand All @@ -38,6 +39,7 @@ export class Button extends LitElement {
`
: html`
<button
part="trigger"
type="button"
?disabled=${this.disabled}
class=${classMap({ button: true, [this.variant]: true })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class ConnectedAccountMenu extends ScopedRegistryHost(LitElement) {

override render() {
return html`<internal-button
exportparts="trigger"
id="menu-button"
aria-haspopup="true"
aria-controls="menu"
Expand Down
Loading
Loading