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

P1: [Darkside] Primitives spacing -> space migrations #3597

Merged
merged 13 commits into from
Mar 3, 2025
Merged

Conversation

KenAJoh
Copy link
Collaborator

@KenAJoh KenAJoh commented Feb 18, 2025

Description

This is the start of various migrations for new tokens.

  • Check every primtive using old Spacing-tokens
  • Update each prop for those primitives to use new space-token

Next up will be CSS, SCSS, Less and JS token migrations from a-spacing -> a-space.

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.")

Sorry, something went wrong.

Copy link

changeset-bot bot commented Feb 18, 2025

🦋 Changeset detected

Latest commit: 6d19a42

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Feb 18, 2025

Storybook demo / Chromatic

📝 Changes to review: 1

1b7d26ddb | 91 components | 135 stories

KenAJoh and others added 4 commits February 19, 2025 09:41
* ✨ Added migration for css, less and scsss

* Update @navikt/aksel/src/codemod/migrations.ts
@KenAJoh KenAJoh changed the title [Darkside] Primitives spacing -> space migrations P1: [Darkside] Primitives spacing -> space migrations Feb 19, 2025
Comment on lines +37 to +46

path.node.specifiers.forEach((specifier) => {
if (
specifier.type === "ImportSpecifier" &&
specifier.imported.name === name
) {
foundName = specifier.local
? specifier.local.name
: specifier.imported.name;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if we already discussed this, and I am not even sure i want it, but just in case we do --> should we add an option for default imports?

Suggested change
path.node.specifiers.forEach((specifier) => {
if (
specifier.type === "ImportSpecifier" &&
specifier.imported.name === name
) {
foundName = specifier.local
? specifier.local.name
: specifier.imported.name;
}
// Check for named imports
path.node.specifiers.forEach((specifier) => {
if (
specifier.type === "ImportSpecifier" &&
specifier.imported.name === name
) {
foundName = specifier.local
? specifier.local.name
: specifier.imported.name;
}
// Check for default imports. i.e.:
// import Box from "@navikt/ds-react/Box"
if (
specifier.type === "ImportDefaultSpecifier" &&
typeof path.node.source.value === "string" &&
path.node.source.value.endsWith(`/${name}`)
) {
foundName = specifier.local.name;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haven't really found any cases where this is used, but could make sense just in case. If we add this, we will need to handle the name differently since

import * as Box from "@navikt/ds-react/Box`

leads to components being used like

<Box.Box>

@KenAJoh KenAJoh merged commit 6728754 into main Mar 3, 2025
5 checks passed
@KenAJoh KenAJoh deleted the darkside-migration branch March 3, 2025 09:37
@github-actions github-actions bot mentioned this pull request Mar 3, 2025
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.

None yet

3 participants