Skip to content

Commit 1b218d9

Browse files
committed
fix: add some styling to match previous app and set up better structure
1 parent 98d72f1 commit 1b218d9

File tree

14 files changed

+82
-92
lines changed

14 files changed

+82
-92
lines changed

packages/e2e/test/web-extension/dapp-connector-preact/src/components/Dashboard.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/e2e/test/web-extension/dapp-connector-preact/src/components/Connect.tsx renamed to packages/e2e/test/web-extension/dapp-connector-preact/src/components/connect/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { logger } from '@cardano-sdk/util-dev';
33
import { ObservableWallet } from '@cardano-sdk/wallet';
44
import { tap, switchMap, combineLatest } from 'rxjs';
55

6-
import { connectWalletDependencies } from '../constants';
7-
import { connectorStore } from '../state/store';
6+
import { connectWalletDependencies } from '../../constants';
7+
import { connectorStore } from '../../state/store';
88

99
export type OnWalletConnected = (wallet: ObservableWallet) => void;
1010

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.dashboard-container {
2+
display: flex;
3+
justify-content: space-between;
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Logs, WalletActions } from '..';
2+
import './dashboard.css';
3+
4+
export const Dashboard = () => {
5+
// TODO: show a message if it's empty or not connected
6+
return (
7+
<div class="dashboard-container">
8+
<WalletActions />
9+
<Logs />
10+
</div>
11+
);
12+
};
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { Connect, type OnWalletConnected } from './Connect';
2-
export { Logs } from './Logs';
3-
export { WalletActions } from './WalletActions';
4-
export { Dashboard } from './Dashboard';
1+
export { Connect, type OnWalletConnected } from './connect';
2+
export { Logs } from './wallet-logs';
3+
export { WalletActions } from './wallet-actions';
4+
export { Dashboard } from './dashboard';
5+
export { Header } from './header';

packages/e2e/test/web-extension/dapp-connector-preact/src/components/WalletActions.tsx renamed to packages/e2e/test/web-extension/dapp-connector-preact/src/components/wallet-actions/index.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useEffect, useState } from 'preact/hooks';
2-
import { Store, connectorStore } from '../state/store';
3-
import { sendCoins, sendSeveralAssets, singleDelegation, singleUndelegation } from '../features';
2+
import { Store, connectorStore } from '../../state/store';
3+
import { sendCoins, sendSeveralAssets, singleDelegation, singleUndelegation } from '../../features';
4+
5+
import './wallet-actions.css';
46

