Dessert Box 项目教程

Dessert Box 项目教程

dessert-boxAn utility to create a Box component from your vanilla-extract + sprinkles tokens.项目地址:https://gitcode.com/gh_mirrors/de/dessert-box

1. 项目的目录结构及介绍

Dessert Box 项目的目录结构如下:

dessert-box/
├── src/
│   ├── atoms.css.ts
│   ├── Box.tsx
│   ├── styledComponents.css.ts
│   └── App.tsx
├── package.json
├── tsconfig.json
├── README.md
└── ...

目录结构介绍

  • src/: 项目的源代码目录,包含主要的 TypeScript 文件。

    • atoms.css.ts: 定义了原子样式(atoms)的文件,使用 vanilla-extract 和 sprinkles 创建。
    • Box.tsx: 创建 Box 组件的文件,使用 createBox 函数。
    • styledComponents.css.ts: 定义了 styled-components 风格的组件。
    • App.tsx: 项目的入口文件,展示了如何使用 Box 组件。
  • package.json: 项目的依赖管理文件,包含了项目的依赖包和脚本命令。

  • tsconfig.json: TypeScript 的配置文件,定义了 TypeScript 编译器的选项。

  • README.md: 项目的说明文档,包含了项目的介绍、安装和使用方法。

2. 项目的启动文件介绍

项目的启动文件是 src/App.tsx,它是项目的入口文件,展示了如何使用 Box 组件。

// src/App.tsx
import React from 'react';
import { StyledHeadline } from './styledComponents.css';

function App() {
  return (
    <StyledHeadline>I have 0 runtime styles 🤯</StyledHeadline>
  );
}

export default App;

启动文件介绍

  • App.tsx: 这是项目的入口文件,使用了 StyledHeadline 组件,展示了如何在没有运行时样式的情况下使用组件。

3. 项目的配置文件介绍

package.json

package.json 文件包含了项目的依赖包和脚本命令。

{
  "name": "dessert-box",
  "version": "1.0.0",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "dependencies": {
    "@dessert-box/react": "^1.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  },
  "devDependencies": {
    "@types/react": "^17.0.3",
    "@types/react-dom": "^17.0.3",
    "typescript": "^4.2.3"
  }
}

tsconfig.json

tsconfig.json 文件定义了 TypeScript 编译器的选项。

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src"]
}

配置文件介绍

  • package.json: 包含了项目的依赖包和脚本命令,定义了项目的启动、构建和测试命令。
  • tsconfig.json: 定义了 TypeScript 编译器的选项,确保 TypeScript 代码能够正确编译。

通过以上介绍,您可以更好地理解 Dessert Box 项目的目录结构、启动文件和配置文件,从而更高效地进行开发和维护。

dessert-boxAn utility to create a Box component from your vanilla-extract + sprinkles tokens.项目地址:https://gitcode.com/gh_mirrors/de/dessert-box

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黎启炼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值