Skip to content

Commit

Permalink
Change back to top
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdinandsalis committed Aug 29, 2024
1 parent ff44b12 commit 209accf
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 85 deletions.
4 changes: 2 additions & 2 deletions app/components/back-to-top.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Link } from '@remix-run/react'
import { ChevronUpIcon } from 'lucide-react'

export function BackToTop() {
export function BackToTop({ className }: { className?: string }) {
return (
<div className="">
<div className={className}>
<Link
to="#"
className="group inline-flex items-center gap-1 rounded-md bg-card/50 p-2 px-6 font-condensed text-lg transition-colors ease-in-out hover:bg-card"
Expand Down
6 changes: 4 additions & 2 deletions app/components/section-heading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Link } from '@remix-run/react'
import { Divider } from './ui/divider.tsx'

export function SectionHeading({
children,
Expand All @@ -20,7 +19,10 @@ export function SectionHeading({
>
<span className="rounded bg-background px-8 py-2">{children}</span>
</h1>
<Divider className="-order-1 col-start-1 col-end-13 row-start-1" />
<div
role="presentation"
className="-order-1 col-start-1 col-end-13 row-start-1 h-[3px] rounded border-none bg-muted"
/>
</Link>
)
}
30 changes: 27 additions & 3 deletions app/components/ui/divider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
import { cn } from '#app/utils/misc.tsx'
import { Link } from '@remix-run/react'
import { ChevronUpIcon } from 'lucide-react'
import { cn } from '#app/utils/misc.js'

export function Divider({ className }: { className?: string }) {
export function Divider({
className,
withBackToTop = true,
}: {
className?: string
withBackToTop?: boolean
}) {
return (
<hr className={cn('h-[3px] rounded border-none bg-muted', className)} />
<div role="presentation" className="group relative">
<hr className={cn('h-[3px] rounded border-none bg-muted', className)} />
{withBackToTop && (
<div className="absolute left-1/2 top-0 -translate-x-1/2 -translate-y-1/2 transform">
<Link
to="#"
className="group inline-flex items-center gap-1 rounded-full bg-muted p-2 px-2 font-condensed text-lg ring ring-muted transition-colors ease-in-out hover:bg-card"
title="Nach oben"
>
<ChevronUpIcon
size={18}
className="stroke-primary transition-transform group-hover:-translate-y-0.5"
/>
</Link>
</div>
)}
</div>
)
}
44 changes: 0 additions & 44 deletions app/data/costs.ts

This file was deleted.

10 changes: 2 additions & 8 deletions app/routes/aktuelles/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { evolve, groupBy, take } from 'ramda'
import { promiseHash } from 'remix-utils/promise'
import slug from 'slug'
import { z } from 'zod'
import { BackToTop } from '#app/components/back-to-top.tsx'
import { Toc } from '#app/components/toc.tsx'
import { Divider } from '#app/components/ui/divider.tsx'
import {
Expand Down Expand Up @@ -93,7 +92,7 @@ export default function Aktuelles() {
]}
/>

<Divider />
<Divider withBackToTop={false} />

<section id="jahrgaenge" className="space-y-8">
<h1 className="font-condensed text-2xl font-bold text-primary md:text-4xl">
Expand All @@ -106,8 +105,6 @@ export default function Aktuelles() {
<YearCard key={year.letter} {...year} />
))}
</div>

<BackToTop />
</section>

<Divider />
Expand Down Expand Up @@ -278,8 +275,6 @@ export default function Aktuelles() {
)
})}
</Accordion>

<BackToTop />
</section>

<Divider />
Expand Down Expand Up @@ -309,9 +304,8 @@ export default function Aktuelles() {
/>
))}
</div>

<BackToTop />
</section>
<Divider className="bg-transparent" />
</div>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/aufnahme+/ _index.query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineQuery } from 'groq'
import { z } from 'zod'

