Skip to content

rgh-netiquette - Support new views - #8141

Merged
kovsu merged 4 commits into
refined-github:mainfrom
kovsu:rgh-netiquetre
Dec 16, 2024
Merged

rgh-netiquette - Support new views#8141
kovsu merged 4 commits into
refined-github:mainfrom
kovsu:rgh-netiquetre

Conversation

@kovsu

@kovsu kovsu commented Dec 9, 2024

Copy link
Copy Markdown
Member

@kovsu
kovsu marked this pull request as draft December 9, 2024 06:08
@kovsu

kovsu commented Dec 9, 2024

Copy link
Copy Markdown
Member Author
image

I have tried bleow code and add some class for TimeLineItem, but it doesn't work.

export default function TimelineItem({
	className,
}: {
	className?: string;
}): JSX.Element {}

And it thorw an error: TypeError: Cannot read properties of undefined. If I add defaultProps, the className is concated not overrode, so it also doesn't work.

@kovsu

kovsu commented Dec 9, 2024

Copy link
Copy Markdown
Member Author

I also check the dom-chef lib, I don't find anything useful for me.

@kovsu
kovsu marked this pull request as ready for review December 9, 2024 07:02
@fregante fregante added the bug label Dec 9, 2024
@fregante

fregante commented Dec 9, 2024

Copy link
Copy Markdown
Member

Unlike React components, any attributes you pass to dom-chef JSX will automatically be added. For classes, they will be appended. So <TimelineItem className='something'> will just work.

However you most likely just want to change the TimelineItem itself since we do want it to stay compatible across all the features that use it (e.g. closing-remarks)

Wherever possible, when you make changes to components or classes, search the codebase for the keyword and you might be able to fix multiple features at once. e.g. like you did for color-fg-muted in #7313

@kovsu

kovsu commented Dec 9, 2024

Copy link
Copy Markdown
Member Author

Unlike React components, any attributes you pass to dom-chef JSX will automatically be added. For classes, they will be appended. So will just work.

As you can see I add ml-md-0 to remove the margin, but it be overrode by ml-md-6. This is the reason why I want to have a customize classname here.

image

@fregante

fregante commented Dec 9, 2024

Copy link
Copy Markdown
Member

As you can see I add ml-md-0 to remove the margin, but it be overrode by ml-md-6

Since the component needs to work in both layouts, then the right class needs to be applied depending on context. TimelineItem is very simple so you can just duplicate it and export a new version just for the new timeline, e.g.

export function TimelineItemOld(): JSX.Element {
	// Classes copied from #issuecomment-new + mt-3 added
	return <div className="ml-0 pl-0 ml-md-6 pl-md-3 mt-3" />;
}

!! adjust/remove all classes as needed
export function TimelineItem(): JSX.Element {
	return <div className="ml-0 pl-0 ml-md-0 pl-md-3 mt-3" />;
}

And then in the features you can use:

const Wrapper = yourLogicToDetectOldView ? TimelineItemOld : TimelineItem;

const banner = (
	<Wrapper>{createBanner({etc})}</Wrapper>
)

You can alternatively use the createBanner style instead of JSX, like:

const banner = createTimelineItem(
	yourLogicToDetectOldView ? 'old' : 'react',
	createBanner({etc})
)

Up to you

@kovsu

kovsu commented Dec 9, 2024

Copy link
Copy Markdown
Member Author
image image

Comment thread source/github-helpers/timeline-item.tsx Outdated
Comment thread source/github-helpers/timeline-item.tsx Outdated

// #8141
export function TimelineItem(): JSX.Element {
return <div className="ml-0 pl-0 pl-md-3 mt-3" />;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make sure it works correctly on all window widths. These classes were for the old version

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM other than the 2 comments, but don't merge it yet. I'll likely release a new version tomorrow with just #8143


// https://github.com/refined-github/refined-github/pull/8141
export function TimelineItem(): JSX.Element {
return <div className="my-2" />;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It seems it only need my-2 in new view. It works on all widths.

Google.Chrome.mp4

@fregante

fregante commented Dec 9, 2024

Copy link
Copy Markdown
Member

Wait, to me it looks like it's in the wrong container. The banner should not go under the sidebar for example, it should be part of the main thread column

@kovsu

kovsu commented Dec 10, 2024

Copy link
Copy Markdown
Member Author

Wait, to me it looks like it's in the wrong container. The banner should not go under the sidebar for example, it should be part of the main thread column

No, it just on the front of comment box. But it is part of the comment container.

CleanShot 2024-12-10 at 08 31 58@2x

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be good to follow this with closing-remarks

@kovsu
kovsu merged commit 9034ec2 into refined-github:main Dec 16, 2024
@kovsu
kovsu deleted the rgh-netiquetre branch December 16, 2024 00:43
@fregante fregante mentioned this pull request May 1, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

rgh-* features broken on new beta views

2 participants