From 09ce97e26355281d1f7c87594ce5bba7117dfb3d Mon Sep 17 00:00:00 2001 From: Kenny Lin Date: Tue, 17 Nov 2026 16:58:12 -0500 Subject: [PATCH 1/3] feat(gamut): make ProgressBar variant optional with a default Co-Authored-By: Claude Haiku 5.5 --- packages/gamut/src/ProgressBar/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gamut/src/ProgressBar/index.tsx b/packages/gamut/src/ProgressBar/index.tsx index 560f2e016e..8af21cb9a9 100644 --- a/packages/gamut/src/ProgressBar/index.tsx +++ b/packages/gamut/src/ProgressBar/index.tsx @@ -25,7 +25,7 @@ export type ProgressBarProps = { /** * Base variant display themes. */ - variant: 'blue' | 'yellow' | 'default'; + variant?: 'blue' | 'yellow' | 'default'; /** * Whether to flatten the bottom or top of the progress bar. @@ -167,7 +167,7 @@ export const ProgressBar: React.FC = ({ percent, pattern: Pattern, size = 'sm', - variant, + variant = 'default', }) => { const showBarBorder = percent > 0 || minimumPercent > 0; const id = React.useId(); From 44bc92687e372e5d8ff34450c411246ff7ad3d64 Mon Sep 17 00:00:00 2001 From: Kenny Lin Date: Tue, 17 Nov 2026 16:58:14 -0500 Subject: [PATCH 2/3] feat(gamut-codemods): add size-and-alignment preset Renames Select sizeVariant to size and converts size values to sm/md/lg and left/right alignment values to start/end on Gamut components, scoped to components imported from @skillsoft/gamut. Co-Authored-By: Claude Haiku 5.5 --- packages/gamut-codemods/README.md | 29 +++- packages/gamut-codemods/src/lib/manifest.ts | 19 +++ packages/gamut-codemods/src/lib/run-source.ts | 1 + .../__testfixtures__/alignment.input.tsx | 10 ++ .../__testfixtures__/alignment.output.tsx | 10 ++ .../__testfixtures__/dynamic.input.tsx | 5 + .../__testfixtures__/dynamic.output.tsx | 5 + .../__testfixtures__/dynamic.warnings.json | 1 + .../__testfixtures__/scoped.input.tsx | 13 ++ .../__testfixtures__/scoped.output.tsx | 13 ++ .../__testfixtures__/select-rename.input.tsx | 8 + .../__testfixtures__/select-rename.output.tsx | 8 + .../__testfixtures__/sizes.input.tsx | 13 ++ .../__testfixtures__/sizes.output.tsx | 13 ++ .../src/migrations/prop-values/index.ts | 144 ++++++++++++++++++ packages/gamut-codemods/src/presets/index.ts | 2 + .../src/presets/size-and-alignment/index.ts | 17 +++ .../presets/size-and-alignment/manifest.ts | 110 +++++++++++++ packages/gamut-codemods/src/transform.test.ts | 9 +- 19 files changed, 426 insertions(+), 4 deletions(-) create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.input.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.output.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.input.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.output.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.warnings.json create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/scoped.input.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/scoped.output.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/select-rename.input.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/select-rename.output.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/sizes.input.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/sizes.output.tsx create mode 100644 packages/gamut-codemods/src/migrations/prop-values/index.ts create mode 100644 packages/gamut-codemods/src/presets/size-and-alignment/index.ts create mode 100644 packages/gamut-codemods/src/presets/size-and-alignment/manifest.ts diff --git a/packages/gamut-codemods/README.md b/packages/gamut-codemods/README.md index b552c85940..1e20a3d379 100644 --- a/packages/gamut-codemods/README.md +++ b/packages/gamut-codemods/README.md @@ -6,12 +6,35 @@ Codemods for moving a repo onto `@skillsoft/gamut` and between its releases. Each preset is one upgrade. Run them in order if you're more than one behind. -| Preset | What it's for | -| ------------ | ------------------------------------------------------- | -| `scope-swap` | Moving from `@codecademy/gamut*` to `@skillsoft/gamut*` | +| Preset | What it's for | +| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| `scope-swap` | Moving from `@codecademy/gamut*` to `@skillsoft/gamut*` | +| `size-and-alignment` | Size values move to `sm` / `md` / `lg`, Select's `sizeVariant` becomes `size`, and left / right alignment values become `start` / `end` | `npx @skillsoft/gamut-codemods list` shows every preset and the migrations inside it. +## Running size-and-alignment + +Run it on code that already imports `@skillsoft/gamut`. Consumers still on `@codecademy/gamut` run `scope-swap` first. + +```sh +# Preview without writing anything +npx @skillsoft/gamut-codemods size-and-alignment . --dry + +# Run it +npx @skillsoft/gamut-codemods size-and-alignment . +``` + +It rewrites JSX attributes on the components listed in `src/presets/size-and-alignment/manifest.ts`, and only when the component is imported from `@skillsoft/gamut`. A local component with the same name, or the same prop on a component that isn't listed (Modal's `size`, for example), is left alone. Aliased imports work. + +- **Sizes:** `size` on Button, Input, Toggle, SelectDropdown, ProgressBar, Badge, and DatePicker's `inputSize`, plus `labelSize` on FormGroup and ConnectedFormGroup, and `size` on FormGroupLabel. Old values map to the new scale. +- **Select:** `sizeVariant` is renamed to `size`, with `small` → `sm` and `base` → `md`. +- **Alignment:** `left` / `right` become `start` / `end` for `iconPosition`, `buttonPlacement`, `alignContentContainer`, `openFrom`, `menuAlignment`, Popover `align` and `beak`, Coachmark `beak`, and GridForm `layout`. Tip and PopoverContainer `alignment` values like `top-left` and `left-center` map to their `start` / `end` forms. + +Only string literals are converted, as `prop="old"` or `prop={'old'}`. Any other expression for a prop that has values to convert gets a warning, so check it by hand. + +Not covered, so check these by hand: values in object literals (such as DataList column `justify`), `textAlign` on `Text`, `position` on GridForm fields, and any prop read from a variable. + ## Running scope-swap Start from a clean working tree. The codemod won't write into uncommitted changes (pass `--force` to override), so `git checkout .` always undoes a run. diff --git a/packages/gamut-codemods/src/lib/manifest.ts b/packages/gamut-codemods/src/lib/manifest.ts index 1e667af00e..0ba3c78154 100644 --- a/packages/gamut-codemods/src/lib/manifest.ts +++ b/packages/gamut-codemods/src/lib/manifest.ts @@ -48,9 +48,28 @@ export interface DeepImport { note?: string; } +export interface PropChange { + /* The prop's new name, when the prop itself was renamed. */ + rename?: string; + /* Old string value -> new string value. Other values are left alone. */ + values?: Record; +} + +export interface ComponentPropChanges { + /* + The package whose components are matched. This is the NEW name, since + these rules run on code that already imports @skillsoft/gamut. + */ + package: string; + /* Component export name -> prop name -> change. */ + components: Record>; +} + export interface Manifest { /* Old package -> new package. */ packages: Record; + /* Prop renames and value changes on specific components, by name. */ + componentProps?: ComponentPropChanges; /* Packages with no replacement under the new name. */ removedPackages: Record; /* Version range written to package.json, keyed by NEW package name. */ diff --git a/packages/gamut-codemods/src/lib/run-source.ts b/packages/gamut-codemods/src/lib/run-source.ts index 42eb019392..67373fb5fb 100644 --- a/packages/gamut-codemods/src/lib/run-source.ts +++ b/packages/gamut-codemods/src/lib/run-source.ts @@ -95,6 +95,7 @@ export const mentionsOldNames = (manifest: Manifest, source: string) => ...Object.keys(manifest.packages), ...Object.keys(manifest.removedPackages), `${manifest.eslintPlugin.from}/`, + ...(manifest.componentProps ? [manifest.componentProps.package] : []), ].some((name) => source.includes(name)); /* `only` and `skip` are comma-separated migration names. */ diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.input.tsx b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.input.tsx new file mode 100644 index 0000000000..f36b86316f --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.input.tsx @@ -0,0 +1,10 @@ +import { Alert, InfoTip, Popover, PopoverContainer } from '@skillsoft/gamut'; + +export const Placement = () => ( + <> + Heads up + + + + +); diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.output.tsx b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.output.tsx new file mode 100644 index 0000000000..0ad719da28 --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/alignment.output.tsx @@ -0,0 +1,10 @@ +import { Alert, InfoTip, Popover, PopoverContainer } from '@skillsoft/gamut'; + +export const Placement = () => ( + <> + Heads up + + + + +); diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.input.tsx b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.input.tsx new file mode 100644 index 0000000000..a2252eb2f9 --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.input.tsx @@ -0,0 +1,5 @@ +import { FillButton } from '@skillsoft/gamut'; + +export const Dynamic = ({ size }: { size: string }) => ( + Go +); diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.output.tsx b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.output.tsx new file mode 100644 index 0000000000..a2252eb2f9 --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.output.tsx @@ -0,0 +1,5 @@ +import { FillButton } from '@skillsoft/gamut'; + +export const Dynamic = ({ size }: { size: string }) => ( + Go +); diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.warnings.json b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.warnings.json new file mode 100644 index 0000000000..4e03b4ba83 --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/dynamic.warnings.json @@ -0,0 +1 @@ +["FillButton size is not a string literal"] diff --git a/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/scoped.input.tsx b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/scoped.input.tsx new file mode 100644 index 0000000000..b9ed34f505 --- /dev/null +++ b/packages/gamut-codemods/src/migrations/prop-values/__testfixtures__/scoped.input.tsx @@ -0,0 +1,13 @@ +import { Badge as CodecademyBadge } from '@codecademy/gamut'; +import { FillButton as Btn, Modal } from '@skillsoft/gamut'; + +const Button = (props: { size: string }) => ; + +export const Scoped = () => ( + <> + Aliased +