· 2 min read · updated
Editing the CV's skills, per profile
A "Skills" section in the CV builder: every group as a <details> (closed), every skill of every profile with a checkbox ("on the CV") and its wording in a…
What we did
- A "Skills" section in the CV builder: every group as a
<details>(closed), every skill of every profile with a checkbox ("on the CV") and its wording in a text field, then my own skills with Add and Remove, and "Reset the skills for<profile>". - The changes are per profile (the mainframe CV can leave out what the web CV keeps), in
SkillEdits(edits.svelte.ts), saved to their ownlocalStoragekey,cv-builder-skills. - They're stored as changes to the YAML, not a copy of it:
onandoff(skill names that differ from the YAML),labels(my wording),added(mine, by group). A skill added to the YAML later still shows up, and Reset just forgets the changes. Switching a skill back to what the YAML says removes it fromon/off. - Export puts the edits in the file under
skills, and import reads them back. storage.ts:loadJson/saveJsonand the checks (isObject,strings,stringRecord), shared by both classes. Skills carry their YAMLnameas a stable key.
What I learned
a ??= bevaluates tob, the plain object I passed in, not the$stateproxy it became. Changes made through the plain object aren't seen. So:this.all[profile] ??= {…}, then readthis.all[profile]back.- Reading must never write: the page calls
get(profile)while it renders, so it returns a shared empty object for a profile with no changes; only the write methods create one. - Function bindings (
bind:checked={() => get, (v) => set}) let a checkbox read and write something computed, here "is it on the CV", which is the YAML plus my changes. isObject(x): x is Record<string, unknown>is a type guard: after theif, TypeScript knows the type.filter((entry): entry is [string, string] => …)does the same forfilter.- Focus after Add goes to the new field (after
tick(), once it's on the page); after Remove, to "Add a skill" nearby, not<body>. :checkboxis jQuery, not CSS.[type='checkbox']it is.
Links
- Svelte: function bindings
- Svelte: tick
- MDN: logical nullish assignment (??=)
- TypeScript: type predicates
- MDN: accent-color
Next
- Use it for real: edit the skills for each profile and print the three CVs. Then the Phase 5.5 PR.