Skip to content

Commit abc0837

Browse files
committed
Simplify react router demo
1 parent bb7056b commit abc0837

3 files changed

Lines changed: 24 additions & 23 deletions

File tree

client/app/bundles/comments/components/TestReactRouter/TestReactRouter.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import BaseComponent from '../../../../libs/components/BaseComponent.jsx';
55
export default class TestReactRouter extends BaseComponent {
66
render() {
77
return (
8-
<div className="container">
9-
<h1>React Router is working!</h1>
10-
<p>
11-
Woohoo, we can use <code>react-router</code> here!
8+
<div className="rounded-[2rem] border border-slate-200 bg-white/90 p-6 shadow-[0_24px_70px_-52px_rgba(15,23,42,0.5)] sm:p-7">
9+
<p className="text-xs font-semibold uppercase tracking-[0.22em] text-sky-700">Route Example</p>
10+
<h1 className="mt-3 text-4xl text-slate-900">React Router is working!</h1>
11+
<p className="mt-3 max-w-2xl text-sm leading-7 text-slate-600 sm:text-base">
12+
This route swaps the content area without leaving the router-enabled demo shell.
1213
</p>
1314
</div>
1415
);

client/app/bundles/comments/layout/Layout.jsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const routeLinkClassName = ({ isActive }) =>
77
classNames(
88
'inline-flex items-center rounded-full border px-4 py-2 text-sm font-semibold transition',
99
isActive
10-
? 'border-amber-300 bg-amber-300 text-slate-900 shadow-lg shadow-amber-200'
11-
: 'border-white/10 bg-white/5 text-slate-100 hover:border-sky-300/50 hover:bg-white/10 hover:text-white',
10+
? 'border-slate-900 bg-slate-900 text-white shadow-lg shadow-slate-200'
11+
: 'border-slate-200 bg-slate-50 text-slate-700 hover:border-sky-300 hover:bg-sky-50 hover:text-sky-700',
1212
);
1313

1414
/* eslint-disable react/prefer-stateless-function */
@@ -17,23 +17,23 @@ export default class Layout extends Component {
1717
const { children } = this.props;
1818

1919
return (
20-
<section className="space-y-8">
21-
<header className="overflow-hidden rounded-[2rem] bg-slate-900 px-6 py-7 text-slate-100 shadow-[0_26px_70px_-42px_rgba(15,23,42,0.7)] sm:px-8">
20+
<section className="space-y-6">
21+
<header className="rounded-[2rem] border border-slate-200 bg-white/90 px-6 py-7 shadow-[0_24px_60px_-46px_rgba(15,23,42,0.35)] sm:px-8">
2222
<div className="max-w-3xl">
23-
<p className="text-xs font-semibold uppercase tracking-[0.28em] text-sky-300">
24-
Router Playground
23+
<p className="text-xs font-semibold uppercase tracking-[0.28em] text-sky-700">
24+
React Router Demo
2525
</p>
26-
<h2 className="mt-3 text-3xl text-white sm:text-4xl">Switch between the three router states.</h2>
27-
<p className="mt-3 max-w-2xl text-sm leading-7 text-slate-300 sm:text-base">
28-
Root comments, a route transition, and a redirect all live in this same server-rendered bundle.
26+
<h2 className="mt-3 text-3xl text-slate-900 sm:text-4xl">The same comments app, with routing.</h2>
27+
<p className="mt-3 max-w-2xl text-sm leading-7 text-slate-600 sm:text-base">
28+
Use the pills to view the comments route, a plain routed screen, and a redirect back to root.
2929
</p>
3030
</div>
3131

32-
<details className="mt-5 rounded-2xl border border-white/10 bg-white/5 p-4">
33-
<summary className="cursor-pointer text-sm font-semibold text-white">
34-
Why this section exists
32+
<details className="mt-5 rounded-2xl border border-slate-200 bg-slate-50 p-4">
33+
<summary className="cursor-pointer text-sm font-semibold text-slate-900">
34+
What this demo proves
3535
</summary>
36-
<ul className="mt-3 space-y-2 text-sm text-slate-300">
36+
<ul className="mt-3 space-y-2 text-sm text-slate-600">
3737
<li>Server render first, then hydrate on the client.</li>
3838
<li>Keep routing and comments in the same Redux-backed flow.</li>
3939
<li>Verify redirects still resolve cleanly after SSR.</li>
@@ -42,13 +42,13 @@ export default class Layout extends Component {
4242

4343
<div className="mt-6 flex flex-wrap gap-3">
4444
<Link end to="/" className={routeLinkClassName}>
45-
Comments (Root URL)
45+
Comments
4646
</Link>
4747
<Link to="/react-router" className={routeLinkClassName}>
48-
Test React Router (&apos;/react-router&apos;)
48+
Route
4949
</Link>
5050
<Link to="/react-router/redirect" className={routeLinkClassName}>
51-
Test Redirect (url to &apos;/react-router/redirect&apos; which goes to root &apos;/&apos;)
51+
Redirect
5252
</Link>
5353
</div>
5454
</header>

spec/system/react_router_demo_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
context "when Root URL", page: :main do
88
it "shows comments section" do
99
visit root_path
10-
click_link "Comments (Root URL)"
10+
click_link "Comments"
1111
expect(page).to have_selector("h2", text: "Comments")
1212
end
1313
end
1414

1515
context "when /react-router URL", page: :main do
1616
it "shows 'React Router is working!' message" do
1717
visit root_path
18-
click_link "Test React Router ('/react-router')"
18+
click_link "Route"
1919
expect(page).to have_selector("h1", text: "React Router is working!")
2020
end
2121
end
2222

2323
context "when /react-router/redirect URL", page: :main do
2424
before do
2525
visit root_path
26-
click_link "Test Redirect (url to '/react-router/redirect' which goes to root '/')"
26+
click_link "Redirect"
2727
end
2828

2929
it "shows comments section" do

0 commit comments

Comments
 (0)