-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mobile categories + routes #456
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,4 +140,7 @@ h1.teal { | |
article .footer-comtainer > div:nth-child(-n + 2) { | ||
flex: 1 1; | ||
} | ||
article { | ||
margin: 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.categoriesGroup { | ||
padding: var(--spacing-12); | ||
} | ||
.categoriesGroup > * { | ||
padding: var(--spacing-16); | ||
} | ||
.categoryTitle { | ||
padding: var(--spacing-24); | ||
cursor: pointer; | ||
display: inline-block; | ||
width: 100%; | ||
} | ||
@media (max-width: 640px) { | ||
.categoriesGroup { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.categoriesGroup.bordered { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there ever a categoriesGroup without the bordered class? |
||
border: 0; | ||
box-shadow: none; | ||
} | ||
.categoryTitle.selected { | ||
background: inherit; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {useState, useEffect} from 'react' | ||
|
||
export default function useIsMobile() { | ||
const mobileWidth = 640 | ||
const [windowWidth, setWindowWidth] = useState<number>(0) | ||
|
||
const isWindow = typeof window !== 'undefined' | ||
|
||
const getWidth = () => (isWindow ? window.innerWidth : windowWidth) | ||
|
||
const resize = () => setWindowWidth(getWidth()) | ||
|
||
useEffect(() => { | ||
if (isWindow) { | ||
setWindowWidth(getWidth()) | ||
|
||
window.addEventListener('resize', resize) | ||
|
||
return () => window.removeEventListener('resize', resize) | ||
} | ||
//eslint-disable-next-line | ||
}, [isWindow]) | ||
|
||
return windowWidth <= mobileWidth | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import ListTable from '~/components/Table' | |
import {loader} from '~/routes/tags.all' | ||
import {CategoriesNav} from '~/components/CategoriesNav/Menu' | ||
import type {Tag as TagType} from '~/server-utils/stampy' | ||
|
||
import useIsMobile from '~/hooks/isMobile' | ||
export {loader} | ||
|
||
export const sortFuncs = { | ||
|
@@ -15,6 +15,7 @@ export const sortFuncs = { | |
} | ||
|
||
export default function Tags() { | ||
const mobile = useIsMobile() | ||
const {data} = useLoaderData<ReturnType<typeof loader>>() | ||
const {currentTag, tags} = data | ||
const [selectedTag, setSelectedTag] = useState<TagType | null>(null) | ||
|
@@ -29,16 +30,18 @@ export default function Tags() { | |
if (selectedTag === null) { | ||
return null | ||
} | ||
const isTagsPage = window.location.pathname.split('/').slice(-2)[0] === 'tags' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this. It would be much better to have a button of some kind that shows a modal with all the tags, rather than having to mess about with urls. It sort of makes sense but would be annoying to have to go through an extra menu each time you wanted to choose a different category. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll have to change the loader, which is in
Then you can only show the |
||
return ( | ||
<Page> | ||
<main> | ||
<div className="article-container"> | ||
<CategoriesNav | ||
categories={tags.filter((tag) => tag.questions.length > 0).sort(sortFuncs[sortBy])} | ||
activeCategoryId={selectedTag.tagId} | ||
/> | ||
|
||
{selectedTag === null ? null : ( | ||
{mobile && !isTagsPage ? null : ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can also do a |
||
<CategoriesNav | ||
categories={tags.filter((tag) => tag.questions.length > 0).sort(sortFuncs[sortBy])} | ||
activeCategoryId={selectedTag.tagId} | ||
/> | ||
)} | ||
{(mobile && isTagsPage) || selectedTag === null ? null : ( | ||
<article> | ||
<h1 className="padding-bottom-40">{selectedTag.name}</h1> | ||
<div className="padding-bottom-24"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a specific reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, cannot use
@media .Class1.Class2
with modules. only@media .Class1