@terrafirmagreg-team/recipe 1.2.38 → 1.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/package.json +5 -5
  2. package/src/components/cards/card/index.tsx +1 -3
  3. package/src/components/cards/card/text.tsx +5 -3
  4. package/src/components/cards/paged-card.tsx +0 -3
  5. package/src/components/cards/scroll-card/index.tsx +42 -7
  6. package/src/components/cards/slot-hitbox.tsx +7 -4
  7. package/src/components/cards/strip-card/index.tsx +1 -2
  8. package/src/components/cards/strip-card/member-cell.tsx +4 -2
  9. package/src/components/views/browser/frame.tsx +73 -33
  10. package/src/components/views/browser/index.tsx +0 -2
  11. package/src/components/views/browser/item-view/index.tsx +12 -9
  12. package/src/components/views/browser/item-view/tags.tsx +3 -3
  13. package/src/components/views/browser/query-controls.tsx +1 -1
  14. package/src/components/views/browser/type-view.tsx +40 -1
  15. package/src/components/views/calc/calculator/actions.tsx +7 -3
  16. package/src/components/views/calc/calculator/index.tsx +18 -8
  17. package/src/components/views/calc/edge.tsx +3 -1
  18. package/src/components/views/calc/node-card/badges.tsx +11 -2
  19. package/src/components/views/calc/node-card/full.tsx +63 -10
  20. package/src/components/views/calc/node-card/port-cells.tsx +13 -8
  21. package/src/components/views/calc/node-card/ports.tsx +39 -13
  22. package/src/components/views/calc/recipe-picker/body.tsx +34 -1
  23. package/src/components/views/calc/sidebar.tsx +8 -2
  24. package/src/hooks/calc/use-actions.ts +2 -0
  25. package/src/hooks/calc/use-amounts.ts +22 -3
  26. package/src/hooks/calc/use-storage.ts +2 -1
  27. package/src/lib/calc/flow.ts +2 -0
  28. package/src/lib/cards/model.test.ts +21 -0
  29. package/src/lib/cards/model.ts +7 -0
  30. package/src/lib/data/parse/widgets.test.ts +51 -0
  31. package/src/lib/data/scroll.ts +9 -0
  32. package/src/components/cards/glare-filter.tsx +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/recipe",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -25,13 +25,13 @@