57
export const WalletActions = () => {
68
const [storeState, setStoreState] = useState<Store>(connectorStore.initialState);
@@ -15,15 +17,14 @@ export const WalletActions = () => {
1517
if (!storeState.wallet) {
1618
return null;
1719
}
18-
// const handleClick = async () => {
1920

20-
// }
2121
const handleSendCoins = async () => {
2222
if (!storeState.wallet) {
2323
return null;
2424
}
2525

2626
const { hash, txId } = await sendCoins({ connectedWallet: storeState.wallet });
27+
console.log('hash and txId', hash, txId);
2728

2829
connectorStore.log({
2930
title: 'Send coins',
@@ -38,7 +39,7 @@ export const WalletActions = () => {
3839
}
3940

4041
const { hash, txId } = await sendSeveralAssets({ connectedWallet: storeState.wallet });
41-
42+
console.log('hash and txId', hash, txId);
4243
connectorStore.log({
4344
title: 'Send several assets',
4445
hash: hash,
@@ -52,6 +53,7 @@ export const WalletActions = () => {
5253
}
5354

5455
const { hash, txId } = await singleDelegation({ connectedWallet: storeState.wallet });
56+
console.log('hash and txId', hash, txId);
5557

5658
connectorStore.log({
5759
title: 'Single delegation',
@@ -66,6 +68,7 @@ export const WalletActions = () => {
6668
}
6769

6870
const { hash, txId } = await singleUndelegation({ connectedWallet: storeState.wallet });
71+
console.log('hash and txId', hash, txId);
6972

7073
connectorStore.log({
7174
title: 'Single undelegation',
@@ -75,11 +78,20 @@ export const WalletActions = () => {
7578
};
7679

7780
return (
78-
<>
79-
<button onClick={() => handleSendCoins()}>Send coins</button>
80-
<button onClick={() => handleSendSeveralAssets()}>Send several assets</button>
81-
<button onClick={() => handleSingleDelegation()}>Single delegation</button>
82-
<button onClick={() => handleSingleUndelegation()}>Single undelegation</button>
83-
</>
81+
<div class="actions-container">
82+
<h3>Wallet actions</h3>
83+
<button class="wallet-button" onClick={() => handleSendCoins()}>
84+
Send coins
85+
</button>
86+
<button class="wallet-button" onClick={() => handleSendSeveralAssets()}>
87+
Send several assets
88+
</button>
89+
<button class="wallet-button" onClick={() => handleSingleDelegation()}>
90+
Single delegation
91+
</button>
92+
<button class="wallet-button" onClick={() => handleSingleUndelegation()}>
93+
Single undelegation
94+
</button>
95+
</div>
8496
);
8597
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.actions-container {
2+
display: flex;
3+
flex-direction: column;
4+
width: 300px;
5+
padding: 20px;
6+
}
7+
8+
.wallet-button {
9+
margin: 10px 20px;
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useState, useEffect } from 'preact/hooks';
2-
import { Store, connectorStore } from '../state/store';
2+
import { Store, connectorStore } from '../../state/store';
3+
4+
import './logs.css';
35

46
export const Logs = () => {
5-
// const [walletInfo, setWalletInfo] = useState([]);
67
const [storeState, setStoreState] = useState<Store>(connectorStore.initialState);
7-
console.log('getting to logs');
8+
89
useEffect(() => {
910
const subscription = connectorStore.subscribe(setStoreState);
1011
connectorStore.init();
@@ -18,25 +19,29 @@ export const Logs = () => {
1819

1920
const getAddresses = () => storeState.addresses?.map((a) => <p>{a.address}</p>);
2021

21-
console.log('Store state:::> ', storeState);
2222
return (
23-
<>
24-
<h2>Connected wallet actions</h2>
23+
<div class="logs-container">
24+
<h3>Logs</h3>
2525
<div>
26-
<p>Balance: {storeState?.balance?.coins}</p>
27-
<p>Addresses: {getAddresses()}</p>
26+
<h4>Balance: </h4> <p>{storeState?.balance?.coins}</p>
27+
<h4>Addresses: </h4> {getAddresses()}
2828
</div>
2929
<div>
3030
{storeState.log.map((entry) => {
3131
return (
3232
<>
3333
<h4>{entry.title}</h4>
34-
<p>hash:{entry.hash}</p>
35-
<p>tx ID: {entry.txId}</p>
34+
<p>
35+
<h5>hash:</h5>
36+
{entry.hash}
37+
</p>
38+
<p>
39+
<h5>tx ID:</h5> {entry.txId}
40+
</p>
3641
</>
3742
);
3843
})}
3944
</div>
40-
</>
45+
</div>
4146
);
4247
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.logs-container {
2+
display: flex;
3+
flex-direction: column;
4+
width: auto;
5+
padding: 20px;
6+
}

packages/e2e/test/web-extension/dapp-connector-preact/src/features/sendCoins.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const sendCoins = async ({
1212

1313
return new Promise(async (resolve) => {
1414
const { hash, txId } = await inspectAndSignTx({ builtTx, connectedWallet: connectedWallet });
15-
console.log('hash, txID:', hash, txId);
1615
resolve({ hash, txId });
1716
});
1817
};

packages/e2e/test/web-extension/dapp-connector-preact/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { hydrate, prerender as ssr } from 'preact-iso';
22
import { Router, Route } from 'preact-router';
3-
import { Header } from './components/Header';
3+
import { Header } from './components/header';
44
import { Home } from './pages/Home';
55
import { NotFound } from './pages/_404';
66
import './style.css';
Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,5 @@
1-
img {
2-
margin-bottom: 1.5rem;
3-
}
4-
5-
img:hover {
6-
filter: drop-shadow(0 0 2em #673ab8aa);
7-
}
8-
9-
.home section {
10-
margin-top: 5rem;
11-
display: grid;
12-
grid-template-columns: repeat(3, 1fr);
13-
column-gap: 1.5rem;
14-
}
151

16-
.resource {
17-
padding: 0.75rem 1.5rem;
18-
border-radius: 0.5rem;
19-
text-align: left;
20-
text-decoration: none;
21-
color: #222;
22-
background-color: #f1f1f1;
23-
border: 1px solid transparent;
24-
}
25-
26-
.resource:hover {
27-
border: 1px solid #000;
28-
box-shadow: 0 25px 50px -12px #673ab888;
29-
}
30-
31-
@media (max-width: 639px) {
32-
.home section {
33-
margin-top: 5rem;
34-
grid-template-columns: 1fr;
35-
row-gap: 1rem;
36-
}
37-
}
382

39-
@media (prefers-color-scheme: dark) {
40-
.resource {
41-
color: #ccc;
42-
background-color: #161616;
43-
}
44-
.resource:hover {
45-
border: 1px solid #bbb;
46-
}
3+
.home {
4+
margin: 0 auto;
475
}

packages/e2e/test/web-extension/dapp-connector-preact/src/state/store.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const connectorStore = {
4343
...state,
4444
log: [...state.log, entry]
4545
};
46+
subject.next(state);
4647
},
4748
setAddressesAndBalances: (addresses: Store['addresses'], balance: Store['balance']) => {
4849
// get the connected wallet and get the addresses and balances
@@ -53,11 +54,5 @@ export const connectorStore = {
5354
};
5455
subject.next(state);
5556
},
56-
sendCoins: () => {
57-
// get connectedWallet
58-
// get the coins to send from the address
59-
// get the address to send it to
60-
subject.next(state);
61-
},
6257
initialState
6358
};

0 commit comments

Comments
 (0)