Skip to content

Commit ac43580

Browse files
Hacksoresarah11918florian-lefebvre
authored
Tailwind v4 onboarding enhancements (#13119)
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
1 parent 828b7b3 commit ac43580

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.changeset/spotty-maps-sneeze.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Adds extra guidance in the terminal when using the `astro add tailwind` CLI command
6+
7+
Now, users are given a friendly reminder to import the stylesheet containing their Tailwind classes into any pages where they want to use Tailwind. Commonly, this is a shared layout component so that Tailwind styling can be used on multiple pages.

packages/astro/src/cli/add/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,19 @@ export async function add(names: string[], { flags }: AddOptions) {
361361
} to your project:\n${list}`,
362362
),
363363
);
364-
logger.info('SKIP_FORMAT', msg.success("Import './src/styles/global.css' in a layout"));
364+
if (integrations.find((integration) => integration.integrationName === 'tailwind')) {
365+
const code = boxen(
366+
getDiffContent('---\n---', "---\nimport './src/styles/global.css'\n---")!,
367+
{
368+
margin: 0.5,
369+
padding: 0.5,
370+
borderStyle: 'round',
371+
title: 'src/layouts/Layout.astro',
372+
},
373+
);
374+
logger.warn('SKIP_FORMAT', msg.actionRequired('You must import your Tailwind stylesheet, e.g. in a shared layout:\n'));
375+
logger.info('SKIP_FORMAT', code + '\n');
376+
}
365377
}
366378
}
367379

packages/astro/src/core/messages.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ export function failure(message: string, tip?: string) {
209209
.join('\n');
210210
}
211211

212+
export function actionRequired(message: string) {
213+
const badge = bgYellow(black(` action required `));
214+
const headline = yellow(message);
215+
return ['', `${badge} ${headline}`]
216+
.filter((v) => v !== undefined)
217+
.map((msg) => ` ${msg}`)
218+
.join('\n');
219+
}
220+
212221
export function cancelled(message: string, tip?: string) {
213222
const badge = bgYellow(black(` cancelled `));
214223
const headline = yellow(message);

0 commit comments

Comments
 (0)