From 60893dae593bcc4b03ca1d72ad5f80f9de370542 Mon Sep 17 00:00:00 2001 From: Zain Fathoni Date: Sun, 6 Aug 2023 15:24:41 +0800 Subject: [PATCH] refactor(icons): replace all inline SVGs with SVG sprites --- README.md | 12 +- app/components/action-cards.tsx | 11 +- app/components/activities-grid.tsx | 23 ++- app/components/breadcrumbs.tsx | 5 +- app/components/card.tsx | 22 +- app/components/icon.tsx | 14 ++ app/components/icons.tsx | 27 --- app/components/taxonomy.tsx | 8 +- app/components/top-navigation.tsx | 38 ++-- app/icons/duotone.tsx | 314 ----------------------------- app/icons/light.tsx | 49 ----- app/icons/solid.tsx | 18 -- app/model/categories.ts | 60 +++--- 13 files changed, 121 insertions(+), 480 deletions(-) create mode 100644 app/components/icon.tsx delete mode 100644 app/components/icons.tsx delete mode 100644 app/icons/duotone.tsx delete mode 100644 app/icons/light.tsx delete mode 100644 app/icons/solid.tsx diff --git a/README.md b/README.md index f34f24b..8744225 100644 --- a/README.md +++ b/README.md @@ -159,13 +159,11 @@ npm run deploy ### How to use FontAwesome in the project 1. Search [FontAwesome Icons](https://fontawesome.com/icons) -2. Download the SVG code (if it's a Pro icon, please ask @zainfathoni to - download it for you) -3. Paste the SVG code into the `SVG INPUT` panel of - [SVGR with these params](https://react-svgr.com/playground/?svgProps=role%3Dimg%2Cfill%3DcurrentColor&typescript=true) -4. Copy the resulting `` tag in the `JSX OUTPUT` panel -5. Paste the `` tag into the corresponding file under the - [icons](/app/icons/) directory +2. Include the icons in the + [senarai](https://fontawesome.com/kits/5899c9809d/icons) icon kit. (please + ask @zainfathoni to do it for you) +3. Upload the new SVG sprites to the `/public/images/` directory +4. Use the `` component and pass the icon set and id as props ## Frequently Used Commands diff --git a/app/components/action-cards.tsx b/app/components/action-cards.tsx index 432ef14..d1a7c42 100644 --- a/app/components/action-cards.tsx +++ b/app/components/action-cards.tsx @@ -1,7 +1,8 @@ -import * as React from 'react' import { Link } from '@remix-run/react' -import { classNames } from '../utils/class-names' +import * as React from 'react' import { Categories } from '../model/categories' +import { classNames } from '../utils/class-names' +import { Icon } from './icon' export function ActionCards({ categories }: { categories: Categories }) { return ( @@ -29,7 +30,11 @@ export function ActionCards({ categories }: { categories: Categories }) { 'rounded-lg inline-flex p-3 ring-4 ring-white' )} > - +
diff --git a/app/components/activities-grid.tsx b/app/components/activities-grid.tsx index f77ea70..27e7d61 100644 --- a/app/components/activities-grid.tsx +++ b/app/components/activities-grid.tsx @@ -1,10 +1,10 @@ import { useMatches } from '@remix-run/react' import * as React from 'react' -import { Grid2Plus } from '../icons/duotone' import type { Activity } from '../model/activities' import { getCategoryByCategorySlug } from '../model/categories' import { classNames } from '../utils/class-names' import { Card } from './card' +import { Icon } from './icon' import { senaraiForm } from './top-navigation' export function ActivitesGrid({ activities }: { activities: Activity[] }) { @@ -19,7 +19,7 @@ export function ActivitesGrid({ activities }: { activities: Activity[] }) {

Belum ada aktivitas {category.title} @@ -84,7 +90,12 @@ export function ActivitesGrid({ activities }: { activities: Activity[] }) { rel="noopener noreferrer" className="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" > -