oliver-zehentleitner / maity
clean-up: web shared modules: one svg/icon builder, every tab bar through M.tabBar, dom.js split
tsk-a0qgqqghf3m3 Open
From the web clean-up audit, area 17 (tsk-hgnbapyw7hnh), read at 80647565 (findings sent to lotse, seq 125424 and 125522). Line numbers are from 80647565, so re-check them on current main. These are mostly mechanical, structural changes with many call sites.
#6 and #47 Shared: SVG building and the icon root copied, tab bars built by hand (duplication).
- The SVG namespace constant is declared in app.js:2580, site-chrome.js:83, product-line.js:16, avatar.js:12, menu.js:16, board-edit.js:124, paths.js:17, statistics.js:14 and swarm.js:15.
- app.js uses it in mark() at :296 but declares it at :2580.
- The same svg(tag, attrs) helper exists in avatar.js:14-18, paths.js:218-222, product-line.js:28-32, statistics.js:39-43 and site-chrome.js:87-91.
- The 6-attribute icon root is copied 7 times in menu.js (31, 45, 56, 67, 80, 96, 112), plus app.js:296-302 and board-edit.js:124-136.
- The Maity mark is drawn three ways: site-chrome.js home(), product-line.js maityMark(), and the loader in app.js:2581 plus its inline copy in index.html.
- M.icons lives in menu.js:134.
- Tab bars: M.tabBar (page-head.js:14) has 3 callers. The same nav is hand-built in account.js:342-345, overview.js:278-280, visitor.js:261-263, member-page.js:277-278 and app.js:1820-1821. The last two have their own CSS (.member-tab, .settings-tabs) for the same thing.
- The language button group is built three times: auth-pages.js:65, landing.js:439 and landing.js:681.
- Proposal:
- M.dom.svg(tag, attrs, ...children) plus one icon() in a small icons.js that also takes M.icons. Draw the mark from one place.
- Every tab bar through M.tabBar, with an optional disabled item for the "later" tab in account.js. Merge the CSS.
- One M.langTabs.
- Effort S + M. Risk low-medium: visual, and e2e selectors on .member-tab.
#48 Shared: dom.js, page-head.js and avatar.js have outgrown their purpose (design).
- dom.js:1 calls itself "DOM helpers", but it also holds:
- member rendering: memberRef, memberChip, silentSince, dormantNote, managesText, handleIn/handleOf, aliasSaid, mentionSpans, ambiguousMention
- the contract word tables (WORDS, dom.js:461-477)
- sniffImage
- sendOnCtrlEnter
That is about 490 lines, mostly domain logic.
- page-head.js defines M.bringing (a permission policy) and M.joinMenu.
- avatar.js:353-363 hangs ten test-only hooks on the production M.avatar (held, REUSE_MAX, cached, watched, offPage, sweep, sized, cells, hueOf, picture).
- Proposal:
- Split the member helpers into member-ref.js, and move WORDS/word into words.js or next to trust.js.
- Leave dom.js with h, append, clear, keepImages and the URL guards.
- Move M.bringing into trust.js.
- Group the test hooks under M.avatar._test.
- Effort L. Risk medium: the script order in index.html.
Order:
- Do #48 last among the web clean-ups, or between them, because it moves helpers that other cards change.
- The tab-bar part conflicts with tsk-chtvqs62cd10 (Settings sub-tabs, PR #1741). Start after it.