@ant-design/icons#CheckCircleTwoTone JavaScript Examples
The following examples show how to use
@ant-design/icons#CheckCircleTwoTone.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisService.js From quick_redis_blog with MIT License | 6 votes |
/**
*连接成功
*
* @static
* @param {*} dispatch
* @memberof RedisService
*/
static dispatchSuccess(node, redis, dispatch) {
if (dispatch !== undefined) {
node.icon = <CheckCircleTwoTone />;
node.redis = redis;
dispatch({
type: MODIFY_HOSTS_DATA,
payload: { node: node },
});
}
}
Example #2
Source File: ListTodo.js From Peppermint with GNU General Public License v3.0 | 5 votes |
ListTodo = () => {
const { todos, getTodos, deleteTodo, allDone, markDone, markUndone } = useContext(
GlobalContext
);
useEffect(() => {
getTodos();
// eslint-disable-next-line
}, []);
return (
<div>
<Button style={{ marginTop: 10 }} onClick={allDone}>
Mark All Done
</Button>
<Divider orientation="left" style={{ width: "auto" }}></Divider>
{todos ? (
todos.map((todo) => {
return (
<div className="todo-list" key={todo._id}>
<ul key={todo._id}>
<li style={{ marginLeft: -35 }} key={todo._id}>
<span className={todo.done ? "done" : ""}>{todo.text}</span>
<Tooltip placement="right" title="Delete">
<Button
onClick={() => deleteTodo(todo._id)}
style={{ float: "right" }}
>
<DeleteTwoTone twoToneColor="#FF0000" />
</Button>
</Tooltip>
{todo.done ? (
<Tooltip placement="left" title="Unmark as done">
<Button
onClick={() => markUndone(todo._id)}
style={{ float: "right", marginRight: 5 }}
>
<MinusCircleTwoTone />
</Button>
</Tooltip>
) : (
<Tooltip placement="left" title="Mark as done">
<Button
onClick={() => markDone(todo._id)}
style={{ float: "right", marginRight: 5 }}
>
<CheckCircleTwoTone twoToneColor="#52c41a" />
</Button>
</Tooltip>
)}
</li>
</ul>
</div>
);
})
) : (
<p></p>
)}
</div>
);
}
Example #3
Source File: two-tone.jsx From virtuoso-design-system with MIT License | 5 votes |
storiesOf('antd/Icon', module).add('two-tone', () =>
<div className="icons-list">
<SmileTwoTone />
<HeartTwoTone twoToneColor="#eb2f96" />
<CheckCircleTwoTone twoToneColor="#52c41a" />
</div>,
{ docs: { page: () => (<><h1 id="enus">en-US</h1>
<p>You can set <code>twoToneColor</code> prop to specific primary color for two-tone icons.</p></>) } });
Example #4
Source File: QuadraticDiplomacyReward.jsx From quadratic-diplomacy with MIT License | 4 votes |
export default function QuadraticDiplomacyReward({
tx,
writeContracts,
userSigner,
votesEntries,
contributorEntries,
isAdmin,
mainnetProvider,
}) {
const [totalRewardAmount, setTotalRewardAmount] = useState(0);
const [rewardStatus, setRewardStatus] = useState(REWARD_STATUS.PENDING);
const [selectedToken, setSelectedToken] = useState("");
const [isSendingTx, setIsSendingTx] = useState(false);
const [voteResults, totalVotes, totalSqrtVotes, totalSquare] = useMemo(() => {
const votes = {};
let voteCount = 0;
let sqrts = 0;
let total = 0;
votesEntries.forEach(entry => {
const vote = entry.amount.toNumber();
const sqrtVote = Math.sqrt(vote);
if (!votes[entry.wallet]) {
votes[entry.wallet] = {
vote: 0,
// Sum of the square root of the votes for each member.
sqrtVote: 0,
hasVoted: false,
};
}
votes[entry.wallet].sqrtVote += sqrtVote;
votes[entry.wallet].vote += vote;
if (!votes[entry.wallet].hasVoted) {
votes[entry.wallet].hasVoted = entry.votingAddress === entry.wallet;
}
voteCount += vote;
// Total sum of the sum of the square roots of the votes for all members.
sqrts += sqrtVote;
});
Object.entries(votes).forEach(([wallet, { sqrtVote }]) => {
total += Math.pow(sqrtVote, 2);
});
return [votes, voteCount, sqrts, total];
}, [votesEntries]);
const columns = useMemo(
() => [
{
title: "Address",
dataIndex: "address",
render: address => <Address address={address} fontSize={16} size="short" ensProvider={mainnetProvider} />,
},
{
title: "Nº of votes",
dataIndex: "vote",
defaultSortOrder: "descend",
align: "center",
sorter: (a, b) => a.vote - b.vote,
},
{
title: "Quadratic votes",
dataIndex: "votesSqrt",
align: "center",
sorter: (a, b) => a.votesSqrt - b.votesSqrt,
render: (votesSqrt, record) => (
<p>
{votesSqrt.toFixed(2)} <Text type="secondary">({(record.votesShare * 100).toFixed(2)}%)</Text>
</p>
),
},
{
title: "Reward Amount",
dataIndex: "rewardAmount",
defaultSortOrder: "descend",
align: "center",
sorter: (a, b) => a.rewardAmount - b.rewardAmount,
render: rewardAmount => (
<p>
{rewardAmount.toFixed(2)} {selectedToken.toUpperCase()}
</p>
),
},
{
title: "Has Voted",
dataIndex: "hasVoted",
align: "center",
filters: [
{ text: "Yes", value: true },
{ text: "No", value: false },
],
onFilter: (value, record) => record.hasVoted === value,
render: hasVoted =>
hasVoted ? <CheckCircleTwoTone twoToneColor="#52c41a" /> : <CloseCircleTwoTone twoToneColor="red" />,
},
],
[mainnetProvider, selectedToken],
);
const dataSource = useMemo(
() =>
Object.entries(voteResults).map(([address, contributor]) => ({
key: address,
address: address,
vote: contributor?.vote,
votesSqrt: contributor?.sqrtVote,
votesShare: Math.pow(contributor?.sqrtVote, 2) / totalSquare,
rewardAmount: (Math.pow(contributor?.sqrtVote, 2) / totalSquare) * totalRewardAmount,
hasVoted: contributor?.hasVoted,
})),
[voteResults, totalSquare, totalRewardAmount],
);
const missingVotingMembers = contributorEntries
?.map(entry => entry.wallet)
.filter(wallet => !voteResults[wallet]?.hasVoted)
// Remove duplicated.
.filter((item, pos, self) => self.indexOf(item) === pos);
const handlePayment = async payFromSelf => {
// ToDo. Do some validation (non-empty elements, etc.)
const wallets = [];
const amounts = [];
setIsSendingTx(true);
// choose appropriate function from contract
let func;
if (selectedToken === "ETH") {
dataSource.forEach(({ address, rewardAmount }) => {
wallets.push(address);
// Flooring some decimals to avoid rounding errors => can result in not having enough funds.
amounts.push(ethers.utils.parseEther((Math.floor(rewardAmount * 10000) / 10000).toString()));
});
func = payFromSelf
? // payable functions need an `overrides` param.
// relevant docs: https://docs.ethers.io/v5/api/contract/contract/#Contract-functionsCall
writeContracts.QuadraticDiplomacyContract.sharePayedETH(wallets, amounts, {
value: ethers.utils.parseEther(totalRewardAmount.toString()),
})
: writeContracts.QuadraticDiplomacyContract.shareETH(wallets, amounts);
} else {
const tokenAddress = writeContracts[selectedToken].address;
const userAddress = await userSigner.getAddress();
const tokenContract = writeContracts[selectedToken].connect(userSigner);
// approve only if have to pay from self wallet
if (payFromSelf) {
await tx(
tokenContract.approve(
writeContracts.QuadraticDiplomacyContract.address,
ethers.utils.parseUnits(totalRewardAmount.toString(), 18),
),
);
}
dataSource.forEach(({ address, rewardAmount }) => {
wallets.push(address);
// Flooring some decimals to avoid rounding errors => can result in not having enough funds.
amounts.push(ethers.utils.parseUnits((Math.floor(rewardAmount * 10000) / 10000).toString()));
});
func = payFromSelf
? writeContracts.QuadraticDiplomacyContract.sharePayedToken(wallets, amounts, tokenAddress, userAddress)
: writeContracts.QuadraticDiplomacyContract.shareToken(wallets, amounts, tokenAddress);
}
await tx(func, update => {
// ToDo. Handle errors.
if (update && (update.status === "confirmed" || update.status === 1)) {
notification.success({
message: "Payment sent!",
});
setRewardStatus(REWARD_STATUS.COMPLETED);
setIsSendingTx(false);
} else if (update.error) {
setIsSendingTx(false);
}
});
};
if (!isAdmin) {
return (
<div style={{ border: "1px solid #cccccc", padding: 16, width: 800, margin: "auto", marginTop: 64 }}>
<Title level={4}>Access denied</Title>
<p>Only admins can send rewards.</p>
</div>
);
}
return (
<div style={{ border: "1px solid #cccccc", padding: 16, width: 1000, margin: "auto", marginTop: 64 }}>
<Title level={3}>Reward Contributors</Title>
<Title level={5}>
Total votes:
<Tag color="#000000">{totalVotes}</Tag>
</Title>
<Title level={5}>
Total Quadratic votes:
<Tag color="#52c41a">{totalSqrtVotes.toFixed(2)}</Tag>
</Title>
<Divider />
<Space split>
<Input
type="number"
disabled={!selectedToken} // disable if no token selected
value={totalRewardAmount}
addonBefore="Total Amount to Distribute"
addonAfter={
<Select defaultValue="Select token..." onChange={setSelectedToken}>
{TOKENS.map(tokenName => (
<Select.Option value={tokenName}>{tokenName}</Select.Option>
))}
</Select>
}
onChange={e => setTotalRewardAmount(e.target.value.toLowerCase())}
/>
</Space>
<Divider />
<Space direction="vertical" style={{ width: "100%" }}>
{missingVotingMembers?.length > 0 && (
<Alert
showIcon
type="warning"
message={<Title level={5}>Votes are pending from:</Title>}
description={missingVotingMembers.map(wallet => (
<p key={wallet}>
<Address address={wallet} fontSize={16} size="short" ensProvider={mainnetProvider} />
</p>
))}
/>
)}
<Table
bordered
dataSource={dataSource}
columns={columns}
pagination={{ pageSize: 10 }}
footer={() =>
!isSendingTx ? (
<Space>
<Button
onClick={() => handlePayment(true)}
disabled={rewardStatus === REWARD_STATUS.COMPLETED || !totalRewardAmount || !dataSource?.length}
size="large"
>
Pay ?
</Button>
<Button
onClick={() => handlePayment(false)}
disabled={rewardStatus === REWARD_STATUS.COMPLETED || !totalRewardAmount || !dataSource?.length}
size="large"
>
Pay from contract ?
</Button>
</Space>
) : (
<Spin size="small" />
)
}
/>
</Space>
<Divider />
</div>
);
}
Example #5
Source File: QuadraticDiplomacyVote.jsx From quadratic-diplomacy with MIT License | 4 votes |
export default function QuadraticDiplomacyVote({
voteCredits,
contributorEntries,
tx,
writeContracts,
isVoter,
mainnetProvider,
}) {
const [selectedContributors, setSelectedContributors] = useState({});
const [currentStep, setCurrentStep] = useState(1);
const [spentVoteTokens, setSpentVoteTokens] = useState(0);
const [isSendingTx, setIsSendingTx] = useState(false);
const availableVoteTokens = voteCredits?.toNumber() ?? 0;
const remainingVoteTokens = availableVoteTokens - spentVoteTokens;
const contributors = useMemo(
() =>
contributorEntries.reduce((entries, current) => {
entries[current.wallet] = 0;
return entries;
}, {}),
[contributorEntries],
);
const allContributorsSelected = Object.keys(contributors).length === Object.keys(selectedContributors).length;
if (!isVoter) {
return (
<div style={{ border: "1px solid", padding: "40px", width: 800, margin: "auto", marginTop: 64, textAlign: "left" }}>
<Title level={4} style={{ fontFamily: "Space Mono" }}>Access denied</Title>
<p>You are not part of the members of this election.</p>
</div>
);
}
const handleSelectAllContributors = () =>
allContributorsSelected ? setSelectedContributors({}) : setSelectedContributors(contributors);
const handleContributorSelection = (e, contributorAddress) => {
setSelectedContributors(prevSelectedContributors => {
if (prevSelectedContributors[contributorAddress] !== undefined) {
const state = { ...prevSelectedContributors };
delete state[contributorAddress];
return state;
} else {
return {
...prevSelectedContributors,
[contributorAddress]: contributors[contributorAddress],
};
}
});
};
const handleContributorVote = (e, op, clickedContributorAddress) => {
// adjust available vote tokens
setSpentVoteTokens(prevSpentVoteTokens => (op === "add" ? prevSpentVoteTokens + 1 : prevSpentVoteTokens - 1));
// update contributor vote tokens
setSelectedContributors(prevSelectedContributors => ({
...prevSelectedContributors,
[clickedContributorAddress]:
op === "add"
? Math.min(prevSelectedContributors[clickedContributorAddress] + 1, availableVoteTokens)
: Math.max(prevSelectedContributors[clickedContributorAddress] - 1, 0),
}));
};
const handleSubmitVotes = async () => {
const wallets = [];
const amounts = [];
Object.entries(selectedContributors).forEach(([contributorAddress, voteTokens]) => {
wallets.push(contributorAddress);
amounts.push(voteTokens);
});
setIsSendingTx(true);
await tx(writeContracts.QuadraticDiplomacyContract.voteMultiple(wallets, amounts), update => {
if (update && (update.status === "confirmed" || update.status === 1)) {
setIsSendingTx(false);
setSpentVoteTokens(0);
setCurrentStep(3);
} else if (update.error) {
setIsSendingTx(false);
}
});
};
return (
<div style={{ border: "1px solid", padding: "40px", width: 800, margin: "auto", marginTop: 64, textAlign: "left" }}>
<Steps initial={1} current={currentStep} labelPlacement="vertical">
<Steps.Step
title="Select Contributors"
subTitle={`${contributorEntries.length} contributors`}
icon={<SmileTwoTone />}
/>
<Steps.Step
title="Allocate Votes"
subTitle={`${remainingVoteTokens} votes left`}
icon={<LikeTwoTone twoToneColor="#eb2f96" />}
/>
<Steps.Step title="Done" subTitle="Thank you!" icon={<CheckCircleTwoTone twoToneColor="#52c41a" />} />
</Steps>
<Divider />
{currentStep === 1 ? (
<List
size="large"
itemLayout="horizontal"
header={<Title level={4} style={{ fontFamily: "Space Mono" }}>1. Who've you been working with?</Title>}
style={{ width: "600px", margin: "0 auto" }}
footer={
<Row justify="end">
<Button
type="primary"
onClick={() => setCurrentStep(2)}
disabled={!Object.keys(selectedContributors).length}
>
Next
</Button>
</Row>
}
dataSource={Object.entries(contributors)}
renderItem={([contributorAddress, votes], index) => (
<>
{index === 0 && (
<List.Item>
<Checkbox
indeterminate={!allContributorsSelected && Object.keys(selectedContributors).length}
checked={allContributorsSelected}
onChange={handleSelectAllContributors}
>
Select All
</Checkbox>
</List.Item>
)}
<List.Item key={contributorAddress}>
<Checkbox
size="large"
onClick={e => handleContributorSelection(e, contributorAddress)}
checked={selectedContributors[contributorAddress] !== undefined}
>
<Address address={contributorAddress} ensProvider={mainnetProvider} fontSize={16} size="short" />
</Checkbox>
</List.Item>
</>
)}
/>
) : currentStep === 2 ? (
<List
size="large"
itemLayout="horizontal"
style={{ width: "600px", margin: "0 auto" }}
header={
<Space direction="vertical">
<Title level={4} style={{ fontFamily: "Space Mono" }}>2. Allocate votes</Title>
<Title level={5}>
Remaining vote tokens:
<Badge
showZero
overflowCount={1000}
count={remainingVoteTokens}
style={{ backgroundColor: "#52c41a" }}
/>
</Title>
</Space>
}
footer={
<Row justify="end">
{!isSendingTx ? (
<>
<Button onClick={() => setCurrentStep(1)} style={{ marginRight: "8px" }} type="secondary">Go back</Button>
<Button type="primary" onClick={handleSubmitVotes}>
Commit votes
</Button>
</>
) : (
<Spin size="small" />
)}
</Row>
}
dataSource={Object.entries(selectedContributors)}
renderItem={([contributorAddress, contributor]) => (
<>
<Badge.Ribbon
showZero
overflowCount={1000}
text={<Title level={5}>{contributor} </Title>}
style={{
backgroundColor: contributor ? "#eb2f96" : "grey",
height: 24,
width: 30,
marginRight: -5,
}}
/>
<List.Item
key={contributorAddress}
extra={
<Button.Group>
<Button
danger
ghost
onClick={e => handleContributorVote(e, "remove", contributorAddress)}
disabled={!contributor}
>
<MinusOutlined />
</Button>
<Button
type="primary"
ghost
onClick={e => handleContributorVote(e, "add", contributorAddress)}
disabled={!remainingVoteTokens}
>
<PlusOutlined />
</Button>
</Button.Group>
}
>
<List.Item.Meta
avatar={
<Address address={contributorAddress} fontSize={16} size="short" ensProvider={mainnetProvider} />
}
/>
</List.Item>
</>
)}
/>
) : (
currentStep === 3 && (
<>
<Title level={3} style={{ fontFamily: "Space Mono" }}>Thank you for voting.</Title>
<p>The allocation to this workstream will be informed by your votes. See you next month!</p>
<Title level={5} style={{ marginTop: "24px" }}>Your votes:</Title>
{Object.entries(selectedContributors).map(([contributorAddress, voteTokens]) => (
<p key={contributorAddress}>
<Address address={contributorAddress} fontSize={16} size="short" ensProvider={mainnetProvider} /> (
<Text>{voteTokens}</Text>)
</p>
))}
</>
)
)}
</div>
);
}
Example #6
Source File: FileUploadModal.jsx From ui with MIT License | 4 votes |
FileUploadModal = (props) => {
const { onUpload, onCancel } = props;
const guidanceFileLink = 'https://drive.google.com/file/d/1VPaB-yofuExinY2pXyGEEx-w39_OPubO/view';
const [selectedTech, setSelectedTech] = useState('10X Chromium');
const [canUpload, setCanUpload] = useState(false);
const [filesList, setFilesList] = useState([]);
useEffect(() => {
setCanUpload(filesList.length && filesList.every((file) => file.valid));
}, [filesList]);
// Handle on Drop
const onDrop = async (acceptedFiles) => {
let filesNotInFolder = false;
const filteredFiles = acceptedFiles
// Remove all hidden files
.filter((file) => !file.name.startsWith('.') && !file.name.startsWith('__MACOSX'))
// Remove all files that aren't in a folder
.filter((file) => {
const inFolder = file.path.includes('/');
filesNotInFolder ||= !inFolder;
return inFolder;
});
if (filesNotInFolder) {
handleError('error', endUserMessages.ERROR_FILES_FOLDER);
}
const newFiles = await Promise.all(filteredFiles.map((file) => (
fileObjectToFileRecord(file, selectedTech)
)));
setFilesList([...filesList, ...newFiles]);
};
const removeFile = (fileName) => {
const newArray = _.cloneDeep(filesList);
const fileIdx = newArray.findIndex((file) => file.name === fileName);
newArray.splice(fileIdx, 1);
setFilesList(newArray);
};
const renderHelpText = () => (
<>
<Space direction='vertical' style={{ width: '100%' }}>
<Paragraph>
For each sample, upload a folder containing the
{' '}
{techOptions[selectedTech].inputInfo.length}
{' '}
count matrix files. The folder's name will be used to name the sample in it. You can change this name later in Data Management.
</Paragraph>
<Paragraph>
The required files for each sample are:
</Paragraph>
<List
dataSource={techOptions[selectedTech].inputInfo}
size='small'
itemLayout='vertical'
bordered
renderItem={(item) => (
<List.Item>
{
item.map((fileName, i) => (
<span key={fileName}>
<Text code>{`${fileName}`}</Text>
{i !== item.length - 1 && ' or '}
</span>
))
}
</List.Item>
)}
/>
</Space>
</>
);
return (
<Modal
title=''
visible
onCancel={onCancel}
width='50%'
footer={(
<Button
data-test-id={integrationTestConstants.ids.FILE_UPLOAD_BUTTON}
type='primary'
key='create'
block
disabled={!canUpload}
onClick={() => {
onUpload(filesList, selectedTech);
setFilesList([]);
}}
>
Upload
</Button>
)}
>
<Row>
<Col span={24}>
<Space direction='vertical' style={{ width: '100%' }}>
<Space align='baseline'>
<Title level={4} style={{ display: 'inline-block' }}>
Technology:
<span style={{ color: 'red', marginRight: '2em' }}>*</span>
</Title>
<Select
defaultValue={selectedTech}
onChange={(value) => setSelectedTech(value)}
>
{Object.keys(techOptions).map((val) => (
<Option key={`key-${val}`} value={val}>{val}</Option>
))}
</Select>
</Space>
<Text type='secondary'>
<i>
Is your dataset generated using another single cell RNA-seq technology (e.g. Nadia, BD Rhapsody, etc.)? Email us to find out if we can support your data:
<a href='mailto:[email protected]'> [email protected]</a>
</i>
</Text>
</Space>
</Col>
</Row>
<Row style={{ margin: '1rem 0' }}>
<Col span={24}>
<Title level={4}>
File Upload:
<span style={{ color: 'red', marginRight: '2em' }}>*</span>
</Title>
{selectedTech && renderHelpText()}
</Col>
</Row>
<Row>
{/* eslint-disable react/jsx-props-no-spreading */}
<Col span={24}>
<Paragraph type='secondary'>
<i>
Don’t have the data in the accepted format? Email us for help with file conversion (e.g. from Fastq or H5 file):
<a href='mailto:[email protected]'> [email protected]</a>
</i>
<span style={{ display: 'block', height: '0.6rem' }} />
<i>
More guidance on supported file types and formats is available
<a rel='noreferrer' target='_blank' href={guidanceFileLink}> here</a>
.
</i>
</Paragraph>
<Dropzone onDrop={onDrop} multiple>
{({ getRootProps, getInputProps }) => (
<div
data-test-id={integrationTestConstants.ids.FILE_UPLOAD_DROPZONE}
style={{ border: '1px solid #ccc', padding: '2rem 0' }}
{...getRootProps({ className: 'dropzone' })}
id='dropzone'
>
<input data-test-id={integrationTestConstants.ids.FILE_UPLOAD_INPUT} {...getInputProps()} webkitdirectory='' />
<Empty description='Drag and drop folders here or click to browse.' image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>
)}
</Dropzone>
</Col>
{/* eslint-enable react/jsx-props-no-spreading */}
{filesList.length ? (
<>
<Divider orientation='center'>To upload</Divider>
<List
dataSource={filesList}
size='small'
itemLayout='horizontal'
grid='{column: 4}'
renderItem={(file) => (
<List.Item
key={file.name}
style={{ width: '100%' }}
>
<Space>
{file.valid
? (
<>
<CheckCircleTwoTone twoToneColor='#52c41a' />
</>
) : (
<>
<CloseCircleTwoTone twoToneColor='#f5222d' />
</>
)}
<Text
ellipsis={{ tooltip: file.name }}
style={{ width: '200px' }}
>
{file.name}
</Text>
<DeleteOutlined style={{ color: 'crimson' }} onClick={() => { removeFile(file.name); }} />
</Space>
</List.Item>
)}
/>
</>
) : ''}
</Row>
</Modal>
);
}