Skip to content

Commit

Permalink
Setup icon spritesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Dec 29, 2023
1 parent e4178b6 commit 81a1ab8
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
11 changes: 11 additions & 0 deletions app/components/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions app/components/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { type SVGProps } from "react";
import href from "./icon.svg";
export { href };

export default function Icon({
icon,
...props
}: SVGProps<SVGSVGElement> & { icon: IconName }) {
return (
<svg {...props}>
<use href={`${href}#${icon}`} />
</svg>
);
}

export const iconNames = ["bookmark", "pencil"] as const;
export type IconName = (typeof iconNames)[number];
17 changes: 13 additions & 4 deletions app/routes/_index/feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type { sort } from "./queries";
import type { TFunction } from "i18next";
import type { ReactNode } from "react";

import { BookmarkIcon, PencilIcon } from "@heroicons/react/20/solid";
import { Link } from "@remix-run/react";
import { Trans } from "react-i18next";

import Icon from "~/components/icon";
import { useLocale } from "~/helpers/use-i18n.hook";
import { cn } from "~/utils/cn";

Expand Down Expand Up @@ -44,7 +44,11 @@ export function FeedList({ t, items }: Props) {
/>
}
icon={
<PencilIcon className="h-5 w-5 text-white" aria-hidden="true" />
<Icon
icon="pencil"
className="h-5 w-5 text-white"
aria-hidden="true"
/>
}
iconColor="bg-amber-500"
createdAt={new Date(item.payload.createdAt)}
Expand Down Expand Up @@ -76,7 +80,11 @@ export function FeedList({ t, items }: Props) {
/>
}
icon={
<PencilIcon className="h-5 w-5 text-white" aria-hidden="true" />
<Icon
icon="pencil"
className="h-5 w-5 text-white"
aria-hidden="true"
/>
}
iconColor="bg-amber-500"
createdAt={new Date(item.payload.createdAt)}
Expand Down Expand Up @@ -109,7 +117,8 @@ export function FeedList({ t, items }: Props) {
/>
}
icon={
<BookmarkIcon
<Icon
icon="bookmark"
className="h-5 w-5 text-white"
aria-hidden="true"
/>
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions icons/bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icons/pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"db:run": "wrangler d1 execute",
"db:migration:create": "wrangler d1 migrations create",
"db:migration:list": "wrangler d1 migrations list",
"db:migration:run": "wrangler d1 migrations apply"
"db:migration:run": "wrangler d1 migrations apply",
"g:icons": "bunx rmx-cli svg-sprite icons app/components"
},
"lint-stage": {
"*.{ts,tsx}": [
Expand Down Expand Up @@ -116,6 +117,7 @@
"pptr-testing-library": "^0.7.0",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.4.0",
"rmx-cli": "^0.4.15",
"tailwindcss": "^3.3.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.2.2",
Expand Down

0 comments on commit 81a1ab8

Please sign in to comment.