Skip to content

Commit

Permalink
move custom tool tip to remain permanent next to scroll to top button (
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark authored Dec 13, 2021
1 parent 26d7681 commit 3ce46b9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/ui/ScrollButton/ScrollButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react'
import cx from 'classnames'
import { ChevronUpIcon } from '@primer/octicons-react'
import { useTranslation } from '../../hooks/useTranslation'

export type ScrollButtonPropsT = {
className?: string
Expand All @@ -9,6 +10,7 @@ export type ScrollButtonPropsT = {

export const ScrollButton = ({ className, ariaLabel }: ScrollButtonPropsT) => {
const [show, setShow] = useState(false)
const { t } = useTranslation(['scroll_button'])

useEffect(() => {
// show scroll button only when view is scrolled down
Expand All @@ -35,9 +37,13 @@ export const ScrollButton = ({ className, ariaLabel }: ScrollButtonPropsT) => {
<div className={cx(className, 'transition-200', show ? 'opacity-100' : 'opacity-0')}>
<button
onClick={onClick}
className={cx(
'tooltipped tooltipped-n tooltipped-no-delay color-bg-accent-emphasis color-fg-on-emphasis circle border-0'
)}
className="color-bg-default color-fg-on-emphasis border-0 d-inline-block mr-2 f6"
>
{t('scroll_to_top')}
</button>
<button
onClick={onClick}
className={cx('color-bg-accent-emphasis color-fg-on-emphasis circle border-0')}
style={{ width: 40, height: 40 }}
aria-label={ariaLabel}
>
Expand Down

0 comments on commit 3ce46b9

Please sign in to comment.