Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code in Action

Claude Code in Action

In this section we will introduce how to use Claude Code to develop a Wall Street Journal-style news card application through our descriptive prompts.

Try not to write a single line of code throughout the process; use our natural language descriptions to let AI complete the entire project for us.

Goals: Create a Wall Street Journal-style news card generator using React + Tailwind CSS

Feature:

Tech Stack:


Complete development process

Phase 1: Project initialization)

Step 1: Create project structure

Open the terminal and start Claude Code:

cd ~/projects

claude

Enter in Claude Code:

我要创建一个新的 React 项目,使用 Vite 作为构建工具

项目名称:wsj-news-card-generator

要求:

1. 使用 Vite 创建 React 项目

2. 集成 Tailwind CSS

3. 添加必要的依赖:html2canvas(用于导出图片)

4. 创建清晰的文件夹结构



请给我完整的命令行步骤

Claude will return something like the following:

Claude Code gives complete operation steps; we can follow its instructions to complete project creation, then create files step by step and adjust gradually.

Alternatively, you can set it in the prompt to create automatically; make sure executable permission is granted.

During automatic creation there will be some prompts; just select yes and press Enter:

When done, a complete project structure is generated, as shown below:

Then, continue in Claude Code:

现在帮我配置 Tailwind CSS

Modify tailwind.config.js, add custom configuration:

1. 添加 WSJ 风格的颜色(深灰色文字、金色强调色)

2. 添加衬线字体(Playfair Display, Merriweather)

3. 扩展阴影效果

Claude will generate tailwind.config.js:

Continue configuring CSS:

修改 src/index.css,导入 Tailwind 和字体

Phase 2: Create core components

Step 2: Create project file structure

创建以下文件夹结构:

src/

  components/

    NewsCard.jsx          # 新闻卡片组件

    NewsCardEditor.jsx    # 编辑器组件

    ExportButton.jsx      # 导出按钮组件

  utils/

    exportImage.js        # 导出图片工具函数

  App.jsx

  main.jsx

During execution, select yes all the way:

Step 3: Develop the NewsCard component

创建 src/components/NewsCard.jsx

要求:

1. 华尔街日报经典风格的新闻卡片

2. 包含:大标题、副标题、正文摘要、作者、日期、分类标签

3. 可选的特色图片(如果提供)

4. 使用 Tailwind 类名,体现 WSJ 的排版美学

5. 添加金色装饰线条

6. 卡片尺寸:适合社交媒体分享(1200x630px)

During execution, select yes all the way:

Claude generates NewsCard.jsx:

Step 4: Create the editor component

创建 src/components/NewsCardEditor.jsx

要求:

1. 左侧是表单编辑区域

2. 右侧是实时预览区域

3. 表单包含:分类、标题、副标题、摘要、作者、日期、图片上传

4. 使用受控组件

5. 图片上传支持拖拽和点击

6. 优雅的表单设计,符合 WSJ 风格

Step 5: Create the export function

创建 src/components/ExportButton.jsx

要求:

1. 使用 html2canvas 导出卡片为 PNG

2. 显示加载状态

3. 点击后自动下载

 4. 优雅的按钮设计

Phase 3: Optimization and enhancement

Step 7: Add preset template function

在 NewsCardEditor 组件中添加预设模板功能

要求:

1. 创建 3-5 个不同主题的新闻模板

2. 用户可以快速选择模板

3. 选择后自动填充表单

4. 在编辑器上方显示模板选择器

Complete effect:

Let it change to content suitable for Chinese-language information

所有描述改为中文,适合生成中文信息的新闻

Complete effect: