react-feather#Square TypeScript Examples
The following examples show how to use
react-feather#Square.
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: Toolbar.tsx From crypto-fees with MIT License | 4 votes |
Toolbar: React.FC<ToolbarProps> = ({
date,
onDateChange,
onFilterToggle,
numFilters,
bundle,
onBundleChange,
onShare,
tags,
onTagRemoved,
}) => {
const router = useRouter();
const { t } = useTranslation()
const [changed, setChanged] = useState(false);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (changed) {
const startLoading = () => setLoading(true);
const stopLoading = () => {
setLoading(false);
setChanged(false);
};
router.events.on('routeChangeStart', startLoading);
router.events.on('routeChangeComplete', stopLoading);
router.events.on('routeChangeError', stopLoading);
return () => {
router.events.off('routeChangeStart', startLoading);
router.events.off('routeChangeComplete', stopLoading);
router.events.off('routeChangeError', stopLoading);
};
}
}, [changed]);
return (
<div className="toolbar">
<div className="tags">
{tags.map((tag: any) => (
<div key={tag.id} className="label" title={tag.label}>
<span>{tag.label}</span>
<button onClick={() => onTagRemoved(tag.id)}>×</button>
</div>
))}
</div>
<div className="buttons">
{showGitcoin && (
<Button
Icon={GTCIcon}
target="gitcoin"
href="https://gitcoin.co/grants/1624/cryptofeesinfo"
>
Support us on Gitcoin
</Button>
)}
{onShare && (
<Button onClick={onShare} Icon={Share}>
{t('Share')}
</Button>
)}
<Button onClick={() => onBundleChange(!bundle)} Icon={bundle ? CheckSquare : Square}>
Bundle
</Button>
<Button onClick={onFilterToggle} Icon={Filter}>
{t('Filters')}
{numFilters > 0 && <span className="chip">{numFilters}</span>}
</Button>
{onDateChange && (
<DatePicker
selected={date}
customInput={<DateButton loading={loading && changed} />}
onChange={(newDate: Date) => {
setChanged(true);
const pad = (num: number) => (num < 10 ? `0${num}` : num.toString());
const formattedDate = `${newDate.getFullYear()}-${pad(newDate.getMonth() + 1)}-${pad(
newDate.getDate()
)}`;
onDateChange(formattedDate);
}}
maxDate={subDays(new Date(), 1)}
popperPlacement="bottom-end"
/>
)}
</div>
<style jsx>{`
.toolbar {
display: flex;
justify-content: flex-end;
align-self: stretch;
}
.buttons > :global(*),
.tags > :global(*) {
margin-left: 4px;
}
.tags {
display: flex;
justify-content: flex-end;
}
.buttons {
display: flex;
justify-content: flex-end;
align-self: stretch;
}
.chip {
background: #828282;
color: #f9fafc;
border-radius: 6px;
font-size: 10px;
padding: 2px 4px;
margin-left: 6px;
}
.label {
font-size: 10px;
display: flex;
max-width: 150px;
align-items: center;
background: #eeeeee;
padding: 2px;
border-radius: 4px;
}
.label span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.label button {
margin-left: 4px;
background: transparent;
border: none;
outline: none;
padding: 4px;
}
.label button:hover {
background: #dedede;
}
:global(.react-datepicker-wrapper),
:global(.react-datepicker__input-container) {
display: inline-flex;
align-items: stretch;
}
@media (max-width: 700px) {
.toolbar {
flex-direction: column-reverse;
}
.tags {
margin-top: 4px;
}
}
`}</style>
</div>
);
}