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

feat: create header, categoryBar, and categoryButton components #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gurtatiLND
Copy link
Collaborator

@gurtatiLND gurtatiLND commented Nov 27, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

1. Header Component

  • Adds a Header component with:
    • An app name (<h1>) and a question mark button on the left (reserved for future functionality).
    • An image on the right side.
    • Full integration of the reusable ImageComponent into the Header.
    • Ensuring compatibility with the latest next/image API.
    • Adding explicit parent dimensions for proper fill behavior.

2. Styling Improvements

  • Refactors long Tailwind class strings into reusable variables for cleaner and more maintainable styling.

3. Create and then Delete CategoryButton Component

4. CategoryBar Component

  • Implements a CategoryBar component that uses the Button component to render a list of category buttons dynamically and now they can be chosen

5. Global CSS Updates

  • Adds a reusable header class in global.css with:
    • background: Defines the header background styling.
    • border-bottom: Adds a bottom border to the header for visual separation.

6. Create ImageComponent:

  • Refactored to align with the updated next/image API:
    • Replaced legacy properties like objectFit with style={{ objectFit: 'cover' }}.
    • Added support for the sizes prop to enhance image loading efficiency.
  • Implemented conditional styling for rounded images via the rounded prop.

Screenshots

Screenshot 2024-11-27 at 17 43 48

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Semantic HTML implemented?
  • Checked with axe DevTools and addressed Critical and Serious issues?
  • Color contrast tested?

Added/updated tests?

Please aim to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: I still don't have(don't know how) any test in my code
  • I need help with writing tests

What gif best describes this PR or how it makes you feel?

alt_text

Copy link
Collaborator

@maxitect maxitect left a comment

Choose a reason for hiding this comment

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

Suggest a few minor changes and discussion points

src/ui/CategoryBar/CategoryButtons.tsx Outdated Show resolved Hide resolved
src/ui/layout/Header.tsx Outdated Show resolved Hide resolved
overflow-x-auto bg-[#1b192e] border-b
border-gray-700 sm:gap-6 sm:px-6`;

const CategoryBar: React.FC = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const CategoryBar: React.FC = () => {
const CategoryBar = () => {

I believe React.FC types are no longer required (meaning you don't need to import React either)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gurtatiLND can you make a decision to commit this or not commit with a comment explaining why please :)

src/ui/layout/Header.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@maxitect maxitect left a comment

Choose a reason for hiding this comment

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

Sorry a few more changes, I think there are a few instances of redundant comments, I've marked them up and you can commit them directly from github if you agree. Also there is a merge conflict that needs to be resolved, as soon as those are all addressed I can approve and merge! :)

overflow-x-auto bg-[#1b192e] border-b
border-gray-700 sm:gap-6 sm:px-6`;

const CategoryBar: React.FC = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@gurtatiLND can you make a decision to commit this or not commit with a comment explaining why please :)

Comment on lines +25 to +33
// Toggle category selection
if (category === 'All') {
setSelectedCategories(['All']); // Reset to "All"
} else {
setSelectedCategories(
(prev) =>
prev.includes(category)
? prev.filter((c) => c !== category) // Remove if already selected
: [...prev.filter((c) => c !== 'All'), category] // Add new category, deselect "All"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need these comments? Suggest removing as they seem redundant

Suggested change
// Toggle category selection
if (category === 'All') {
setSelectedCategories(['All']); // Reset to "All"
} else {
setSelectedCategories(
(prev) =>
prev.includes(category)
? prev.filter((c) => c !== category) // Remove if already selected
: [...prev.filter((c) => c !== 'All'), category] // Add new category, deselect "All"
if (category === 'All') {
setSelectedCategories(['All']);
} else {
setSelectedCategories(
(prev) =>
prev.includes(category)
? prev.filter((c) => c !== category)
: [...prev.filter((c) => c !== 'All'), category]

Things We Do
</h1>
<Button
label="?" // The button text
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
label="?" // The button text
label="?"

redundant comment

</div>

{/* Right side: Image */}
<div className="relative w-10 h-10 sm:w-12 sm:h-12"> {/* Explicit dimensions */}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<div className="relative w-10 h-10 sm:w-12 sm:h-12"> {/* Explicit dimensions */}
<div className="relative w-10 h-10 sm:w-12 sm:h-12">

redundant comment

src="/icons/dummy_img.png"
alt="Logo"
sizes="(max-width: 768px) 100vw, 50vw"
rounded={false} // Set to true for rounded images
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
rounded={false} // Set to true for rounded images
rounded={false}

redundant comment (the parameter is already called "rounded")

Comment on lines +2 to +5
label: string; // The text displayed on the button
onClick?: () => void; // Optional: Click handler
className?: string; // Optional: Additional Tailwind or custom classes
ariaPressed?: boolean; // Optional: For accessibility
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
label: string; // The text displayed on the button
onClick?: () => void; // Optional: Click handler
className?: string; // Optional: Additional Tailwind or custom classes
ariaPressed?: boolean; // Optional: For accessibility
label: string;
onClick?: () => void;
className?: string;
ariaPressed?: boolean;

redundant comments - these parameters are well named and self-explanatory :)

Comment on lines +21 to +23
fill // Makes the image responsive
sizes={sizes}
style={{ objectFit: 'cover' }} // Ensures proper scaling
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fill // Makes the image responsive
sizes={sizes}
style={{ objectFit: 'cover' }} // Ensures proper scaling
fill
sizes={sizes}
style={{ objectFit: 'cover' }}

possibly redundant comments

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.

2 participants