Skip to content

Commit

Permalink
remove "-v0" from "wikilink" and "wikitab" element ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 17, 2023
1 parent 7da1485 commit 2160d3a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/cards/Article.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$: summary = event?.tags.find(([k]) => k === 'summary')?.[1];
function addClickListenerToWikilinks() {
const elements = document.querySelectorAll('[id^="wikilink-v0-"]');
const elements = document.querySelectorAll('[id^="wikilink-"]');
elements.forEach((element) => {
element.addEventListener('click', () => {
let title = element.id.slice(12);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/LinkToArticle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
</script>

<button
id={`wikilink-v0-${content.toLocaleLowerCase().replaceAll(' ', '-')}`}
id={`wikilink-${content.toLocaleLowerCase().replaceAll(' ', '-')}`}
class="text-indigo-600 underline">{content}</button
>
2 changes: 1 addition & 1 deletion src/lib/components/TabElement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

<!-- svelte-ignore a11y-no-static-element-interactions a11y-click-events-have-key-events -->
<div
id={`wikitab-v0-${tab.id}`}
id={`wikitab-${tab.id}`}
class="
overflow-y-auto
overflow-x-hidden
Expand Down
5 changes: 2 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export function next(): number {

export function scrollTabIntoView(el: string | HTMLElement, wait: boolean) {
function scrollTab() {
const element =
typeof el === 'string' ? document.querySelector(`[id^="wikitab-v0-${el}"]`) : el;
const element = typeof el === 'string' ? document.querySelector(`[id^="wikitab-${el}"]`) : el;
if (!element) return;

element.scrollIntoView({
Expand All @@ -53,7 +52,7 @@ export function scrollTabIntoView(el: string | HTMLElement, wait: boolean) {
}

export function isElementInViewport(el: string | HTMLElement) {
const element = typeof el === 'string' ? document.querySelector(`[id^="wikitab-v0-${el}"]`) : el;
const element = typeof el === 'string' ? document.querySelector(`[id^="wikitab-${el}"]`) : el;
if (!element) return;

const rect = element.getBoundingClientRect();
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

<!-- svelte-ignore a11y-no-static-element-interactions a11y-click-events-have-key-events -->
<div
id={`wikitab-v0-special-search`}
id={`wikitab-special-search`}
class="
overflow-y-auto
overflow-x-hidden
Expand Down

0 comments on commit 2160d3a

Please sign in to comment.