forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New components, convert hooks to components, bug fixes.
- Loading branch information
Showing
21 changed files
with
330 additions
and
181 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import Icon from './Icon'; | ||
import styles from './Button.module.css'; | ||
|
||
export default function Button({ icon, children, className, onClick }) { | ||
return ( | ||
<button type="button" className={classNames(styles.button, className)} onClick={onClick}> | ||
{icon && <Icon icon={icon} />} | ||
{children} | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.button { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background: #f5f5f5; | ||
padding: 4px 8px; | ||
border-radius: 4px; | ||
border: 0; | ||
outline: none; | ||
cursor: pointer; | ||
} | ||
|
||
.button:hover { | ||
background: #eaeaea; | ||
} | ||
|
||
.button svg { | ||
display: block; | ||
width: 16px; | ||
height: 16px; | ||
margin-right: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import styles from './Icon.module.css'; | ||
|
||
export default function Icon({ icon, className }) { | ||
return <div className={classNames(styles.icon, className)}>{icon}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.icon { | ||
display: inline-flex; | ||
justify-content: center; | ||
align-items: center; | ||
vertical-align: middle; | ||
} | ||
|
||
.icon > svg { | ||
width: 16px; | ||
height: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import NextLink from 'next/link'; | ||
import styles from './Link.module.css'; | ||
|
||
export default function Link({ href, className, children }) { | ||
return ( | ||
<NextLink href={href}> | ||
<a className={classNames(styles.link, className)}>{children}</a> | ||
</NextLink> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.link, | ||
.link:active, | ||
.link:visited { | ||
position: relative; | ||
color: #2c2c2c; | ||
text-decoration: none; | ||
} | ||
|
||
.link:before { | ||
content: ''; | ||
position: absolute; | ||
bottom: -2px; | ||
width: 0; | ||
height: 2px; | ||
background: #2680eb; | ||
opacity: 0.5; | ||
transition: width 100ms; | ||
} | ||
|
||
.link:hover:before { | ||
width: 100%; | ||
transition: width 100ms; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState, useRef, useEffect } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export default function StickyHeader({ | ||
className, | ||
stickyClassName, | ||
stickyStyle, | ||
children, | ||
enabled = true, | ||
}) { | ||
const [sticky, setSticky] = useState(false); | ||
const ref = useRef(); | ||
const offsetTop = useRef(0); | ||
|
||
useEffect(() => { | ||
const checkPosition = () => { | ||
if (ref.current) { | ||
if (!offsetTop.current) { | ||
offsetTop.current = ref.current.offsetTop; | ||
} | ||
const state = window.pageYOffset > offsetTop.current; | ||
if (sticky !== state) { | ||
setSticky(state); | ||
} | ||
} | ||
}; | ||
|
||
checkPosition(); | ||
|
||
if (enabled) { | ||
window.addEventListener('scroll', checkPosition); | ||
} | ||
|
||
return () => { | ||
window.removeEventListener('scroll', checkPosition); | ||
}; | ||
}, [sticky, enabled]); | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
data-sticky={sticky} | ||
className={classNames(className, { [stickyClassName]: sticky })} | ||
{...(sticky && { style: stickyStyle })} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.