components#FlexList TypeScript Examples
The following examples show how to use
components#FlexList.
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: province.tsx From covid19-visualized with MIT License | 5 votes |
Page: NextPage = () => {
const { data, loading } = useFetch<IDFormat<IDProvince[]>>(API_INDONESIA + 'provinsi')(
data => {
data.data = data.data.filter(({ kodeProvi }) => kodeProvi)
return data
}
)
return (
<>
<Head>
<title>Indonesia Province | COVID-19 Visualized</title>
{meta}
</Head>
<div className="text-center my-12">
<h1 className="my-2">Indonesia Province</h1>
</div>
<div className="divider-line mb-32" />
<div className="btn-link mb-24">
<Link href="/indonesia">
<Button block color="secondary" text="< Back to Indonesia Cases" />
</Link>
</div>
<DataSearch<IDProvince>
data={data?.data}
loading={loading}
searchPlaceholder="Search province... (eg: jakarta)"
searchFilter={(keyword, item) => item.provinsi.toLowerCase().includes(keyword)}
>
{(data, keyword) => data.length
? (
<FlexList<IDProvince> data={data} wrapperClass="my-12" itemClass="my-12">
{province => (
<Region
chart={{
confirmed: province.kasusPosi,
recovered: province.kasusSemb,
deaths: province.kasusMeni
}}
header={`(#${province.kodeProvi}) ${province.provinsi}`}
>
<p>Total Positif: <span className="font is-weight-bold color is-txt-warning">{province.kasusPosi}</span></p>
<p className="mt-8">Aktif: <span className="font is-weight-bold color is-txt-warning">{getActiveCaseID(province)}</span></p>
<p>Sembuh: <span className="font is-weight-bold color is-txt-success">{province.kasusSemb}</span></p>
<p>Meninggal: <span className="font is-weight-bold color is-txt-danger">{province.kasusMeni}</span></p>
</Region>
)}
</FlexList>
) : (
<h3 className="text-center my-24">{
keyword.length
? `No matching province "${keyword}" found.`
: 'Please type the name of province that you want to search.'
}</h3>
)
}
</DataSearch>
</>
)
}
Example #2
Source File: region.tsx From covid19-visualized with MIT License | 5 votes |
Page: NextPage = () => {
const countries = useFetch<Country[]>(API_BASEURL + 'confirmed')(
data => (
data.sort(({ countryRegion: prev }, { countryRegion: next }) => (next > prev) ? -1 : 1)
)
)
return (
<>
<Head>
<title>Country and Region | COVID-19 Visualized</title>
{meta}
</Head>
<div className="text-center my-12">
<h1 className="my-2">Country and Region</h1>
</div>
<div className="divider-line mb-32" />
<div className="btn-link mb-24">
<Link href="/">
<Button block color="secondary" text="< Back to Home" />
</Link>
</div>
<DataSearch<Country>
data={countries.data}
loading={countries.loading}
searchPlaceholder="Search country state or province... (eg: indonesia)"
searchFilter={(keyword, item) => {
const region = item.countryRegion.toLowerCase()
const province = item.provinceState?.toLowerCase()
return region.includes(keyword) || (province ? province.includes(keyword) : false)
}}
>
{(data, keyword) => data.length
? (
<FlexList<Country> data={data} wrapperClass="my-12" itemClass="my-12">
{country => (
<Region
chart={{
confirmed: country.confirmed,
recovered: country.recovered,
deaths: country.deaths
}}
header={
country.provinceState
? `${country.provinceState}, ${country.countryRegion}`
: country.countryRegion
}
footer={`Last updated at: ${dateFormat(country.lastUpdate, true)}`}
>
<p>Total Confirmed: <span className="font is-weight-bold color is-txt-warning">{country.confirmed}</span></p>
<p className="mt-8">Active: <span className="font is-weight-bold color is-txt-warning">{getActiveCase(country)}</span></p>
<p>Recovered: <span className="font is-weight-bold color is-txt-success">{country.recovered}</span></p>
<p>Deaths: <span className="font is-weight-bold color is-txt-danger">{country.deaths}</span></p>
</Region>
)}
</FlexList>
) : (
<h3 className="text-center my-24">{
keyword.length
? `No matching country or province "${keyword}" found.`
: 'Please type the name of the country that you want to search.'
}</h3>
)
}
</DataSearch>
</>
)
}