Files
pwap/pezkuwi-sdk-ui/packages/page-js/src/ActionButtons.tsx
T
Claude c71ddb6e0d Add Pezkuwi SDK UI - Polkadot.js Apps clone
- Clone Polkadot.js Apps repository
- Update package.json with Pezkuwi branding
- Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944)
- Create comprehensive README for SDK UI
- Set up project structure with all packages

Next steps:
- Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme
- Replace logos with Pezkuwi branding
- Test build and deployment
2025-11-14 00:55:17 +00:00

106 lines
2.5 KiB
TypeScript

// Copyright 2017-2025 @polkadot/app-js authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { useCallback, useState } from 'react';
import { Button, Input, Popup } from '@polkadot/react-components';
import { useTranslation } from './translate.js';
interface Props {
className?: string;
isCustomExample: boolean;
isRunning: boolean;
removeSnippet: () => void;
runJs: () => void;
saveSnippet: (snippetName: string) => void;
snippetName?: string;
stopJs: () => void;
}
function ActionButtons ({ className = '', isCustomExample, isRunning, removeSnippet, runJs, saveSnippet, stopJs }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const [snippetName, setSnippetName] = useState('');
const _onChangeName = useCallback(
(snippetName: string) => setSnippetName(snippetName),
[]
);
const _onPopupClose = useCallback(
(): void => {
setSnippetName('');
},
[]
);
const _saveSnippet = useCallback(
(): void => {
saveSnippet(snippetName);
_onPopupClose();
},
[_onPopupClose, saveSnippet, snippetName]
);
return (
<Button.Group className={`${className} action-button`}>
{isCustomExample
? (
<Button
icon='trash'
onClick={removeSnippet}
/>
)
: (
<Popup
className='popup-local'
onCloseAction={_onPopupClose}
value={
<>
<Input
autoFocus
maxLength={50}
min={1}
onChange={_onChangeName}
onEnter={_saveSnippet}
placeholder={t('Name your example')}
value={snippetName}
withLabel={false}
/>
<Button
icon='save'
isDisabled={!snippetName.length}
label={t('Save snippet to local storage')}
onClick={_saveSnippet}
/>
</>
}
>
<Button
icon='save'
isReadOnly={false}
/>
</Popup>
)
}
{isRunning
? (
<Button
icon='times'
onClick={stopJs}
/>
)
: (
<Button
className='play-button'
icon='play'
onClick={runJs}
/>
)
}
</Button.Group>
);
}
export default React.memo(ActionButtons);