linter-passing

This commit is contained in:
tonyrewin 2022-11-19 11:16:00 +03:00
parent 89450336e7
commit 8364acb85b
4 changed files with 17 additions and 24 deletions

View File

@ -11,6 +11,7 @@ import { useSession } from '../../context/session'
import { locale } from '../../stores/ui'
import { translit } from '../../utils/ru2en'
import { SearchField } from '../_shared/SearchField'
import { scrollHandler } from '../../utils/scroll'
type AllAuthorsPageSearchParams = {
by: '' | 'name' | 'shouts' | 'rating'
@ -21,7 +22,7 @@ type Props = {
}
const PAGE_SIZE = 20
const ALPHABET = Array.from('@АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ')
const ALPHABET = [...'@АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ']
export const AllAuthorsView = (props: Props) => {
const { sortedAuthors } = useAuthorsStore({ authors: props.authors })
@ -77,16 +78,6 @@ export const AllAuthorsView = (props: Props) => {
</div>
</div>
)
const scrollHandler = (elemId) => {
const anchor = document.querySelector('#' + elemId)
// console.debug(elemId)
if (anchor) {
window.scrollTo({
top: anchor.getBoundingClientRect().top - 100,
behavior: 'smooth'
})
}
}
const [searchResults, setSearchResults] = createSignal<Author[]>([])
// eslint-disable-next-line sonarjs/cognitive-complexity
const searchAuthors = (value) => {

View File

@ -10,6 +10,7 @@ import { locale } from '../../stores/ui'
import { translit } from '../../utils/ru2en'
import styles from '../../styles/AllTopics.module.scss'
import { SearchField } from '../_shared/SearchField'
import { scrollHandler } from '../../utils/scroll'
type AllTopicsPageSearchParams = {
by: 'shouts' | 'authors' | 'title' | ''
@ -20,7 +21,7 @@ type AllTopicsViewProps = {
}
const PAGE_SIZE = 20
const ALPHABET = Array.from('#АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ')
const ALPHABET = [...'#АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ']
export const AllTopicsView = (props: AllTopicsViewProps) => {
const { searchParams, changeSearchParam } = useRouter<AllTopicsPageSearchParams>()
@ -114,16 +115,6 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
</div>
)
const scrollHandler = (elemId) => {
const anchor = document.querySelector('#' + elemId)
// console.debug(elemId)
if (anchor) {
window.scrollTo({
top: anchor.getBoundingClientRect().top - 100,
behavior: 'smooth'
})
}
}
return (
<div class={clsx(styles.allTopicsPage, 'container')}>
<div class="shift-content">

View File

@ -13,8 +13,8 @@ export const initClient = (options) => {
console.info('[graphql] devmode detected')
return localClient(options)
} else return createClient(options)
} catch (e) {
console.error(e)
} catch (error) {
console.error(error)
return localClient(options)
}
}

View File

@ -14,3 +14,14 @@ export const restoreScrollPosition = () => {
left: scrollPosition.left
})
}
export const scrollHandler = (elemId) => {
const anchor = document.querySelector('#' + elemId)
// console.debug(elemId)
if (anchor) {
window.scrollTo({
top: anchor.getBoundingClientRect().top - 100,
behavior: 'smooth'
})
}
}