Skip to content

Commit

Permalink
Adds tailwindcss class sorting with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
borisghidaglia committed Jul 20, 2024
1 parent 844fe75 commit f3078d9
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"prettier-plugin-tailwindcss"
]
}
6 changes: 3 additions & 3 deletions app/_actions/addUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { isValidHashInHnUserAbout } from "@/lib/hnAboutParsing";
export const addUser = async (
hash: string,
prevState: any,
formData: FormData
formData: FormData,
) => {
// Basic check that username and location are valid
const { username, location } = Object.fromEntries(formData);
Expand Down Expand Up @@ -52,7 +52,7 @@ export const addUser = async (

async function saveUserAndCity(
user: UserWithoutMetadata,
city: CityWithoutMetadata
city: CityWithoutMetadata,
) {
const currentDate = Date.now();

Expand Down Expand Up @@ -83,7 +83,7 @@ async function saveUserAndCity(

async function getHnUserAboutSection(username: string) {
const hnUser: null | { about: string } = await fetch(
`https://hacker-news.firebaseio.com/v0/user/${username}.json`
`https://hacker-news.firebaseio.com/v0/user/${username}.json`,
).then((res) => res.json());

return hnUser?.about;
Expand Down
4 changes: 2 additions & 2 deletions app/_db/City.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export async function decrementCityHackerCount(cityId: string) {

export async function fetchCity(
rawCity: string,
rawCountry: string
rawCountry: string,
): Promise<CityWithoutMetadata | undefined> {
const matches = await fetch(
`https://nominatim.openstreetmap.org/search?city=${rawCity}&country=${rawCountry}&format=json&place=city&limit=1&addressdetails=1&accept-language=en-US`
`https://nominatim.openstreetmap.org/search?city=${rawCity}&country=${rawCountry}&format=json&place=city&limit=1&addressdetails=1&accept-language=en-US`,
).then((res) => res.json());
const cityData = matches[0];
const {
Expand Down
2 changes: 1 addition & 1 deletion app/_db/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const getUser = cache(async (username: string) => {
});

export const saveUser = async (
user: Omit<DbUser, "createdAt"> & { createdAt?: number }
user: Omit<DbUser, "createdAt"> & { createdAt?: number },
) => {
const command = new PutCommand({
TableName: "CityUserTable",
Expand Down
4 changes: 2 additions & 2 deletions app/_tests/hnAboutParsing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe("parseHnAboutSection", () => {
expect(
isValidHashInHnUserAbout(
about,
"meet.hn-81db6831-e53e-42ea-b76e-c94a3f84888c"
)
"meet.hn-81db6831-e53e-42ea-b76e-c94a3f84888c",
),
).toBe(true);
});

Expand Down
108 changes: 54 additions & 54 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;

--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;

--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;

--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;

--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;

--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;

--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;

--radius: 0.5rem;
}
--radius: 0.5rem;
}

.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;

--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;

--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;

--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;

--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;

--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;

--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;

--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;

--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
14 changes: 7 additions & 7 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default async function Home({
: null;

return (
<main className="grid grid-cols-[max-content,1fr] h-dvh overflow-hidden">
<div className="p-5 space-y-8 w-[512px] overflow-scroll">
<main className="grid h-dvh grid-cols-[max-content,1fr] overflow-hidden">
<div className="w-[512px] space-y-8 overflow-scroll p-5">
<h1 className="text-3xl font-bold">Meet HN</h1>
<p>
Please, set this hash in your account description:
Expand Down Expand Up @@ -72,7 +72,7 @@ async function UserTable({ city }: { city: City }) {
>
<p className="font-medium">{clientUser.username}</p>
<svg
className="h-3.5 w-3.5 ml-1 mt-0.5"
className="ml-1 mt-0.5 h-3.5 w-3.5"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 -960 960 960"
>
Expand All @@ -88,11 +88,11 @@ async function UserTable({ city }: { city: City }) {
) : null}
</div>
<GroupToggleItem>
<div className="col-span-full text-gray-400 text-sm my-1">
<div className="col-span-full my-1 text-sm text-gray-400">
{clientUser.about}
</div>
</GroupToggleItem>
<div className="h-px bg-gray-300 col-span-full"></div>
<div className="col-span-full h-px bg-gray-300"></div>
</Fragment>
);
})}
Expand All @@ -108,7 +108,7 @@ const Socials = ({
socialLinks: UserSocials;
}) => {
return (
<ul className="flex gap-1 flex-wrap items-center">
<ul className="flex flex-wrap items-center gap-1">
{Object.entries(socialLinks).map(([name, link]) =>
link ? (
<li
Expand All @@ -119,7 +119,7 @@ const Socials = ({
{platformNameToSvg[name as keyof UserSocials]}
</a>
</li>
) : null
) : null,
)}
</ul>
);
Expand Down
6 changes: 3 additions & 3 deletions components/MapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function MapContainer({ cities }: { cities: City[] }) {
const userCoord = getCoordinatesFromRegion();
const mapContainer = leafletMap(mapRef.current).setView(
[userCoord.lat, userCoord.lon],
3
3,
);

mapContainerRef.current = mapContainer;
Expand All @@ -71,7 +71,7 @@ export default function MapContainer({ cities }: { cities: City[] }) {
.bindTooltip(
`${city.name}, ${city.hackers} ${
city.hackers > 1 ? "hackers" : "hacker"
}`
}`,
)
.openTooltip();
cityMarker.on("click", () => handleCitySelection(city));
Expand All @@ -85,7 +85,7 @@ export default function MapContainer({ cities }: { cities: City[] }) {
};
}, [cities, mapContainerRef.current]);

return <div ref={mapRef} className="w-full h-full" />;
return <div ref={mapRef} className="h-full w-full" />;
}

function getCoordinatesFromRegion() {
Expand Down
4 changes: 2 additions & 2 deletions components/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function SignUpForm({ hash }: { hash: string }) {
const [state, formAction] = useFormState(addUser.bind(null, hash), {} as any);

return (
<form action={formAction} className="max-w-xl flex flex-col gap-2">
<form action={formAction} className="flex max-w-xl flex-col gap-2">
<Input
name="username"
type="text"
Expand Down Expand Up @@ -39,7 +39,7 @@ function SubmitButton() {
disabled={pending}
>
<svg
className={`animate-spin -ml-1 mr-3 h-5 w-5 text-white ${
className={`-ml-1 mr-3 h-5 w-5 animate-spin text-white ${
pending ? "" : "hidden"
}`}
xmlns="http://www.w3.org/2000/svg"
Expand Down
22 changes: 11 additions & 11 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
Expand Down Expand Up @@ -32,26 +32,26 @@ const buttonVariants = cva(
size: "default",
},
}
)
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
asChild?: boolean;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
);
}
)
Button.displayName = "Button"
);
Button.displayName = "Button";

export { Button, buttonVariants }
export { Button, buttonVariants };
12 changes: 6 additions & 6 deletions components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
Expand All @@ -17,9 +17,9 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
ref={ref}
{...props}
/>
)
);
}
)
Input.displayName = "Input"
);
Input.displayName = "Input";

export { Input }
export { Input };
Loading

0 comments on commit f3078d9

Please sign in to comment.