Skip to content

Commit 2c99cd5

Browse files
committed
feat: enhance TrainLogoSymbol and Menu components for improved theming and functionality
- Updated TrainLogoSymbol to use currentColor for better theme adaptability. - Introduced SelectorItem component in Menu for theme selection, allowing users to switch between light, dark, and system themes. - Adjusted MenuList to utilize SelectorItem for theme management, enhancing user experience. - Modified LoadingConnect styles to align with new theme settings. - Updated global styles for loader color consistency.
1 parent 831135c commit 2c99cd5

8 files changed

Lines changed: 98 additions & 43 deletions

File tree

apps/app/components/Icons/TrainLogoSymbol.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react'
22

33
const TrainLogoSymbol = (props) => (
4-
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="60" viewBox="0 0 50 60" fill="none" {...props}>
5-
<path fillRule="evenodd" clipRule="evenodd" d="M9.17871 14.3067C9.17871 11.6925 10.8726 9.37808 13.369 8.58142L22.5472 5.65211C24.072 5.16544 25.711 5.16544 27.2357 5.65211L36.414 8.58142C38.9104 9.37808 40.6043 11.6925 40.6043 14.3067C40.6043 14.3067 40.6043 31.6634 40.6043 33.1123C40.6043 34.5611 40.6043 35.9168 38.7296 37.7865C36.855 39.6562 34.811 42.515 31.7269 42.515H18.0561C14.972 42.515 12.928 39.6562 11.0534 37.7865C9.17871 35.9168 9.17871 34.6167 9.17871 33.1123C9.17871 31.6078 9.17871 14.3067 9.17871 14.3067ZM12.6984 17.8171C12.6984 16.7092 13.5988 15.8111 14.7096 15.8111H35.0734C36.1841 15.8111 37.0846 16.7092 37.0846 17.8171V23.6333C37.0846 24.4394 36.6008 25.1672 35.8564 25.4809L27.8279 28.8655C25.9507 29.6569 23.8323 29.6569 21.9551 28.8655L13.9266 25.4809C13.1822 25.1672 12.6984 24.4394 12.6984 23.6333V17.8171Z" fill="#E6E6E6" />
6-
<path fillRule="evenodd" clipRule="evenodd" d="M7 52.1591L15.508 43.6465H19.2412L17.6068 45.2817H31.9327L30.2988 43.647H34.032L42.9167 52.5365L41.0502 54.4041L38.4691 51.8216H11.0704L8.86658 54.0267L7 52.1591ZM13.8359 49.0547H35.7036L33.4411 46.791H16.0984L13.8359 49.0547Z" fill="#E6E6E6" />
4+
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="60" viewBox="0 0 50 60" fill="currentColor" {...props}>
5+
<path fillRule="evenodd" clipRule="evenodd" d="M9.17871 14.3067C9.17871 11.6925 10.8726 9.37808 13.369 8.58142L22.5472 5.65211C24.072 5.16544 25.711 5.16544 27.2357 5.65211L36.414 8.58142C38.9104 9.37808 40.6043 11.6925 40.6043 14.3067C40.6043 14.3067 40.6043 31.6634 40.6043 33.1123C40.6043 34.5611 40.6043 35.9168 38.7296 37.7865C36.855 39.6562 34.811 42.515 31.7269 42.515H18.0561C14.972 42.515 12.928 39.6562 11.0534 37.7865C9.17871 35.9168 9.17871 34.6167 9.17871 33.1123C9.17871 31.6078 9.17871 14.3067 9.17871 14.3067ZM12.6984 17.8171C12.6984 16.7092 13.5988 15.8111 14.7096 15.8111H35.0734C36.1841 15.8111 37.0846 16.7092 37.0846 17.8171V23.6333C37.0846 24.4394 36.6008 25.1672 35.8564 25.4809L27.8279 28.8655C25.9507 29.6569 23.8323 29.6569 21.9551 28.8655L13.9266 25.4809C13.1822 25.1672 12.6984 24.4394 12.6984 23.6333V17.8171Z" fill="currentColor" />
6+
<path fillRule="evenodd" clipRule="evenodd" d="M7 52.1591L15.508 43.6465H19.2412L17.6068 45.2817H31.9327L30.2988 43.647H34.032L42.9167 52.5365L41.0502 54.4041L38.4691 51.8216H11.0704L8.86658 54.0267L7 52.1591ZM13.8359 49.0547H35.7036L33.4411 46.791H16.0984L13.8359 49.0547Z" fill="currentColor" />
77
</svg>
88
)
99

