News page layout
Introduction
Section titled βIntroductionβIn this guide, we will update the layout of the NewsCategoryPage
page by adding some dummy news story summary areas.
These will be simple coloured rectangles at the moment to get a general idea of layout. We will add real data to them later.
Getting started
Section titled βGetting startedβUse the code below as a quick wireframe component.
Copy and paste it into your app/routes/news.$category.tsx
file, directly above the NewsCategoryPage
component:
13 collapsed lines
import { invariant } from '@epic-web/invariant'import { type LoaderFunctionArgs, json } from '@remix-run/node'import { useLoaderData } from '@remix-run/react'import { toTitleCase } from '~/utils/stringUtils.ts'
export async function loader({ params }: LoaderFunctionArgs) { const { category } = params
invariant(typeof category === 'string', 'Category not found') const categoryTitle = toTitleCase(category)
return json({ categoryTitle })}
const WireframeBlock = () => { return ( <div className="h-72 animate-pulse rounded-lg bg-gray-200 dark:bg-gray-700" /> )}
export default function NewsCategoryPage() { const { categoryTitle } = useLoaderData<typeof loader>()
return ( <div className="container py-16"> <h2 className="text-h2">{categoryTitle}</h2> </div> )}
You can then call this component multiple times in your NewsCategoryPage
to create a wireframe layout. For example, if you wanted a five column layout, you could do this:
<div className="grid grid-cols-5 gap-6"> <WireframeBlock /> <WireframeBlock /> <WireframeBlock /> <WireframeBlock /> <WireframeBlock /></div>
This will create a layout with five columns, each containing a wireframe block:
Summary
Section titled βSummaryβIn this step, we:
- Created a wireframe layout for the
NewsCategoryPage
using Tailwind CSS. - Added a
WireframeBlock
component to create a simple coloured rectangle to represent a news story summary. - Completed a challenge to create a wireframe layout for the
NewsCategoryPage
using Tailwind CSS.
Next steps
Section titled βNext stepsβOur site is beginning to take shape!
We have a home page and a shared layout for our news category page.
In the next step, we will work on the database for our website.