Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Tailwind CSS Toggle Feature #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 44 additions & 31 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
/* Reset default margins and set full height */
html, body {
margin: 0;
padding: 0;
height: 100%;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
#root {
height: 100%;
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
.page-wrapper {
min-height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
.card-container {
width: 24rem;
background-color: #1f2937;
border-radius: 0.5rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
padding: 2rem;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.card {
padding: 2em;
.card-tailwind {
height: 8rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.read-the-docs {
color: #888;
.card-title {
font-size: 1.5rem;
font-weight: bold;
color: white;
margin-bottom: 2rem;
}

.title-tailwind {
color: transparent;
background-image: linear-gradient(to right, #bfdbfe, #a5f3fc);
background-clip: text;
-webkit-background-clip: text;
margin-bottom: 1rem;
}
44 changes: 34 additions & 10 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
import { useState } from 'react'
import './App.css'

function App() {
const [count, setCount] = useState(0)
const styles = {
default: {
toggle: 'fixed top-6 right-6 bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600 transition-colors',
button: 'bg-white text-gray-800 px-6 py-2 rounded-lg font-semibold hover:bg-gray-100 transition-colors'
},
tailwind: {
toggle: 'fixed top-6 right-6 bg-gradient-to-r from-blue-500 to-blue-600 text-white px-6 py-3 rounded-lg font-bold text-lg shadow-lg hover:from-blue-600 hover:to-blue-700 transition-all duration-200',
button: 'bg-gradient-to-r from-blue-500 to-cyan-500 text-white px-6 py-2 rounded-lg font-semibold hover:from-blue-600 hover:to-cyan-600 transition-all duration-300 shadow-lg transform hover:scale-105'
}
}

export default function App() {
const [count, setCount] = useState(0)
const [isTailwind, setIsTailwind] = useState(false)

const s = isTailwind ? styles.tailwind : styles.default

return (
<>
<h1>Technical Evaluation</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
<div className="page-container">
<button
onClick={() => setIsTailwind(!isTailwind)}
className={s.toggle}
>
{isTailwind ? 'Disable' : 'Enable'} Tailwind
</button>

<div className={`card-container ${isTailwind ? 'card-tailwind' : ''}`}>
<h1 className={`card-title ${isTailwind ? 'title-tailwind' : ''}`}>
Technical Evaluation
</h1>
<button
onClick={() => setCount(count + 1)}
className={s.button}
>
count is {count}
</button>
</div>
</>
</div>
)
}

export default App
}
12 changes: 12 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}