Skip to content

Commit b1a0134

Browse files
committed
add interaction
1 parent 18d821b commit b1a0134

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

app/interactive/button.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
5+
export default function Button() {
6+
const [isSpun, setIsSpun] = useState(false);
7+
8+
return (
9+
<button
10+
onClick={() => {
11+
setIsSpun((spun) => !spun);
12+
}}
13+
className={`
14+
${isSpun ? 'rotate-180' : ''}
15+
transition-transform
16+
rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600
17+
`}
18+
>
19+
Spin me!
20+
</button>
21+
);
22+
}

app/interactive/page.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// transition-transform
2+
3+
import Button from './button';
4+
5+
export const metadata = {
6+
title: 'I am awesome!',
7+
};
8+
9+
export default function Home() {
10+
return (
11+
<>
12+
<div className="border-b border-gray-200 pb-5 sm:flex sm:items-center sm:justify-between">
13+
<h2 className="text-base font-semibold leading-6 text-gray-900">
14+
Interactivity
15+
</h2>
16+
<div className="mt-3 flex sm:ml-4 sm:mt-0">
17+
<span className="text-sm text-gray-500 italic">Woo!</span>
18+
</div>
19+
</div>
20+
<div className="p-8 flex justify-center">
21+
<Button />
22+
</div>
23+
</>
24+
);
25+
}

app/interactive/x-page.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This won't work!
2+
3+
export const metadata = {
4+
title: 'I am awesome!',
5+
};
6+
7+
export default function Home() {
8+
return (
9+
<>
10+
<div className="border-b border-gray-200 pb-5 sm:flex sm:items-center sm:justify-between">
11+
<h2 className="text-base font-semibold leading-6 text-gray-900">
12+
Interactivity
13+
</h2>
14+
<div className="mt-3 flex sm:ml-4 sm:mt-0">
15+
<span className="text-sm text-gray-500 italic">Woo!</span>
16+
</div>
17+
</div>
18+
<div className="p-y-4 flex justify-end">
19+
<button
20+
onClick={() => {
21+
// do something
22+
}}
23+
className="rounded-md bg-indigo-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
24+
>
25+
Spin me!
26+
</button>
27+
</div>
28+
</>
29+
);
30+
}

0 commit comments

Comments
 (0)