92 lines
2.8 KiB
HTML
92 lines
2.8 KiB
HTML
Voici un exemple de composant frontend complet en React avec Tailwind, un design moderne, responsive et animations CSS.
|
|
|
|
**index.html**
|
|
```html
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Composant Web</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
|
<link href="index.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<div class="container mx-auto p-4 pt-6 md:p-6 lg:p-12 xl:p-24">
|
|
<div class="bg-white shadow-md rounded-md p-4 md:p-6 lg:p-12 xl:p-24">
|
|
<h1 class="text-4xl font-bold mb-4">Composant Web</h1>
|
|
<p class="text-lg text-gray-600 mb-4">Un exemple de composant frontend complet en React avec Tailwind, un design moderne, responsive et animations CSS.</p>
|
|
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Cliquez ici</button>
|
|
</div>
|
|
</div>
|
|
<script src="index.js"></script>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
**index.css**
|
|
```css
|
|
.animated {
|
|
animation: fade-in 2s ease-in-out;
|
|
}
|
|
|
|
@keyframes fade-in {
|
|
0% {
|
|
opacity: 0;
|
|
transform: translateY(10px);
|
|
}
|
|
100% {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
@layer components {
|
|
@screen lg {
|
|
.bg-white {
|
|
background-color: #fff;
|
|
}
|
|
.shadow-md {
|
|
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.rounded-md {
|
|
border-radius: 0.5rem;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
**index.js**
|
|
```javascript
|
|
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
|
|
function ComposantWeb() {
|
|
return (
|
|
<div className="animate fade-in">
|
|
<h1>Titre du composant</h1>
|
|
<p>Contenu du composant</p>
|
|
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Cliquez ici</button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
root.render(
|
|
<React.StrictMode>
|
|
<ComposantWeb />
|
|
</React.StrictMode>
|
|
);
|
|
```
|
|
|
|
Cette solution utilise React pour créer un composant web complet avec un design moderne, responsive et animations CSS. Le fichier `index.html` contient le code intégré pour le composant web. Les fichiers `index.css` et `index.js` sont séparés pour faciliter la maintenance et la modification du code.
|
|
|
|
Notez que pour utiliser Tailwind CSS, vous devez ajouter le code suivant dans vos fichiers `index.css` et `index.js` :
|
|
```javascript
|
|
import tailwind from 'tailwind';
|
|
tailwind.config = {
|
|
// ...
|
|
};
|
|
```
|
|
|
|
Cependant, dans cet exemple simple, je n'ai pas utilisé de config personnalisée pour Tailwind CSS. Vous pouvez personnaliser les variables et les classes pour répondre à vos besoins spécifiques. |