25
25
  "dependencies": {
26
26
  "@terrafirmagreg-team/data": "^1.2.14",
27
27
  "@terrafirmagreg-team/dump": "^1.2.25",
28
- "@terrafirmagreg-team/game": "^1.2.15",
29
- "@terrafirmagreg-team/kit": "^1.2.36",
28
+ "@terrafirmagreg-team/game": "^1.2.17",
29
+ "@terrafirmagreg-team/kit": "^1.2.37",
30
30
  "@terrafirmagreg-team/mdx": "^1.2.14",
31
31
  "@terrafirmagreg-team/preview": "^1.2.12",
32
32
  "@terrafirmagreg-team/sites": "^1.2.5",
33
- "@terrafirmagreg-team/translate": "^1.2.14",
34
- "@terrafirmagreg-team/ui": "^1.2.28",
33
+ "@terrafirmagreg-team/translate": "^1.2.16",
34
+ "@terrafirmagreg-team/ui": "^1.2.30",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { useMemo, useRef } from 'react';
4
4
  import { SlotHitbox } from '@terrafirmagreg-team/recipe/components/cards/slot-hitbox';
5
- import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
6
5
  import {
7
6
  cardStripGeo,
8
7
  countCoveredText,
@@ -120,7 +119,6 @@ export function RecipeCard({
120
119
  decoding="async"
121
120
  draggable={false}
122
121
  onError={onFail}
123
- style={recipeGlareFilter}
124
122
  />
125
123
  </>
126
124
  ) : null}
@@ -167,7 +165,7 @@ export function RecipeCard({
167
165
  />
168
166
  ))
169
167
  : null}
170
- {inView && interactive ? (
168
+ {inView ? (
171
169
  <CardWidgetTips
172
170
  widgets={recipe.widgets}
173
171
  entities={entities}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
4
4
  import { dumpTextString } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
5
+ import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
5
6
  import type { RecipeTextWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
6
7
 
7
8
  export function CardText({
@@ -26,7 +27,7 @@ export function CardText({
26
27
  : widget.text;
27
28
  if (!content) return null;
28
29
  const wrap = widget.type === 'paragraph';
29
- const rgb = (widget.color ?? 0xffffff) & 0xffffff;
30
+ const rgb = widgetTextColor(widget.color, widget.shadow === true);
30
31
  const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
31
32
  return (
32
33
  <span
@@ -45,15 +46,16 @@ export function CardText({
45
46
  ...(wrap ? { width: widget.w * scale } : {}),
46
47
  }),
47
48
  fontSize: size ?? 8 * scale,
49
+ fontWeight: 700,
48
50
  color: `#${rgb.toString(16).padStart(6, '0')}`,
49
51
  ...(widget.shadow === true
50
52
  ? {
51
- textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
53
+ textShadow: `${scale / 2}px ${scale / 2}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
52
54
  }
53
55
  : {}),
54
56
  }}
55
57
  >
56
- <McText text={content} surface="light" />
58
+ <McText text={content} surface="normal" />
57
59
  </span>
58
60
  );
59
61
  }
@@ -5,7 +5,6 @@ import { RecipeCard } from './card';
5
5
  import { SlotHitbox } from './slot-hitbox';
6
6
  import { StripCard } from './strip-card';
7
7
  import { ScrollCard } from './scroll-card';
8
- import { recipeGlareFilter } from './glare-filter';
9
8
  import { recipeGrid } from '@terrafirmagreg-team/recipe/lib/data/grid';
10
9
  import { recipeScroll } from '@terrafirmagreg-team/recipe/lib/data/scroll';
11
10
  import { recipeSlots } from '@terrafirmagreg-team/recipe/lib/browser/recipe-slots';
@@ -134,7 +133,6 @@ export function PagedCard({
134
133
  loading="lazy"
135
134
  decoding="async"
136
135
  onError={onFail}
137
- style={recipeGlareFilter}
138
136
  />
139
137
  {inView && !props.frameOnly
140
138
  ? slots
@@ -174,7 +172,6 @@ export function PagedCard({
174
172
  height={natural}
175
173
  style={{
176
174
  transform: `translateY(${-(natural - capH)}px)`,
177
- ...recipeGlareFilter,
178
175
  }}
179
176
  loading="lazy"
180
177
  decoding="async"
@@ -1,6 +1,13 @@
1
1
  'use client';
2
2
 
3
- import { useId, useMemo, useRef, useState, type ComponentProps } from 'react';
3
+ import {
4
+ useId,
5
+ useMemo,
6
+ useRef,
7
+ useState,
8
+ type ComponentProps,
9
+ type CSSProperties,
10
+ } from 'react';
4
11
  import { RecipeCard } from '@terrafirmagreg-team/recipe/components/cards/card';
5
12
  import { StripCardMember } from '@terrafirmagreg-team/recipe/components/cards/strip-card/member-cell';
6
13
  import { CardScrollbar } from '@terrafirmagreg-team/recipe/components/cards/controls/card-scrollbar';
@@ -9,11 +16,16 @@ import {
9
16
  type ScrollElement,
10
17
  type ScrollFrame,
11
18
  } from '@terrafirmagreg-team/recipe/lib/data/scroll';
19
+ import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
12
20
  import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
13
21
  import { dumpRelPublicUrl } from '@terrafirmagreg-team/dump/lib/dump/paths';
14
22
  import { useInView } from '@terrafirmagreg-team/ui/hooks/use-in-view';
15
23
  import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
16
24
  import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
25
+ import {
26
+ dumpTextLines,
27
+ dumpTextString,
28
+ } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
17
29
  import { stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
18
30
 
19
31
  const FALLBACK_PITCH = 18;
@@ -314,7 +326,8 @@ export function ScrollCard(props: Props) {
314
326
  : undefined;
315
327
 
316
328
  const renderText = (el: ScrollElement, index: number, moving: boolean) => {
317
- const rgb = (el.color ?? 0xffffff) & 0xffffff;
329
+ const rgb = widgetTextColor(el.color, true);
330
+ const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
318
331
  const x = (el.x - viewport.x) * scale;
319
332
  const y = (el.y - viewport.y) * scale;
320
333
  const shifted = (horizontal ? x : y) - (moving ? offset * scale : 0);
@@ -326,10 +339,21 @@ export function ScrollCard(props: Props) {
326
339
  left: horizontal ? shifted : x,
327
340
  top: horizontal ? y : shifted,
328
341
  fontSize: 8 * scale,
342
+ fontWeight: 700,
329
343
  color: `#${rgb.toString(16).padStart(6, '0')}`,
344
+ textShadow: `${scale / 2}px ${scale / 2}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
330
345
  }}
331
346
  >
332
- <McText text={el.text ?? ''} surface="dark" />
347
+ <McText
348
+ text={
349
+ (el.component
350
+ ? dumpTextString(props.langMap ?? {}, el.component)
351
+ : undefined) ||
352
+ el.text ||
353
+ ''
354
+ }
355
+ surface="dark"
356
+ />
333
357
  </span>
334
358
  );
335
359
  };
@@ -404,7 +428,11 @@ export function ScrollCard(props: Props) {
404
428
  x={0}
405
429
  y={0}
406
430
  pitch={el.w * scale}
407
- tooltipLines={el.tooltip}
431
+ tooltipLines={
432
+ el.tooltipComponents?.length
433
+ ? dumpTextLines(props.langMap ?? {}, el.tooltipComponents)
434
+ : el.tooltip
435
+ }
408
436
  interactive={interactive}
409
437
  tooltipLevel={slotTooltip}
410
438
  />
@@ -412,8 +440,11 @@ export function ScrollCard(props: Props) {
412
440
  ) : null}
413
441
  {el.label ? (
414
442
  <span
415
- className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
416
- style={{ fontSize: (el.w / 16) * 7 * scale }}
443
+ className="font-mc mc-count pointer-events-none absolute right-0 bottom-0 leading-none"
444
+ style={{
445
+ fontSize: (el.w / 16) * 7 * scale,
446
+ '--mc-count-shift': `${scale}px`,
447
+ } as CSSProperties}
417
448
  >
418
449
  {el.label}
419
450
  </span>
@@ -458,7 +489,11 @@ export function ScrollCard(props: Props) {
458
489
  y={0}
459
490
  pitch={cell}
460
491
  hideIcon
461
- tooltipLines={el.tooltip}
492
+ tooltipLines={
493
+ el.tooltipComponents?.length
494
+ ? dumpTextLines(props.langMap ?? {}, el.tooltipComponents)
495
+ : el.tooltip
496
+ }
462
497
  interactive={interactive}
463
498
  tooltipLevel={slotTooltip}
464
499
  />
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import type { CSSProperties } from 'react';
2
3
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
4
 
4
5
  import Link from 'next/link';
@@ -142,11 +143,12 @@ export function SlotHitbox({
142
143
  {widget.kind === 'tag' ? (
143
144
  <span
144
145
  aria-hidden
145
- className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-black"
146
+ className="font-mc mc-count pointer-events-none absolute top-0 left-0 leading-none"
146
147
  style={{
147
148
  paddingLeft: scale / 2,
148
149
  fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
149
- }}
150
+ '--mc-count-shift': `${scale}px`,
151
+ } as CSSProperties}
150
152
  >
151
153
  #
152
154
  </span>
@@ -163,7 +165,7 @@ export function SlotHitbox({
163
165
  widget.count !== undefined && widget.count > 1 ? (
164
166
  <span
165
167
  aria-hidden
166
- className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
168
+ className="font-mc mc-count pointer-events-none absolute right-0 bottom-0 leading-none"
167
169
  style={{
168
170
  paddingRight: scale,
169
171
  paddingBottom: scale,
@@ -171,7 +173,8 @@ export function SlotHitbox({
171
173
  (Math.min(widget.w, widget.h) / 16) *
172
174
  (widget.kind === 'fluid' ? 4 : 7) *
173
175
  scale,
174
- }}
176
+ '--mc-count-shift': `${scale}px`,
177
+ } as CSSProperties}
175
178
  >
176
179
  {widget.kind === 'fluid'
177
180
  ? formatFluidAmount(widget.count)
@@ -3,7 +3,6 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
4
  import { Fragment, useRef, useState } from 'react';
5
5
  import { SlotHitbox } from '@terrafirmagreg-team/recipe/components/cards/slot-hitbox';
6
- import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
7
6
  import { StripCardSprite } from '@terrafirmagreg-team/recipe/components/cards/strip-card/sprite';
8
7
  import {
9
8
  StripCardTagCopy,
@@ -101,7 +100,7 @@ export function StripCard({
101
100
  setMeasured({ src, h: event.currentTarget.naturalHeight })
102
101
  }
103
102
  />
104
- <div className="absolute inset-0" style={recipeGlareFilter}>
103
+ <div className="absolute inset-0">
105
104
  <Hint label={title}>
106
105
  <StripCardSprite
107
106
  src={src}
@@ -109,8 +109,10 @@ export function StripCardMember({
109
109
  )}
110
110
  {badges.length > 0 && (
111
111
  <span
112
- className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
113
- style={{ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7) }}
112
+ className="font-mc mc-count pointer-events-none absolute right-0 bottom-0 leading-none"
113
+ style={{
114
+ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7),
115
+ }}
114
116
  >
115
117
  {badges.join(' ')}
116
118
  </span>
@@ -9,6 +9,7 @@ import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
9
9
  import { RecipeToolbar } from '@terrafirmagreg-team/recipe/components/views/browser/toolbar';
10
10
  import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
11
11
  import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
12
+ import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
12
13
  import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
13
14
 
14
15
  type FeedList = {
@@ -26,6 +27,9 @@ export function RecipeFrame({
26
27
  strip,
27
28
  rail,
28
29
  back,
30
+ navPrev,
31
+ navNext,
32
+ onNavWheel,
29
33
  onPageChange,
30
34
  children,
31
35
  }: {
@@ -35,6 +39,9 @@ export function RecipeFrame({
35
39
  strip?: ReactNode;
36
40
  rail?: ReactNode;
37
41
  back?: { href: string; label: string };
42
+ navPrev?: ReactNode;
43
+ navNext?: ReactNode;
44
+ onNavWheel?: (dir: -1 | 1) => void;
38
45
  onPageChange?: (page: number) => void;
39
46
  children: ReactNode;
40
47
  }) {
@@ -62,45 +69,78 @@ export function RecipeFrame({
62
69
  <div className="min-w-0 flex-1">{strip}</div>
63
70
  </div>
64
71
  ) : null}
65
- <div className="flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border pb-2 pt-2">
66
- {back ? (
67
- <Link
68
- href={back.href}
69
- className="shrink-0 text-xs text-muted-foreground hover:text-foreground"
72
+ <div
73
+ className={cn(
74
+ 'grid items-center gap-x-3 border-b border-border pb-2 pt-2',
75
+ navPrev || navNext
76
+ ? 'grid-cols-[minmax(0,1fr)_minmax(0,360px)_minmax(0,1fr)]'
77
+ : 'grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]',
78
+ )}
79
+ >
80
+ <div className="flex min-w-0 justify-start">
81
+ {back ? (
82
+ <Link
83
+ href={back.href}
84
+ className="shrink-0 text-xs text-muted-foreground hover:text-foreground"
85
+ >
86
+ ← {back.label}
87
+ </Link>
88
+ ) : null}
89
+ </div>
90
+ {navPrev || navNext ? (
91
+ <div
92
+ onWheel={
93
+ onNavWheel
94
+ ? (event) => onNavWheel(event.deltaY > 0 ? 1 : -1)
95
+ : undefined
96
+ }
97
+ className="flex w-full max-w-90 min-w-0 items-center gap-2"
70
98
  >
71
- ← {back.label}
72
- </Link>
73
- ) : null}
74
- <div className="min-w-0 flex-1">{header}</div>
75
- <div className="ms-auto flex items-center gap-2">
99
+ {navPrev}
100
+ <div className="min-w-0 flex-1">{header}</div>
101
+ {navNext}
102
+ </div>
103
+ ) : (
104
+ <div className="min-w-0 max-w-full">{header}</div>
105
+ )}
106
+ <div className="flex min-w-0 items-center justify-self-end">
76
107
  <RecipeToolbar session={session} />
77
108
  </div>
78
109
  </div>
79
110
  {list ? (
80
- onPageChange ? (
81
- <Pager
82
- layout="center"
83
- page={list.page}
84
- pages={list.pages}
85
- to={list.to}
86
- total={list.total}
87
- label={t('{page}/{pages}', { note: 'recipe.page_of' })}
88
- className="pt-2"
89
- onPage={onPageChange}
90
- />
91
- ) : (
92
- <QueryPager
93
- dataset={session.dataset}
94
- params={{ ...session.nav, id: undefined }}
95
- query={session.query}
96
- list={list}
97
- label={t('{page}/{pages}', { note: 'recipe.page_of' })}
98
- className="pt-2"
99
- />
100
- )
111
+ <div
112
+ onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
113
+ className="mx-auto w-full max-w-90"
114
+ >
115
+ {onPageChange ? (
116
+ <Pager
117
+ layout="spread"
118
+ page={list.page}
119
+ pages={list.pages}
120
+ to={list.to}
121
+ total={list.total}
122
+ label={t('{page}/{pages}', { note: 'recipe.page_of' })}
123
+ className="pt-2"
124
+ onPage={onPageChange}
125
+ />
126
+ ) : (
127
+ <QueryPager
128
+ dataset={session.dataset}
129
+ params={{ ...session.nav, id: undefined }}
130
+ query={session.query}
131
+ list={list}
132
+ label={t('{page}/{pages}', { note: 'recipe.page_of' })}
133
+ className="pt-2"
134
+ />
135
+ )}
136
+ </div>
101
137
  ) : null}
102
- <div className="flex min-h-0 flex-1 gap-2 overflow-hidden pt-2">
103
- {rail}
138
+ <div className="relative flex min-h-0 flex-1 overflow-hidden pt-2">
139
+ {rail ? (
140
+ <div className="absolute start-0 top-2 bottom-0 z-10 flex flex-col">
141
+ {rail}
142
+ </div>
143
+ ) : null}
104
144
  <div
105
145
  onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
106
146
  className="flex min-w-0 flex-1 flex-col"
@@ -13,7 +13,6 @@ import {
13
13
  import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
14
14
  import { recipeConfig } from '@terrafirmagreg-team/recipe/lib/config';
15
15
  import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
16
- import { RecipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
17
16
  import { TypeView } from '@terrafirmagreg-team/recipe/components/views/browser/type-view';
18
17
  import { ItemView } from '@terrafirmagreg-team/recipe/components/views/browser/item-view';
19
18
  import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/calculator';
@@ -138,7 +137,6 @@ function RecipeBrowserContent({
138
137
 
139
138
  return (
140
139
  <EntryProvider dataset={dataset} lang={lang} langMap={session.langMap}>
141
- <RecipeGlareFilter />
142
140
  <div
143
141
  className={cn(
144
142
  'viewport-shell recipe-viewport not-prose flex w-full flex-col gap-3',
@@ -138,19 +138,22 @@ export function ItemView({ session }: { session: RecipeSession }) {
138
138
  }
139
139
  header={
140
140
  <div className="flex flex-col gap-1.5">
141
- <ItemViewHeader
142
- item={item}
143
- kind={kind}
144
- name={name}
145
- parsed={parsed}
146
- favorite={favorites.isFavorite(item)}
147
- onToggleFavorite={() => favorites.toggleItem(item)}
148
- onAddToCalc={() => addToCalc(item, kind)}
149
- />
141
+ <div className="mx-auto w-full max-w-90">
142
+ <ItemViewHeader
143
+ item={item}
144
+ kind={kind}
145
+ name={name}
146
+ parsed={parsed}
147
+ favorite={favorites.isFavorite(item)}
148
+ onToggleFavorite={() => favorites.toggleItem(item)}
149
+ onAddToCalc={() => addToCalc(item, kind)}
150
+ />
151
+ </div>
150
152
  <PaneTabs
151
153
  value={pane.pane}
152
154
  options={pane.options}
153
155
  onChange={pane.select}
156
+ className="mx-auto w-fit"
154
157
  />
155
158
  </div>
156
159
  }
@@ -27,9 +27,9 @@ export function ItemTagGroups({
27
27
  return <EmptyState variant="empty">{t('No tags for this item.', { note: 'recipe.empty_tags' })}</EmptyState>;
28
28
  }
29
29
  return (
30
- <div className="flex flex-col gap-3 pt-1">
30
+ <div className="flex flex-col items-center gap-3 pt-1">
31
31
  {groups.map(([tagKind, ids]) => (
32
- <div key={tagKind} className="flex flex-col gap-1.5">
32
+ <div key={tagKind} className="flex flex-col items-center gap-1.5">
33
33
  {groups.length > 1 && (
34
34
  <p className="text-xs font-medium text-muted-foreground">
35
35
  {tagKind === 'block'
@@ -37,7 +37,7 @@ export function ItemTagGroups({
37
37
  : t('Items', { note: 'recipe.tags_item' })}
38
38
  </p>
39
39
  )}
40
- <div className="flex flex-wrap gap-1">
40
+ <div className="flex flex-wrap justify-center gap-1">
41
41
  {ids.map((id) => {
42
42
  const bare = id.replace(/^#+/, '');
43
43
  return (
@@ -82,7 +82,7 @@ export function QueryPager({
82
82
  const resolved = useResolvedLang();
83
83
  return (
84
84
  <Pager
85
- layout="center"
85
+ layout="spread"
86
86
  page={list.page}
87
87
  pages={list.pages}
88
88
  to={list.to}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useRef } from 'react';
4
+ import { PagerArrow } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
4
5
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
5
6
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
6
7
  import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
@@ -105,6 +106,22 @@ export function TypeView({ session }: { session: RecipeSession }) {
105
106
  true,
106
107
  );
107
108
 
109
+ const goCategory = (dir: -1 | 1) => {
110
+ const cur = nonEmptyIds.indexOf(shown ?? '');
111
+ const next =
112
+ nonEmptyIds[(cur + dir + nonEmptyIds.length) % nonEmptyIds.length];
113
+ if (!next || next === shown) return;
114
+ replaceUrlState(
115
+ recipeHref(dataset, resolved, {
116
+ ...nav,
117
+ type: next,
118
+ id: undefined,
119
+ solo: undefined,
120
+ rpage: undefined,
121
+ }),
122
+ );
123
+ };
124
+
108
125
  const onSwipe = (dir: -1 | 1) => {
109
126
  if (recipeId) {
110
127
  const next = focusIndex + dir;
@@ -167,8 +184,30 @@ export function TypeView({ session }: { session: RecipeSession }) {
167
184
  }}
168
185
  />
169
186
  }
187
+ navPrev={
188
+ <PagerArrow
189
+ dir={-1}
190
+ label={t('Previous category', { note: 'recipe.axis.prev' })}
191
+ disabled={nonEmptyIds.length < 2}
192
+ onClick={() => goCategory(-1)}
193
+ />
194
+ }
195
+ navNext={
196
+ <PagerArrow
197
+ dir={1}
198
+ label={t('Next category', { note: 'recipe.axis.next' })}
199
+ disabled={nonEmptyIds.length < 2}
200
+ onClick={() => goCategory(1)}
201
+ />
202
+ }
203
+ onNavWheel={goCategory}
170
204
  header={
171
- <PlaceHeader session={session} overline={t('Categories', { note: 'recipe.axis_type' })} />
205
+ <div className="flex min-w-0 justify-center">
206
+ <PlaceHeader
207
+ session={session}
208
+ overline={t('Categories', { note: 'recipe.axis_type' })}
209
+ />
210
+ </div>
172
211
  }
173
212
  rail={
174
213
  <WorkstationRail
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { Check, CircleAlert, Share2, Trash2 } from 'lucide-react';
3
+ import { Check, CircleAlert, LoaderCircle, Share2, Trash2 } from 'lucide-react';
4
4
  import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
5
5
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
6
6
  import { RecipeToolbar } from '@terrafirmagreg-team/recipe/components/views/browser/toolbar';
@@ -11,6 +11,7 @@ import { useFeatureFlags } from '@terrafirmagreg-team/kit/hooks/use-features';
11
11
  export function CalcActions({
12
12
  session,
13
13
  shared,
14
+ sharing,
14
15
  shareError,
15
16
  shareFailed,
16
17
  onShare,
@@ -19,6 +20,7 @@ export function CalcActions({
19
20
  }: {
20
21
  session: RecipeSession;
21
22
  shared: boolean;
23
+ sharing?: boolean;
22
24
  shareError?: boolean;
23
25
  shareFailed?: boolean;
24
26
  onShare: () => void;
@@ -41,7 +43,7 @@ export function CalcActions({
41
43
  ) : null}
42
44
  <IconButton
43
45
  overlay
44
- disabled={flags?.share === false}
46
+ disabled={flags?.share === false || sharing}
45
47
  className={shareError ? 'text-red-500' : undefined}
46
48
  label={
47
49
  shared
@@ -52,7 +54,9 @@ export function CalcActions({
52
54
  }
53
55
  onClick={onShare}
54
56
  >
55
- {shared ? (
57
+ {sharing ? (
58
+ <LoaderCircle className="size-3.5 animate-spin" />
59
+ ) : shared ? (
56
60
  <Check className="size-3.5" />
57
61
  ) : shareError ? (
58
62
  <CircleAlert className="size-3.5" />
@@ -56,14 +56,17 @@ export function Calculator({ session }: { session: RecipeSession }) {
56
56
  const { focusNodeRef, onFocusNode, focusNodeId, setFocusNodeId } =
57
57
  useCalcFocus(cards);
58
58
  const { resetGen } = useCalcReset(activeTabId);
59
- const { displayCards, flushAmounts, onCrafts } = useCalcAmounts({
60
- cards,
61
- wires,
62
- tagSelections,
63
- persist,
64
- });
59
+ const { displayCards, pendingCrafts, flushAmounts, onCrafts } =
60
+ useCalcAmounts({
61
+ cards,
62
+ wires,
63
+ tagSelections,
64
+ resolved: deferredNodes,
65
+ persist,
66
+ });
65
67
  const {
66
68
  shared,
69
+ sharing,
67
70
  shareError,
68
71
  onShare,
69
72
  flowData,
@@ -101,8 +104,14 @@ export function Calculator({ session }: { session: RecipeSession }) {
101
104
  );
102
105
 
103
106
  const data = useMemo(
104
- () => ({ ...flowData, onCrafts, getRecipesForItem, ensureMaterial }),
105
- [flowData, onCrafts, getRecipesForItem, ensureMaterial],
107
+ () => ({
108
+ ...flowData,
109
+ onCrafts,
110
+ pendingCrafts,
111
+ getRecipesForItem,
112
+ ensureMaterial,
113
+ }),
114
+ [flowData, onCrafts, pendingCrafts, getRecipesForItem, ensureMaterial],
106
115
  );
107
116
 
108
117
  return (
@@ -150,6 +159,7 @@ export function Calculator({ session }: { session: RecipeSession }) {
150
159
  <CalcActions
151
160
  session={session}
152
161
  shared={shared}
162
+ sharing={sharing}
153
163
  shareError={shareError}
154
164
  shareFailed={shareFailed}
155
165
  onShare={onShare}