Files
pwap/pezkuwi-sdk-ui/packages/react-components/src/ToggleGroup.tsx
T
pezkuwichain 971df8edba Rebrand: Remove 3rd party chains, update domains to PezkuwiChain
- Remove all 3rd party parachain configurations from endpoints:
  - productionRelayPolkadot.ts: Keep only system parachains
  - productionRelayDicle.ts: Keep only system parachains
  - testingRelayZagros.ts: Keep only system parachains
  - testingRelayTeyrChain.ts: Keep only system parachains

- Update domain references:
  - polkadot.js.org → pezkuwichain.app
  - wiki.polkadot.network → wiki.pezkuwichain.io
  - dotapps.io → pezkuwichain.app
  - statement.polkadot.network → docs.pezkuwichain.io/statement
  - support.polkadot.network → docs.pezkuwichain.io

- Update repository references:
  - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap

- Rename system parachains to Pezkuwi ecosystem:
  - PolkadotAssetHub → PezkuwiAssetHub
  - polkadotBridgeHub → pezkuwiBridgeHub
  - polkadotCollectives → pezkuwiCollectives
  - polkadotCoretime → pezkuwiCoretime
  - polkadotPeople → pezkuwiPeople

- Update network name in claims utility:
  - Polkadot → Pezkuwi
2026-01-09 03:08:11 +03:00

109 lines
2.3 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { useCallback, useMemo } from 'react';
import Button from './Button/index.js';
import { styled } from './styled.js';
interface Option {
isDisabled?: boolean;
text: string;
value: string | number;
}
interface Props {
className?: string;
onChange: (index: number, value: string | number) => void;
options: (Option | null | undefined | false)[];
value: number;
}
interface ToggleProps {
index: number;
isDisabled?: boolean;
isSelected: boolean;
onChange: (index: number, value: string | number) => void;
text: string;
value: string | number;
}
function ToggleIndex ({ index, isDisabled, isSelected, onChange, text, value }: ToggleProps): React.ReactElement<ToggleProps> {
const _onClick = useCallback(
(): void => {
!isDisabled && onChange(index, value);
},
[isDisabled, index, onChange, value]
);
return (
<Button
icon={
isSelected
? 'check'
: 'circle'
}
isBasic
isDisabled={isDisabled}
isSelected={isSelected}
key={text}
label={text}
onClick={_onClick}
/>
);
}
const ToggleIndexMemo = React.memo(ToggleIndex);
function ToggleGroup ({ className = '', onChange, options, value }: Props): React.ReactElement<Props> | null {
const available = useMemo(
() => options.filter((o): o is Option => !!o),
[options]
);
if (!available.length || !available[0].value) {
return null;
}
return (
<StyledDiv className={`${className} ui--ToggleGroup`}>
{available.map(({ isDisabled, text, value: optValue }, index): React.ReactNode => (
<ToggleIndexMemo
index={index}
isDisabled={isDisabled}
isSelected={value === index}
key={index}
onChange={onChange}
text={text}
value={optValue}
/>
))}
</StyledDiv>
);
}
const StyledDiv = styled.div`
display: inline-block;
margin-right: 1.5rem;
.ui--Button {
margin: 0;
&:not(:first-child) {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
&:not(:last-child) {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.ui--Icon {
width: 1em;
}
}
`;
export default React.memo(ToggleGroup);