Skip to content

Commit

Permalink
feat (frameworks/react): swr and tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Sep 4, 2024
1 parent 70e6989 commit 13c0052
Show file tree
Hide file tree
Showing 18 changed files with 6,431 additions and 8 deletions.
11 changes: 4 additions & 7 deletions full-stack/6-react-swr/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# React + Vite
# React + Swr

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
~~~
npm i swr
~~~
1 change: 0 additions & 1 deletion full-stack/6-react-swr/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from 'react'
import user1 from './assets/user1.svg'
import user2 from './assets/user2.svg'
import umbrellas from '/umbrellas.jpg'
Expand Down
24 changes: 24 additions & 0 deletions full-stack/7-react-swr-tailwind/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 17 additions & 0 deletions full-stack/7-react-swr-tailwind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# React + Tailwind

https://tailwindcss.com/docs/guides/vite

~~~
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
~~~

* file: `tailwind.config.js`
* replace `content: [],`
~~~
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
~~~
38 changes: 38 additions & 0 deletions full-stack/7-react-swr-tailwind/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import js from '@eslint/js'
import globals from 'globals'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: { react: { version: '18.3' } },
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
]
13 changes: 13 additions & 0 deletions full-stack/7-react-swr-tailwind/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading

0 comments on commit 13c0052

Please sign in to comment.