@typestyles/migrate 0.0.0-unstable.f96b13308930 → 0.0.0-unstable.fafbc20d2cdc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @typestyles/migrate
2
2
 
3
- CLI codemods for migrating from **styled-components** and **Emotion** to [typestyles](https://github.com/type-styles/typestyles).
3
+ CLI codemods for migrating from **styled-components** and **Emotion** to [typestyles](https://github.com/phthalo-dev/typestyles).
4
4
 
5
5
  Moving off runtime CSS-in-JS is often the hardest part of adopting typestyles. This package automates the boring, safe transforms so you can focus on prop-based dynamics (`createVar` / `assignVars`) and design tokens — the parts that need human judgment.
6
6
 
@@ -8,18 +8,18 @@ Full migration guide: [typestyles.dev/docs/migration](https://typestyles.dev/doc
8
8
 
9
9
  ## What it transforms
10
10
 
11
- | Source | Becomes |
12
- | ----------------------------------- | --------------------------------------------------- |
13
- | `styled.div\`...\`` | `styles.class('div', { ... })` + `className` on JSX |
14
- | `styled(Button)\`...\`` | `styles.class('button', { ... })` + `className` |
15
- | `` css`...` `` (Emotion) | `styles.class(...)` |
16
- | Static template literals | CSS object properties (via PostCSS parser) |
17
- | `` `${props => props.x}` `` | `createVar` + `assignVars` + `styles.class` |
18
- | `` `${props => props.x ? A : B}` `` | `styles.component` variants + JSX rewrite |
19
- | `` `${({ x }) => x}` `` | `createVar` + `assignVars` (destructured params) |
20
- | `@media` in templates | Nested `'@media (…)'` objects in style definitions |
11
+ | Source | Becomes |
12
+ | ----------------------------------- | -------------------------------------------------- |
13
+ | `styled.div\`...\`` | `style('div', { ... })` + `className` on JSX |
14
+ | `styled(Button)\`...\`` | `style('button', { ... })` + `className` |
15
+ | `` css`...` `` (Emotion) | `style(...)` |
16
+ | Static template literals | CSS object properties (via PostCSS parser) |
17
+ | `` `${props => props.x}` `` | `createVar` + `assignVars` + `style` |
18
+ | `` `${props => props.x ? A : B}` `` | `recipe` variants + JSX rewrite |
19
+ | `` `${({ x }) => x}` `` | `createVar` + `assignVars` (destructured params) |
20
+ | `@media` in templates | Nested `'@media (…)'` objects in style definitions |
21
21
 
22
- The codemod rewrites JSX usage for styled components it can safely transform and adds the required `import { styles } from 'typestyles'`.
22
+ The codemod rewrites JSX usage for styled components it can safely transform and adds `createTypeStyles` plus a `style` binding when needed (`import { createTypeStyles } from 'typestyles'`).
23
23
 
24
24
  ## What it skips (with warnings)
25
25
 
@@ -29,7 +29,7 @@ Honest automation beats silent breakage:
29
29
  - **Exported styled components** — avoids changing your public API shape without review
30
30
  - **Non-JSX references** to styled component variables
31
31
 
32
- Prop-based patterns like `` `${props => props.color}` `` and `` `${(props) => props.width}px` `` are converted to [`createVar` + `assignVars`](https://typestyles.dev/docs/dynamic-styles). Boolean prop ternaries like `` `${props => props.primary ? '#0066ff' : '#6b7280'}` `` become `styles.component` variants. Suffix text after the interpolation (e.g. `px`) is applied at the call site.
32
+ Prop-based patterns like `` `${props => props.color}` `` and `` `${(props) => props.width}px` `` are converted to [`createVar` + `assignVars`](https://typestyles.dev/docs/dynamic-styles). Boolean prop ternaries like `` `${props => props.primary ? '#0066ff' : '#6b7280'}` `` become `recipe` variants. Suffix text after the interpolation (e.g. `px`) is applied at the call site.
33
33
 
34
34
  ## Installation
35
35
 
@@ -107,9 +107,11 @@ export function App() {
107
107
  **After:**
108
108
 
109
109
  ```tsx
110
- import { styles } from 'typestyles';
110
+ import { createTypeStyles } from 'typestyles';
111
111
 
112
- const button = styles.class('button', {
112
+ const { style } = createTypeStyles();
113
+
114
+ const button = style('button', {
113
115
  padding: '8px 16px',
114
116
  background: '#0066ff',
115
117
  color: 'white',
@@ -124,7 +126,7 @@ export function App() {
124
126
  }
125
127
  ```
126
128
 
127
- For components with variants, follow up manually with `styles.component()` — see the [styled-components migration section](https://typestyles.dev/docs/migration#from-styled-components).
129
+ For components with variants, follow up manually with `recipe()` — see the [styled-components migration section](https://typestyles.dev/docs/migration#from-styled-components). Consider `createTypeStyles({ scopeId: 'your-app' })` for production apps.
128
130
 
129
131
  ## Programmatic API
130
132
 
@@ -150,7 +152,7 @@ await runMigration(process.cwd(), {
150
152
  1. **Dry-run** on a branch and review diffs
151
153
  2. **Fix warnings** — convert dynamic templates to vars or inline styles
152
154
  3. **Apply with `--write`**
153
- 4. **Refactor** repeated `styles.class` calls into `styles.component` with variants
155
+ 4. **Refactor** repeated `style()` calls into `recipe()` with variants
154
156
  5. **Add tokens** — replace hard-coded colors/spacing with `tokens.create`
155
157
  6. **Enable extraction** — add `@typestyles/vite` or your bundler plugin for production zero-runtime
156
158