Skip to content
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

fix: Minor fixes #16

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Minor fixes
* Fixes `initialData` on carouselImages query
* Improves check for theme on `localStorage`
* Improves CSS logic for the `Tile` component
  • Loading branch information
gonstoll committed Jan 3, 2023
commit eacce2e23c725df6dea3b8000f55b25c19b9d9b6
5 changes: 2 additions & 3 deletions src/components/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ export default function Carousel() {
const {data: carouselImages} = useQuery({
queryKey: ['carouselImages'],
queryFn: getAllCarouselImages,
initialData: [],
});

const images = carouselImages.map(img => (
const images = carouselImages?.map(img => (
<div
key={img._key}
className="w-80 md:w-98 h-80 md:h-98 bg-gray-400 rounded shrink-0 snap-center relative"
Expand All @@ -27,7 +26,7 @@ export default function Carousel() {
</div>
));

if (!images.length) return null;
if (!images || !images.length) return null;

return (
<div className="mt-40">
Expand Down
1 change: 1 addition & 0 deletions src/components/ImageBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function ImageBlock({type, images}: Props) {
<div key={img._key} className="col-span-1">
<NextImage
{...img}
loading="lazy"
placeholder="blur"
className={`rounded ${imageClass}`}
/>
Expand Down
35 changes: 9 additions & 26 deletions src/components/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,28 @@ interface Props {

export default function Tile({title, link, size, icon}: Props) {
const sizeClasses = {
small: {
content: 'text-base',
tile: 'h-10 gap-4',
},
medium: {
content: 'text-3-1/2xl',
tile: 'py-5 gap-6',
},
large: {
content: 'text-3-1/2xl',
tile: 'py-9 gap-8',
},
small: 'text-base h-10 gap-4',
medium: 'text-3-1/2xl py-5 gap-6',
large: 'text-3-1/2xl py-9 gap-8',
};

return link ? (
<Link
href={link}
className={`${sizeClasses[size].tile} flex items-center justify-between border-b-1 border-black dark:border-white group`}
className={`${sizeClasses[size]} flex items-center justify-between border-b-1 border-black dark:border-white text-black dark:text-white group`}
aria-label={title}
>
<p className={`${sizeClasses[size].content} text-black dark:text-white`}>
{title}
</p>
<p
className={`${sizeClasses[size].content} text-black dark:text-white group-hover:-rotate-45 duration-200 transition-transform ease-linear`}
>
<p>{title}</p>
<p className="group-hover:-rotate-45 duration-200 transition-transform ease-linear">
{icon ?? '→'}
</p>
</Link>
) : (
<div
className={`${sizeClasses[size].tile} flex items-center justify-between border-b-1 border-black dark:border-white`}
className={`${sizeClasses[size]} flex items-center justify-between border-b-1 border-black dark:border-white text-black dark:text-white`}
>
<p className={`${sizeClasses[size].content} text-black dark:text-white`}>
{title}
</p>
<p className={`${sizeClasses[size].content} text-black dark:text-white`}>
{icon ?? 'wip'}
</p>
<p>{title}</p>
<p>{icon ?? 'wip'}</p>
</div>
);
}
2 changes: 1 addition & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Document() {
__html: `
if (
localStorage.theme === 'dark' ||
(!('theme' in localStorage) &&
(!localStorage.get('theme') &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
document.documentElement.classList.add('dark');
Expand Down