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

Fix alignment of tip button on Github people page. #87

Merged
merged 2 commits into from
Sep 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions scripts/brave_rewards/publisher/github/tipping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,7 @@ const getMemberListItemMetaData = async (elem: Element) => {
throw new Error('Invalid arguments')
}

const ancestor = elem.closest('.table-list-cell')
if (!ancestor) {
throw new Error('Failed to parse DOM')
}

const anchors = ancestor.getElementsByTagName('A')
if (!anchors || anchors.length === 0) {
throw new Error('Failed to parse DOM')
}

const anchor = anchors[0] as HTMLAnchorElement
const anchor = elem as HTMLAnchorElement
if (!anchor.href) {
throw new Error('Failed to parse DOM')
}
Expand Down Expand Up @@ -406,8 +396,13 @@ const memberListItemInsertFunction = (parent: Element) => {
}

const path = window.location.pathname
const memberText = parent.children[1] as HTMLElement
if (!memberText || !path.startsWith('/orgs/')) {
const memberTextDiv = parent.children[1] as HTMLElement
if (!memberTextDiv || !memberTextDiv.children.length || !path.startsWith('/orgs/')) {
return
}

const memberText = memberTextDiv.children[0] as HTMLElement
if (!memberText) {
return
}

Expand All @@ -418,12 +413,16 @@ const memberListItemInsertFunction = (parent: Element) => {

if (path.split('/').includes('teams')) {
// Special case, different styling for same element
memberText.appendChild(tipAction)
memberTextDiv.insertBefore(tipAction, memberTextDiv.children[1])
tipAction.style.paddingLeft = '5px'
tipAction.style.paddingRight = '12px'
tipAction.style.verticalAlign = 'text-bottom'
} else {
memberText.style.width = '250px'
if (memberText.children.length > 0) {
memberText.insertBefore(tipAction, memberText.children[1])
}
const span = document.createElement('span')
span.style.display = 'flex'
memberTextDiv.insertBefore(span, memberText)
span.appendChild(memberText)
span.appendChild(tipAction)
}
}

Expand Down