Skip to content

Commit

Permalink
chore: more example
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Apr 28, 2024
1 parent 383a1a9 commit 3d20083
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
10 changes: 8 additions & 2 deletions examples/react-server/src/__snapshots__/basic.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ exports[`basic 1`] = `
0
</div>
<button
class="server-btn"
name="value"
value="-1"
>
-1
</button>
<button
class="server-btn"
name="value"
value="1"
>
Expand Down Expand Up @@ -84,10 +86,14 @@ exports[`basic 1`] = `
Count:
0
</div>
<button>
<button
class="client-btn"
>
-1
</button>
<button>
<button
class="client-btn"
>
+1
</button>
</div>
Expand Down
27 changes: 27 additions & 0 deletions examples/react-server/src/routes/_client.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* based on https://github.com/remix-run/remix/blob/4a23e6e3a861238ea5ad285c7d436102bdd43564/templates/remix-tutorial/app/app.css#L32 */

.client-btn {
background-color: #fdd;
font-size: 1rem;
font-family: inherit;
border: none;
border-radius: 8px;
padding: 0.5rem 0.75rem;
box-shadow:
0 0px 1px hsla(0, 0%, 0%, 0.2),
0 1px 2px hsla(0, 0%, 0%, 0.2);
line-height: 1.5;
margin: 0.4rem;
font-weight: 500;
}

.client-btn:hover {
box-shadow:
0 0px 1px hsla(0, 0%, 0%, 0.6),
0 1px 2px hsla(0, 0%, 0%, 0.2);
}

.client-btn:active {
box-shadow: 0 0px 1px hsla(0, 0%, 0%, 0.4);
transform: translateY(1px);
}
5 changes: 3 additions & 2 deletions examples/react-server/src/routes/_client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import "./_client.css";
import React from "react";
import { checkAnswer } from "./_action";

Expand All @@ -16,10 +17,10 @@ export function ClientComponent() {
<h4>Hello Client Component</h4>
<div data-hydrated={hydrated}>hydrated: {String(hydrated)}</div>
<div>Count: {count}</div>
<button className="btn" onClick={() => setCount((v) => v - 1)}>
<button className="client-btn" onClick={() => setCount((v) => v - 1)}>
-1
</button>
<button className="btn" onClick={() => setCount((v) => v + 1)}>
<button className="client-btn" onClick={() => setCount((v) => v + 1)}>
+1
</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions examples/react-server/src/routes/_server.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* based on https://github.com/remix-run/remix/blob/4a23e6e3a861238ea5ad285c7d436102bdd43564/templates/remix-tutorial/app/app.css#L32 */

.btn {
.server-btn {
background-color: #ddf;
font-size: 1rem;
font-family: inherit;
border: none;
Expand All @@ -9,19 +10,18 @@
box-shadow:
0 0px 1px hsla(0, 0%, 0%, 0.2),
0 1px 2px hsla(0, 0%, 0%, 0.2);
background-color: white;
line-height: 1.5;
margin: 0.4rem;
font-weight: 500;
}

.btn:hover {
.server-btn:hover {
box-shadow:
0 0px 1px hsla(0, 0%, 0%, 0.6),
0 1px 2px hsla(0, 0%, 0%, 0.2);
}

.btn:active {
.server-btn:active {
box-shadow: 0 0px 1px hsla(0, 0%, 0%, 0.4);
transform: translateY(1px);
}
4 changes: 2 additions & 2 deletions examples/react-server/src/routes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function ServerActionDemo() {
<h4>Hello Server Action</h4>
<form action={changeCounter}>
<div>Count: {getCounter()}</div>
<button className="btn" name="value" value={-1}>
<button className="server-btn" name="value" value={-1}>
-1
</button>
<button className="btn" name="value" value={+1}>
<button className="server-btn" name="value" value={+1}>
+1
</button>
</form>
Expand Down

0 comments on commit 3d20083

Please sign in to comment.