react-icons/fa#FaMinus TypeScript Examples
The following examples show how to use
react-icons/fa#FaMinus.
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: LongPressButton.tsx From calendar-hack with MIT License | 5 votes |
LongPressButton: React.FC<Props> = ({ activeCb, doneCb, type }) => {
const timer = useCallback(
() => {
timerID = window.setInterval(function doCb() {
activeCb();
}, 100);
},
[activeCb],
);
function pressingDown(e: React.MouseEvent | React.TouchEvent) {
timer();
console.log(e);
e.preventDefault();
}
function notPressingDown(e: React.MouseEvent | React.TouchEvent) {
// Stop the timer
if (undefined !== timerID) {
clearInterval(timerID);
}
doneCb();
}
// create element ref
const innerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (innerRef && innerRef.current) {
const div = innerRef.current;
const cancel = (event: TouchEvent) => event.preventDefault();
div.addEventListener('touchstart', cancel, { passive: false });
div.addEventListener('touchend', cancel, { passive: false });
return () => {
div.removeEventListener('touchend', cancel);
}
}
}, []);
const themeContext = useContext(ThemeContext);
return (
<IconContext.Provider value={{ color: themeContext.colors.buttonIcons, size: "1.5em" }}>
<Root ref={innerRef} onMouseDown={pressingDown} onMouseUp={notPressingDown} onMouseLeave={notPressingDown}
onTouchStart={pressingDown} onTouchEnd={notPressingDown}>
{type === 'plus' && <FaPlus style={{ verticalAlign: 'middle' }} />}
{type === 'minus' && <FaMinus style={{ verticalAlign: 'middle' }} />}
</Root>
</IconContext.Provider>
)
}
Example #2
Source File: ScanTasksView.tsx From crossfeed with Creative Commons Zero v1.0 Universal | 4 votes |
ScanTasksView: React.FC = () => {
const { apiPost, token } = useAuthContext();
const [scanTasks, setScanTasks] = useState<ScanTask[]>([]);
const [totalResults, setTotalResults] = useState(0);
const [errors, setErrors] = useState<Errors>({});
const killScanTask = async (index: number) => {
try {
const row = scanTasks[index];
await apiPost(`/scan-tasks/${row.id}/kill`, { body: {} });
setScanTasks(
Object.assign([], scanTasks, {
[index]: {
...row,
status: 'failed'
}
})
);
} catch (e) {
setErrors({
global:
e.status === 422 ? 'Unable to kill scan' : e.message ?? e.toString()
});
console.log(e);
}
};
const renderExpanded = (row: Row<ScanTask>) => {
const { original } = row;
return (
<div className={classes.expandedRoot}>
{original.fargateTaskArn && (
<>
<h4>
Logs
{original.fargateTaskArn?.match('.*/(.*)') && (
<a
target="_blank"
rel="noopener noreferrer"
href={`https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#logsV2:log-groups/log-group/${process
.env
.REACT_APP_FARGATE_LOG_GROUP!}/log-events/worker$252Fmain$252F${
(original.fargateTaskArn.match('.*/(.*)') || [])[1]
}`}
>
{' '}
(View all on CloudWatch)
</a>
)}
</h4>
<Log
token={token ?? ''}
url={`${process.env.REACT_APP_API_URL}/scan-tasks/${original.id}/logs`}
/>
</>
)}
<h4>Input</h4>
<small>
<pre>{JSON.stringify(JSON.parse(original.input), null, 2)}</pre>
</small>
<h4>Output</h4>
<small>
<pre>{original.output || 'None'}</pre>
</small>
{row.original.status !== 'finished' &&
row.original.status !== 'failed' && (
<>
<h4>Actions</h4>
<a
href="# "
onClick={(e) => {
e.preventDefault();
killScanTask(row.index);
}}
>
Kill
</a>
</>
)}
</div>
);
};
const columns: Column<ScanTask>[] = [
{
Header: 'ID',
accessor: 'id',
Filter: ColumnFilter,
disableSortBy: true,
disableFilters: true
},
{
Header: 'Status',
accessor: 'status',
Filter: selectFilter([
'created',
'queued',
'requested',
'started',
'finished',
'failed'
]),
disableSortBy: true
},
{
Header: 'Name',
id: 'name',
accessor: ({ scan }) => scan?.name,
Filter: selectFilter([
// TODO: sync this with the SCAN_SCHEMA
'censys',
'amass',
'findomain',
'portscanner',
'wappalyzer',
'censysIpv4',
'censysCertificates',
'sslyze',
'searchSync',
'cve',
'dotgov',
'webscraper',
'intrigueIdent',
'shodan',
'hibp',
'lookingGlass',
'dnstwist',
'peCybersixgill',
'peHibpSync',
'peShodan',
'peDomMasq',
'rootDomainSync'
]),
disableSortBy: true
},
{
Header: 'Created At',
id: 'createdAt',
accessor: ({ createdAt }) => dateAccessor(createdAt),
disableFilters: true
},
{
Header: 'Finished At',
id: 'finishedAt',
accessor: ({ finishedAt }) => dateAccessor(finishedAt),
disableFilters: true
},
{
Header: 'Details',
Cell: ({ row }: CellProps<ScanTask>) => (
<span
{...row.getToggleRowExpandedProps()}
className="text-center display-block"
>
{row.isExpanded ? <FaMinus /> : <FaPlus />}
</span>
),
disableFilters: true
}
];
const PAGE_SIZE = 25;
const fetchScanTasks = useCallback(
async (query: Query<ScanTask>) => {
const { page, sort, filters } = query;
try {
const { result, count } = await apiPost<ApiResponse>(
'/scan-tasks/search',
{
body: {
page,
sort: sort[0]?.id ?? 'createdAt',
order: sort[0]?.desc ? 'DESC' : 'ASC',
filters: filters
.filter((f) => Boolean(f.value))
.reduce(
(accum, next) => ({
...accum,
[next.id]: next.value
}),
{}
)
}
}
);
setScanTasks(result);
setTotalResults(count);
} catch (e) {
console.error(e);
}
},
[apiPost]
);
const renderPagination = (table: TableInstance<ScanTask>) => (
<Paginator table={table} totalResults={totalResults} />
);
return (
<>
{errors.global && <p className={classes.error}>{errors.global}</p>}
<Table<ScanTask>
renderPagination={renderPagination}
columns={columns}
data={scanTasks}
pageCount={Math.ceil(totalResults / PAGE_SIZE)}
fetchData={fetchScanTasks}
pageSize={PAGE_SIZE}
initialSortBy={[
{
id: 'createdAt',
desc: true
}
]}
renderExpanded={renderExpanded}
/>
</>
);
}