Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Migration]: box -> boxNew #3669

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

[Migration]: box -> boxNew #3669

wants to merge 22 commits into from

Conversation

JulianNymark
Copy link
Contributor

Description

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation / Decision Records
  • Storybook
  • Style mappings (@navikt/core/css/config/_mappings.js)
  • Component tokens (@navikt/core/css/tokens.json)
  • CSS class deprecations (@navikt/aksel-stylelint/src/deprecations.ts)
  • Exports (@navikt/core/react/src/index.ts and @navikt/core/react/package.json)
  • New component? CSS import (@navikt/core/css/index.css)
  • Breaking change? Update migration guide. Consider codemod.
  • Changeset (Format: <Component>: <gitmoji?> <Text>. E.g. "Button: ✨ Add feature xyz.")

Copy link

changeset-bot bot commented Mar 17, 2025

⚠️ No Changeset found

Latest commit: 1d119bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@JulianNymark JulianNymark changed the title 🚧 box migration scaffolding 🚧 box migration Mar 18, 2025
@JulianNymark JulianNymark marked this pull request as ready for review March 18, 2025 12:37
@JulianNymark JulianNymark marked this pull request as draft March 18, 2025 12:38
Copy link
Contributor

github-actions bot commented Mar 24, 2025

Storybook demo / Chromatic

24124919d | 91 components | 135 stories

@JulianNymark JulianNymark marked this pull request as ready for review March 24, 2025 14:43
@JulianNymark JulianNymark changed the title 🚧 box migration [Migration]: box -> boxNew Mar 24, 2025
@JulianNymark
Copy link
Contributor Author

it's currently missing a change to using BoxNew (but does the logic w/ lookups into the legacyTokenConf object look ok?) it works in this one minimal test i made too, but i can't help but think it's missing something? (apart from BoxNew ofc) 🤔

@KenAJoh
Copy link
Collaborator

KenAJoh commented Mar 24, 2025

it's currently missing a change to using BoxNew (but does the logic w/ lookups into the legacyTokenConf object look ok?) it works in this one minimal test i made too, but i can't help but think it's missing something? (apart from BoxNew ofc) 🤔

Think it should work, token-name keys should match the names used for the props 🤞 But wouldn't hurt to skim over them to make sure.

@JulianNymark
Copy link
Contributor Author

JulianNymark commented Mar 27, 2025

Decided to not be as cool and preserve existing localName, if you get the new box, it will always become BoxNew in code... I think this in a way makes it easier to search across your entire repo later and know you got all the boxes, but if you had AkselBox or SpecialBoxName somewhere in your codebase, it might be easier to miss if they kept that name?🤔. It's also fairly KISS to understand what's going on. old stuff is retained exactly as it was (only now your files get comments added to them).

suggestion, what about calling it something borderline overly verbose / ugly, but also indicate that it's "our" box, like AkselBoxNew? I think the intended DX here is that you have to look through every instance of all your boxes is code (old and new) and unify them, so you manually migrate all the old ones that couldn't be automigrated, and then renaming all the new ones to have the same / minimal name of Box. 🤔

There really doesn't seem to be a winning way of doing all the work for developers, we have to use two different names because there's no going around having multiple Box types during migration 😢. The more I think about it, the more I think i like Box for the new, and OldBox for the old ones... if everything migrates successfully, then you might be done already? (you might want to keep the name Box as is, since it's a short and simple name?. Increased chance of collisions with some other generic Box an app might have, but I also have a hunch that very few will have multiple Boxes in their app (in Nav apps).

Copy link
Collaborator

@KenAJoh KenAJoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code errors on build now, so cant test

[@navikt/aksel]: src/codemod/transforms/darkside/box-to-boxnew/box-to-boxnew.ts(68,43): error TS2339: Property 'name' does not exist on type 'JSXIdentifier | JSXNamespacedName | JSXMemberExpression'.
[@navikt/aksel]:   Property 'name' does not exist on type 'JSXMemberExpression'.
[@navikt/aksel]: src/codemod/transforms/darkside/box-to-boxnew/box-to-boxnew.ts(69,43): error TS2339: Property 'name' does not exist on type 'JSXIdentifier | JSXNamespacedName | JSXMemberExpression'.
[@navikt/aksel]:   Property 'name' does not exist on type 'JSXMemberExpression'.
[@navikt/aksel]: src/codemod/transforms/spacing/primitives-spacing/spacing.ts(5,3): error TS2724: '"../../../utils/ast"' has no exported member named 'findProp'. Did you mean 'findProps'?
[@navikt/aksel]: Process exited (exit code 2), completed in 1s 992ms

@JulianNymark
Copy link
Contributor Author

@KenAJoh nice idempotency tests! (i forgot about those completely)

@JulianNymark JulianNymark enabled auto-merge (squash) March 31, 2025 12:34
@JulianNymark JulianNymark requested a review from KenAJoh March 31, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants