Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ngundotra committed Oct 9, 2024
1 parent 555a43a commit 16e4531
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
29 changes: 18 additions & 11 deletions app/components/common/Downloadable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { ComponentType, ReactNode } from 'react';
import { Download, IconProps } from 'react-feather';

export function DownloadableIcon({ data, filename, children }: { data: string; filename: string; children: ReactNode }) {
export function DownloadableIcon({
data,
filename,
children,
}: {
data: string;
filename: string;
children: ReactNode;
}) {
const handleClick = async () => {
const blob = new Blob([Buffer.from(data, 'base64')]);
const fileDownloadUrl = URL.createObjectURL(blob);
Expand All @@ -19,18 +27,18 @@ export function DownloadableIcon({ data, filename, children }: { data: string; f
);
}

export function DownloadableButton({
data,
filename,
children,
export function DownloadableButton({
data,
filename,
children,
type,
icon: Icon = Download as ComponentType<IconProps>
}: {
data: string;
filename: string;
icon: Icon = Download as ComponentType<IconProps>,
}: {
data: string;
filename: string;
children?: ReactNode;
type?: string;
icon?: ComponentType<IconProps>
icon?: ComponentType<IconProps>;
}) {
const handleDownload = async () => {
const blob = new Blob([Buffer.from(data, 'base64')], type ? { type } : {});
Expand All @@ -48,4 +56,3 @@ export function DownloadableButton({
</div>
);
}

14 changes: 5 additions & 9 deletions app/components/common/IDLBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import React from 'react';
import { IdlSpec } from '@/app/utils/convertLegacyIdl';

interface IDLBadgeProps {
spec: IdlSpec
spec: IdlSpec;
}

export function IDLBadge({ spec }: IDLBadgeProps) {
const badgeClass = spec === 'legacy' ? 'bg-warning' : 'bg-success';
const badgeText = spec === 'legacy' ? 'Legacy' : '0.30.1';
const badgeClass = spec === 'legacy' ? 'bg-warning' : 'bg-success';
const badgeText = spec === 'legacy' ? 'Legacy' : '0.30.1';

return (
<span className={`badge ${badgeClass}`}>
{badgeText} Anchor IDL
</span>
);
}
return <span className={`badge ${badgeClass}`}>{badgeText} Anchor IDL</span>;
}
8 changes: 4 additions & 4 deletions app/types/react-json-view.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'react-json-view';

declare module 'react-json-view' {
interface ReactJsonViewProps {
displayArrayKey?: boolean;
}
}
interface ReactJsonViewProps {
displayArrayKey?: boolean;
}
}
20 changes: 16 additions & 4 deletions app/utils/anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,22 @@ function mapField(key: string, value: any, type: IdlType, idl: Idl, keySuffix?:
keySuffix={keySuffix}
nestingLevel={nestingLevel}
>
<div className="text-lg-start" style={{ fontSize: '0.85rem', lineHeight: '1.2', maxWidth: '100%', overflowWrap: 'break-word', whiteSpace: 'normal', wordBreak: 'break-all'}}>{(value as Buffer).toString('base64')}</div>
</SimpleRow>
<div
className="text-lg-start"
style={{
fontSize: '0.85rem',
lineHeight: '1.2',
maxWidth: '100%',
overflowWrap: 'break-word',
whiteSpace: 'normal',
wordBreak: 'break-all',
}}
>
{(value as Buffer).toString('base64')}
</div>
</SimpleRow>
);
}else if (type === 'pubkey') {
} else if (type === 'pubkey') {
return (
<SimpleRow
key={keySuffix ? `${key}-${keySuffix}` : key}
Expand Down Expand Up @@ -477,7 +489,7 @@ function typeDisplayName(
case 'i256':
case 'u256':
case 'bytes':
return 'bytes (Base64)'
return 'bytes (Base64)';
case 'string':
return type.toString();
case 'pubkey':
Expand Down

0 comments on commit 16e4531

Please sign in to comment.