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

Rules page #60

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Rules page #60

wants to merge 3 commits into from

Conversation

MoaKK
Copy link

@MoaKK MoaKK commented Oct 17, 2024

First attempt at creating rules page, open for reviews and suggestions.

Created rules page, necessary mock-data and components, and routing to subpages,

Have only implemented a temporary 'design' of how I want the page to look. Don't think i used the proper approach to using components and/or creating components. Would therefore like suggestions on how i could improve or refractor the actual code, current design of the page, improper use of tailwind properties, or any other areas of improvements.

Closes #18.

.env.example Show resolved Hide resolved
@@ -0,0 +1,15 @@
import { rulesMockdata } from '@/mock-data/rules';

export default function SubPage({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe RuleSubsetPage as the name?

const page = rulesMockdata.find(
(rule) => rule.id === Number.parseInt(subset),
);
if (!page) return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning an empty page, please use notFound to return a 404 page instead

src/app/[locale]/(default)/rules/layout.tsx Show resolved Hide resolved
src/components/rules/RulesPagesList.tsx Show resolved Hide resolved
return (
<>
<div className='p-4 text-center'>
<h1>{t('title')}</h1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps remove the border from the bottom, so it doesn't overlay with the ruleset button below

src/lib/locale/index.ts Show resolved Hide resolved
Copy link
Member

@michaelbrusegard michaelbrusegard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at the code right now, but I also think the styling can be improved. Maybe look at some other websites or examples and try to get inspiration. Also you can look at more "fancy" components to add to learn about that and it can be fun to work on, like aceturnity etc


export default function SubPage({
params: { subset },
}: { params: { subset: string } }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every single page and layout needs the unstable_setRequestLocale, including this one. It allows for static generation of pages

}: RulesLayoutProps) {
unstable_setRequestLocale(locale);

return <>{children}</>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout is not needed if it is empty and not doing anything. But it should be doing something. I would insert the title here and move the page into a route group. Also you need a loading.tsx for the rulesPage, that can then be inside this route group

src/app/[locale]/(default)/rules/page.tsx Show resolved Hide resolved

return (
<>
<div className='p-4 text-center'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put these classes on the h1 directly instead of on a div around it? Also mke sure the text has the same styles as on other pages for consistancy

<div className='xs:w-full sm:w-full md:w-1/2'>
<h2 className='text-center'>{t('forEveryone')}</h2>
{notInternal.map((rule) => (
<SubPages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me being picky, but I think calling a component for something related to page is confusing when it isnt a page. maybe call it RuleCard or RuleLink etc... just suggestions

function SubPages({ className, id, internal, title, photoUrl }: SubPagesProps) {
return (
<Link
href={{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When putting a link around something and it doesnt have text it needs an aria-label that explains what it does. I think, this may be wrong other places in the app too, maybe we should look into this

params: { subset: id },
}}
>
<div className='mx-auto mb-3 flex min-h-[3.18rem] min-w-[20rem] max-w-2xl transform rounded-xl border transition delay-150 duration-300 ease-in-out hover:scale-105 hover:shadow-lg'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid using arbitrary values in the styling if not for a very good reasin. like the min-h and min-w here

/>
))}
</div>
<div className='xs:w-full sm:w-full md:w-1/2'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here sm: style can be remove as it is covered by the xs prop before it

/>
)}
</div>
<div className='flex w-3/4 items-center justify-center'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this div needed, i am not sure i thing an mx-auto could make it redundant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of this file, it comes from doing npm install, but we only need the lock file from bun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Rules page
3 participants