Skip to content

Commit

Permalink
Merge pull request #445 from gregrickaby/feature/mantine-v6
Browse files Browse the repository at this point in the history
Mantine v6
  • Loading branch information
gregrickaby authored Mar 2, 2023
2 parents 2256981 + 0f01746 commit d7afbba
Show file tree
Hide file tree
Showing 7 changed files with 942 additions and 3,590 deletions.
38 changes: 21 additions & 17 deletions components/BackToTop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import {ActionIcon, createStyles, useMantineColorScheme} from '@mantine/core'
import {
Affix,
Button,
createStyles,
rem,
Transition,
useMantineColorScheme
} from '@mantine/core'
import {useWindowScroll} from '@mantine/hooks'
import {IconArrowUp} from '@tabler/icons-react'

Expand All @@ -19,22 +26,19 @@ export default function BackToTop() {
const {classes} = useStyles()
const {colorScheme} = useMantineColorScheme()

// Only show the button if the user has scrolled down 100px.
if (scroll.y < 100) {
return <></>
}

return (
<ActionIcon
aria-label="scroll to top"
className={classes.backToTop}
color={colorScheme === 'dark' ? 'gray' : 'dark'}
onClick={() => scrollTo({y: 0})}
size="xl"
tabIndex={0}
variant="filled"
>
<IconArrowUp />
</ActionIcon>
<Affix position={{bottom: rem(20), right: rem(20)}}>
<Transition transition="slide-up" mounted={scroll.y > 0}>
{(transitionStyles) => (
<Button
leftIcon={<IconArrowUp size="1rem" />}
style={transitionStyles}
onClick={() => scrollTo({y: 0})}
>
Scroll to top
</Button>
)}
</Transition>
</Affix>
)
}
6 changes: 3 additions & 3 deletions components/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ export default function Media(props: Post) {
*/
function maybeLazyLoad() {
// For large desktop, eager load the first 12 images.
if (width > theme.breakpoints.lg) {
if (width > 1200) {
return props.index > 11 ? 'lazy' : 'eager'
}

// For small desktop, eager load the first 9 images.
if (width > theme.breakpoints.md) {
if (width > 1024) {
return props.index > 8 ? 'lazy' : 'eager'
}

// For tablet, eager load the first 6 images.
if (width > theme.breakpoints.md) {
if (width > 768) {
return props.index > 5 ? 'lazy' : 'eager'
}

Expand Down
14 changes: 6 additions & 8 deletions components/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Button,
Card,
createStyles,
Flex,
SimpleGrid
} from '@mantine/core'
import dynamic from 'next/dynamic'
Expand Down Expand Up @@ -36,11 +37,6 @@ const useStyles = createStyles((theme) => ({
borderBottom: '1px solid transparent',
textDecoration: 'none'
}
},

loadMore: {
display: 'flex',
margin: `${theme.spacing.xl}px auto`
}
}))

Expand Down Expand Up @@ -133,9 +129,11 @@ export default function Results() {
))}
</SimpleGrid>
{!loading && (
<Button className={classes.loadMore} ref={ref} onClick={infiniteScroll}>
{loadingMore ? <>Loading...</> : <>Load more</>}
</Button>
<Flex justify="center" align="center" p="xl">
<Button ref={ref} onClick={infiniteScroll}>
{loadingMore ? <>Loading...</> : <>Load more</>}
</Button>
</Flex>
)}
</>
)
Expand Down
12 changes: 6 additions & 6 deletions components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
Switch,
useMantineColorScheme
} from '@mantine/core'
import {useHotkeys} from '@mantine/hooks'
import {useDisclosure, useHotkeys} from '@mantine/hooks'
import {IconSettings} from '@tabler/icons-react'
import {useState} from 'react'
import {useRedditContext} from '~/components/RedditProvider'
import Sort from '~/components/Sort'

Expand All @@ -26,7 +25,7 @@ const useStyles = createStyles((theme) => ({
* Settings component.
*/
export default function Settings() {
const [opened, setOpened] = useState(false)
const [opened, {open, close}] = useDisclosure(false)
const {colorScheme, toggleColorScheme} = useMantineColorScheme()
const {blurNSFW, setBlurNSFW} = useRedditContext()
const {classes} = useStyles()
Expand All @@ -38,17 +37,18 @@ export default function Settings() {
<ActionIcon
aria-label="open settings"
className={classes.settings}
onClick={() => setOpened(true)}
onClick={open}
size="lg"
variant="transparent"
>
<IconSettings size={48} />
</ActionIcon>

<Modal
closeButtonLabel="close settings"
onClose={() => setOpened(false)}
closeButtonProps={{'aria-label': 'close settings'}}
onClose={close}
opened={opened}
padding="xl"
title="Settings"
>
<Stack justify="space-between">
Expand Down
Loading

1 comment on commit d7afbba

@vercel
Copy link

@vercel vercel bot commented on d7afbba Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.