Skip to content

feat: added a method to assign an id to the Section component#30

Open
kenmistry wants to merge 1 commit into
web3templates:mainfrom
kenmistry:feat/assign-id-to-section
Open

feat: added a method to assign an id to the Section component#30
kenmistry wants to merge 1 commit into
web3templates:mainfrom
kenmistry:feat/assign-id-to-section

Conversation

@kenmistry

Copy link
Copy Markdown

Hi, I am proposing a method to assign an id attribute to the Section component so as to facilitate ease of locating via a unique identifier and of navigating between different Section components.

Not sure if this is needed at this time, given that the repo has not seen any updates for over a year. Happy to remove this PR if the repo is no longer maintained.

Copilot AI review requested due to automatic review settings March 26, 2026 07:28
@vercel

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

@kenmistry is attempting to deploy a commit to the Web3templates Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for assigning stable HTML id attributes to section header areas so they can be linked to / scrolled to directly within the landing page.

Changes:

  • Introduces a sectionId prop on SectionTitle and wires it to Container.
  • Extends Container to optionally render a div id.
  • Enables global smooth scrolling via scroll-behavior: smooth.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/components/SectionTitle.tsx Adds sectionId prop and passes it down to Container.
src/components/Container.tsx Adds an optional idName prop and applies it as the rendered div’s id.
src/app/page.tsx Assigns concrete ids (section-onesection-four) to each SectionTitle instance.
src/app/globals.css Enables smooth scrolling globally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

export const SectionTitle = (props: Readonly<SectionTitleProps>) => {
return (
<Container
idName={`${props.sectionId}`}

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

idName={${props.sectionId}} stringifies undefined into the literal "undefined". Because Container treats any non-empty string as truthy, this results in <div id="undefined"> when sectionId isn’t provided. Pass props.sectionId through directly (no template literal) and/or only set the prop when defined.

Suggested change
idName={`${props.sectionId}`}
idName={props.sectionId}

Copilot uses AI. Check for mistakes.
Comment on lines 3 to 6
interface ContainerProps {
children: React.ReactNode;
idName?: string;
className?: string;

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

The new Container prop name idName is non-standard for a component that maps directly to a <div> attribute, and it makes call sites harder to read. Consider renaming this prop to id (or accepting React.HTMLAttributes<HTMLDivElement> / ...rest and spreading onto the <div>) to align with common React patterns and avoid a bespoke API surface.

Copilot uses AI. Check for mistakes.
Comment thread src/app/globals.css
}

html {
scroll-behavior: smooth;

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

Enabling scroll-behavior: smooth globally can cause motion-sickness and violates user preference for reduced motion. Add a @media (prefers-reduced-motion: reduce) override (e.g., revert to auto) so smooth scrolling is disabled for those users.

Suggested change
scroll-behavior: smooth;
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}

Copilot uses AI. Check for mistakes.
Comment on lines 4 to 6
interface SectionTitleProps {
sectionId?: string;
preTitle?: string;

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

PR title/description mention adding an id to a Section component, but the change introduces sectionId on SectionTitle and an idName prop on Container. Please align the PR metadata with the actual components being changed (or rename/refactor to match the intended Section abstraction) to avoid confusion for maintainers.

Copilot uses AI. Check for mistakes.
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