Skip to content

Commit 910c1b9

Browse files
authored
Merge pull request #1281 from dfinity/feat/oisy-ui-enhancements
feat(oisy-demo): enhance UI with custom OISY icon and button styles
2 parents df87cf4 + 3926ae1 commit 910c1b9

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

hosting/oisy-signer-demo/frontend/src/App.jsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
import { useEffect, useState } from 'react';
2-
import { Moon, Sun, ExternalLink, Copy, X, Loader2 } from 'lucide-react';
2+
import { Moon, Sun, ExternalLink, Copy, X, Loader2, LogOut } from 'lucide-react';
33
import { Button } from '@/components/ui/button';
44
import { Switch } from '@/components/ui/switch';
5+
import { OisyIcon } from '@/components/ui/oisyIcon';
56
import ICPLogo from './assets/icp.svg';
67
import USDCLogo from './assets/usdc.svg';
78
import OISYLogo from './assets/oisy.svg';
89
import { useOisyWallet } from './hooks/useOisyWallet';
910
import { CKUSDC_LEDGER_ID } from './libs/constants';
1011
import { toMainUnit } from './libs/utils';
1112

13+
// Helper functions for button styling and content
14+
const getButtonVariant = (isConnected, darkMode) => {
15+
if (!isConnected) return 'connect';
16+
return darkMode ? 'disconnect-dark' : 'disconnect';
17+
};
18+
19+
const getButtonContent = (isConnected) => {
20+
if (isConnected) {
21+
return (
22+
<>
23+
<LogOut className="mr-2 h-4 w-4" />
24+
Disconnect
25+
</>
26+
);
27+
}
28+
29+
return (
30+
<>
31+
<OisyIcon />
32+
Connect OISY Wallet
33+
</>
34+
);
35+
};
36+
1237
export default function App() {
1338
const {
1439
connect,
@@ -84,10 +109,15 @@ export default function App() {
84109
<h1 className="text-xl font-semibold">OISY Signer Demo</h1>
85110
</div>
86111
<div className="flex items-center gap-4">
87-
<Switch checked={darkMode} onCheckedChange={setDarkMode} />
88-
{darkMode ? <Moon size={18} /> : <Sun size={18} />}
89-
<Button onClick={isConnected ? disconnect : connect}>
90-
{isConnected ? 'Disconnect' : 'Connect'}
112+
<div className="flex items-center gap-2">
113+
<Switch checked={darkMode} onCheckedChange={setDarkMode} />
114+
{darkMode ? <Moon size={18} /> : <Sun size={18} />}
115+
</div>
116+
<Button
117+
onClick={isConnected ? disconnect : connect}
118+
variant={getButtonVariant(isConnected, darkMode)}
119+
>
120+
{getButtonContent(isConnected)}
91121
</Button>
92122
</div>
93123
</header>

hosting/oisy-signer-demo/frontend/src/components/ui/button.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const buttonVariants = cva(
99
variant: {
1010
default: 'bg-blue-600 text-white hover:bg-blue-700',
1111
destructive: 'bg-red-600 text-white hover:bg-red-700',
12+
connect: 'bg-blue-600 text-white hover:bg-blue-700',
13+
disconnect: 'bg-black text-white hover:bg-gray-800',
14+
'disconnect-dark': 'bg-red-600 text-white hover:bg-red-700',
1215
},
1316
size: {
1417
default: 'h-10 px-4 py-2',
@@ -23,7 +26,9 @@ const buttonVariants = cva(
2326

2427
export const Button = React.forwardRef(({ className, variant, size, ...props }, ref) => {
2528
return (
26-
<button className={cn(buttonVariants({ variant, size }), className)} ref={ref} {...props} />
29+
<button className={cn(buttonVariants({ variant, size }), className)} ref={ref} {...props}>
30+
{props.children}
31+
</button>
2732
);
2833
});
2934
Button.displayName = 'Button';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
3+
export const OisyIcon = ({ className = "mr-2 h-5 w-5", ...props }) => (
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
width="20"
7+
height="20"
8+
viewBox="0 0 32 32"
9+
fill="none"
10+
className={className}
11+
{...props}
12+
>
13+
<circle cx="16" cy="16" r="16" fill="white" />
14+
<path
15+
fill="#000"
16+
fillRule="evenodd"
17+
d="m17.754 24.305-.347 1.533a.68.68 0 0 1-.767.524 48.88 48.88 0 0 1-1.423-.247.681.681 0 0 1-.537-.822l.307-1.354a28 28 0 0 1-1.398-.314l-.306 1.354a.681.681 0 0 1-.837.512 51.56 51.56 0 0 1-1.39-.387.68.68 0 0 1-.47-.804l.345-1.525c-3.784-1.517-6.173-4.097-5.16-8.502l.245-1.08c.981-4.42 4.246-5.716 8.315-5.456l.345-1.523a.68.68 0 0 1 .768-.524c.47.075.944.158 1.422.249.38.072.621.445.536.822l-.306 1.353a28.45 28.45 0 0 1 1.397.317l.306-1.353a.681.681 0 0 1 .837-.511c.471.125.935.254 1.392.389a.68.68 0 0 1 .467.803l-.346 1.53c3.735 1.516 6.07 4.094 5.08 8.475l-.244 1.08c-.973 4.383-4.204 5.695-8.23 5.46Zm5.492-6.339.137-.607c.967-4.019-2.248-5.52-6.213-6.474-4.007-.848-7.556-.876-8.411 3.167l-.138.608c-.97 4.037 2.245 5.538 6.227 6.496 3.99.844 7.538.872 8.398-3.19Z"
18+
clipRule="evenodd"
19+
/>
20+
</svg>
21+
);

0 commit comments

Comments
 (0)