Skip to content

Commit

Permalink
fix: only display banner if no session and minor layout updates (#283)
Browse files Browse the repository at this point in the history
* add consistent margin bottom on pages

* add icons for time and servings

* update banner condition

* update icon to carrot
  • Loading branch information
sirisayshello authored Nov 20, 2024
1 parent a59dd80 commit 7655a59
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Link from "next/link";
export default function About() {
return (
<Center>
<Stack pb={"xl"} maw={"60ch"}>
<Stack mb="4rem" maw={"60ch"}>
<Stack mt={"xl"}>
<Title ta="center">About us</Title>
<Text>
Expand Down
2 changes: 2 additions & 0 deletions src/app/dashboard/[slug]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EditRecipeForm } from "@/components/EditRecipeForm";
import { getAuth } from "@/lib/auth";
import prisma from "@/lib/db";
import { getUserTags } from "@/lib/queries";
import { Space } from "@mantine/core";
import { notFound } from "next/navigation";

export default async function EditRecipePage({
Expand Down Expand Up @@ -36,6 +37,7 @@ export default async function EditRecipePage({
<Breadcrumbs />

<EditRecipeForm recipe={convertedRecipe} userTags={userTags} />
<Space h="4rem" />
</>
);
}
26 changes: 22 additions & 4 deletions src/app/dashboard/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import prisma from "@/lib/db";
import Link from "next/link";
import { Anchor, Group, Stack, Title, Text, Box, Badge } from "@mantine/core";
import {
Anchor,
Group,
Stack,
Title,
Text,
Box,
Badge,
Space,
} from "@mantine/core";

import { IngredientsAndInstructionsToggle } from "@/components/IngredientsAndInstructionsToggle";
import { getAuth } from "@/lib/auth";
import { notFound } from "next/navigation";
import { ScreenAwakeToggle } from "@/components/ScreenAwakeToggle";
import { Breadcrumbs } from "@/components/Breadcrumbs";
import EditRecipeButton from "@/components/EditRecipeButton";
import { IconClockHour4, IconToolsKitchen2 } from "@tabler/icons-react";

export default async function RecipePage({
searchParams,
Expand Down Expand Up @@ -68,8 +78,15 @@ export default async function RecipePage({
{recipe.author}
</Anchor>
</Text>
<Text size="xs">Total time: {recipe.time}</Text>
<Text size="xs">Servings: {recipe.yield}</Text>
<Group gap={"xs"}>
<IconClockHour4 size={16} />
<Text size="xs">Total time: {recipe.time}</Text>
</Group>

<Group gap={"xs"}>
<IconToolsKitchen2 size={16} />
<Text size="xs">Servings: {recipe.yield}</Text>
</Group>
</Group>

{/* The ScreenAwakeToggle is rendered inside IngredientsAndInstructionsToggle on small screens */}
Expand All @@ -81,7 +98,7 @@ export default async function RecipePage({
<IngredientsAndInstructionsToggle recipe={convertedRecipe} />
</Box>

<Group pb={"xl"}>
<Group>
{recipe.tags?.map((tagRelation, index) => (
<Badge
key={index}
Expand All @@ -97,6 +114,7 @@ export default async function RecipePage({
</Badge>
))}
</Group>
<Space h="4rem" />
</>
);
}
2 changes: 1 addition & 1 deletion src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function Dashboard() {
</Group>
</Box>
<RecipesList tags={tags} recipes={convertedRecipes} />
<Space h="xl" />
<Space h="4rem" />
</>
);
}
2 changes: 1 addition & 1 deletion src/app/welcome/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function Welcome() {
</Box>
<RecipeForm session={session} userTags={userTags} />
<RecipesList recipes={convertedRecipes} title="Your latest recipes" />
<Space h="xl" />
<Space h="4rem" />
</Flex>
);
}
7 changes: 2 additions & 5 deletions src/components/EditRecipeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Flex,
Group,
Paper,
Space,
TagsInput,
Text,
TextInput,
Expand Down Expand Up @@ -238,7 +237,7 @@ export const EditRecipeForm = ({ recipe, userTags }: EditRecipeProps) => {

{/* General info */}

<Fieldset radius={"sm"} mb="md" legend="Recipe information">
<Fieldset radius={"sm"} mt="lg" mb="lg" legend="Recipe information">
<TextInput
radius={"sm"}
label="Title"
Expand Down Expand Up @@ -281,7 +280,7 @@ export const EditRecipeForm = ({ recipe, userTags }: EditRecipeProps) => {
view={view}
/>

<Fieldset radius={"sm"} mb="md" legend="Tags">
<Fieldset radius={"sm"} legend="Tags">
<TagsInput
radius={"sm"}
label="Recipe tags"
Expand All @@ -294,8 +293,6 @@ export const EditRecipeForm = ({ recipe, userTags }: EditRecipeProps) => {
comboboxProps={{ dropdownPadding: 8 }}
/>
</Fieldset>

<Space h="md" />
</form>
</>
);
Expand Down
6 changes: 2 additions & 4 deletions src/components/IngredientsAndInstructionsToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useState } from "react";
import RenderedInstructions from "./RenderedInstructions";
import RenderedIngredients from "./RenderedIngredients";
import { ScreenAwakeToggle } from "./ScreenAwakeToggle";
import { IconLadle, IconMushroom } from "@tabler/icons-react";
import { IconCarrot, IconLadle } from "@tabler/icons-react";

type IngAndInstToggleProps = {
recipe: UserRecipe;
Expand Down Expand Up @@ -122,9 +122,7 @@ export const IngredientsAndInstructionsToggle = ({
label: (
<>
<Center style={{ gap: 10 }}>
<IconMushroom
style={{ width: rem(16), height: rem(16) }}
/>
<IconCarrot style={{ width: rem(16), height: rem(16) }} />
<Text size="sm" visibleFrom="xs">
Ingredients
</Text>
Expand Down
7 changes: 2 additions & 5 deletions src/components/RecipeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export const RecipeForm = ({ session, userTags }: RecipeFormProps) => {
component="section"
style={{ justifySelf: "flex-start" }}
>

<Divider my="md" />

<Box
Expand Down Expand Up @@ -227,9 +226,8 @@ export const RecipeForm = ({ session, userTags }: RecipeFormProps) => {
{/* Only shown when there is no scraped recipe, user is not logged in and no notifications are on screen */}
<Transition
mounted={
!recipe?.ingredients &&
!session &&
notificationsStore.notifications.length === 0
(!session && notificationsStore.notifications.length === 0) ||
(!session && !!recipe)
}
transition="slide-down"
duration={300}
Expand All @@ -241,7 +239,6 @@ export const RecipeForm = ({ session, userTags }: RecipeFormProps) => {
</Box>
)}
</Transition>
{recipe && <CreateAccountBanner />}
</Stack>
);
};

0 comments on commit 7655a59

Please sign in to comment.