refactor(libs): graduate Icon / LayoutStateService / brand tokens to libs/shared/* #99
Reference in New Issue
Block a user
Delete Branch "feat/portal-shell/libs-graduation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Per ADR-0020 §"Shared-libs graduation": the three primitives that
portal-shell(today) andportal-admin(next) will both share move out ofapps/portal-shell/src/and into the workspace libs. Mechanical move — no behaviour change, prepares the ground for the admin-app PR.Graduated
Iconcomponent (+IconNametype)apps/portal-shell/src/app/components/icon/libs/shared/ui/src/lib/icon/LayoutStateService(+ThemeModetype)apps/portal-shell/src/app/state/libs/shared/state/src/lib/@themeblockapps/portal-shell/src/styles.csslibs/shared/tokens/src/brand-tokens.cssNotable changes
app-icon→lib-icon. Required by the lib's ESLint@angular-eslint/component-selectorrule (prefixlibfor shared libs). All ~20 usages inportal-shelltemplates updated in one sweep.shared-statelibrary generated vianx g @nx/angular:library libs/shared/state. Mirrors the existingfeature-auth/shared-uishape (vite + Angular + spec setup).tsconfig.base.jsonpath aliasshared-stateadded by the generator.shared-state: new lib →scope:shared, type:shared.shared-ui: wasscope:portal-shell(scaffold default) →scope:shared, type:shared.shared-tokensis now CSS-only. The placeholder TS function is gone;index.tsis an emptyexport {}with a TODO note. Vitest config flipspassWithNoTests: trueso the test target stops failing on the empty lib.portal-shell'sstyles.cssdrops the inline@theme {}block and instead@imports../../../libs/shared/tokens/src/brand-tokens.css. Both apps will read the same source.shared-ui/src/lib/shared-ui/removed.Verification
nx run-many -t lint test buildacrossportal-shell, shared-ui, shared-state, shared-tokens— green.main— noise-level delta).--color-brand-primary-500: #12546c, …) still inlined in the producedstyles-*.css.dist/.../browser/{en,fr}/emitted as expected.What this PR explicitly does NOT do
portal-adminends up needing them, they graduate in their own PR.portal-admin. That's the next PR on the admin track — and now imports fromshared-ui/shared-state/shared-tokenswill Just Work.feature-auth's tagging. It still saysscope:portal-shell; revisit when the auth implementation actually lands and the dual-audience design (per ADR-0008) makes the right scope obvious.Test plan
pnpm exec nx serve portal-shell— the dev experience is unchanged.Per ADR-0020 §"Shared-libs graduation": the three primitives that both `portal-shell` (today) and `portal-admin` (next) will share move out of `apps/portal-shell/src/` and into the workspace libs. Mechanical move — no behaviour change. Graduated: - `Icon` component → `libs/shared/ui/src/lib/icon/`. Selector renamed `app-icon` → `lib-icon` (consumed via `<lib-icon>`), `IconName` re-exported from `shared-ui`. - `LayoutStateService` (+ `ThemeMode` type) → `libs/shared/state/src/lib/`. New library generated via `nx g @nx/angular:library` to match the existing `feature-auth` / `shared-ui` shape. - Brand-palette `@theme` block → `libs/shared/tokens/src/brand-tokens.css`. `portal-shell`'s `styles.css` imports it by relative path. Lib tags updated so the module-boundary lint rule lets both apps consume them: - `shared-state`: new lib → `scope:shared, type:shared`. - `shared-ui`: was `scope:portal-shell` (stopgap from the initial scaffold) → `scope:shared, type:shared`. Side-edits: - `tsconfig.base.json` gains the `shared-state` path alias (generator-applied). - `shared-tokens` is now CSS-only — its placeholder TS function is removed and its vitest config flips `passWithNoTests: true` since there is nothing to test there yet. - Placeholder `shared-ui/shared-ui.{ts,html,css,spec.ts}` files removed. Verification: - Lint / test / build run-many across the four projects — green. - portal-shell: 28 tests, shared-state: 9, shared-ui: 3 (= the same 40 specs as before, redistributed across the new libs). - Production build: 128.7 KB gzip initial per locale (was 128.5 KB on main — noise-level delta). - Brand tokens still inlined in the produced `styles-*.css`. - Both `dist/.../browser/{en,fr}/` emitted as expected. No public-API breakage. The migration to `portal-admin` is now a clean `import { Icon } from 'shared-ui'` + `LayoutStateService` inject + `@import` of `brand-tokens.css` on admin's `styles.css` — no duplication.