mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 15:36:18 -05:00
Phase 2, part 2. Baseline 72 -> 63.
Migrated: Tables, SortableTable, DonatePage, Share, Headline, ErrorBoundary,
and the QR code, VIN decoder, and temperature calculators.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>`, keeping its grouped `results`
shape because four call sites already build it. A real
combobox: arrows move, Enter takes the highlighted suggestion
or submits the raw text, Escape closes without clearing.
Pagination Semantic's prop names, but onPageChange gets the page number
rather than an (event, data) pair.
TabBar the strip and its house style only; routing stays at the call
site, which is what decides what is active.
IconStack two glyphs composed into one symbol, named once for assistive
technology (Semantic's IconGroup).
Table.HeaderCell gains `sorted` and `onSort`.
That last one is a fix, not just a port. Semantic's `sorted` prop set
`aria-sort`; migrating a table by hand dropped it, leaving a clickable <th>
that no keyboard could reach and no screen reader could describe. Putting it
in the library means the next table gets it right without anyone remembering.
Night mode holes closed along the way: the QR codes on the donate, share, and
calculator pages are white by necessity — a scanner needs the contrast — and
they render as SVG, which the media filter does not target. In night mode that
was a lit panel. They now carry `.media`, so the filter remaps the block as a
unit and the contrast survives the mapping.
Also: `paypal` joins the icon map rather than being imported ad hoc in a page,
and FileBrowser stops passing Semantic-only table props into a DOM element.
85 lines
3.4 KiB
JavaScript
85 lines
3.4 KiB
JavaScript
import React, {useState} from "react";
|
|
import {PageContainer, useTitle} from "./Common";
|
|
import {Button, Header, IconButton, Modal, Panel, Table} from "./ui";
|
|
import QRCode from "react-qr-code";
|
|
|
|
const bitcoinAddress = '1mi1ddLSd6LmkuwJd1ttZsKuED724vYjS';
|
|
const bitcoinContent = `bitcoin:${bitcoinAddress}`;
|
|
const ethereumAddress = '0xC27C39b31A3a9D12C345A58aFe8a42a2e1eb0448';
|
|
const ethereumContent = `ethereum:${ethereumAddress}`;
|
|
const litecoinAddress = `LKngzDZUZcggxk2fTAZYmBcksLBMrnhioA`;
|
|
const litecoinContent = `litecoin:${litecoinAddress}`;
|
|
const moneroAddress = '87jv2NpGb5sbUwk7zYYwEY5RAoh1jRfTo4d1BAewVdJJFKg2bDF2UXtLfTc8LZkkSagDsnJyevLpZaZ846QHcLDjUenBrcY';
|
|
const moneroContent = `monero:${moneroAddress};`
|
|
|
|
function CoinQRButton({qrCodeValue, header, buttonColor}) {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
return <>
|
|
<IconButton icon='qrcode' label={`Show ${header} QR code`} color={buttonColor}
|
|
onClick={() => setOpen(true)}/>
|
|
<Modal closeIcon
|
|
open={open}
|
|
onClose={() => setOpen(false)}
|
|
onOpen={() => setOpen(true)}
|
|
>
|
|
<Modal.Header>{header}</Modal.Header>
|
|
<Modal.Content>
|
|
{/* `media`: the white field a scanner needs is filtered as a unit by night mode,
|
|
rather than sitting on screen as a lit panel. */}
|
|
<div className='media'
|
|
style={{backgroundColor: '#FFFFFF', display: 'inline-block', padding: '1em'}}>
|
|
<QRCode value={qrCodeValue} size={300}/>
|
|
</div>
|
|
</Modal.Content>
|
|
</Modal>
|
|
</>
|
|
}
|
|
|
|
function CoinRow({header, qrCodeValue, address, buttonColor}) {
|
|
return <>
|
|
<Header as='h3'>{header}</Header>
|
|
<Table>
|
|
<Table.Body>
|
|
<Table.Row>
|
|
<Table.Cell style={{width: '1%', whiteSpace: 'nowrap'}}>
|
|
<CoinQRButton qrCodeValue={qrCodeValue} header={header} buttonColor={buttonColor}/>
|
|
</Table.Cell>
|
|
<Table.Cell style={{textAlign: 'left'}}>
|
|
<pre>{address}</pre>
|
|
</Table.Cell>
|
|
</Table.Row>
|
|
</Table.Body>
|
|
</Table>
|
|
</>
|
|
}
|
|
|
|
export function DonatePage() {
|
|
useTitle('Donate');
|
|
|
|
return <PageContainer>
|
|
<Panel>
|
|
<Header as='h1'>Donate</Header>
|
|
<Header as='h3'>We appreciate any support you can provide to WROLPi!</Header>
|
|
|
|
<p>
|
|
<Button
|
|
size='xl'
|
|
icon='paypal'
|
|
component='a'
|
|
role='primary'
|
|
href='https://www.paypal.com/donate/?hosted_button_id=ZH2CN92SMJ66N'
|
|
rel='noopener noreferrer'
|
|
target='_blank'
|
|
>
|
|
Donate on PayPal
|
|
</Button>
|
|
</p>
|
|
|
|
<CoinRow header='Monero' qrCodeValue={moneroContent} address={moneroAddress} buttonColor='orange'/>
|
|
<CoinRow header='Litecoin' qrCodeValue={litecoinContent} address={litecoinAddress} buttonColor='grey'/>
|
|
<CoinRow header='Ethereum' qrCodeValue={ethereumContent} address={ethereumAddress} buttonColor='blue'/>
|
|
<CoinRow header='Bitcoin' qrCodeValue={bitcoinContent} address={bitcoinAddress} buttonColor='yellow'/>
|
|
</Panel>
|
|
</PageContainer>;
|
|
}
|