apps/app/components/Swap/AtomicChat/Actions/UserActions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const UserLockAction: FC<UserCommitActionProps> = ({ quote, type }) => {
4242

4343
if (!sourceClient) throw new Error("No source client")
4444

45-
const result = await sourceClient.userLock({
45+
const result = await sourceClient.userLock({
4646
...resolveQuote(quote),
4747
sourceAddress: sourceWallet.address,
4848
destinationAddress: address,
@@ -77,6 +77,7 @@ export const UserLockAction: FC<UserCommitActionProps> = ({ quote, type }) => {
7777
}
7878
}
7979
catch (e) {
80+
debugger
8081
console.error('[UserLock] failed', e?.message ?? String(e), ...(e?.logs ? [e.logs] : []))
8182
setError({ message: e?.details || e?.message || e?.code || e?.name || 'Unknown error' })
8283
}

apps/app/components/TrainMenu/Menu.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import LinkWrapper from "../LinkWraapper"
33
import { ReactNode } from "react"
44
import { motion } from "framer-motion";
55
import { useEffect, useRef, useState } from "react"
6+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/shadcn/select"
67

78
const Menu = ({ children }: { children: ReactNode }) => {
89
return <div className="flex flex-col gap-3">
@@ -179,9 +180,54 @@ const ToggleItem = ({ children, icon, checked, onChange }: ToggleItemProps) => {
179180
)
180181
}
181182

183+
type SelectOption = {
184+
value: string;
185+
label: string;
186+
icon?: React.ComponentType<{ className?: string }>;
187+
};
188+
189+
type SelectorItemProps = {
190+
label: string;
191+
icon?: JSX.Element;
192+
value: string;
193+
onValueChange: (value: string) => void;
194+
options: SelectOption[];
195+
};
196+
197+
const SelectorItem = ({ label, icon, value, onValueChange, options }: SelectorItemProps) => {
198+
const current = options.find(o => o.value === value) ?? options[0]
199+
const CurrentIcon = current.icon
200+
201+
return (
202+
<div className="gap-4 flex relative select-none items-center px-4 py-1.5 w-full text-primary-text">
203+
{icon && <div>{icon}</div>}
204+
<p className="text-primary-text">{label}</p>
205+
<div className="ml-auto">
206+
<Select value={value} onValueChange={onValueChange}>
207+
<SelectTrigger>
208+
<SelectValue>
209+
{CurrentIcon && <CurrentIcon className="h-4 w-4" />}
210+
{current.label}
211+
</SelectValue>
212+
</SelectTrigger>
213+
<SelectContent>
214+
{options.map(({ value: val, icon: Icon, label: optLabel }) => (
215+
<SelectItem key={val} value={val}>
216+
{Icon && <Icon className="h-4 w-4" />}
217+
{optLabel}
218+
</SelectItem>
219+
))}
220+
</SelectContent>
221+
</Select>
222+
</div>
223+
</div>
224+
)
225+
}
226+
182227
Menu.Group = Group
183228
Menu.Item = Item
184229
Menu.Footer = Footer
185230
Menu.ToggleItem = ToggleItem
231+
Menu.SelectorItem = SelectorItem
186232

187233
export default Menu

apps/app/components/TrainMenu/MenuList.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BookOpen, Home, LibraryIcon, Shield, MessageSquarePlus, CircleHelp, Info, Settings2, Zap, RotateCcw, ScrollText, Sun } from "lucide-react";
1+
import { BookOpen, Home, LibraryIcon, Shield, MessageSquarePlus, CircleHelp, Info, Settings2, Zap, RotateCcw, ScrollText, Sun, Moon, Monitor } from "lucide-react";
22
import { useSwapPreferencesStore } from "@/stores/swapPreferencesStore";
33
import { useTheme } from "next-themes";
44
import { useRouter } from "next/router";
@@ -73,13 +73,17 @@ const MenuList: FC<{ goToStep: (step: MenuStep, path?: string) => void }> = ({ g
7373
Auto Reveal Secret
7474
</Menu.ToggleItem>
7575

76-
<Menu.ToggleItem
76+
<Menu.SelectorItem
77+
label="Theme"
7778
icon={<Sun className="h-5 w-5" />}
78-
checked={theme === "light"}
79-
onChange={(checked) => setTheme(checked ? "light" : "default")}
80-
>
81-
Light Mode
82-
</Menu.ToggleItem>
79+
value={theme ?? "system"}
80+
onValueChange={setTheme}
81+
options={[
82+
{ value: "system", icon: Monitor, label: "System" },
83+
{ value: "light", icon: Sun, label: "Light" },
84+
{ value: "default", icon: Moon, label: "Dark" },
85+
]}
86+
/>
8387

8488
</>
8589
</Menu.Group>

apps/app/components/WalletModal/LoadingConnect.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ export const LoadingConnect: FC<{ onRetry: () => void, selectedConnector: Wallet
2525
<div className="flex flex-col gap-3 items-center justify-end row-start-2 row-span-1">
2626
<div className="flex-col flex items-center">
2727
<div className="grid grid-cols-3 items-center gap-2">
28-
<div className="p-3 bg-secondary-700 rounded-lg z-10">
29-
<TrainLogoSymbol className="w-11 h-11" />
28+
<div className="p-3 bg-secondary-500 rounded-lg z-10">
29+
<TrainLogoSymbol className="w-11 h-11 text-primary-logoColor" />
3030
</div>
3131
{
3232
connectionError ?
3333
<Link2Off className="w-auto h-auto place-self-center" />
3434
:
3535
<div className="loader text-[3px]! place-self-center" />
3636
}
37-
<div className="p-3 bg-secondary-700 rounded-lg z-10">
37+
<div className="p-3 bg-secondary-500 rounded-lg z-10">
3838
<ConnectorIcon className="w-11 h-auto" />
3939
</div>
4040
</div>

apps/app/pages/_app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ function App({ Component, pageProps }) {
7373
>
7474
<ThemeProvider
7575
attribute="data-theme"
76-
defaultTheme="default"
76+
defaultTheme="system"
7777
themes={["default", "light"]}
7878
storageKey="theme"
7979
disableTransitionOnChange
80-
enableSystem={false}
80+
enableSystem={true}
81+
value={{ light: "light", dark: "default" }}
8182
>
8283
<IntercomProvider appId={INTERCOM_APP_ID} initializeDelay={2500}>
8384
<Component key={router.asPath} {...pageProps} />

apps/app/styles/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ textarea:disabled::placeholder {
446446
animation: bblFadInOut 1.8s infinite ease-in-out;
447447
}
448448
.loader {
449-
color: #FFF;
449+
color: rgb(var(--ls-colors-primary-text));
450450
font-size: 7px;
451451
position: relative;
452452
text-indent: -9999em;

packages/blockchains/starknet/src/client.ts

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cairo, Contract, hash, num, addAddressPadding, ProviderOrAccount, RpcProvider, type Call } from 'starknet'
1+
import { cairo, CallData, Contract, hash, num, addAddressPadding, ProviderOrAccount, RpcProvider, type Call, byteArray } from 'starknet'
22
import {
33
UserLockParams,
44
LockParams,
@@ -44,31 +44,34 @@ export class StarknetHTLCClient extends HTLCClient {
4444
const approveCall: Call = erc20.populate("approve", [params.atomicContract, cairo.uint256(parsedAmount)])
4545

4646
// Build user_lock call
47-
const htlcContract = this.createContract(params.atomicContract, signer.account)
48-
const userLockCall: Call = htlcContract.populate('user_lock', [
49-
{
50-
hashlock: cairo.uint256(BigInt(params.hashlock)),
51-
amount: cairo.uint256(parsedAmount),
52-
reward_amount: cairo.uint256(params.rewardAmount ? BigInt(params.rewardAmount) : 0n),
53-
timelock_delta: params.timelockDelta ?? 150,
54-
reward_timelock_delta: params.rewardTimelockDelta ?? 0,
55-
quote_expiry: params.quoteExpiry,
56-
sender: params.sourceAddress,
57-
recipient: params.srcLpAddress,
58-
token: tokenAddress,
59-
reward_token: params.rewardToken ?? '',
60-
reward_recipient: params.rewardRecipient ?? '',
61-
src_chain: params.sourceChain || '',
62-
},
63-
{
64-
dst_chain: params.destinationChain,
65-
dst_address: params.destinationAddress,
66-
dst_amount: cairo.uint256(BigInt(params.destinationAmount)),
67-
dst_token: params.destinationAsset,
68-
},
69-
String(params.nonce), // userData — nonce timestamp for recovery
70-
params.solverData || '',
71-
])
47+
const userLockCall: Call = {
48+
contractAddress: params.atomicContract,
49+
entrypoint: 'user_lock',
50+
calldata: CallData.compile([
51+
{
52+
hashlock: cairo.uint256(BigInt(params.hashlock)),
53+
amount: cairo.uint256(parsedAmount),
54+
reward_amount: cairo.uint256(params.rewardAmount ? BigInt(params.rewardAmount) : 0n),
55+
timelock_delta: params.timelockDelta ?? 150,
56+
reward_timelock_delta: params.rewardTimelockDelta ?? 0,
57+
quote_expiry: params.quoteExpiry,
58+
sender: params.sourceAddress,
59+
recipient: params.srcLpAddress,
60+
token: tokenAddress,
61+
reward_token: byteArray.byteArrayFromString(params.rewardToken ?? ''),
62+
reward_recipient: byteArray.byteArrayFromString(params.rewardRecipient ?? ''),
63+
src_chain: byteArray.byteArrayFromString(params.sourceChain || ''),
64+
},
65+
{
66+
dst_chain: byteArray.byteArrayFromString(params.destinationChain),
67+
dst_address: byteArray.byteArrayFromString(params.destinationAddress),
68+
dst_amount: cairo.uint256(BigInt(params.destinationAmount)),
69+
dst_token: byteArray.byteArrayFromString(params.destinationAsset),
70+
},
71+
byteArray.byteArrayFromString(String(params.nonce)), // userData — nonce timestamp for recovery
72+
byteArray.byteArrayFromString(params.solverData || ''),
73+
]),
74+
}
7275

7376
try {
7477
const { transaction_hash } = await signer.account.execute([approveCall, userLockCall])

0 commit comments

Comments
 (0)