export const AufnahemQuerySchema = z.object({
export const AufnahmeQuerySchema = z.object({
currentSchoolYear: z
.object({
_id: z.string(),
Expand All @@ -25,7 +25,7 @@ export const AufnahemQuerySchema = z.object({
.nullable(),
})

export type AufnahemQuery = z.infer<typeof AufnahemQuerySchema>
export type AufnahmeQuery = z.infer<typeof AufnahmeQuerySchema>

// current school year
export const aufnahmeQuery = defineQuery(`{
Expand Down
17 changes: 5 additions & 12 deletions app/routes/aufnahme+/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { unstable_defineLoader as defineLoader } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import { loadQuery } from '@sanity/react-loader'
import { DownloadIcon, ExternalLinkIcon, InfoIcon } from 'lucide-react'
import { BackToTop } from '#app/components/back-to-top.tsx'
import { Toc } from '#app/components/toc.tsx'
import { Divider } from '#app/components/ui/divider.tsx'
import { cn } from '#app/utils/misc.tsx'
import {
type AufnahemQuery,
AufnahemQuerySchema,
type AufnahmeQuery,
AufnahmeQuerySchema,
aufnahmeQuery,
} from './ _index.query.ts'

Expand All @@ -17,8 +16,8 @@ export function meta() {
}

export const loader = defineLoader(async () => {
const queryResult = await loadQuery<AufnahemQuery>(aufnahmeQuery)
return AufnahemQuerySchema.parse(queryResult.data)
const queryResult = await loadQuery<AufnahmeQuery>(aufnahmeQuery)
return AufnahmeQuerySchema.parse(queryResult.data)
})

export default function Aufnahme() {
Expand Down Expand Up @@ -110,8 +109,6 @@ export default function Aufnahme() {
melden!
</p>
</div>

<BackToTop />
</article>

<Divider />
Expand Down Expand Up @@ -160,8 +157,6 @@ export default function Aufnahme() {
</a>{' '}
</p>
</div>

<BackToTop />
</article>

<Divider />
Expand Down Expand Up @@ -245,7 +240,6 @@ export default function Aufnahme() {
})}
</dl>
</div>
<BackToTop />
</article>

<Divider />
Expand All @@ -262,9 +256,8 @@ export default function Aufnahme() {
Einkommensnachweise und Begründung) gestellt werden.
</p>
</div>

<BackToTop />
</article>
<Divider className="bg-transparent" />
</div>
</div>
)
Expand Down
14 changes: 11 additions & 3 deletions app/routes/curriculum.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackToTop } from '#app/components/back-to-top.tsx'
import { Divider } from '#app/components/ui/divider.tsx'

export function meta() {
return [{ title: 'Curriculum | Walz' }]
Expand All @@ -12,7 +12,7 @@ export default function Curriculum() {
</h1>

<div id="in-jahren" className="space-y-8">
<div className="space-y-8 divide-y divide-muted md:space-y-12">
<div className="space-y-8 md:space-y-12">
<article className="space-y-4 pt-4">
<hgroup>
<span
Expand Down Expand Up @@ -42,6 +42,8 @@ export default function Curriculum() {
</div>
</article>

<Divider />

<article className="space-y-4 pt-4">
<hgroup>
<span
Expand Down Expand Up @@ -70,6 +72,8 @@ export default function Curriculum() {
</div>
</article>

<Divider />

<article className="space-y-4 pt-4">
<hgroup>
<span
Expand Down Expand Up @@ -101,6 +105,8 @@ export default function Curriculum() {
</div>
</article>

<Divider />

<article className="space-y-4 pt-4">
<hgroup>
<span
Expand Down Expand Up @@ -133,6 +139,8 @@ export default function Curriculum() {
</div>
</article>

<Divider />

<article className="space-y-4 pt-4">
<hgroup>
<span
Expand Down Expand Up @@ -168,7 +176,7 @@ export default function Curriculum() {
</article>
</div>

<BackToTop />
<Divider className="bg-transparent" />
</div>
</div>
)
Expand Down
11 changes: 2 additions & 9 deletions app/routes/ueber-uns+/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function UeberUns() {
]}
/>

<Divider />
<Divider withBackToTop={false} />

<div className="max-w-2xl space-y-4 hyphens-auto text-base md:text-xl">
<p>
Expand Down Expand Up @@ -196,8 +196,6 @@ export default function UeberUns() {
</div>
</div>
</article>

<BackToTop />
</section>

<Divider />
Expand All @@ -217,8 +215,6 @@ export default function UeberUns() {
/>
))}
</div>

<BackToTop />
</section>

<Divider />
Expand Down Expand Up @@ -302,8 +298,6 @@ export default function UeberUns() {
</p>
</div>
</article>

<BackToTop />
</section>

<Divider />
Expand Down Expand Up @@ -341,9 +335,8 @@ export default function UeberUns() {
eingeräumt werden.
</p>
</div>

<BackToTop />
</section>
<Divider className="bg-transparent" />
</div>
</div>
)
Expand Down

0 comments on commit 209accf

Please sign in to comment.