mirror of
https://github.com/bitbaum/solon.git
synced 2026-12-04 05:07:04 +01:00
solon.orangecat.ch went unresponsive about 20 minutes after #618 went live (17:46 UTC, healthy at deploy, unanswered from ~18:05). A forced redeploy at 18:19 was rolled back by the box health check (http=000), and the site answers only now and then, after ~4 s: the process is saturated, not crashed, as in this morning's outage. It was stable for seven hours before #618. Reverting to restore the site; #618 comes back once the expensive part is found. Claude-Session: https://claude.ai/code/session_019MDtmvTCDbJAYNKQpNyKzz Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
49acf74622
commit
0257e1691c
29 files changed
+673
-1273
No files matched your search
@@ -96,31 +96,6 @@ one to read for the detail. Fixes get the same weight as features.
|
||||
again, as after each vote day, stopped with "Maximum call stack size exceeded" once the results
|
||||
were already held. It now loads.
|
||||
|
||||
### Changed
|
||||
|
||||
- **/compare answers on one screen.** Each topic draws its scale as a bar with every place's
|
||||
numbered mark on its step and one line per place saying what the law does; the articles, their
|
||||
words and the enforcement reports are folded underneath, one tap away. Tax, topics coded for
|
||||
only one place, and the sources are folded too. On a phone the page went from about 9,300 px
|
||||
to 3,100 px, and nothing scrolls sideways: a place's level is a small menu, not a scrolling
|
||||
row, and suggestions wrap.
|
||||
- **A place page starts with the place in four numbers.** Under the photograph: the laws in force
|
||||
there, how many took effect in the past twelve months, the official ways to change them, and the
|
||||
places inside it, each a tap to the part that explains it (and opens it). The three newest
|
||||
changes show with the rest one row away; the first group of figures shows and the others fold;
|
||||
how its law is changed, the places inside it and the record are a row each. Switzerland went from
|
||||
about 9,800 px to 6,100 px on a phone, Zürich from 6,400 px to 5,000 px.
|
||||
- **The home page's sixteen problems read as one list.** Each card is the problem in the words of
|
||||
the person who has it; what Solon does about it and the page where it happens open under it on a
|
||||
tap. The audience photographs are shorter on a phone. The page went from about 19,800 px to
|
||||
16,400 px.
|
||||
- **/law starts from the search and the places with the most law.** The examples are buttons; the
|
||||
places are tiles with their count and a bar against the largest, deepest first; places with a
|
||||
handful of acts, and the cantons, states and communes, fold to a row each. 5,400 px to 2,900 px
|
||||
on a phone.
|
||||
- **/budgets is one chart.** Every government's newest spending as a bar in the reader's currency,
|
||||
largest first, with where most of it went and the balance under it.
|
||||
|
||||
## 2026-11-27
|
||||
|
||||
### Added
|
||||
|
||||
+14
-36
@@ -607,7 +607,7 @@
|
||||
"kicker": "Orte nebeneinander",
|
||||
"metaTitle": "Orte vergleichen · Orte",
|
||||
"metaDescription": "Bis zu vier Orte nebeneinander: was Sie die Steuern an jedem kosten würden, und die amtlichen Zahlen dahinter.",
|
||||
"intro": "Bis zu {limit} Orte nebeneinander. Jedes Thema zeigt, wo das Gesetz jeden Ort auf einer Skala einordnet; aufklappen für die Artikel und, getrennt davon, wie das Gesetz durchgesetzt wird.",
|
||||
"intro": "Stellen Sie bis zu {limit} Orte nebeneinander: was das Gesetz zu jedem Thema sagt und, davon getrennt, wie es durchgesetzt wird, dann was Sie die Steuer kosten würde. Jede Zeile nennt ihre Quelle.",
|
||||
"empty": "Noch nichts zu vergleichen. Beginnen Sie dort, wo Sie sind, oder fügen Sie oben einen Ort hinzu.",
|
||||
"notFound": "{count, plural, one {Ein Ort in diesem Link ist nicht erfasst und wurde weggelassen.} other {# Orte in diesem Link sind nicht erfasst und wurden weggelassen.}}",
|
||||
"yourSituation": "Ihre Situation",
|
||||
@@ -667,23 +667,27 @@
|
||||
"full": "{limit} Orte sind das Maximum eines Vergleichs. Entfernen Sie einen, um einen weiteren hinzuzufügen."
|
||||
},
|
||||
"law": {
|
||||
"title": "Was das Gesetz sagt",
|
||||
"intro": "Eine Frage pro Thema, beantwortet auf einer geschriebenen Skala. Weiter links lässt Ihnen mehr Wahl. Das ist keine Note und kein Urteil über besser oder schlechter.",
|
||||
"title": "Was das Gesetz sagt und wie es durchgesetzt wird",
|
||||
"intro": "Jedes Thema ist eine Frage an das Gesetz, beantwortet auf einer schriftlichen Skala, mit den Artikeln und ihrem Wortlaut. Wie das Gesetz durchgesetzt wird, steht getrennt: Die Angaben sind spärlich und weich, deshalb trägt jede, wer sie gemacht hat, für welche Jahre und wie weit man ihr trauen kann, und keine verschiebt einen Ort auf der Skala.",
|
||||
"says": "Was das Gesetz sagt",
|
||||
"enforced": "Wie es durchgesetzt wird",
|
||||
"enforcedIntro": "Was Polizei und andere nach eigenen Angaben tun, getrennt vom Gesetz.",
|
||||
"freerEnd": "Lässt Ihnen am meisten",
|
||||
"lessFreeEnd": "Lässt Ihnen am wenigsten",
|
||||
"freest": "Lässt Ihnen am meisten: {place}.",
|
||||
"freest": "Lässt Ihnen am meisten: {place}. Die entscheidende Regel steht bei jedem Ort.",
|
||||
"same": "Die verglichenen Orte stehen auf demselben Punkt dieser Skala.",
|
||||
"freerNote": "Freier heisst hier: Das Gesetz überlässt der Person mehr von der Entscheidung. Das ist die Reihenfolge der schriftlichen Skala oben, keine Punktzahl: Jeder Ort steht dort, wo ihn sein eigener Wortlaut hinstellt, und eine andere Skala könnte anders ordnen.",
|
||||
"via": "Recht von {place}",
|
||||
"about": "zu {place}",
|
||||
"words": "Der Wortlaut des Gesetzes",
|
||||
"translation": "Auf Englisch:",
|
||||
"open": "Offen gelassen:",
|
||||
"atPublisher": "(beim Herausgeber)",
|
||||
"settled": "Kodiert von {by} und von einer zweiten Person geprüft.",
|
||||
"awaiting": "Kodiert von {by}; noch von keiner zweiten Person geprüft.",
|
||||
"notCoded": "Noch nicht kodiert: {places}.",
|
||||
"noEnforcement": "Noch keine Angabe zur Durchsetzung gefunden.",
|
||||
"statedBy": "Angabe von {by}, {period}",
|
||||
"period": "{from} bis {to}",
|
||||
"since": "seit {from}",
|
||||
"read": "gelesen am {on}",
|
||||
@@ -695,20 +699,8 @@
|
||||
},
|
||||
"noEnforcementAny": "Für diese Orte wurde noch keine Angabe zur Durchsetzung gefunden.",
|
||||
"fewTitle": "Bisher nur für einen dieser Orte kodiert",
|
||||
"notCodedShort": "noch nicht eingeordnet",
|
||||
"whyTitle": "Warum: die Artikel und ihr Wortlaut",
|
||||
"whyHint": "{count, plural, one {Das Gesetz hinter # Ort und die Skala} other {Das Gesetz hinter jedem der # Orte und die Skala}}",
|
||||
"scaleTitle": "Die Skala",
|
||||
"enforcedHint": "{count, plural, one {# Bericht, getrennt vom Gesetz} other {# Berichte, getrennt vom Gesetz}}",
|
||||
"whySure": "{count, plural, one {Wie sicher, und die Quelle} other {Wie sicher, und die # Quellen}}",
|
||||
"trust": {
|
||||
"high": "Hohe Sicherheit",
|
||||
"medium": "Mittlere Sicherheit",
|
||||
"low": "Geringe Sicherheit"
|
||||
}
|
||||
},
|
||||
"taxHint": "Einkommen eingeben für eine Schätzung an jedem Ort",
|
||||
"sourcesHint": "{count, plural, one {# Quelle, mit Datum und Lizenz} other {# Quellen, jede mit Datum und Lizenz}}"
|
||||
"codedFor": "kodiert für {places}"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"searchLabel": "Adresse, Ort oder Postleitzahl suchen",
|
||||
@@ -817,8 +809,7 @@
|
||||
"level": "{level} ({count})"
|
||||
},
|
||||
"record": {
|
||||
"title": "Namen, Kennungen und Quellen",
|
||||
"hint": "{count, plural, one {# Quelle} other {# Quellen}}, andere Namen, amtliche Kennungen"
|
||||
"title": "Namen, Kennungen und Quellen"
|
||||
},
|
||||
"taxMap": {
|
||||
"title": "Steuer nach Ort",
|
||||
@@ -923,8 +914,7 @@
|
||||
"title": "Was sich zuletzt geändert hat",
|
||||
"intro": "{count, plural, one {# Erlass} other {# Erlasse}} von {place} und der übergeordneten Orte traten in den letzten zwölf Monaten in Kraft. Die neuesten:",
|
||||
"new": "Neu, in Kraft seit {date}",
|
||||
"amended": "Geändert, in Kraft seit {date}",
|
||||
"more": "{count, plural, one {# weiterer} other {# weitere}}"
|
||||
"amended": "Geändert, in Kraft seit {date}"
|
||||
},
|
||||
"explore": {
|
||||
"title": "Die Schweizer Gemeinden in Zahlen",
|
||||
@@ -999,13 +989,6 @@
|
||||
"moreVotes": "{count} frühere Abstimmungen",
|
||||
"explore": "Mit jeder Gemeinde vergleichen",
|
||||
"allVotes": "Alle eidgenössischen Abstimmungen"
|
||||
},
|
||||
"glance": {
|
||||
"label": "Dieser Ort in Zahlen",
|
||||
"laws": "{count, plural, one {Erlass hier in Kraft} other {Erlasse hier in Kraft}}",
|
||||
"changed": "{count, plural, one {in den letzten 12 Monaten in Kraft getreten} other {in den letzten 12 Monaten in Kraft getreten}}",
|
||||
"routes": "{count, plural, one {offizieller Weg, sie zu ändern} other {offizielle Wege, sie zu ändern}}",
|
||||
"places": "{count, plural, one {Ort darin} other {Orte darin}}"
|
||||
}
|
||||
},
|
||||
"AuthError": {
|
||||
@@ -1066,11 +1049,7 @@
|
||||
"browseHint": "Beginnen Sie bei Ihrem Wohnort. Dort gilt auch das Recht Ihres Kantons und des Bundes.",
|
||||
"placeActs": "{count, plural, one {# Erlass} other {# Erlasse}}",
|
||||
"communes": "{count, plural, one {# Gemeinde} other {# Gemeinden}}",
|
||||
"didYouMean": "Meinten Sie:",
|
||||
"held": "{acts} Erlasse aus {places} Orten, jeder in einfachen Worten durchsuchbar.",
|
||||
"allPlaces": "{count, plural, one {# weiterer Ort} other {# weitere Orte}}",
|
||||
"regionsTitle": "Kantone, Bundesstaaten und Gemeinden",
|
||||
"regionsHint": "{count, plural, one {# Ort unterhalb eines Landes} other {# Orte unterhalb eines Landes}}"
|
||||
"didYouMean": "Meinten Sie:"
|
||||
},
|
||||
"act": {
|
||||
"kicker": "Recht",
|
||||
@@ -2454,8 +2433,7 @@
|
||||
"label": "Geld zeigen in",
|
||||
"converted": "Beträge in {to}, umgerechnet aus {from} zum Durchschnittskurs von {year} ({sources}).",
|
||||
"notConverted": "Beträge in {from}: Solon hält keinen Kurs für {year}, um sie in {to} umzurechnen."
|
||||
},
|
||||
"chartTitle": "Was jede Regierung im neuesten Jahr ausgab, in {currency}"
|
||||
}
|
||||
},
|
||||
"MethodLab": {
|
||||
"tablist": "Wie dieselben Vorlieben gezählt werden",
|
||||
|
||||
+14
-36
@@ -1188,7 +1188,7 @@
|
||||
"kicker": "Places side by side",
|
||||
"metaTitle": "Compare places · Places",
|
||||
"metaDescription": "Put up to four places side by side: what tax would cost you in each, and the official figures that set it.",
|
||||
"intro": "Up to {limit} places side by side. Each topic shows where the law puts every place on one scale; open it for the articles, and, kept apart, how the law is enforced.",
|
||||
"intro": "Put up to {limit} places side by side: what the law says on each topic and how it is enforced, kept apart, then what tax would cost you. Every line names its source.",
|
||||
"empty": "Nothing to compare yet. Start from where you are, or add a place above.",
|
||||
"notFound": "{count, plural, one {One place in this link is not recorded, so it was left out.} other {# places in this link are not recorded, so they were left out.}}",
|
||||
"yourSituation": "Your situation",
|
||||
@@ -1248,23 +1248,27 @@
|
||||
"full": "{limit} places is the most one comparison holds. Remove one to add another."
|
||||
},
|
||||
"law": {
|
||||
"title": "What the law says",
|
||||
"intro": "One question per topic, answered on a written scale. Further left leaves more of the choice to you. That is not a score and not a verdict on better or worse.",
|
||||
"title": "What the law says, and how it is enforced",
|
||||
"intro": "Each topic is one question asked of the statute and answered on a written scale, with the articles and their words. How the law is enforced is shown apart: it is scarce and soft, so each statement carries who made it, for which years and how far it can be trusted, and it never moves a place on the scale.",
|
||||
"says": "What the law says",
|
||||
"enforced": "How it is enforced",
|
||||
"enforcedIntro": "What police and others report doing, kept apart from the law.",
|
||||
"freerEnd": "Leaves the most to you",
|
||||
"lessFreeEnd": "Leaves the least to you",
|
||||
"freest": "Leaves the most to you: {place}.",
|
||||
"freest": "Leaves the most to you: {place}. The rule that decides it is under each place.",
|
||||
"same": "The places compared stand on the same point of this scale.",
|
||||
"freerNote": "More free here means the law leaves more of the choice to the person. It is the order of the written scale above, not a score: each place stands where its own words put it, and a different scale could order them differently.",
|
||||
"via": "law of {place}",
|
||||
"about": "about {place}",
|
||||
"words": "The words of the law",
|
||||
"translation": "In English:",
|
||||
"open": "Left open:",
|
||||
"atPublisher": "(at the publisher)",
|
||||
"settled": "Coded by {by} and checked by a second reader.",
|
||||
"awaiting": "Coded by {by}; no second reader has checked it yet.",
|
||||
"notCoded": "Not coded yet: {places}.",
|
||||
"noEnforcement": "No statement about enforcement found yet.",
|
||||
"statedBy": "Stated by {by}, {period}",
|
||||
"period": "{from} to {to}",
|
||||
"since": "since {from}",
|
||||
"read": "read {on}",
|
||||
@@ -1276,20 +1280,8 @@
|
||||
},
|
||||
"noEnforcementAny": "No statement about how this is enforced has been found yet for these places.",
|
||||
"fewTitle": "Coded for only one of these places so far",
|
||||
"notCodedShort": "not coded yet",
|
||||
"whyTitle": "Why: the articles and their words",
|
||||
"whyHint": "{count, plural, one {The law behind # place, and the scale} other {The law behind each of # places, and the scale}}",
|
||||
"scaleTitle": "The scale",
|
||||
"enforcedHint": "{count, plural, one {# report, kept apart from the law} other {# reports, kept apart from the law}}",
|
||||
"whySure": "{count, plural, one {How sure, and the source} other {How sure, and the # sources}}",
|
||||
"trust": {
|
||||
"high": "High confidence",
|
||||
"medium": "Medium confidence",
|
||||
"low": "Low confidence"
|
||||
}
|
||||
},
|
||||
"taxHint": "Enter your income for an estimate in each place",
|
||||
"sourcesHint": "{count, plural, one {# source, with its date and licence} other {# sources, each with its date and licence}}"
|
||||
"codedFor": "coded for {places}"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"searchLabel": "Find an address, a place or a postcode",
|
||||
@@ -1398,8 +1390,7 @@
|
||||
"level": "{level} ({count})"
|
||||
},
|
||||
"record": {
|
||||
"title": "Names, identifiers and sources",
|
||||
"hint": "{count, plural, one {# source} other {# sources}}, other names, official identifiers"
|
||||
"title": "Names, identifiers and sources"
|
||||
},
|
||||
"taxMap": {
|
||||
"title": "Tax by place",
|
||||
@@ -1504,8 +1495,7 @@
|
||||
"title": "What changed lately",
|
||||
"intro": "{count, plural, one {# law} other {# laws}} of {place} and the places above it took effect in the past twelve months. The newest:",
|
||||
"new": "New, in force since {date}",
|
||||
"amended": "Amended, in force since {date}",
|
||||
"more": "{count, plural, one {# more} other {# more}}"
|
||||
"amended": "Amended, in force since {date}"
|
||||
},
|
||||
"explore": {
|
||||
"title": "Swiss communes in numbers",
|
||||
@@ -1580,13 +1570,6 @@
|
||||
"moreVotes": "{count} earlier votes",
|
||||
"explore": "Compare with every commune",
|
||||
"allVotes": "All federal votes"
|
||||
},
|
||||
"glance": {
|
||||
"label": "This place in numbers",
|
||||
"laws": "{count, plural, one {law in force here} other {laws in force here}}",
|
||||
"changed": "{count, plural, one {took effect in the past 12 months} other {took effect in the past 12 months}}",
|
||||
"routes": "{count, plural, one {official way to change them} other {official ways to change them}}",
|
||||
"places": "{count, plural, one {place inside} other {places inside}}"
|
||||
}
|
||||
},
|
||||
"AuthError": {
|
||||
@@ -1647,11 +1630,7 @@
|
||||
"browseHint": "Begin with where you live. The law of your canton and of the Confederation applies there too.",
|
||||
"placeActs": "{count, plural, one {# act} other {# acts}}",
|
||||
"communes": "{count, plural, one {# commune} other {# communes}}",
|
||||
"didYouMean": "Did you mean:",
|
||||
"held": "{acts} laws from {places} places, each searchable in plain words.",
|
||||
"allPlaces": "{count, plural, one {# more place} other {# more places}}",
|
||||
"regionsTitle": "Cantons, states and communes",
|
||||
"regionsHint": "{count, plural, one {# place below a country} other {# places below a country}}"
|
||||
"didYouMean": "Did you mean:"
|
||||
},
|
||||
"act": {
|
||||
"kicker": "Law",
|
||||
@@ -3035,8 +3014,7 @@
|
||||
"label": "Show money in",
|
||||
"converted": "Amounts in {to}, converted from {from} at {year}'s average rate ({sources}).",
|
||||
"notConverted": "Amounts in {from}: Solon holds no {year} rate to convert them to {to}."
|
||||
},
|
||||
"chartTitle": "What each government spent in its newest year, in {currency}"
|
||||
}
|
||||
},
|
||||
"MethodLab": {
|
||||
"tablist": "How to count the same preferences",
|
||||
|
||||
+14
-36
@@ -607,7 +607,7 @@
|
||||
"kicker": "Des lieux côte à côte",
|
||||
"metaTitle": "Comparer des lieux · Lieux",
|
||||
"metaDescription": "Jusqu’à quatre lieux côte à côte : ce que l’impôt vous coûterait dans chacun, et les chiffres officiels qui le fixent.",
|
||||
"intro": "Jusqu’à {limit} lieux côte à côte. Chaque thème montre où la loi place chaque lieu sur une même échelle ; ouvrez-le pour les articles et, à part, la manière dont la loi est appliquée.",
|
||||
"intro": "Placez jusqu'à {limit} lieux côte à côte : ce que dit la loi sur chaque sujet et, à part, comment elle est appliquée, puis ce que l'impôt vous coûterait. Chaque ligne cite sa source.",
|
||||
"empty": "Rien à comparer pour l'instant. Partez de là où vous êtes, ou ajoutez un lieu ci-dessus.",
|
||||
"notFound": "{count, plural, one {Un lieu de ce lien n’est pas recensé ; il a été omis.} other {# lieux de ce lien ne sont pas recensés ; ils ont été omis.}}",
|
||||
"yourSituation": "Votre situation",
|
||||
@@ -667,23 +667,27 @@
|
||||
"full": "{limit} lieux, c'est le maximum d'une comparaison. Retirez-en un pour en ajouter un autre."
|
||||
},
|
||||
"law": {
|
||||
"title": "Ce que dit la loi",
|
||||
"intro": "Une question par thème, répondue sur une échelle écrite. Plus à gauche, plus le choix vous revient. Ce n’est ni une note ni un jugement sur le meilleur ou le pire.",
|
||||
"title": "Ce que dit la loi, et comment elle est appliquée",
|
||||
"intro": "Chaque sujet est une question posée à la loi et répondue sur une échelle écrite, avec les articles et leur texte. L'application de la loi est montrée à part : les données sont rares et fragiles, chacune dit donc qui l'affirme, pour quelles années et à quel point s'y fier, et aucune ne déplace un lieu sur l'échelle.",
|
||||
"says": "Ce que dit la loi",
|
||||
"enforced": "Comment elle est appliquée",
|
||||
"enforcedIntro": "Ce que la police et d'autres déclarent faire, à part de la loi.",
|
||||
"freerEnd": "Vous laisse le plus",
|
||||
"lessFreeEnd": "Vous laisse le moins",
|
||||
"freest": "Vous laisse le plus de choix : {place}.",
|
||||
"freest": "Vous laisse le plus : {place}. La règle qui en décide figure sous chaque lieu.",
|
||||
"same": "Les lieux comparés sont au même point de cette échelle.",
|
||||
"freerNote": "Plus libre signifie ici que la loi laisse davantage le choix à la personne. C'est l'ordre de l'échelle écrite ci-dessus, pas une note : chaque lieu se tient là où son propre texte le place, et une autre échelle pourrait les ordonner autrement.",
|
||||
"via": "droit de {place}",
|
||||
"about": "sur {place}",
|
||||
"words": "Le texte de la loi",
|
||||
"translation": "En anglais :",
|
||||
"open": "Laissé ouvert :",
|
||||
"atPublisher": "(chez l'éditeur)",
|
||||
"settled": "Codé par {by} et vérifié par une seconde personne.",
|
||||
"awaiting": "Codé par {by} ; aucune seconde personne ne l'a encore vérifié.",
|
||||
"notCoded": "Pas encore codé : {places}.",
|
||||
"noEnforcement": "Aucune déclaration sur l'application trouvée pour l'instant.",
|
||||
"statedBy": "Déclaré par {by}, {period}",
|
||||
"period": "du {from} au {to}",
|
||||
"since": "depuis le {from}",
|
||||
"read": "lu le {on}",
|
||||
@@ -695,20 +699,8 @@
|
||||
},
|
||||
"noEnforcementAny": "Aucune déclaration sur l'application n'a encore été trouvée pour ces lieux.",
|
||||
"fewTitle": "Codé pour un seul de ces lieux jusqu'ici",
|
||||
"notCodedShort": "pas encore codé",
|
||||
"whyTitle": "Pourquoi : les articles et leur texte",
|
||||
"whyHint": "{count, plural, one {La loi derrière # lieu, et l’échelle} other {La loi derrière chacun des # lieux, et l’échelle}}",
|
||||
"scaleTitle": "L’échelle",
|
||||
"enforcedHint": "{count, plural, one {# rapport, à part de la loi} other {# rapports, à part de la loi}}",
|
||||
"whySure": "{count, plural, one {Quelle certitude, et la source} other {Quelle certitude, et les # sources}}",
|
||||
"trust": {
|
||||
"high": "Confiance élevée",
|
||||
"medium": "Confiance moyenne",
|
||||
"low": "Confiance faible"
|
||||
}
|
||||
},
|
||||
"taxHint": "Saisissez votre revenu pour une estimation dans chaque lieu",
|
||||
"sourcesHint": "{count, plural, one {# source, avec sa date et sa licence} other {# sources, chacune avec sa date et sa licence}}"
|
||||
"codedFor": "codé pour {places}"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"searchLabel": "Chercher une adresse, un lieu ou un code postal",
|
||||
@@ -817,8 +809,7 @@
|
||||
"level": "{level} ({count})"
|
||||
},
|
||||
"record": {
|
||||
"title": "Noms, identifiants et sources",
|
||||
"hint": "{count, plural, one {# source} other {# sources}}, autres noms, identifiants officiels"
|
||||
"title": "Noms, identifiants et sources"
|
||||
},
|
||||
"taxMap": {
|
||||
"title": "L'impôt par lieu",
|
||||
@@ -923,8 +914,7 @@
|
||||
"title": "Ce qui a changé récemment",
|
||||
"intro": "{count, plural, one {# acte} other {# actes}} de {place} et des lieux dont il relève sont entrés en vigueur au cours des douze derniers mois. Les plus récents :",
|
||||
"new": "Nouveau, en vigueur depuis le {date}",
|
||||
"amended": "Modifié, en vigueur depuis le {date}",
|
||||
"more": "{count, plural, one {# de plus} other {# de plus}}"
|
||||
"amended": "Modifié, en vigueur depuis le {date}"
|
||||
},
|
||||
"explore": {
|
||||
"title": "Les communes suisses en chiffres",
|
||||
@@ -999,13 +989,6 @@
|
||||
"moreVotes": "{count} votations antérieures",
|
||||
"explore": "Comparer avec chaque commune",
|
||||
"allVotes": "Toutes les votations fédérales"
|
||||
},
|
||||
"glance": {
|
||||
"label": "Ce lieu en chiffres",
|
||||
"laws": "{count, plural, one {loi en vigueur ici} other {lois en vigueur ici}}",
|
||||
"changed": "{count, plural, one {entrée en vigueur ces 12 derniers mois} other {entrées en vigueur ces 12 derniers mois}}",
|
||||
"routes": "{count, plural, one {voie officielle pour les changer} other {voies officielles pour les changer}}",
|
||||
"places": "{count, plural, one {lieu à l’intérieur} other {lieux à l’intérieur}}"
|
||||
}
|
||||
},
|
||||
"AuthError": {
|
||||
@@ -1066,11 +1049,7 @@
|
||||
"browseHint": "Commencez par votre lieu de domicile. Le droit de votre canton et celui de la Confédération s’y appliquent aussi.",
|
||||
"placeActs": "{count, plural, one {# acte} other {# actes}}",
|
||||
"communes": "{count, plural, one {# commune} other {# communes}}",
|
||||
"didYouMean": "Vouliez-vous dire :",
|
||||
"held": "{acts} textes de {places} lieux, chacun consultable en mots simples.",
|
||||
"allPlaces": "{count, plural, one {# autre lieu} other {# autres lieux}}",
|
||||
"regionsTitle": "Cantons, États et communes",
|
||||
"regionsHint": "{count, plural, one {# lieu sous un pays} other {# lieux sous un pays}}"
|
||||
"didYouMean": "Vouliez-vous dire :"
|
||||
},
|
||||
"act": {
|
||||
"kicker": "Droit",
|
||||
@@ -2454,8 +2433,7 @@
|
||||
"label": "Montrer l'argent en",
|
||||
"converted": "Montants en {to}, convertis depuis {from} au cours moyen de {year} ({sources}).",
|
||||
"notConverted": "Montants en {from} : Solon ne détient aucun cours de {year} pour les convertir en {to}."
|
||||
},
|
||||
"chartTitle": "Ce que chaque gouvernement a dépensé lors de sa dernière année, en {currency}"
|
||||
}
|
||||
},
|
||||
"MethodLab": {
|
||||
"tablist": "Comment compter les mêmes préférences",
|
||||
|
||||
+14
-36
@@ -607,7 +607,7 @@
|
||||
"kicker": "Luoghi a confronto",
|
||||
"metaTitle": "Confrontare luoghi · Luoghi",
|
||||
"metaDescription": "Fino a quattro luoghi a confronto: quanto ti costerebbero le imposte in ciascuno, e le cifre ufficiali che le fissano.",
|
||||
"intro": "Fino a {limit} luoghi a confronto. Ogni tema mostra dove la legge colloca ciascun luogo su una scala; aprilo per gli articoli e, a parte, per come la legge viene applicata.",
|
||||
"intro": "Metti fino a {limit} luoghi uno accanto all'altro: che cosa dice la legge su ogni tema e, separatamente, come viene applicata, poi quanto ti costerebbe l'imposta. Ogni riga cita la sua fonte.",
|
||||
"empty": "Ancora niente da confrontare. Parti da dove sei, o aggiungi un luogo qui sopra.",
|
||||
"notFound": "{count, plural, one {Un luogo di questo link non è registrato ed è stato omesso.} other {# luoghi di questo link non sono registrati e sono stati omessi.}}",
|
||||
"yourSituation": "La tua situazione",
|
||||
@@ -667,23 +667,27 @@
|
||||
"full": "{limit} luoghi sono il massimo di un confronto. Togline uno per aggiungerne un altro."
|
||||
},
|
||||
"law": {
|
||||
"title": "Cosa dice la legge",
|
||||
"intro": "Una domanda per tema, con risposta su una scala scritta. Più a sinistra, più la scelta resta a te. Non è un punteggio né un giudizio su meglio o peggio.",
|
||||
"title": "Che cosa dice la legge, e come viene applicata",
|
||||
"intro": "Ogni tema è una domanda posta alla legge e risposta su una scala scritta, con gli articoli e il loro testo. L'applicazione della legge è mostrata a parte: i dati sono scarsi e incerti, quindi ognuno dice chi lo afferma, per quali anni e quanto ci si può fidare, e nessuno sposta un luogo sulla scala.",
|
||||
"says": "Che cosa dice la legge",
|
||||
"enforced": "Come viene applicata",
|
||||
"enforcedIntro": "Ciò che la polizia e altri dichiarano di fare, separato dalla legge.",
|
||||
"freerEnd": "Ti lascia di più",
|
||||
"lessFreeEnd": "Ti lascia di meno",
|
||||
"freest": "Ti lascia più scelta: {place}.",
|
||||
"freest": "Ti lascia di più: {place}. La regola che lo decide è sotto ogni luogo.",
|
||||
"same": "I luoghi confrontati stanno sullo stesso punto di questa scala.",
|
||||
"freerNote": "Più libero qui significa che la legge lascia alla persona più della scelta. È l'ordine della scala scritta qui sopra, non un punteggio: ogni luogo sta dove lo mette il suo testo, e un'altra scala potrebbe ordinarli diversamente.",
|
||||
"via": "diritto di {place}",
|
||||
"about": "su {place}",
|
||||
"words": "Il testo della legge",
|
||||
"translation": "In inglese:",
|
||||
"open": "Lasciato aperto:",
|
||||
"atPublisher": "(presso l'editore)",
|
||||
"settled": "Codificato da {by} e verificato da una seconda persona.",
|
||||
"awaiting": "Codificato da {by}; nessuna seconda persona l'ha ancora verificato.",
|
||||
"notCoded": "Non ancora codificato: {places}.",
|
||||
"noEnforcement": "Nessuna dichiarazione sull'applicazione trovata finora.",
|
||||
"statedBy": "Dichiarato da {by}, {period}",
|
||||
"period": "dal {from} al {to}",
|
||||
"since": "dal {from}",
|
||||
"read": "letto il {on}",
|
||||
@@ -695,20 +699,8 @@
|
||||
},
|
||||
"noEnforcementAny": "Per questi luoghi non è ancora stata trovata alcuna dichiarazione sull'applicazione.",
|
||||
"fewTitle": "Finora codificato per uno solo di questi luoghi",
|
||||
"notCodedShort": "non ancora codificato",
|
||||
"whyTitle": "Perché: gli articoli e il loro testo",
|
||||
"whyHint": "{count, plural, one {La legge dietro # luogo, e la scala} other {La legge dietro ciascuno dei # luoghi, e la scala}}",
|
||||
"scaleTitle": "La scala",
|
||||
"enforcedHint": "{count, plural, one {# rapporto, separato dalla legge} other {# rapporti, separati dalla legge}}",
|
||||
"whySure": "{count, plural, one {Quanto è sicuro, e la fonte} other {Quanto è sicuro, e le # fonti}}",
|
||||
"trust": {
|
||||
"high": "Affidabilità alta",
|
||||
"medium": "Affidabilità media",
|
||||
"low": "Affidabilità bassa"
|
||||
}
|
||||
},
|
||||
"taxHint": "Inserisci il tuo reddito per una stima in ogni luogo",
|
||||
"sourcesHint": "{count, plural, one {# fonte, con data e licenza} other {# fonti, ognuna con data e licenza}}"
|
||||
"codedFor": "codificato per {places}"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"searchLabel": "Cerca un indirizzo, un luogo o un numero postale",
|
||||
@@ -817,8 +809,7 @@
|
||||
"level": "{level} ({count})"
|
||||
},
|
||||
"record": {
|
||||
"title": "Nomi, identificativi e fonti",
|
||||
"hint": "{count, plural, one {# fonte} other {# fonti}}, altri nomi, identificativi ufficiali"
|
||||
"title": "Nomi, identificativi e fonti"
|
||||
},
|
||||
"taxMap": {
|
||||
"title": "L'imposta per luogo",
|
||||
@@ -923,8 +914,7 @@
|
||||
"title": "Cosa è cambiato di recente",
|
||||
"intro": "{count, plural, one {# atto} other {# atti}} di {place} e dei luoghi di cui fa parte sono entrati in vigore negli ultimi dodici mesi. I più recenti:",
|
||||
"new": "Nuovo, in vigore dal {date}",
|
||||
"amended": "Modificato, in vigore dal {date}",
|
||||
"more": "{count, plural, one {altre #} other {altre #}}"
|
||||
"amended": "Modificato, in vigore dal {date}"
|
||||
},
|
||||
"explore": {
|
||||
"title": "I comuni svizzeri in cifre",
|
||||
@@ -999,13 +989,6 @@
|
||||
"moreVotes": "{count} votazioni precedenti",
|
||||
"explore": "Confronta con ogni comune",
|
||||
"allVotes": "Tutte le votazioni federali"
|
||||
},
|
||||
"glance": {
|
||||
"label": "Questo luogo in cifre",
|
||||
"laws": "{count, plural, one {legge in vigore qui} other {leggi in vigore qui}}",
|
||||
"changed": "{count, plural, one {entrata in vigore negli ultimi 12 mesi} other {entrate in vigore negli ultimi 12 mesi}}",
|
||||
"routes": "{count, plural, one {via ufficiale per cambiarle} other {vie ufficiali per cambiarle}}",
|
||||
"places": "{count, plural, one {luogo al suo interno} other {luoghi al suo interno}}"
|
||||
}
|
||||
},
|
||||
"AuthError": {
|
||||
@@ -1066,11 +1049,7 @@
|
||||
"browseHint": "Cominci dal luogo in cui abita. Vi si applicano anche il diritto del suo cantone e quello della Confederazione.",
|
||||
"placeActs": "{count, plural, one {# atto} other {# atti}}",
|
||||
"communes": "{count, plural, one {# comune} other {# comuni}}",
|
||||
"didYouMean": "Intendeva:",
|
||||
"held": "{acts} atti da {places} luoghi, ciascuno consultabile a parole semplici.",
|
||||
"allPlaces": "{count, plural, one {# altro luogo} other {altri # luoghi}}",
|
||||
"regionsTitle": "Cantoni, stati e comuni",
|
||||
"regionsHint": "{count, plural, one {# luogo sotto un paese} other {# luoghi sotto un paese}}"
|
||||
"didYouMean": "Intendeva:"
|
||||
},
|
||||
"act": {
|
||||
"kicker": "Diritto",
|
||||
@@ -2454,8 +2433,7 @@
|
||||
"label": "Mostrare il denaro in",
|
||||
"converted": "Importi in {to}, convertiti da {from} al cambio medio del {year} ({sources}).",
|
||||
"notConverted": "Importi in {from}: Solon non detiene alcun cambio del {year} per convertirli in {to}."
|
||||
},
|
||||
"chartTitle": "Quanto ha speso ogni governo nell’ultimo anno, in {currency}"
|
||||
}
|
||||
},
|
||||
"MethodLab": {
|
||||
"tablist": "Come contare le stesse preferenze",
|
||||
|
||||
+14
-36
@@ -607,7 +607,7 @@
|
||||
"kicker": "Места рядом",
|
||||
"metaTitle": "Сравнить места · Места",
|
||||
"metaDescription": "До четырёх мест рядом: сколько налогов вы бы платили в каждом и официальные цифры, которые их определяют.",
|
||||
"intro": "До {limit} мест рядом. Каждая тема показывает, куда закон ставит каждое место на одной шкале; откройте её, чтобы увидеть статьи и, отдельно, как закон применяется.",
|
||||
"intro": "Сравните до {limit} мест: что говорит закон по каждой теме и, отдельно, как он применяется, а затем сколько стоил бы вам налог. У каждой строки есть источник.",
|
||||
"empty": "Пока нечего сравнивать. Начните с того места, где вы находитесь, или добавьте место выше.",
|
||||
"notFound": "{count, plural, one {# место из этой ссылки не учтено и пропущено.} few {# места из этой ссылки не учтены и пропущены.} many {# мест из этой ссылки не учтены и пропущены.} other {# места из этой ссылки не учтены и пропущены.}}",
|
||||
"yourSituation": "Ваша ситуация",
|
||||
@@ -667,23 +667,27 @@
|
||||
"full": "{limit} мест — максимум для одного сравнения. Уберите одно, чтобы добавить другое."
|
||||
},
|
||||
"law": {
|
||||
"title": "Что говорит закон",
|
||||
"intro": "Один вопрос на тему, ответ на записанной шкале. Чем левее, тем больше выбора остаётся вам. Это не оценка и не суждение о лучшем или худшем.",
|
||||
"title": "Что говорит закон и как он применяется",
|
||||
"intro": "Каждая тема — один вопрос к закону с ответом по письменной шкале, со статьями и их текстом. Применение закона показано отдельно: данных мало и они неточны, поэтому у каждого утверждения указано, кто его сделал, за какие годы и насколько ему можно доверять, и ни одно не сдвигает место на шкале.",
|
||||
"says": "Что говорит закон",
|
||||
"enforced": "Как он применяется",
|
||||
"enforcedIntro": "Что, по их словам, делают полиция и другие, отдельно от закона.",
|
||||
"freerEnd": "Оставляет вам больше всего",
|
||||
"lessFreeEnd": "Оставляет вам меньше всего",
|
||||
"freest": "Оставляет вам больше всего выбора: {place}.",
|
||||
"freest": "Больше всего оставляет вам: {place}. Решающее правило указано у каждого места.",
|
||||
"same": "Сравниваемые места стоят на одной точке этой шкалы.",
|
||||
"freerNote": "Свободнее здесь значит, что закон оставляет человеку больше выбора. Это порядок письменной шкалы выше, а не оценка: каждое место стоит там, куда его ставит собственный текст закона, и другая шкала могла бы упорядочить их иначе.",
|
||||
"via": "право: {place}",
|
||||
"about": "о месте {place}",
|
||||
"words": "Текст закона",
|
||||
"translation": "По-английски:",
|
||||
"open": "Остаётся открытым:",
|
||||
"atPublisher": "(у издателя)",
|
||||
"settled": "Закодировано: {by}; проверено вторым человеком.",
|
||||
"awaiting": "Закодировано: {by}; второй человек ещё не проверил.",
|
||||
"notCoded": "Ещё не закодировано: {places}.",
|
||||
"noEnforcement": "Сведений о применении пока не найдено.",
|
||||
"statedBy": "Источник: {by}, {period}",
|
||||
"period": "с {from} по {to}",
|
||||
"since": "с {from}",
|
||||
"read": "прочитано {on}",
|
||||
@@ -695,20 +699,8 @@
|
||||
},
|
||||
"noEnforcementAny": "Для этих мест сведений о применении пока не найдено.",
|
||||
"fewTitle": "Пока закодировано только для одного из этих мест",
|
||||
"notCodedShort": "ещё не закодировано",
|
||||
"whyTitle": "Почему: статьи и их текст",
|
||||
"whyHint": "{count, plural, one {Закон для # места и шкала} other {Закон для каждого из # мест и шкала}}",
|
||||
"scaleTitle": "Шкала",
|
||||
"enforcedHint": "{count, plural, one {# сообщение, отдельно от закона} few {# сообщения, отдельно от закона} many {# сообщений, отдельно от закона} other {# сообщения, отдельно от закона}}",
|
||||
"whySure": "{count, plural, one {Насколько надёжно, и источник} other {Насколько надёжно, и источники (#)}}",
|
||||
"trust": {
|
||||
"high": "Высокая надёжность",
|
||||
"medium": "Средняя надёжность",
|
||||
"low": "Низкая надёжность"
|
||||
}
|
||||
},
|
||||
"taxHint": "Введите доход, чтобы получить оценку для каждого места",
|
||||
"sourcesHint": "{count, plural, one {# источник, с датой и лицензией} few {# источника, каждый с датой и лицензией} many {# источников, каждый с датой и лицензией} other {# источника, каждый с датой и лицензией}}"
|
||||
"codedFor": "закодировано для: {places}"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"searchLabel": "Найти адрес, место или индекс",
|
||||
@@ -817,8 +809,7 @@
|
||||
"level": "{level} ({count})"
|
||||
},
|
||||
"record": {
|
||||
"title": "Названия, идентификаторы и источники",
|
||||
"hint": "{count, plural, one {# источник} few {# источника} many {# источников} other {# источника}}, другие названия, официальные идентификаторы"
|
||||
"title": "Названия, идентификаторы и источники"
|
||||
},
|
||||
"taxMap": {
|
||||
"title": "Налог по месту",
|
||||
@@ -923,8 +914,7 @@
|
||||
"title": "Что изменилось за последнее время",
|
||||
"intro": "За последние двенадцать месяцев в силу вступили {count, plural, one {# акт} few {# акта} many {# актов} other {# акта}} — здесь ({place}) и на вышестоящих уровнях. Самые новые:",
|
||||
"new": "Новый, в силе с {date}",
|
||||
"amended": "Изменён, в силе с {date}",
|
||||
"more": "{count, plural, one {ещё #} few {ещё #} many {ещё #} other {ещё #}}"
|
||||
"amended": "Изменён, в силе с {date}"
|
||||
},
|
||||
"explore": {
|
||||
"title": "Швейцарские общины в цифрах",
|
||||
@@ -999,13 +989,6 @@
|
||||
"moreVotes": "Ещё {count} голосований",
|
||||
"explore": "Сравнить со всеми коммунами",
|
||||
"allVotes": "Все федеральные голосования"
|
||||
},
|
||||
"glance": {
|
||||
"label": "Это место в цифрах",
|
||||
"laws": "{count, plural, one {закон действует здесь} few {закона действуют здесь} many {законов действуют здесь} other {закона действуют здесь}}",
|
||||
"changed": "{count, plural, one {вступил в силу за 12 месяцев} few {вступили в силу за 12 месяцев} many {вступили в силу за 12 месяцев} other {вступили в силу за 12 месяцев}}",
|
||||
"routes": "{count, plural, one {официальный способ их изменить} few {официальных способа их изменить} many {официальных способов их изменить} other {официального способа их изменить}}",
|
||||
"places": "{count, plural, one {место внутри} few {места внутри} many {мест внутри} other {места внутри}}"
|
||||
}
|
||||
},
|
||||
"AuthError": {
|
||||
@@ -1066,11 +1049,7 @@
|
||||
"browseHint": "Начните с места, где вы живёте. Там действуют также право вашего кантона и право Конфедерации.",
|
||||
"placeActs": "{count, plural, one {# акт} few {# акта} many {# актов} other {# акта}}",
|
||||
"communes": "{count, plural, one {# община} few {# общины} many {# общин} other {# общины}}",
|
||||
"didYouMean": "Возможно, вы имели в виду:",
|
||||
"held": "{acts} актов из {places} мест, по каждому можно искать простыми словами.",
|
||||
"allPlaces": "{count, plural, one {ещё # место} few {ещё # места} many {ещё # мест} other {ещё # места}}",
|
||||
"regionsTitle": "Кантоны, штаты и коммуны",
|
||||
"regionsHint": "{count, plural, one {# место внутри страны} few {# места внутри страны} many {# мест внутри страны} other {# места внутри страны}}"
|
||||
"didYouMean": "Возможно, вы имели в виду:"
|
||||
},
|
||||
"act": {
|
||||
"kicker": "Право",
|
||||
@@ -2454,8 +2433,7 @@
|
||||
"label": "Показывать деньги в",
|
||||
"converted": "Суммы в {to}, пересчитаны из {from} по среднему курсу {year} года ({sources}).",
|
||||
"notConverted": "Суммы в {from}: у Solon нет курса за {year} год, чтобы пересчитать их в {to}."
|
||||
},
|
||||
"chartTitle": "Сколько потратило каждое правительство за последний год, в {currency}"
|
||||
}
|
||||
},
|
||||
"MethodLab": {
|
||||
"tablist": "Как подсчитать одни и те же предпочтения",
|
||||
|
||||
@@ -84,17 +84,6 @@ body {
|
||||
@apply inline-flex items-center justify-center rounded-control border border-default bg-surface-base px-4 py-2 text-sm font-semibold text-fg-primary transition-colors hover:bg-surface-raised;
|
||||
}
|
||||
|
||||
/*
|
||||
* A place's mark on /compare: its number in the chart series colour
|
||||
* (chartkit `data-series`), the same on the scale, the list and the cards,
|
||||
* so a reader follows one place down the page by colour and by number.
|
||||
*/
|
||||
.place-mark {
|
||||
@apply inline-flex size-6 shrink-0 items-center justify-center rounded-pill text-xs font-bold tabular-nums;
|
||||
background: var(--ck-series, var(--ck-ink));
|
||||
color: var(--ck-bg);
|
||||
}
|
||||
|
||||
/* A text field. One definition, so every form on the site looks the same. */
|
||||
.field {
|
||||
@apply block w-full min-h-12 rounded-control border border-default bg-surface-raised px-4 text-base text-fg-primary placeholder:text-fg-tertiary focus:border-accent focus:outline-none;
|
||||
|
||||
@@ -5,12 +5,7 @@ import type { BudgetIndexRow } from "@/lib/budgets/page";
|
||||
import CurrencyPicker from "./currency-picker";
|
||||
import type { BudgetsTranslator } from "./translator";
|
||||
|
||||
/**
|
||||
* Every holder Solon holds a budget for, as one chart: what each spent in its
|
||||
* newest year as a bar in the reader’s currency, largest first, with where
|
||||
* most of the money went and whether it balanced under it. Each row opens the
|
||||
* budget.
|
||||
*/
|
||||
/** Every holder Solon holds a budget for: its newest year, the totals and where most of the money goes. */
|
||||
export default function BudgetIndex({
|
||||
rows,
|
||||
currency,
|
||||
@@ -23,12 +18,6 @@ export default function BudgetIndex({
|
||||
next: string;
|
||||
t: BudgetsTranslator;
|
||||
}) {
|
||||
// Largest first, so the page is a picture of who spends what; one in another measure after.
|
||||
const ranked = [...rows].sort(
|
||||
(a, b) => (b.spendingAmount ?? -1) - (a.spendingAmount ?? -1) || a.name.localeCompare(b.name),
|
||||
);
|
||||
const largest = Math.max(1, ...rows.map((r) => r.spendingAmount ?? 0));
|
||||
const scopes = new Set(rows.map((r) => r.scope)).size;
|
||||
return (
|
||||
<PageLayout title={t("indexTitle")} kicker={t("kicker")} description={t("indexIntro")}>
|
||||
<div className="mb-6">
|
||||
@@ -42,46 +31,33 @@ export default function BudgetIndex({
|
||||
{rows.length === 0 ? (
|
||||
<p className="text-fg-secondary">{t("indexEmpty")}</p>
|
||||
) : (
|
||||
<section aria-labelledby="budgets-chart" className="max-w-4xl space-y-3">
|
||||
<h2 id="budgets-chart" className="headline text-2xl text-fg-primary">
|
||||
{t("chartTitle", { currency })}
|
||||
</h2>
|
||||
<ol className="divide-y divide-default overflow-hidden rounded-surface border border-default bg-surface-base">
|
||||
{ranked.map((row) => (
|
||||
<li key={`${row.slug}-${row.scope}`}>
|
||||
<Link
|
||||
href={`/budgets/${row.slug}`}
|
||||
className="block min-h-11 space-y-1.5 px-4 py-3 hover:bg-surface-raised sm:px-6"
|
||||
>
|
||||
<span className="flex items-baseline justify-between gap-4">
|
||||
<span className="min-w-0 truncate font-medium text-fg-primary">{row.name}</span>
|
||||
<span className="shrink-0 text-sm font-semibold tabular-nums text-fg-primary">
|
||||
{row.spending ?? "—"}
|
||||
</span>
|
||||
<ul className="max-w-4xl divide-y divide-default overflow-hidden rounded-surface border border-default bg-surface-base">
|
||||
{rows.map((row) => (
|
||||
<li key={`${row.slug}-${row.scope}`}>
|
||||
<Link
|
||||
href={`/budgets/${row.slug}`}
|
||||
className="flex min-h-11 flex-col gap-1 px-5 py-3 hover:bg-surface-raised sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:px-6"
|
||||
>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-medium text-fg-primary">{row.name}</span>
|
||||
<span className="block text-sm text-fg-tertiary">
|
||||
{row.scope} · {row.year}
|
||||
{row.largest ? ` · ${t("columns.largest")}: ${row.largest}` : ""}
|
||||
</span>
|
||||
{row.spendingAmount !== null && (
|
||||
<span aria-hidden className="block h-2 rounded-pill bg-surface-overlay">
|
||||
<span
|
||||
className="block h-2 rounded-pill bg-accent"
|
||||
style={{ width: `${Math.max(1, (row.spendingAmount / largest) * 100)}%` }}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
<span className="block text-xs text-fg-tertiary">
|
||||
{[
|
||||
scopes > 1 ? row.scope : null,
|
||||
row.year,
|
||||
row.largest && `${t("columns.largest")}: ${row.largest}`,
|
||||
row.balance && `${t("columns.balance")} ${row.balance}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
</span>
|
||||
<span className="shrink-0 text-sm text-fg-secondary">
|
||||
{[
|
||||
row.spending && `${t("columns.spending")} ${row.spending}`,
|
||||
row.balance && `${t("columns.balance")} ${row.balance}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}{" "}
|
||||
→
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</PageLayout>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,6 @@ import { getLocale } from "next-intl/server";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { translatedTitles } from "@/lib/law/translate";
|
||||
import ActRow from "./act-row";
|
||||
import LawPlaces from "./law-places";
|
||||
import type { LawTranslator } from "./coverage-report";
|
||||
import Excerpt from "./excerpt";
|
||||
import { authorityName, readerAuthorityNames } from "@/lib/law/authority-names";
|
||||
@@ -30,6 +29,21 @@ interface LawIndexProps {
|
||||
|
||||
const listClass = "divide-y divide-default rounded-surface border border-default bg-surface-base";
|
||||
|
||||
async function PlaceLink({ node, t }: { node: PlaceNode; t: LawTranslator }) {
|
||||
const names = await readerAuthorityNames();
|
||||
return (
|
||||
<Link
|
||||
href={`/law/place/${node.key}`}
|
||||
className="flex min-h-11 items-center justify-between gap-4 px-5 py-2 hover:bg-surface-raised"
|
||||
>
|
||||
<span className="font-medium text-fg-primary">{authorityName(names, node.key)}</span>
|
||||
<span className="shrink-0 text-sm tabular-nums text-fg-tertiary">
|
||||
{t("index.placeActs", { count: node.inForce + node.statusNotStated })}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finding the law. One search box over titles and over the text of every act,
|
||||
* and below it the places, so someone who does not know a word of the law can
|
||||
@@ -87,16 +101,18 @@ export default async function LawIndex({
|
||||
</form>
|
||||
|
||||
{!searched && (
|
||||
<p className="flex flex-wrap items-center gap-2 text-sm text-fg-secondary">
|
||||
{t("index.examplesTitle")}
|
||||
{(["one", "two", "three"] as const).map((key) => (
|
||||
<Link
|
||||
key={key}
|
||||
href={`/law?q=${encodeURIComponent(t(`index.examples.${key}`))}`}
|
||||
className="inline-flex min-h-11 items-center rounded-pill border border-default bg-surface-base px-4 text-fg-primary hover:bg-surface-raised"
|
||||
>
|
||||
{t(`index.examples.${key}`)}
|
||||
</Link>
|
||||
<p className="text-sm text-fg-secondary">
|
||||
{t("index.examplesTitle")}{" "}
|
||||
{(["one", "two", "three"] as const).map((key, i) => (
|
||||
<span key={key}>
|
||||
{i > 0 && " · "}
|
||||
<Link
|
||||
href={`/law?q=${encodeURIComponent(t(`index.examples.${key}`))}`}
|
||||
className="underline"
|
||||
>
|
||||
{t(`index.examples.${key}`)}
|
||||
</Link>
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
@@ -165,16 +181,58 @@ export default async function LawIndex({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<LawPlaces places={places} t={t} />
|
||||
<section className="space-y-4" aria-labelledby="law-browse">
|
||||
<div className="space-y-1">
|
||||
<h2 id="law-browse" className="font-semibold text-fg-primary">
|
||||
{t("index.browseTitle")}
|
||||
</h2>
|
||||
<p className="text-sm text-fg-secondary">{t("index.browseHint")}</p>
|
||||
</div>
|
||||
{places.map((country) => (
|
||||
<div key={country.key} className="space-y-3">
|
||||
<ul className={listClass}>
|
||||
<li>
|
||||
<PlaceLink node={country} t={t} />
|
||||
</li>
|
||||
{country.children.map((region) => (
|
||||
<li key={region.key}>
|
||||
{region.children.length === 0 ? (
|
||||
<PlaceLink node={region} t={t} />
|
||||
) : (
|
||||
<details>
|
||||
<summary className="flex min-h-11 cursor-pointer items-center justify-between gap-4 px-5 py-2 hover:bg-surface-raised">
|
||||
<span className="font-medium text-fg-primary">{region.name}</span>
|
||||
<span className="shrink-0 text-sm text-fg-tertiary">
|
||||
{t("index.communes", { count: region.children.length })}
|
||||
</span>
|
||||
</summary>
|
||||
<ul className="divide-y divide-default border-t border-default">
|
||||
<li>
|
||||
<PlaceLink node={region} t={t} />
|
||||
</li>
|
||||
{region.children.map((commune) => (
|
||||
<li key={commune.key} className="pl-4">
|
||||
<PlaceLink node={commune} t={t} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
||||
<Link href="/law/ask" className="btn-secondary min-h-11">
|
||||
<p className="space-x-4 text-sm">
|
||||
<Link href="/law/ask" className="font-medium text-fg-primary underline">
|
||||
{t("index.askLink")}
|
||||
</Link>
|
||||
<Link href="/law/coverage" className="text-fg-secondary underline">
|
||||
{t("index.coverageLink")}
|
||||
</Link>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
import { Meter } from "@bitbaum/chartkit/react";
|
||||
import { getLocale } from "next-intl/server";
|
||||
import { Link } from "@/i18n/navigation";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import type { PlaceNode } from "@/lib/law/places";
|
||||
import { authorityName, readerAuthorityNames } from "@/lib/law/authority-names";
|
||||
import type { LawTranslator } from "./coverage-report";
|
||||
|
||||
/** Tiles shown before the rest fold: enough for the places most readers live in. */
|
||||
const SHOWN = 8;
|
||||
/** A place with fewer acts is a start, not yet a body of law: it waits in the folded list. */
|
||||
const DEEP = 10;
|
||||
|
||||
const actsOf = (node: PlaceNode) => node.inForce + node.statusNotStated;
|
||||
const everyNode = (nodes: readonly PlaceNode[]): PlaceNode[] =>
|
||||
nodes.flatMap((n) => [n, ...everyNode(n.children)]);
|
||||
|
||||
/**
|
||||
* Where the law Solon holds comes from, as a picture: the places with the
|
||||
* most law first, each a tile with its count and a bar against the largest,
|
||||
* so a reader sees at once what is deep and what is thin. The rest fold, and
|
||||
* the cantons, states and communes under a country are one row more.
|
||||
*/
|
||||
export default async function LawPlaces({
|
||||
places,
|
||||
t,
|
||||
}: {
|
||||
places: readonly PlaceNode[];
|
||||
t: LawTranslator;
|
||||
}) {
|
||||
if (places.length === 0) return null;
|
||||
const names = await readerAuthorityNames();
|
||||
const number = new Intl.NumberFormat(await getLocale());
|
||||
const ranked = [...places].sort((a, b) => actsOf(b) - actsOf(a));
|
||||
const largest = Math.max(1, actsOf(ranked[0]!));
|
||||
const nodes = everyNode(places);
|
||||
const total = nodes.reduce((sum, n) => sum + actsOf(n), 0);
|
||||
const shown = ranked.filter((n, i) => i === 0 || (i < SHOWN && actsOf(n) >= DEEP));
|
||||
const rest = ranked.slice(shown.length);
|
||||
const withParts = ranked.filter((c) => c.children.length > 0);
|
||||
const below = nodes.length - places.length;
|
||||
|
||||
const tile = (node: PlaceNode) => (
|
||||
<li key={node.key} className="min-w-0">
|
||||
<Link
|
||||
href={`/law/place/${node.key}`}
|
||||
className="flex h-full min-h-11 flex-col gap-2 rounded-surface border border-default bg-surface-base px-4 py-3 transition-colors hover:bg-surface-raised"
|
||||
>
|
||||
<span className="truncate font-medium text-fg-primary">
|
||||
{authorityName(names, node.key) || node.name}
|
||||
</span>
|
||||
<span className="text-xl font-bold tabular-nums leading-none text-fg-primary">
|
||||
{number.format(actsOf(node))}
|
||||
</span>
|
||||
<Meter
|
||||
value={actsOf(node)}
|
||||
max={largest}
|
||||
label={t("index.placeActs", { count: actsOf(node) })}
|
||||
tone="neutral"
|
||||
showValue={false}
|
||||
/>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
const grid = (list: readonly PlaceNode[]) => (
|
||||
<ul className="grid grid-cols-2 gap-2 sm:grid-cols-4">{list.map(tile)}</ul>
|
||||
);
|
||||
|
||||
return (
|
||||
<section className="space-y-4" aria-labelledby="law-browse">
|
||||
<div className="space-y-1">
|
||||
<h2 id="law-browse" className="headline text-2xl text-fg-primary">
|
||||
{t("index.browseTitle")}
|
||||
</h2>
|
||||
<p className="text-sm text-fg-secondary">
|
||||
{t("index.held", { acts: number.format(total), places: number.format(nodes.length) })}
|
||||
</p>
|
||||
</div>
|
||||
{grid(shown)}
|
||||
{rest.length > 0 && (
|
||||
<Disclosure
|
||||
title={t("index.allPlaces", { count: rest.length })}
|
||||
hint={rest
|
||||
.slice(0, 6)
|
||||
.map((n) => authorityName(names, n.key) || n.name)
|
||||
.join(" · ")}
|
||||
>
|
||||
{grid(rest)}
|
||||
</Disclosure>
|
||||
)}
|
||||
{withParts.length > 0 && (
|
||||
<Disclosure title={t("index.regionsTitle")} hint={t("index.regionsHint", { count: below })}>
|
||||
{withParts.map((country) => (
|
||||
<div key={country.key} className="space-y-2">
|
||||
<h3 className="text-sm font-semibold text-fg-secondary">
|
||||
{authorityName(names, country.key) || country.name}
|
||||
</h3>
|
||||
<ul className="divide-y divide-default rounded-surface border border-default">
|
||||
{country.children.map((region) => (
|
||||
<li key={region.key}>
|
||||
{region.children.length === 0 ? (
|
||||
<RegionLink node={region} label={authorityName(names, region.key)} t={t} />
|
||||
) : (
|
||||
<details className="group">
|
||||
<summary className="flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 px-4 py-2 hover:bg-surface-raised [&::-webkit-details-marker]:hidden">
|
||||
<span className="font-medium text-fg-primary">
|
||||
{authorityName(names, region.key) || region.name}
|
||||
</span>
|
||||
<span className="shrink-0 text-sm text-fg-tertiary">
|
||||
{t("index.communes", { count: region.children.length })}
|
||||
</span>
|
||||
</summary>
|
||||
<ul className="divide-y divide-default border-t border-default">
|
||||
<li>
|
||||
<RegionLink
|
||||
node={region}
|
||||
label={authorityName(names, region.key)}
|
||||
t={t}
|
||||
/>
|
||||
</li>
|
||||
{region.children.map((commune) => (
|
||||
<li key={commune.key} className="pl-4">
|
||||
<RegionLink
|
||||
node={commune}
|
||||
label={authorityName(names, commune.key)}
|
||||
t={t}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</Disclosure>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function RegionLink({ node, label, t }: { node: PlaceNode; label: string; t: LawTranslator }) {
|
||||
return (
|
||||
<Link
|
||||
href={`/law/place/${node.key}`}
|
||||
className="flex min-h-11 items-center justify-between gap-4 px-4 py-2 hover:bg-surface-raised"
|
||||
>
|
||||
<span className="min-w-0 text-fg-primary">{label || node.name}</span>
|
||||
<span className="shrink-0 text-sm tabular-nums text-fg-tertiary">
|
||||
{t("index.placeActs", { count: actsOf(node) })}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import PageLayout from "@/components/ui/page-layout";
|
||||
import type { LawTopic } from "@/lib/places/compare-law";
|
||||
import type { Comparison } from "@/lib/places/compare-view";
|
||||
@@ -21,8 +20,8 @@ interface CompareIndexProps {
|
||||
/**
|
||||
* /compare (design §9.2): the places at the top, changed where they are shown
|
||||
* (remove, another level, add from here, nearby, before, suggestions or a
|
||||
* search), then each topic answered on its drawn scale with the why and the
|
||||
* enforcement folded under it, then what tax would cost, folded. Which places are compared lives in the link, so a comparison can be
|
||||
* search), then what the law says and how it is enforced, then what tax would
|
||||
* cost. Which places are compared lives in the link, so a comparison can be
|
||||
* shared; what the reader types for the estimate never does.
|
||||
*/
|
||||
export default function CompareIndex({
|
||||
@@ -36,8 +35,8 @@ export default function CompareIndex({
|
||||
const compared = comparison.columns;
|
||||
return (
|
||||
<PageLayout title={t("compare.title")} kicker={t("compare.kicker")}>
|
||||
<div className="max-w-3xl space-y-8">
|
||||
<p className="mb-0 text-fg-secondary">{t("compare.intro", { limit })}</p>
|
||||
<div className="max-w-5xl space-y-10">
|
||||
<p className="mb-0 max-w-3xl text-fg-secondary">{t("compare.intro", { limit })}</p>
|
||||
|
||||
<ComparePicker
|
||||
places={compared.map((c) => ({
|
||||
@@ -60,9 +59,12 @@ export default function CompareIndex({
|
||||
{compared.length > 0 ? (
|
||||
<>
|
||||
<LawComparison topics={topics} t={t} />
|
||||
<Disclosure title={t("compare.taxTitle")} hint={t("compare.taxHint")}>
|
||||
<section className="space-y-4">
|
||||
<h2 className="mb-0 text-xl font-semibold text-fg-primary">
|
||||
{t("compare.taxTitle")}
|
||||
</h2>
|
||||
<PlaceComparison comparison={comparison} />
|
||||
</Disclosure>
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
<p className="rounded-surface border border-default bg-surface-base p-6 text-fg-secondary">
|
||||
@@ -70,14 +72,7 @@ export default function CompareIndex({
|
||||
</p>
|
||||
)}
|
||||
|
||||
{comparison.sources.length > 0 && (
|
||||
<Disclosure
|
||||
title={t("sources.title")}
|
||||
hint={t("compare.sourcesHint", { count: comparison.sources.length })}
|
||||
>
|
||||
<SourceList sources={comparison.sources} t={t} heading={false} />
|
||||
</Disclosure>
|
||||
)}
|
||||
<SourceList sources={comparison.sources} t={t} />
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
|
||||
@@ -13,7 +13,6 @@ import { useLocale, useTranslations } from "next-intl";
|
||||
import { useRouter } from "@/i18n/navigation";
|
||||
import { compareHref } from "@/lib/places/compare-view";
|
||||
import { locationAllowed, placeHere, readPosition } from "./locate-here";
|
||||
import PlaceMark from "./place-mark";
|
||||
|
||||
export interface PickerPlace {
|
||||
slugPath: string;
|
||||
@@ -46,7 +45,6 @@ interface Hit {
|
||||
const RECENT_KEY = "solon.compare.recent";
|
||||
const RECENT_KEPT = 8;
|
||||
const DEBOUNCE_MS = 200;
|
||||
const CHOICES_SHOWN = 6;
|
||||
|
||||
/** What was compared before, as stored on this device; the server has none. */
|
||||
const recentStore = {
|
||||
@@ -77,7 +75,7 @@ function parseRecent(stored: string): Suggestion[] {
|
||||
}
|
||||
}
|
||||
|
||||
/** A short labelled set of places to add, wrapping onto a second line rather than scrolling sideways. */
|
||||
/** One row of choices that scrolls sideways rather than wrapping (fleet: one shape per kind). */
|
||||
function ChoiceRow({
|
||||
label,
|
||||
items,
|
||||
@@ -91,20 +89,17 @@ function ChoiceRow({
|
||||
}) {
|
||||
if (items.length === 0) return null;
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-1">
|
||||
<p className="mb-0 text-xs font-semibold uppercase tracking-caps text-fg-tertiary">{label}</p>
|
||||
<ul className="mb-0 flex flex-wrap gap-2">
|
||||
{items.slice(0, CHOICES_SHOWN).map((s) => (
|
||||
<li key={s.slugPath}>
|
||||
<ul className="-mx-1 flex gap-2 overflow-x-auto px-1 pb-1">
|
||||
{items.map((s) => (
|
||||
<li key={s.slugPath} className="shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onPick(s)}
|
||||
aria-label={addLabel(s.name)}
|
||||
className="inline-flex min-h-11 items-center gap-1 rounded-pill border border-default bg-surface-base px-4 text-sm font-medium text-fg-primary hover:bg-surface-raised"
|
||||
className="btn-secondary min-h-11 whitespace-nowrap"
|
||||
>
|
||||
<span aria-hidden className="text-fg-tertiary">
|
||||
+
|
||||
</span>
|
||||
{s.name}
|
||||
</button>
|
||||
</li>
|
||||
@@ -115,12 +110,11 @@ function ChoiceRow({
|
||||
}
|
||||
|
||||
/**
|
||||
* A place's level as a small native menu: the country down to the place
|
||||
* itself. The phone's own picker opens on a tap, so there is no row to scroll
|
||||
* sideways, and every entry says its level (Zürich the canton, Zürich the
|
||||
* commune).
|
||||
* A place's levels in one row, the country first and the place itself chosen:
|
||||
* one tap compares at another level. The chosen one is scrolled into view, and
|
||||
* a name the row holds twice (Zürich the canton, Zürich the commune) says its level.
|
||||
*/
|
||||
function LevelMenu({
|
||||
function LevelRow({
|
||||
place,
|
||||
label,
|
||||
onPick,
|
||||
@@ -129,26 +123,45 @@ function LevelMenu({
|
||||
label: string;
|
||||
onPick: (slugPath: string) => void;
|
||||
}) {
|
||||
const row = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
const chosen = row.current?.querySelector<HTMLElement>("[aria-pressed='true']");
|
||||
if (row.current && chosen) {
|
||||
row.current.scrollLeft = chosen.offsetLeft + chosen.offsetWidth - row.current.clientWidth + 8;
|
||||
}
|
||||
}, [place.slugPath]);
|
||||
const twice = (name: string) => place.chain.filter((l) => l.name === name).length > 1;
|
||||
return (
|
||||
<label className="relative inline-flex min-h-11 max-w-full items-center">
|
||||
<span className="sr-only">{label}</span>
|
||||
<select
|
||||
value={place.slugPath}
|
||||
onChange={(e) => onPick(e.target.value)}
|
||||
className="min-h-9 max-w-full cursor-pointer appearance-none truncate rounded-pill border border-default bg-surface-base py-1 pl-3 pr-8 text-sm text-fg-secondary hover:bg-surface-raised"
|
||||
>
|
||||
{place.chain.map((level) => (
|
||||
<option key={level.slugPath} value={level.slugPath}>
|
||||
{level.slugPath === place.slugPath
|
||||
? level.levelName
|
||||
: `${level.levelName}: ${level.name}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<span aria-hidden className="pointer-events-none absolute right-3 text-xs text-fg-tertiary">
|
||||
▾
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
ref={row}
|
||||
role="group"
|
||||
aria-label={label}
|
||||
className="flex overflow-x-auto rounded-control border border-default p-1"
|
||||
>
|
||||
{place.chain.map((level) => {
|
||||
const current = level.slugPath === place.slugPath;
|
||||
return (
|
||||
<button
|
||||
key={level.slugPath}
|
||||
type="button"
|
||||
aria-pressed={current}
|
||||
title={level.levelName}
|
||||
onClick={() => !current && onPick(level.slugPath)}
|
||||
className={`min-h-11 shrink-0 whitespace-nowrap rounded-control px-3 text-sm font-semibold ${
|
||||
current ? "bg-accent text-on-accent" : "text-fg-primary hover:bg-surface-raised"
|
||||
}`}
|
||||
>
|
||||
{level.name}
|
||||
{twice(level.name) && (
|
||||
<span className={current ? "font-normal" : "font-normal text-fg-tertiary"}>
|
||||
{" "}
|
||||
({level.levelName})
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -255,33 +268,45 @@ export default function ComparePicker({ places, limit, guessed, suggestions }: C
|
||||
|
||||
return (
|
||||
<section aria-label={t("label")} className="space-y-3">
|
||||
<ul className="mb-0 grid gap-2 sm:grid-cols-2">
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{places.map((place, i) => (
|
||||
<li
|
||||
key={place.slugPath}
|
||||
className="flex min-w-0 items-center gap-3 rounded-surface border border-default bg-surface-base py-1 pl-3 pr-1"
|
||||
className="min-w-0 space-y-2 rounded-surface border border-default bg-surface-base p-3"
|
||||
>
|
||||
<PlaceMark index={i} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="mb-0 truncate font-semibold text-fg-primary">{place.name}</p>
|
||||
{place.chain.length > 1 ? (
|
||||
<LevelMenu
|
||||
place={place}
|
||||
label={t("levels", { place: place.name })}
|
||||
onPick={(slugPath) => go(paths.map((p, j) => (j === i ? slugPath : p)))}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<div className="min-w-0">
|
||||
<p className="mb-0 truncate font-semibold text-fg-primary">{place.name}</p>
|
||||
<p className="mb-0 text-sm text-fg-tertiary">{place.levelName}</p>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => go(paths.filter((p) => p !== place.slugPath))}
|
||||
aria-label={t("remove", { place: place.name })}
|
||||
className="-mr-1 -mt-1 inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center rounded-control text-fg-secondary hover:bg-surface-raised"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => go(paths.filter((p) => p !== place.slugPath))}
|
||||
aria-label={t("remove", { place: place.name })}
|
||||
className="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center rounded-control text-lg text-fg-tertiary hover:bg-surface-raised hover:text-fg-primary"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
{place.chain.length > 1 && (
|
||||
<LevelRow
|
||||
place={place}
|
||||
label={t("levels", { place: place.name })}
|
||||
onPick={(slugPath) => go(paths.map((p, j) => (j === i ? slugPath : p)))}
|
||||
/>
|
||||
)}
|
||||
{i === 0 && guessed && (
|
||||
<p className="mb-0 text-sm text-fg-secondary">
|
||||
{t("guessed")}{" "}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void locate(false)}
|
||||
className="min-h-11 font-semibold text-fg-primary underline"
|
||||
>
|
||||
{t("useLocation")}
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
{!full && (
|
||||
@@ -291,28 +316,15 @@ export default function ComparePicker({ places, limit, guessed, suggestions }: C
|
||||
onClick={() => setAdding((a) => !a)}
|
||||
aria-expanded={adding}
|
||||
aria-controls={searchId}
|
||||
className="flex h-full min-h-14 w-full items-center justify-center gap-2 rounded-surface border border-dashed border-default px-3 font-semibold text-fg-primary hover:bg-surface-raised"
|
||||
className="flex h-full min-h-16 w-full items-center justify-center gap-2 rounded-surface border border-dashed border-default p-3 font-semibold text-fg-primary hover:bg-surface-raised"
|
||||
>
|
||||
<span aria-hidden="true">{adding ? "−" : "+"}</span>
|
||||
<span aria-hidden="true">+</span>
|
||||
{places.length === 0 ? t("addFirst") : t("add")}
|
||||
</button>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
{guessed && places.length > 0 && (
|
||||
<p className="mb-0 text-sm text-fg-secondary">
|
||||
{t("guessed")}{" "}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void locate(false)}
|
||||
className="min-h-11 font-semibold text-fg-primary underline underline-offset-4"
|
||||
>
|
||||
{locating === "busy" ? t("locating") : t("useLocation")}
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{full && <p className="mb-0 text-sm text-fg-secondary">{t("full", { limit })}</p>}
|
||||
|
||||
{adding && !full && (
|
||||
|
||||
@@ -1,56 +1,21 @@
|
||||
import { Link } from "@/i18n/navigation";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import type { LawCell, LawLink, LawTopic } from "@/lib/places/compare-law";
|
||||
import PlaceMark from "./place-mark";
|
||||
import type { PlacesTranslator } from "./translator";
|
||||
|
||||
type CodedCell = LawCell & { coding: NonNullable<LawCell["coding"]> };
|
||||
|
||||
/** The scale's points from the end that leaves the most to the person; written order when the rubric names no free end. */
|
||||
const fromFreer = (topic: LawTopic) =>
|
||||
topic.freer === "higher" ? [...topic.scale].reverse() : topic.scale;
|
||||
|
||||
/** A span of whole years reads as years ("2019–2025"); anything else keeps its days. */
|
||||
export function period(from: string, to: string | null, t: PlacesTranslator): string {
|
||||
const year = (d: string) => d.slice(0, 4);
|
||||
if (!to) return t("compare.law.since", { from: from.endsWith("-01-01") ? year(from) : from });
|
||||
if (from.endsWith("-01-01") && to.endsWith("-12-31"))
|
||||
return year(from) === year(to) ? year(from) : `${year(from)}–${year(to)}`;
|
||||
return t("compare.law.period", { from, to });
|
||||
}
|
||||
|
||||
// Static class names, so Tailwind sees each one.
|
||||
const COLUMNS: Record<number, string> = {
|
||||
2: "grid-cols-2",
|
||||
3: "grid-cols-3",
|
||||
4: "grid-cols-4",
|
||||
5: "grid-cols-5",
|
||||
6: "grid-cols-6",
|
||||
};
|
||||
|
||||
function ArticleLinks({ links, t }: { links: LawLink[]; t: PlacesTranslator }) {
|
||||
if (links.length === 0) return null;
|
||||
return (
|
||||
<ul className="mb-0 flex flex-wrap gap-x-4 text-sm">
|
||||
<ul className="mb-0 flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
||||
{links.map((l) => (
|
||||
<li key={l.label}>
|
||||
{l.inSolon ? (
|
||||
<Link
|
||||
href={l.href}
|
||||
prefetch={false}
|
||||
className="inline-flex min-h-11 items-center font-medium underline underline-offset-4"
|
||||
>
|
||||
<Link href={l.href} prefetch={false} className="font-medium underline">
|
||||
{l.label}
|
||||
</Link>
|
||||
) : (
|
||||
<a
|
||||
href={l.href}
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex min-h-11 items-center font-medium underline underline-offset-4"
|
||||
>
|
||||
<a href={l.href} rel="noopener noreferrer" className="font-medium underline">
|
||||
{l.label}
|
||||
<span className="text-fg-tertiary"> ↗</span>
|
||||
<span className="sr-only"> {t("compare.law.atPublisher")}</span>
|
||||
<span className="text-fg-tertiary"> {t("compare.law.atPublisher")}</span>
|
||||
</a>
|
||||
)}
|
||||
</li>
|
||||
@@ -59,292 +24,214 @@ function ArticleLinks({ links, t }: { links: LawLink[]; t: PlacesTranslator }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The answer, drawn: the scale as a row of steps from the freer end, each
|
||||
* place's mark on the step its law puts it, and under it one line per place
|
||||
* that says the step in words. Read in two seconds; the why is folded below.
|
||||
*/
|
||||
function Scale({ topic, t }: { topic: LawTopic; t: PlacesTranslator }) {
|
||||
const points = fromFreer(topic);
|
||||
const indexed = topic.cells.map((cell, index) => ({ cell, index }));
|
||||
return (
|
||||
<figure className="mb-0 space-y-3">
|
||||
<div
|
||||
role="img"
|
||||
aria-label={indexed
|
||||
.filter(({ cell }) => cell.coding)
|
||||
.map(({ cell }) => `${cell.name}: ${cell.coding!.point}`)
|
||||
.join("; ")}
|
||||
className="space-y-1"
|
||||
>
|
||||
<ol className={`mb-0 grid gap-1 ${COLUMNS[points.length] ?? "grid-flow-col auto-cols-fr"}`}>
|
||||
{points.map((point) => {
|
||||
const here = indexed.filter(({ cell }) => cell.coding?.value === point.value);
|
||||
return (
|
||||
<li key={point.value} className="flex flex-col items-stretch gap-1.5">
|
||||
<span className="flex min-h-6 flex-wrap items-end justify-center gap-1">
|
||||
{here.map(({ cell, index }) => (
|
||||
<PlaceMark key={cell.slugPath} index={index} />
|
||||
))}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden
|
||||
className={`block h-2 rounded-pill ${
|
||||
here.length > 0 ? "bg-accent" : "bg-surface-overlay"
|
||||
}`}
|
||||
/>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
{topic.freer && (
|
||||
<p aria-hidden className="mb-0 flex justify-between gap-4 text-xs text-fg-tertiary">
|
||||
<span>{t("compare.law.freerEnd")}</span>
|
||||
<span className="text-right">{t("compare.law.lessFreeEnd")}</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<figcaption>
|
||||
<ul className="mb-0 space-y-2">
|
||||
{indexed.map(({ cell, index }) => (
|
||||
<li key={cell.slugPath} className="flex items-start gap-3">
|
||||
<PlaceMark index={index} />
|
||||
<p className="mb-0 min-w-0 text-sm">
|
||||
<span className="font-semibold text-fg-primary">{cell.name}</span>
|
||||
<span className="text-fg-tertiary"> — </span>
|
||||
<span className={cell.coding ? "text-fg-primary" : "text-fg-tertiary"}>
|
||||
{cell.coding ? cell.coding.point : t("compare.law.notCodedShort")}
|
||||
</span>
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</figcaption>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
const period = (from: string, to: string | null, t: PlacesTranslator) =>
|
||||
to ? t("compare.law.period", { from, to }) : t("compare.law.since", { from });
|
||||
|
||||
/** Why a place stands where it does: the reading, the articles, the words, who coded it. */
|
||||
function Why({ cell, index, t }: { cell: CodedCell; index: number; t: PlacesTranslator }) {
|
||||
/** A place's answer on the scale: the point, what put it there, the articles and their words. */
|
||||
function Coded({
|
||||
cell,
|
||||
t,
|
||||
}: {
|
||||
cell: LawCell & { coding: NonNullable<LawCell["coding"]> };
|
||||
t: PlacesTranslator;
|
||||
}) {
|
||||
const c = cell.coding;
|
||||
return (
|
||||
<li className="min-w-0 space-y-2">
|
||||
<p className="mb-0 flex items-center gap-2 font-semibold text-fg-primary">
|
||||
<PlaceMark index={index} />
|
||||
<span className="min-w-0">
|
||||
{cell.name}
|
||||
{c.via && (
|
||||
<span className="font-normal text-fg-tertiary">
|
||||
{" "}
|
||||
· {t("compare.law.via", { place: c.via })}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<li className="min-w-0 space-y-2 rounded-surface border border-default bg-surface-base p-4">
|
||||
<p className="mb-0 font-semibold text-fg-primary">
|
||||
{cell.name}
|
||||
{c.via && (
|
||||
<span className="font-normal text-fg-tertiary">
|
||||
{" "}
|
||||
· {t("compare.law.via", { place: c.via })}
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
<p className="mb-0 text-fg-secondary">{c.reading}</p>
|
||||
<p className="mb-0 text-sm text-fg-secondary">{c.reading}</p>
|
||||
<ArticleLinks links={c.provisions} t={t} />
|
||||
{c.quotes.length > 0 && (
|
||||
<details className="group">
|
||||
<summary className="inline-flex min-h-11 cursor-pointer list-none items-center gap-2 font-medium text-fg-primary [&::-webkit-details-marker]:hidden">
|
||||
<span
|
||||
aria-hidden
|
||||
className="text-fg-tertiary transition-transform group-open:rotate-90 motion-reduce:transition-none"
|
||||
>
|
||||
›
|
||||
</span>
|
||||
{t("compare.law.words")}
|
||||
</summary>
|
||||
<div className="space-y-3 pb-2">
|
||||
{c.quotes.map((q) => (
|
||||
<figure key={q.text.slice(0, 48)} className="mb-0 space-y-1">
|
||||
<blockquote
|
||||
lang={q.lang}
|
||||
className="mb-0 whitespace-pre-line border-l-2 border-default pl-3 text-fg-primary"
|
||||
>
|
||||
{q.text}
|
||||
</blockquote>
|
||||
{q.translation && (
|
||||
<p className="mb-0 pl-3 text-xs text-fg-secondary">{q.translation}</p>
|
||||
)}
|
||||
</figure>
|
||||
))}
|
||||
{c.open && (
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
<span className="font-semibold text-fg-primary">{t("compare.law.open")}</span>{" "}
|
||||
{c.open}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
<p className="mb-0 text-xs text-fg-tertiary">
|
||||
{t(`compare.law.confidence.${c.confidence}`)}{" "}
|
||||
{c.settled
|
||||
? t("compare.law.settled", { by: c.codedBy })
|
||||
: t("compare.law.awaiting", { by: c.codedBy })}
|
||||
</p>
|
||||
<details className="text-sm">
|
||||
<summary className="min-h-11 cursor-pointer py-2 font-medium text-fg-primary">
|
||||
{t("compare.law.words")}
|
||||
</summary>
|
||||
<div className="space-y-3 pt-1">
|
||||
{c.quotes.map((q) => (
|
||||
<figure key={q.text.slice(0, 48)} className="mb-0 space-y-1">
|
||||
<blockquote
|
||||
lang={q.lang}
|
||||
className="mb-0 whitespace-pre-line border-l-2 border-default pl-3 text-fg-primary"
|
||||
>
|
||||
{q.text}
|
||||
</blockquote>
|
||||
{q.translation && (
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
<span className="text-fg-tertiary">{t("compare.law.translation")} </span>
|
||||
{q.translation}
|
||||
</p>
|
||||
)}
|
||||
</figure>
|
||||
))}
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
<span className="font-semibold text-fg-primary">
|
||||
{t(`compare.law.confidence.${c.confidence}`)}
|
||||
</span>{" "}
|
||||
{c.confidenceNote}
|
||||
</p>
|
||||
{c.open && (
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
<span className="font-semibold text-fg-primary">{t("compare.law.open")}</span>{" "}
|
||||
{c.open}
|
||||
</p>
|
||||
)}
|
||||
<p className="mb-0 text-xs text-fg-tertiary">
|
||||
{c.settled
|
||||
? t("compare.law.settled", { by: c.codedBy })
|
||||
: t("compare.law.awaiting", { by: c.codedBy })}
|
||||
</p>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const CONFIDENCE_STYLE = {
|
||||
high: "border-default text-fg-primary",
|
||||
medium: "border-default text-fg-secondary",
|
||||
low: "border-dashed border-default text-fg-tertiary",
|
||||
} as const;
|
||||
|
||||
/** What is reported about enforcement, place by place: each statement, who made it, for when, how sure. */
|
||||
function Enforcement({ topic, t }: { topic: LawTopic; t: PlacesTranslator }) {
|
||||
/**
|
||||
* One topic: the scale, from the end that leaves the most to the person to the
|
||||
* end that leaves the least, with each place on the point its own law puts it
|
||||
* and the words that put it there. Then, apart and labelled, what is reported
|
||||
* about enforcement: who said it, for when, and how far it can be trusted.
|
||||
*/
|
||||
function Topic({ topic, t }: { topic: LawTopic; t: PlacesTranslator }) {
|
||||
const points = topic.freer === "higher" ? [...topic.scale].reverse() : topic.scale;
|
||||
const uncoded = topic.cells.filter((c) => !c.coding);
|
||||
const anyEnforcement = topic.cells.some((c) => c.enforcement.length > 0);
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
<p className="mb-0 text-xs text-fg-secondary">{t("compare.law.enforcedIntro")}</p>
|
||||
<ul className="mb-0 space-y-5">
|
||||
{topic.cells.map((cell, index) => (
|
||||
<li key={cell.slugPath} className="space-y-2">
|
||||
<p className="mb-0 flex items-center gap-2 font-semibold text-fg-primary">
|
||||
<PlaceMark index={index} />
|
||||
{cell.name}
|
||||
</p>
|
||||
{cell.enforcement.length === 0 ? (
|
||||
<p className="mb-0 text-fg-tertiary">{t("compare.law.noEnforcement")}</p>
|
||||
) : (
|
||||
<ul className="mb-0 space-y-3 border-l-2 border-subtle pl-4">
|
||||
{cell.enforcement.map((e) => (
|
||||
<li key={e.recordKey} className="space-y-1">
|
||||
<p className="mb-0 text-fg-primary">{e.summary}</p>
|
||||
<p className="mb-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-tertiary">
|
||||
<span
|
||||
title={e.confidenceNote}
|
||||
className={`rounded-pill border px-2 py-0.5 font-semibold ${CONFIDENCE_STYLE[e.confidence]}`}
|
||||
>
|
||||
{t(`compare.law.trust.${e.confidence}`)}
|
||||
</span>
|
||||
<span>{e.statedBy}</span>
|
||||
<span aria-hidden>·</span>
|
||||
<span>{period(e.from, e.to, t)}</span>
|
||||
{e.via && (
|
||||
<>
|
||||
<span aria-hidden>·</span>
|
||||
<span>{t("compare.law.about", { place: e.via })}</span>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
<details className="text-xs">
|
||||
<summary className="inline-flex min-h-11 cursor-pointer items-center text-fg-secondary">
|
||||
{t("compare.law.whySure", { count: e.sources.length })}
|
||||
</summary>
|
||||
<div className="space-y-1 pb-1 text-fg-secondary">
|
||||
<p className="mb-0">{e.confidenceNote}</p>
|
||||
<ul className="mb-0 space-y-1">
|
||||
<article className="space-y-5 rounded-surface border border-default bg-surface-raised p-4 sm:p-6">
|
||||
<header className="space-y-1">
|
||||
<h3 className="mb-0 text-lg font-semibold text-fg-primary">{topic.label}</h3>
|
||||
<p className="mb-0 text-fg-secondary">{topic.question}</p>
|
||||
</header>
|
||||
|
||||
{topic.order && topic.order.length >= 2 && (
|
||||
<p className="mb-0 font-medium text-fg-primary">
|
||||
{topic.order[0]!.rank === topic.order.at(-1)!.rank
|
||||
? t("compare.law.same")
|
||||
: t("compare.law.freest", {
|
||||
place: topic.order
|
||||
.filter((o) => o.rank === 1)
|
||||
.map((o) => o.name)
|
||||
.join(", "),
|
||||
})}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<section aria-label={t("compare.law.says")} className="space-y-3">
|
||||
<p className="mb-0 text-xs font-semibold uppercase tracking-caps text-fg-tertiary">
|
||||
{t("compare.law.says")}
|
||||
</p>
|
||||
{topic.freer && (
|
||||
<p className="mb-0 flex justify-between text-xs text-fg-tertiary">
|
||||
<span>{t("compare.law.freerEnd")}</span>
|
||||
<span aria-hidden="true">↓</span>
|
||||
<span>{t("compare.law.lessFreeEnd")}</span>
|
||||
</p>
|
||||
)}
|
||||
<ol className="mb-0 space-y-3">
|
||||
{points.map((point) => {
|
||||
const here = topic.cells.filter((c) => c.coding?.value === point.value);
|
||||
return (
|
||||
<li key={point.value} className="space-y-2">
|
||||
<div className={here.length === 0 ? "opacity-70" : undefined}>
|
||||
<p className="mb-0 text-sm font-semibold text-fg-primary">{point.label}</p>
|
||||
<p className="mb-0 text-xs text-fg-secondary">{point.definition}</p>
|
||||
</div>
|
||||
{here.length > 0 && (
|
||||
<ul className="mb-0 grid gap-2 md:grid-cols-2">
|
||||
{here.map((cell) => (
|
||||
<Coded
|
||||
key={cell.slugPath}
|
||||
cell={cell as Parameters<typeof Coded>[0]["cell"]}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
{uncoded.length > 0 && (
|
||||
<p className="mb-0 text-sm text-fg-secondary">
|
||||
{t("compare.law.notCoded", { places: uncoded.map((c) => c.name).join(", ") })}
|
||||
</p>
|
||||
)}
|
||||
{topic.freer && (
|
||||
<p className="mb-0 text-xs text-fg-tertiary">{t("compare.law.freerNote")}</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section
|
||||
aria-label={t("compare.law.enforced")}
|
||||
className="space-y-3 rounded-surface border border-dashed border-default p-4"
|
||||
>
|
||||
<p className="mb-0 text-xs font-semibold uppercase tracking-caps text-fg-tertiary">
|
||||
{t("compare.law.enforced")}
|
||||
</p>
|
||||
<p className="mb-0 text-xs text-fg-secondary">{t("compare.law.enforcedIntro")}</p>
|
||||
{!anyEnforcement ? (
|
||||
<p className="mb-0 text-sm text-fg-secondary">{t("compare.law.noEnforcementAny")}</p>
|
||||
) : (
|
||||
<ul className="mb-0 space-y-3">
|
||||
{topic.cells.map((cell) => (
|
||||
<li key={cell.slugPath} className="space-y-2">
|
||||
<p className="mb-0 text-sm font-semibold text-fg-primary">{cell.name}</p>
|
||||
{cell.enforcement.length === 0 ? (
|
||||
<p className="mb-0 text-sm text-fg-secondary">{t("compare.law.noEnforcement")}</p>
|
||||
) : (
|
||||
<ul className="mb-0 space-y-2">
|
||||
{cell.enforcement.map((e) => (
|
||||
<li key={e.recordKey} className="space-y-1 text-sm">
|
||||
<p className="mb-0 text-fg-primary">{e.summary}</p>
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
{t("compare.law.statedBy", {
|
||||
by: e.statedBy,
|
||||
period: period(e.from, e.to, t),
|
||||
})}
|
||||
{e.via && <> · {t("compare.law.about", { place: e.via })}</>}
|
||||
</p>
|
||||
<p className="mb-0 text-xs text-fg-secondary">
|
||||
<span className="font-semibold text-fg-primary">
|
||||
{t(`compare.law.confidence.${e.confidence}`)}
|
||||
</span>{" "}
|
||||
{e.confidenceNote}
|
||||
</p>
|
||||
<ul className="mb-0 flex flex-wrap gap-x-4 gap-y-1 text-xs">
|
||||
{e.sources.map((s) => (
|
||||
<li key={s.url}>
|
||||
<a
|
||||
href={s.url}
|
||||
rel="noopener noreferrer"
|
||||
className="text-fg-primary underline underline-offset-4"
|
||||
title={t("compare.law.read", { on: s.read })}
|
||||
className="text-fg-tertiary underline"
|
||||
>
|
||||
{s.publisher}
|
||||
</a>{" "}
|
||||
<span className="text-fg-tertiary">
|
||||
{t("compare.law.read", { on: s.read })}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{topic.wanted && (
|
||||
<p className="mb-0 text-xs text-fg-tertiary">
|
||||
{t("compare.law.wanted", { wanted: topic.wanted })}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* One topic: the question, the verdict in a sentence, the scale drawn with
|
||||
* every place on it. Then two folded parts a reader opens when they want
|
||||
* them: why each place stands there (articles, words), and, kept apart, what
|
||||
* is reported about enforcement.
|
||||
*/
|
||||
function Topic({ topic, t }: { topic: LawTopic; t: PlacesTranslator }) {
|
||||
const coded = topic.cells.flatMap((cell, index) =>
|
||||
cell.coding ? [{ cell: cell as CodedCell, index }] : [],
|
||||
);
|
||||
const reports = topic.cells.reduce((n, c) => n + c.enforcement.length, 0);
|
||||
const verdict =
|
||||
topic.order && topic.order.length >= 2
|
||||
? topic.order[0]!.rank === topic.order.at(-1)!.rank
|
||||
? t("compare.law.same")
|
||||
: t("compare.law.freest", {
|
||||
place: topic.order
|
||||
.filter((o) => o.rank === 1)
|
||||
.map((o) => o.name)
|
||||
.join(", "),
|
||||
})
|
||||
: null;
|
||||
return (
|
||||
<article className="space-y-4 rounded-surface border border-default bg-surface-raised p-4 sm:p-6">
|
||||
<header className="space-y-1">
|
||||
<h3 className="mb-0 text-lg font-semibold text-fg-primary">{topic.label}</h3>
|
||||
<p className="mb-0 text-sm text-fg-secondary">{topic.question}</p>
|
||||
</header>
|
||||
{verdict && <p className="mb-0 font-semibold text-fg-primary">{verdict}</p>}
|
||||
<Scale topic={topic} t={t} />
|
||||
|
||||
<div className="space-y-2">
|
||||
<Disclosure
|
||||
title={t("compare.law.whyTitle")}
|
||||
hint={t("compare.law.whyHint", { count: coded.length })}
|
||||
>
|
||||
<ul className="mb-0 space-y-6">
|
||||
{coded.map(({ cell, index }) => (
|
||||
<Why key={cell.slugPath} cell={cell} index={index} t={t} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="space-y-2">
|
||||
<p className="mb-0 text-xs font-semibold uppercase tracking-caps text-fg-tertiary">
|
||||
{t("compare.law.scaleTitle")}
|
||||
</p>
|
||||
<ol className="mb-0 space-y-2">
|
||||
{fromFreer(topic).map((point, i) => (
|
||||
<li key={point.value} className="flex gap-3">
|
||||
<span className="w-4 shrink-0 text-right text-xs tabular-nums text-fg-tertiary">
|
||||
{i + 1}
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-medium text-fg-primary">{point.label}</span>
|
||||
<span className="block text-xs text-fg-secondary">{point.definition}</span>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
{topic.freer && (
|
||||
<p className="mb-0 text-xs text-fg-tertiary">{t("compare.law.freerNote")}</p>
|
||||
)}
|
||||
<p className="mb-0 text-xs text-fg-tertiary">{topic.author}</p>
|
||||
</div>
|
||||
</Disclosure>
|
||||
<Disclosure
|
||||
title={t("compare.law.enforced")}
|
||||
hint={
|
||||
reports > 0
|
||||
? t("compare.law.enforcedHint", { count: reports })
|
||||
: t("compare.law.noEnforcementAny")
|
||||
}
|
||||
className="border-dashed"
|
||||
>
|
||||
<Enforcement topic={topic} t={t} />
|
||||
</Disclosure>
|
||||
</div>
|
||||
)}
|
||||
{topic.wanted && (
|
||||
<p className="mb-0 text-xs text-fg-tertiary">
|
||||
{t("compare.law.wanted", { wanted: topic.wanted })}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<p className="mb-0 text-xs text-fg-tertiary">{topic.author}</p>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -352,7 +239,7 @@ function Topic({ topic, t }: { topic: LawTopic; t: PlacesTranslator }) {
|
||||
/** What the law says on each topic coded for the places compared, and, apart, how it is enforced. */
|
||||
export default function LawComparison({ topics, t }: { topics: LawTopic[]; t: PlacesTranslator }) {
|
||||
if (topics.length === 0) return null;
|
||||
// A topic two places answer is a comparison; one only one place answers is listed, folded.
|
||||
// A topic two places answer is a comparison; one only one place answers is kept, folded.
|
||||
const coded = (topic: LawTopic) => topic.cells.filter((c) => c.coding).length;
|
||||
const single = topics[0]!.cells.length < 2;
|
||||
const full = topics.filter((topic) => single || coded(topic) >= 2);
|
||||
@@ -361,20 +248,36 @@ export default function LawComparison({ topics, t }: { topics: LawTopic[]; t: Pl
|
||||
<section className="space-y-4">
|
||||
<div className="space-y-1">
|
||||
<h2 className="mb-0 text-xl font-semibold text-fg-primary">{t("compare.law.title")}</h2>
|
||||
<p className="mb-0 max-w-2xl text-sm text-fg-secondary">{t("compare.law.intro")}</p>
|
||||
<p className="mb-0 max-w-3xl text-sm text-fg-secondary">{t("compare.law.intro")}</p>
|
||||
</div>
|
||||
{full.map((topic) => (
|
||||
<Topic key={topic.key} topic={topic} t={t} />
|
||||
))}
|
||||
{few.length > 0 && (
|
||||
<Disclosure
|
||||
title={t("compare.law.fewTitle")}
|
||||
hint={few.map((topic) => topic.label).join(" · ")}
|
||||
>
|
||||
<div className="space-y-2">
|
||||
<p className="mb-0 text-sm font-semibold text-fg-primary">{t("compare.law.fewTitle")}</p>
|
||||
{few.map((topic) => (
|
||||
<Topic key={topic.key} topic={topic} t={t} />
|
||||
<details
|
||||
key={topic.key}
|
||||
className="rounded-surface border border-default bg-surface-base px-4"
|
||||
>
|
||||
<summary className="flex min-h-11 cursor-pointer items-center py-2 text-sm">
|
||||
<span className="font-medium text-fg-primary">{topic.label}</span>
|
||||
<span className="ml-2 text-fg-tertiary">
|
||||
{t("compare.law.codedFor", {
|
||||
places: topic.cells
|
||||
.filter((c) => c.coding)
|
||||
.map((c) => c.name)
|
||||
.join(", "),
|
||||
})}
|
||||
</span>
|
||||
</summary>
|
||||
<div className="pb-4">
|
||||
<Topic topic={topic} t={t} />
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
</Disclosure>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { getFormatter } from "next-intl/server";
|
||||
import OfficialRoutes from "@/components/law/official-routes";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import { Link } from "@/i18n/navigation";
|
||||
import type { Locale } from "@/i18n/routing";
|
||||
import { localizeRoute, routesOfAuthority } from "@/lib/config/law/routes";
|
||||
import { routesOfAuthority } from "@/lib/config/law/routes";
|
||||
import type { PlaceLaw } from "@/lib/law/place-law";
|
||||
import type { RecentChange } from "@/lib/law/recent";
|
||||
import type { PlacesTranslator } from "./translator";
|
||||
@@ -31,13 +30,14 @@ export async function PlaceRoutes({
|
||||
}) {
|
||||
const withRoutes = routesAlong(law);
|
||||
if (withRoutes.length === 0) return null;
|
||||
// Folded: the bars and provisions are for the reader about to sign, not for every visit.
|
||||
const names = [
|
||||
...new Set(withRoutes.flatMap((a) => a.routes.map((r) => localizeRoute(r, locale).name))),
|
||||
];
|
||||
return (
|
||||
<Disclosure id="place-routes" title={t("change.title")} hint={names.join(" · ")}>
|
||||
<p className="mb-0 text-fg-secondary">{t("change.intro")}</p>
|
||||
<section aria-labelledby="place-routes" className="space-y-6">
|
||||
<div>
|
||||
<h2 id="place-routes" className="headline text-2xl text-fg-primary">
|
||||
{t("change.title")}
|
||||
</h2>
|
||||
<p className="mb-0 mt-2 text-sm text-fg-secondary">{t("change.intro")}</p>
|
||||
</div>
|
||||
{withRoutes.map(({ authority, routes }) => (
|
||||
<div key={authority.key} className="space-y-3">
|
||||
{withRoutes.length > 1 && (
|
||||
@@ -46,13 +46,10 @@ export async function PlaceRoutes({
|
||||
<OfficialRoutes routes={routes} locale={locale} heading={false} />
|
||||
</div>
|
||||
))}
|
||||
</Disclosure>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/** The newest changes shown; the rest of the year is one row away. */
|
||||
const SHOWN = 3;
|
||||
|
||||
export async function PlaceRecentChanges({
|
||||
recent,
|
||||
law,
|
||||
@@ -71,48 +68,40 @@ export async function PlaceRecentChanges({
|
||||
const names = new Map(law.map((a) => [a.key, a.name]));
|
||||
const date = (iso: string) =>
|
||||
format.dateTime(new Date(`${iso}T00:00:00Z`), { dateStyle: "medium", timeZone: "UTC" });
|
||||
const changeList = (changes: readonly RecentChange[]) => (
|
||||
<ul className="divide-y divide-default overflow-hidden rounded-surface border border-default bg-surface-base">
|
||||
{changes.map((c) => (
|
||||
<li key={c.actId}>
|
||||
<Link
|
||||
href={`/law/${c.actId}`}
|
||||
className="flex min-h-11 flex-col gap-1 px-5 py-3 hover:bg-surface-raised sm:flex-row sm:items-baseline sm:justify-between sm:gap-6"
|
||||
>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-medium text-fg-primary [overflow-wrap:anywhere]">
|
||||
{c.title}
|
||||
</span>
|
||||
{law.length > 1 && (
|
||||
<span className="block text-xs text-fg-tertiary">
|
||||
{names.get(c.authority) ?? c.authority}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-sm text-fg-tertiary">
|
||||
{t(c.amended ? "recent.amended" : "recent.new", { date: date(c.inForceFrom) })}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
return (
|
||||
<section aria-labelledby="place-recent" className="space-y-4">
|
||||
<div>
|
||||
<h2 id="place-recent" className="headline scroll-mt-24 text-2xl text-fg-primary">
|
||||
<h2 id="place-recent" className="headline text-2xl text-fg-primary">
|
||||
{t("recent.title")}
|
||||
</h2>
|
||||
<p className="mb-0 mt-2 text-sm text-fg-secondary">
|
||||
{t("recent.intro", { place, count: recent.total })}
|
||||
</p>
|
||||
</div>
|
||||
{changeList(recent.changes.slice(0, SHOWN))}
|
||||
{recent.changes.length > SHOWN && (
|
||||
<Disclosure title={t("recent.more", { count: recent.changes.length - SHOWN })}>
|
||||
{changeList(recent.changes.slice(SHOWN))}
|
||||
</Disclosure>
|
||||
)}
|
||||
<ul className="divide-y divide-default overflow-hidden rounded-surface border border-default bg-surface-base">
|
||||
{recent.changes.map((c) => (
|
||||
<li key={c.actId}>
|
||||
<Link
|
||||
href={`/law/${c.actId}`}
|
||||
className="flex min-h-11 flex-col gap-1 px-5 py-3 hover:bg-surface-raised sm:flex-row sm:items-baseline sm:justify-between sm:gap-6"
|
||||
>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-medium text-fg-primary [overflow-wrap:anywhere]">
|
||||
{c.title}
|
||||
</span>
|
||||
{law.length > 1 && (
|
||||
<span className="block text-xs text-fg-tertiary">
|
||||
{names.get(c.authority) ?? c.authority}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-sm text-fg-tertiary">
|
||||
{t(c.amended ? "recent.amended" : "recent.new", { date: date(c.inForceFrom) })}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Meter, Sparkline } from "@bitbaum/chartkit/react";
|
||||
import { Link } from "@/i18n/navigation";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import { PROFILE_FIGURE_GROUPS } from "@/lib/config/places/profile-figures";
|
||||
import { UNITS } from "@/lib/config/places/units";
|
||||
import type { ProfileFigureView } from "@/lib/places/profile-figures";
|
||||
@@ -33,90 +32,83 @@ export default function PlaceFigures({
|
||||
t: PlacesTranslator;
|
||||
}) {
|
||||
if (figures.length === 0) return null;
|
||||
const card = (f: ProfileFigureView) => {
|
||||
const percent = f.position
|
||||
? Math.round((f.position.below / Math.max(1, f.position.others)) * 100)
|
||||
: null;
|
||||
// The ends said as ends: "higher than 0%" reads as a riddle.
|
||||
const position =
|
||||
f.position && percent !== null
|
||||
? f.position.below === 0
|
||||
? t("figures.lowest", { count: f.position.others + 1, year: f.year })
|
||||
: f.position.below === f.position.others
|
||||
? t("figures.highest", { count: f.position.others + 1, year: f.year })
|
||||
: t("figures.position", {
|
||||
percent,
|
||||
count: f.position.others,
|
||||
year: f.year,
|
||||
})
|
||||
: null;
|
||||
return (
|
||||
<li
|
||||
key={f.key}
|
||||
className="flex min-w-0 flex-col gap-2 rounded-surface border border-default bg-surface-base p-4"
|
||||
>
|
||||
<span className="text-sm text-fg-secondary">{f.label}</span>
|
||||
<div className="flex items-end justify-between gap-4">
|
||||
<span className="text-2xl font-semibold tabular-nums text-fg-primary">
|
||||
{formatFigure(f, locale)}
|
||||
</span>
|
||||
<Sparkline
|
||||
points={f.trend.map((p) => ({ x: p.year, y: p.value }))}
|
||||
label={t("figures.trend", {
|
||||
label: f.label,
|
||||
from: f.trend[0]?.year ?? f.year,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{position && percent !== null && (
|
||||
<div className="flex items-center gap-3">
|
||||
<Meter value={percent} max={100} label={position} tone="neutral" showValue={false} />
|
||||
<p className="mb-0 text-xs text-fg-secondary">{position}</p>
|
||||
</div>
|
||||
)}
|
||||
<Link
|
||||
href={f.href}
|
||||
className="mt-auto text-xs text-fg-tertiary underline-offset-4 hover:text-fg-secondary hover:underline"
|
||||
>
|
||||
{t("figures.source", { publisher: f.publisher, year: f.year })} →
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
const groups = PROFILE_FIGURE_GROUPS.map((group) => ({
|
||||
group,
|
||||
rows: figures.filter((f) => f.group === group),
|
||||
})).filter((g) => g.rows.length > 0);
|
||||
const grid = (rows: readonly ProfileFigureView[]) => (
|
||||
<ul className="grid gap-3 sm:grid-cols-2">{rows.map(card)}</ul>
|
||||
);
|
||||
const [first, ...rest] = groups;
|
||||
return (
|
||||
<section aria-labelledby="place-figures" className="space-y-4">
|
||||
<section aria-labelledby="place-figures" className="space-y-6">
|
||||
<div>
|
||||
<h2 id="place-figures" className="headline text-2xl text-fg-primary">
|
||||
{t("figures.title")}
|
||||
</h2>
|
||||
<p className="mb-0 mt-2 text-sm text-fg-secondary">{t("figures.intro", { place })}</p>
|
||||
</div>
|
||||
{/* The first group answers; the others are a row each until asked for. */}
|
||||
{first && (
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-semibold text-fg-secondary">
|
||||
{t(`figures.groups.${first.group}`)}
|
||||
</h3>
|
||||
{grid(first.rows)}
|
||||
</div>
|
||||
)}
|
||||
{rest.map(({ group, rows }) => (
|
||||
<Disclosure
|
||||
key={group}
|
||||
title={t(`figures.groups.${group}`)}
|
||||
hint={rows.map((f) => f.label).join(" · ")}
|
||||
>
|
||||
{grid(rows)}
|
||||
</Disclosure>
|
||||
))}
|
||||
{PROFILE_FIGURE_GROUPS.map((group) => {
|
||||
const rows = figures.filter((f) => f.group === group);
|
||||
if (rows.length === 0) return null;
|
||||
return (
|
||||
<div key={group} className="space-y-3">
|
||||
<h3 className="text-sm font-semibold text-fg-secondary">
|
||||
{t(`figures.groups.${group}`)}
|
||||
</h3>
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{rows.map((f) => {
|
||||
const percent = f.position
|
||||
? Math.round((f.position.below / Math.max(1, f.position.others)) * 100)
|
||||
: null;
|
||||
// The ends said as ends: "higher than 0%" reads as a riddle.
|
||||
const position =
|
||||
f.position && percent !== null
|
||||
? f.position.below === 0
|
||||
? t("figures.lowest", { count: f.position.others + 1, year: f.year })
|
||||
: f.position.below === f.position.others
|
||||
? t("figures.highest", { count: f.position.others + 1, year: f.year })
|
||||
: t("figures.position", {
|
||||
percent,
|
||||
count: f.position.others,
|
||||
year: f.year,
|
||||
})
|
||||
: null;
|
||||
return (
|
||||
<li
|
||||
key={f.key}
|
||||
className="flex min-w-0 flex-col gap-3 rounded-surface border border-default bg-surface-base p-5"
|
||||
>
|
||||
<span className="text-sm text-fg-secondary">{f.label}</span>
|
||||
<div className="flex items-end justify-between gap-4">
|
||||
<span className="text-3xl font-semibold tabular-nums text-fg-primary">
|
||||
{formatFigure(f, locale)}
|
||||
</span>
|
||||
<Sparkline
|
||||
points={f.trend.map((p) => ({ x: p.year, y: p.value }))}
|
||||
label={t("figures.trend", {
|
||||
label: f.label,
|
||||
from: f.trend[0]?.year ?? f.year,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{position && percent !== null && (
|
||||
<div className="flex items-center gap-3">
|
||||
<Meter
|
||||
value={percent}
|
||||
max={100}
|
||||
label={position}
|
||||
tone="neutral"
|
||||
showValue={false}
|
||||
/>
|
||||
<p className="mb-0 text-xs text-fg-secondary">{position}</p>
|
||||
</div>
|
||||
)}
|
||||
<Link
|
||||
href={f.href}
|
||||
className="mt-auto text-xs text-fg-tertiary underline-offset-4 hover:text-fg-secondary hover:underline"
|
||||
>
|
||||
{t("figures.source", { publisher: f.publisher, year: f.year })} →
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import type { PlaceLaw } from "@/lib/law/place-law";
|
||||
import type { PlacesTranslator } from "./translator";
|
||||
import { routesAlong } from "./place-change";
|
||||
|
||||
export interface GlanceCounts {
|
||||
law: readonly PlaceLaw[];
|
||||
/** Laws that took effect in the past twelve months. */
|
||||
changed: number;
|
||||
/** Places one level and more inside it. */
|
||||
places: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A place in four numbers, right under its photograph: the laws in force
|
||||
* here, how many changed this year, the official ways its people can change
|
||||
* them, the places inside it. Each is a way to the part of the page that
|
||||
* explains it, so the page reads as an answer first and a reference after.
|
||||
* A number Solon does not hold is left out, never shown as a zero.
|
||||
*/
|
||||
export default function PlaceGlance({
|
||||
counts,
|
||||
locale,
|
||||
t,
|
||||
}: {
|
||||
counts: GlanceCounts;
|
||||
locale: string;
|
||||
t: PlacesTranslator;
|
||||
}) {
|
||||
const number = new Intl.NumberFormat(locale);
|
||||
const inForce = counts.law.reduce((sum, a) => sum + a.acts, 0);
|
||||
const routes = routesAlong(counts.law).reduce((sum, a) => sum + a.routes.length, 0);
|
||||
const tiles = [
|
||||
{ key: "laws" as const, count: inForce, href: "#place-law" },
|
||||
{ key: "changed" as const, count: counts.changed, href: "#place-recent" },
|
||||
{ key: "routes" as const, count: routes, href: "#place-routes" },
|
||||
{ key: "places" as const, count: counts.places, href: "#place-parts" },
|
||||
].filter((tile) => tile.count > 0);
|
||||
if (tiles.length === 0) return null;
|
||||
return (
|
||||
<nav aria-label={t("glance.label")}>
|
||||
<ul className="grid grid-cols-2 gap-2 sm:grid-cols-4">
|
||||
{tiles.map((tile) => (
|
||||
<li key={tile.key} className="min-w-0">
|
||||
<a
|
||||
href={tile.href}
|
||||
className="flex h-full min-h-11 flex-col gap-1 rounded-surface border border-default bg-surface-base px-4 py-3 transition-colors hover:bg-surface-raised"
|
||||
>
|
||||
<span className="text-2xl font-bold tabular-nums leading-none text-fg-primary">
|
||||
{number.format(tile.count)}
|
||||
</span>
|
||||
<span className="text-xs text-fg-secondary">
|
||||
{t(`glance.${tile.key}`, { count: tile.count })}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export function PlaceLawCard({
|
||||
className="rounded-surface border border-default bg-surface-base"
|
||||
>
|
||||
<div className="p-5 sm:p-6">
|
||||
<h2 id="place-law" className="scroll-mt-24 font-semibold text-fg-primary">
|
||||
<h2 id="place-law" className="font-semibold text-fg-primary">
|
||||
{t("law.title")}
|
||||
</h2>
|
||||
<p className="mt-1 text-sm text-fg-secondary">
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/** A compared place's number in its series colour: the same mark wherever /compare shows the place. */
|
||||
export default function PlaceMark({ index, label }: { index: number; label?: string }) {
|
||||
return (
|
||||
<span
|
||||
data-series={index + 1}
|
||||
className="place-mark"
|
||||
aria-hidden={label ? undefined : true}
|
||||
aria-label={label}
|
||||
role={label ? "img" : undefined}
|
||||
>
|
||||
{index + 1}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Link } from "@/i18n/navigation";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import { placePhoto } from "@/lib/places/place-photo";
|
||||
import type { PlaceView } from "@/lib/places/place-view";
|
||||
import PlaceTile from "./place-tile";
|
||||
@@ -16,14 +15,10 @@ const MAX_TILES = 120;
|
||||
*/
|
||||
export default function PlaceParts({ view, t }: { view: PlaceView; t: PlacesTranslator }) {
|
||||
return (
|
||||
// Folded: a way down to a canton or a commune, not something every visit reads.
|
||||
<Disclosure
|
||||
id="place-parts"
|
||||
title={t("parts.title", { place: view.name })}
|
||||
hint={view.parts
|
||||
.map((group) => t("parts.level", { level: group.levelName, count: group.places.length }))
|
||||
.join(" · ")}
|
||||
>
|
||||
<section aria-labelledby="place-parts" className="space-y-6">
|
||||
<h2 id="place-parts" className="headline text-2xl text-fg-primary">
|
||||
{t("parts.title", { place: view.name })}
|
||||
</h2>
|
||||
{view.parts.map((group) => {
|
||||
const places = group.places.map((place) => ({
|
||||
...place,
|
||||
@@ -35,11 +30,9 @@ export default function PlaceParts({ view, t }: { view: PlaceView; t: PlacesTran
|
||||
places.every((p) => p.canonicalPath);
|
||||
return (
|
||||
<div key={group.levelName} className="space-y-3">
|
||||
{view.parts.length > 1 && (
|
||||
<h3 className="text-sm font-semibold text-fg-secondary">
|
||||
{t("parts.level", { level: group.levelName, count: group.places.length })}
|
||||
</h3>
|
||||
)}
|
||||
<h3 className="text-sm font-semibold text-fg-secondary">
|
||||
{t("parts.level", { level: group.levelName, count: group.places.length })}
|
||||
</h3>
|
||||
{tiles ? (
|
||||
<ul className="grid grid-cols-2 gap-3 sm:grid-cols-3">
|
||||
{places.map((place, i) => (
|
||||
@@ -78,6 +71,6 @@ export default function PlaceParts({ view, t }: { view: PlaceView; t: PlacesTran
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Disclosure>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import type { RecentChange } from "@/lib/law/recent";
|
||||
import type { Locale } from "@/i18n/routing";
|
||||
import type { ProfileFigureView } from "@/lib/places/profile-figures";
|
||||
import PlaceParts from "./place-parts";
|
||||
import PlaceGlance from "./place-glance";
|
||||
import Disclosure from "@/components/ui/disclosure";
|
||||
import SourceList from "./source-list";
|
||||
import { WORLD_PACK } from "@/lib/config/places/countries/world";
|
||||
import { placeHref } from "@/lib/places/place-href";
|
||||
@@ -62,10 +60,9 @@ function PlaceName({ place }: { place: PlaceLink }) {
|
||||
/**
|
||||
* One place, at any level — a country, a canton, a commune, a quarter — on a
|
||||
* page of its own that can be shared. Read top-down: where it sits, the law
|
||||
* a place in four numbers, the law that applies there and what changed in
|
||||
* it, the figures, then the reference parts folded to a row each: how its law
|
||||
* is changed, the places inside it, tax (a summary; the calculator is its own
|
||||
* page), what a resident can do, and the record behind it all. Every word of structure comes from the pack;
|
||||
* that applies there, the places inside it, then tax (a summary; the
|
||||
* calculator is its own page), what a resident can do, and the record behind
|
||||
* it all, closed until asked for. Every word of structure comes from the pack;
|
||||
* nothing here knows a country.
|
||||
*/
|
||||
export default function PlaceProfile({
|
||||
@@ -90,44 +87,27 @@ export default function PlaceProfile({
|
||||
);
|
||||
|
||||
return (
|
||||
<ProfileFrame
|
||||
hero={hero}
|
||||
glance={
|
||||
<PlaceGlance
|
||||
counts={{
|
||||
law,
|
||||
changed: recent?.total ?? 0,
|
||||
places: view.parts.reduce((sum, group) => sum + group.places.length, 0),
|
||||
}}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
aside={profile ? <CountryProfile profile={profile} t={t} /> : null}
|
||||
>
|
||||
<ProfileFrame hero={hero} aside={profile ? <CountryProfile profile={profile} t={t} /> : null}>
|
||||
<>
|
||||
{contest && <ContestNote {...contest} statusShown={!!profile} t={t} />}
|
||||
|
||||
<PlaceLawCard law={law} name={view.name} t={t} />
|
||||
|
||||
{recent && recent.changes.length > 0 && (
|
||||
<PlaceRecentChanges recent={recent} law={law} place={view.name} locale={locale} t={t} />
|
||||
)}
|
||||
|
||||
<PlaceFigures figures={figures} place={view.name} locale={locale} t={t} />
|
||||
|
||||
{local}
|
||||
|
||||
{/* The reference parts, a row each until asked for. */}
|
||||
{(routesAlong(law).length > 0 || view.parts.length > 0) && (
|
||||
<div className="space-y-3">
|
||||
{routesAlong(law).length > 0 && <PlaceRoutes law={law} locale={locale} t={t} />}
|
||||
{view.parts.length > 0 && <PlaceParts view={view} t={t} />}
|
||||
</div>
|
||||
{/* Async parts are mounted only when they have something to show. */}
|
||||
{routesAlong(law).length > 0 && <PlaceRoutes law={law} locale={locale} t={t} />}
|
||||
|
||||
{recent && recent.changes.length > 0 && (
|
||||
<PlaceRecentChanges recent={recent} law={law} place={view.name} locale={locale} t={t} />
|
||||
)}
|
||||
|
||||
{budget && <BudgetLinkCard {...budget} />}
|
||||
|
||||
{view.parts.length > 0 && <PlaceParts view={view} t={t} />}
|
||||
|
||||
{view.alsoServedBy.length > 0 && (
|
||||
<section>
|
||||
<h2 className="mb-3 font-semibold text-fg-primary">{t("alsoServedBy")}</h2>
|
||||
@@ -204,45 +184,47 @@ export default function PlaceProfile({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Disclosure
|
||||
title={t("record.title")}
|
||||
hint={t("record.hint", { count: view.sources.length })}
|
||||
>
|
||||
<p className="text-fg-secondary">
|
||||
{t("official")}: {t("officialNote")}
|
||||
</p>
|
||||
{(view.otherNames.length > 0 || view.identifiers.length > 0) && (
|
||||
<dl className="space-y-2">
|
||||
{view.otherNames.length > 0 &&
|
||||
row(
|
||||
t("otherNames"),
|
||||
view.otherNames.map((n) => (
|
||||
<span key={`${n.locale}-${n.name}`} className="block" lang={n.locale}>
|
||||
{n.name} <span className="text-fg-tertiary">({n.locale})</span>
|
||||
</span>
|
||||
)),
|
||||
)}
|
||||
{view.identifiers.map((id) =>
|
||||
row(
|
||||
id.label,
|
||||
id.url ? (
|
||||
<a
|
||||
href={id.url}
|
||||
className="font-mono hover:underline"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{id.value}
|
||||
</a>
|
||||
) : (
|
||||
<span className="font-mono">{id.value}</span>
|
||||
<details className="rounded-surface border border-default bg-surface-base p-5 text-sm sm:p-6">
|
||||
<summary className="cursor-pointer font-semibold text-fg-primary">
|
||||
{t("record.title")}
|
||||
</summary>
|
||||
<div className="mt-4 space-y-6">
|
||||
<p className="text-fg-secondary">
|
||||
{t("official")}: {t("officialNote")}
|
||||
</p>
|
||||
{(view.otherNames.length > 0 || view.identifiers.length > 0) && (
|
||||
<dl className="space-y-2">
|
||||
{view.otherNames.length > 0 &&
|
||||
row(
|
||||
t("otherNames"),
|
||||
view.otherNames.map((n) => (
|
||||
<span key={`${n.locale}-${n.name}`} className="block" lang={n.locale}>
|
||||
{n.name} <span className="text-fg-tertiary">({n.locale})</span>
|
||||
</span>
|
||||
)),
|
||||
)}
|
||||
{view.identifiers.map((id) =>
|
||||
row(
|
||||
id.label,
|
||||
id.url ? (
|
||||
<a
|
||||
href={id.url}
|
||||
className="font-mono hover:underline"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{id.value}
|
||||
</a>
|
||||
) : (
|
||||
<span className="font-mono">{id.value}</span>
|
||||
),
|
||||
`${id.label}-${id.value}`,
|
||||
),
|
||||
`${id.label}-${id.value}`,
|
||||
),
|
||||
)}
|
||||
</dl>
|
||||
)}
|
||||
<SourceList sources={view.sources} t={t} />
|
||||
</Disclosure>
|
||||
)}
|
||||
</dl>
|
||||
)}
|
||||
<SourceList sources={view.sources} t={t} />
|
||||
</div>
|
||||
</details>
|
||||
</>
|
||||
</ProfileFrame>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { ReactNode } from "react";
|
||||
import OpenOnHash from "@/components/ui/open-on-hash";
|
||||
|
||||
/**
|
||||
* A place page's frame, one for every place: its hero, then the page in two
|
||||
@@ -10,12 +9,9 @@ export default function ProfileFrame({
|
||||
hero,
|
||||
aside,
|
||||
wide = false,
|
||||
glance,
|
||||
children,
|
||||
}: {
|
||||
hero: ReactNode;
|
||||
/** The place in a few numbers, the full width under the hero, before anything else. */
|
||||
glance?: ReactNode;
|
||||
aside?: ReactNode;
|
||||
/** A page that is a wall of places, not a column of text: the full width. */
|
||||
wide?: boolean;
|
||||
@@ -24,9 +20,7 @@ export default function ProfileFrame({
|
||||
return (
|
||||
<>
|
||||
{hero}
|
||||
<main className="section-shell space-y-10 py-section-tight">
|
||||
<OpenOnHash />
|
||||
{glance}
|
||||
<main className="section-shell py-section-tight">
|
||||
<div
|
||||
className={
|
||||
aside
|
||||
|
||||
@@ -5,19 +5,16 @@ import type { PlacesTranslator } from "./translator";
|
||||
export default function SourceList({
|
||||
sources,
|
||||
t,
|
||||
heading = true,
|
||||
}: {
|
||||
sources: PlaceSource[];
|
||||
t: PlacesTranslator;
|
||||
/** False where the list sits under a title of its own (a folded part). */
|
||||
heading?: boolean;
|
||||
}) {
|
||||
if (sources.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<section>
|
||||
{heading && <h2 className="mb-3 font-semibold text-fg-primary">{t("sources.title")}</h2>}
|
||||
<h2 className="mb-3 font-semibold text-fg-primary">{t("sources.title")}</h2>
|
||||
<ul className="space-y-3 text-sm">
|
||||
{sources.map((source) => (
|
||||
<li key={`${source.publisher}-${source.dataset}`} className="text-fg-secondary">
|
||||
|
||||
@@ -7,7 +7,6 @@ import CountryProfile from "./country-profile";
|
||||
import type { WorldProfileView } from "@/lib/places/world-profile";
|
||||
import { PlaceLawCard } from "./place-head";
|
||||
import PlaceFigures from "./place-figures";
|
||||
import PlaceGlance from "./place-glance";
|
||||
import { PlaceRecentChanges, PlaceRoutes, routesAlong } from "./place-change";
|
||||
import type { RecentChange } from "@/lib/law/recent";
|
||||
import type { Locale } from "@/i18n/routing";
|
||||
@@ -51,30 +50,21 @@ export default function WorldRegionPage({
|
||||
t,
|
||||
}: WorldRegionPageProps) {
|
||||
return (
|
||||
<ProfileFrame
|
||||
hero={hero}
|
||||
glance={
|
||||
<PlaceGlance
|
||||
counts={{ law, changed: recent?.total ?? 0, places: 0 }}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
}
|
||||
aside={profile ? <CountryProfile profile={profile} t={t} /> : null}
|
||||
>
|
||||
<ProfileFrame hero={hero} aside={profile ? <CountryProfile profile={profile} t={t} /> : null}>
|
||||
<>
|
||||
{contest && <ContestNote {...contest} statusShown={!!profile} t={t} />}
|
||||
|
||||
<PlaceLawCard law={law} name={name} t={t} />
|
||||
|
||||
<PlaceFigures figures={figures} place={name} locale={locale} t={t} />
|
||||
|
||||
{/* Async parts are mounted only when they have something to show. */}
|
||||
{routesAlong(law).length > 0 && <PlaceRoutes law={law} locale={locale} t={t} />}
|
||||
|
||||
{recent && recent.changes.length > 0 && (
|
||||
<PlaceRecentChanges recent={recent} law={law} place={name} locale={locale} t={t} />
|
||||
)}
|
||||
|
||||
<PlaceFigures figures={figures} place={name} locale={locale} t={t} />
|
||||
|
||||
{routesAlong(law).length > 0 && <PlaceRoutes law={law} locale={locale} t={t} />}
|
||||
|
||||
{budget && <BudgetLinkCard {...budget} />}
|
||||
|
||||
<section
|
||||
|
||||
@@ -42,8 +42,7 @@ export default function AudienceTile({
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
const box =
|
||||
"group relative flex min-h-72 items-end sm:min-h-[26rem] overflow-hidden bg-surface-page";
|
||||
const box = "group relative flex min-h-[26rem] items-end overflow-hidden bg-surface-page";
|
||||
return href ? (
|
||||
<Link href={href} className={box}>
|
||||
{inner}
|
||||
|
||||
@@ -6,8 +6,8 @@ import { HIRE_HREF } from "@/lib/site-config";
|
||||
|
||||
/**
|
||||
* "What it solves": concrete problems, one person's first, then society's.
|
||||
* Each card is the problem; what happens on Solon, and the page where it
|
||||
* happens, open under it on a tap, so sixteen problems read as one screen — named by that page's own title. Structure from
|
||||
* Each card is the problem, what happens on Solon, and the page where it
|
||||
* happens — named by that page's own title. Structure from
|
||||
* lib/content/problems.ts; every sentence from messages `Home.problems`.
|
||||
*/
|
||||
export default function Problems() {
|
||||
@@ -32,38 +32,28 @@ export default function Problems() {
|
||||
<div key={scale.key} className="mt-14 sm:mt-16">
|
||||
<h3 className="headline text-display-3 text-fg-primary">{t(`${scale.key}.title`)}</h3>
|
||||
<p className="mt-2 text-fg-secondary">{t(`${scale.key}.lede`)}</p>
|
||||
<ul className="mt-6 grid grid-cols-1 items-start gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||||
<ul className="mt-6 grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{scale.items.map((item) => (
|
||||
<li key={item.key} className="min-w-0">
|
||||
{/* The problem is the card; what Solon does about it opens under it. */}
|
||||
<details className="group h-full rounded-surface border border-default bg-surface-base">
|
||||
<summary className="flex min-h-11 cursor-pointer list-none items-start justify-between gap-4 p-5 sm:p-6 [&::-webkit-details-marker]:hidden">
|
||||
<span className="text-lg font-semibold text-fg-primary">
|
||||
{t(`items.${item.key}.problem`)}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden
|
||||
className="mt-1 text-xl leading-none text-fg-tertiary transition-transform group-open:rotate-45 motion-reduce:transition-none"
|
||||
>
|
||||
+
|
||||
</span>
|
||||
</summary>
|
||||
<div className="border-t border-subtle px-5 pb-5 pt-4 sm:px-6 sm:pb-6">
|
||||
<div className="text-xs font-bold uppercase tracking-caps text-fg-tertiary">
|
||||
{t("answer")}
|
||||
</div>
|
||||
<p className="mt-2 leading-relaxed text-fg-secondary">
|
||||
{t(`items.${item.key}.solution`)}
|
||||
</p>
|
||||
<Link
|
||||
href={problemHref(item.link)}
|
||||
className="mt-4 inline-flex min-h-11 items-center gap-2 text-sm font-semibold text-fg-primary underline-offset-4 hover:underline"
|
||||
>
|
||||
{site(`links.${item.link}`)}
|
||||
<ArrowRight className="h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
</details>
|
||||
<li
|
||||
key={item.key}
|
||||
className="flex min-w-0 flex-col rounded-surface border border-default bg-surface-base p-5 sm:p-6"
|
||||
>
|
||||
<p className="text-lg font-semibold text-fg-primary">
|
||||
{t(`items.${item.key}.problem`)}
|
||||
</p>
|
||||
<div className="mt-5 text-xs font-bold uppercase tracking-caps text-fg-tertiary">
|
||||
{t("answer")}
|
||||
</div>
|
||||
<p className="mt-2 flex-1 leading-relaxed text-fg-secondary">
|
||||
{t(`items.${item.key}.solution`)}
|
||||
</p>
|
||||
<Link
|
||||
href={problemHref(item.link)}
|
||||
className="mt-4 inline-flex min-h-11 items-center gap-2 self-start text-sm font-semibold text-fg-primary underline-offset-4 hover:underline"
|
||||
>
|
||||
{site(`links.${item.link}`)}
|
||||
<ArrowRight className="h-4 w-4 shrink-0" aria-hidden="true" />
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* A part of a page most readers do not need, closed until asked for: one line
|
||||
* that says what is inside, a 44px row to open it. Pages answer first and
|
||||
* fold the working away in these, so a phone reader scrolls past one line,
|
||||
* not a screen.
|
||||
*/
|
||||
export default function Disclosure({
|
||||
title,
|
||||
hint,
|
||||
children,
|
||||
open = false,
|
||||
id,
|
||||
className = "",
|
||||
}: {
|
||||
/**
|
||||
* On the summary, so a link to `#id` lands on the row and opens it (the
|
||||
* browser opens a closed <details> around a fragment's target).
|
||||
*/
|
||||
id?: string;
|
||||
title: React.ReactNode;
|
||||
/** What is inside, in a few words, shown under the title while it is closed. */
|
||||
hint?: React.ReactNode;
|
||||
children: React.ReactNode;
|
||||
open?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<details
|
||||
open={open}
|
||||
className={`group rounded-surface border border-default bg-surface-base text-sm ${className}`}
|
||||
>
|
||||
<summary
|
||||
id={id}
|
||||
className="flex min-h-11 scroll-mt-24 cursor-pointer list-none items-center gap-3 px-4 py-2 sm:px-5 [&::-webkit-details-marker]:hidden"
|
||||
>
|
||||
<span
|
||||
aria-hidden
|
||||
className="text-fg-tertiary transition-transform group-open:rotate-90 motion-reduce:transition-none"
|
||||
>
|
||||
›
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-semibold text-fg-primary">{title}</span>
|
||||
{hint && <span className="block text-xs text-fg-tertiary">{hint}</span>}
|
||||
</span>
|
||||
</summary>
|
||||
<div className="space-y-6 border-t border-subtle px-4 py-5 sm:px-5">{children}</div>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
/**
|
||||
* Opens the folded part a link points at. A `Disclosure` carries its id on
|
||||
* its summary, which the browser scrolls to but does not open; a reader who
|
||||
* tapped "26 places inside" came to see the places, not a closed row. Runs on
|
||||
* arrival and on every in-page jump. Rendered once per page that folds.
|
||||
*/
|
||||
export default function OpenOnHash() {
|
||||
useEffect(() => {
|
||||
const open = () => {
|
||||
const id = decodeURIComponent(window.location.hash.slice(1));
|
||||
const target = id ? document.getElementById(id) : null;
|
||||
const details = target?.closest("details");
|
||||
if (details && !details.open) details.open = true;
|
||||
};
|
||||
open();
|
||||
window.addEventListener("hashchange", open);
|
||||
return () => window.removeEventListener("hashchange", open);
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
@@ -308,8 +308,6 @@ describe("which budget a page shows", () => {
|
||||
const [row] = budgetIndexRows(budgets, DISPLAY);
|
||||
expect(row).toMatchObject({ slug: "germany", year: 2024, spending: "49%", balance: "-3%" });
|
||||
expect(row?.largest).toMatch(/^Social protection · 41%$/);
|
||||
// A share of GDP is not money: the index draws no bar against money for it.
|
||||
expect(row?.spendingAmount).toBeNull();
|
||||
});
|
||||
|
||||
it("orders a holder's sections by scope, outturn before allocation", () => {
|
||||
@@ -365,8 +363,6 @@ describe("one currency for the reader", () => {
|
||||
);
|
||||
expect(conversionOf(de!, DISPLAY)).toMatchObject({ from: "EUR", to: "CHF", converted: true });
|
||||
expect(conversionOf(de!, { ...DISPLAY, currency: "EUR" })).toBeNull();
|
||||
// The index draws the same amount as a bar, as a number.
|
||||
expect(budgetIndexRows([de!], DISPLAY)[0]?.spendingAmount).toBeCloseTo(chf, -3);
|
||||
});
|
||||
|
||||
it("South Ossetia's roubles reach the reader in francs, at 2023's rates", () => {
|
||||
|
||||
@@ -112,27 +112,12 @@ export interface BudgetIndexRow {
|
||||
scope: string;
|
||||
year: number;
|
||||
spending: string | null;
|
||||
/**
|
||||
* Spending as a number in the reader's currency, so the index can draw it
|
||||
* against the others; null where it is a share of GDP or has no rate for
|
||||
* its year, which a bar in the reader's money would misstate.
|
||||
*/
|
||||
spendingAmount: number | null;
|
||||
revenue: string | null;
|
||||
balance: string | null;
|
||||
/** The function with the largest share of spending, and that share. */
|
||||
largest: string | null;
|
||||
}
|
||||
|
||||
/** A figure in the reader's currency as a number, where the budget is money and a rate exists for its year. */
|
||||
function amountIn(v: number | undefined | null, b: Budget, display: MoneyDisplay): number | null {
|
||||
if (v === undefined || v === null || b.measure.kind !== "money") return null;
|
||||
return (
|
||||
convert(display.rates, v * b.measure.unit, b.measure.currency, display.currency, b.year)
|
||||
?.amount ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/** One row per holder and scope: the budget `pickBudget` shows, every figure in the budget's own measure. */
|
||||
export function budgetIndexRows(
|
||||
budgets: readonly Budget[],
|
||||
@@ -160,7 +145,6 @@ export function budgetIndexRows(
|
||||
scope: scope ? localized(scope.label, locale) : b.scope,
|
||||
year: b.year,
|
||||
spending: value(b.expenditure.get(BUDGET_TAXONOMIES.expenditure.total)),
|
||||
spendingAmount: amountIn(b.expenditure.get(BUDGET_TAXONOMIES.expenditure.total), b, display),
|
||||
revenue: value(b.revenue.get(BUDGET_TAXONOMIES.revenue.total)),
|
||||
balance: value(b.balance),
|
||||
largest:
|
||||
|
||||
Reference in new issue
Block a user