Skip to content

Commit

Permalink
Add better icons
Browse files Browse the repository at this point in the history
  • Loading branch information
altugbakan committed Nov 19, 2023
1 parent 3980b7d commit da040c8
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 205 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
"@astrojs/mdx": "^1.1.5",
"@astrojs/tailwind": "^5.0.2",
"astro": "^3.5.5",
"astro-icon": "^0.8.1",
"tailwindcss": "^3.3.5"
},
"devDependencies": {
"@iconify/json": "^2.2.143",
"@iconify/tailwind": "^0.1.3",
"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.1"
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import { Icon } from "astro-icon";
import { Image } from "astro:assets";
import Logo from "../images/logo.png";
Expand Down Expand Up @@ -66,8 +65,8 @@ const { className } = Astro.props;
toggle-theme-button
aria-label="Toggle theme"
>
<Icon name="ph:moon-fill" class="w-6 h-6 hidden dark:block" />
<Icon name="ph:sun-fill" class="w-6 h-6 block dark:hidden" />
<span class="icon-[ph--moon-fill] text-2xl hidden dark:block" />
<span class="icon-[ph--sun-fill] text-2xl block dark:hidden" />
</button>
</section>
</div>
Expand Down
14 changes: 4 additions & 10 deletions src/components/Project.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import Icon from "astro-icon";
import type { CollectionEntry } from "astro:content";
interface Props {
Expand All @@ -18,28 +17,23 @@ const { project } = Astro.props;
<p class="text-gray- dark:text-gray-400 mb-2">
{project.data.description}
</p>
<div class="flex flex-row space-between gap-2">
<div class="flex flex-row align-middle gap-2">
<a
href={project.data.url}
rel="noopener noreferrer"
target="_blank"
aria-label={`Visit project ${project.data.name}'s webpage`}
>
<Icon
name="mdi:globe"
class="inline-block w-5 h-5 mr-1 hover:scale-110"
/>
<span
class="icon-[mdi--globe] text-xl hover:scale-110" />
</a>
<a
href={project.data.github}
rel="noopener noreferrer"
target="_blank"
aria-label={`Visit project ${project.data.name}'s GitHub`}
>
<Icon
name="mdi:github"
class="inline-block w-5 h-5 mr-1 hover:scale-110"
/>
<span class="icon-[mdi--github] text-xl hover:scale-110" />
</a>
</div>
</div>
12 changes: 4 additions & 8 deletions src/components/Socials.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
import { Icon } from "astro-icon";
---

<p class="flex flex-row gap-4 justify-center">
<a
class="hover:scale-110"
Expand All @@ -10,7 +6,7 @@ import { Icon } from "astro-icon";
rel="noopener noreferrer"
aria-label="Altuğ's GitHub"
>
<Icon name="mdi:github" class="w-8 h-8 dark:fill-white" />
<span class="icon-[mdi--github] text-4xl dark:fill-white" />
</a>
<a
class="hover:scale-110"
Expand All @@ -19,7 +15,7 @@ import { Icon } from "astro-icon";
rel="noopener noreferrer"
aria-label="Altuğ's Twitter"
>
<Icon name="mdi:twitter" class="w-8 h-8 dark:fill-white" />
<span class="icon-[mdi--twitter] text-4xl dark:fill-white" />
</a>
<a
class="hover:scale-110"
Expand All @@ -28,13 +24,13 @@ import { Icon } from "astro-icon";
rel="noopener noreferrer"
aria-label="Altuğ's LinkedIn"
>
<Icon name="mdi:linkedin" class="w-8 h-8 dark:fill-white" />
<span class="icon-[mdi--linkedin] text-4xl dark:fill-white" />
</a>
<a
class="hover:scale-110"
href="mailto:[email protected]"
aria-label="Send an e-mail to Altuğ"
>
<Icon name="mdi:email" class="w-8 h-8 dark:fill-white" />
<span class="icon-[mdi--email] text-4xl dark:fill-white" />
</a>
</p>
22 changes: 22 additions & 0 deletions src/components/TechIcon.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
interface Props {
name: string;
}
const { name } = Astro.props;
function getIcon(): string {
switch (name) {
case "Arduino":
return "icon-[devicon--arduino]";
case "C++":
return "icon-[devicon--cplusplus]";
case "Rust":
return "icon-[simple-icons--rust]";
default:
return `icon-[carbon--unknown]`;
}
}
---

<span class={`${getIcon()} text-4xl`} />
1 change: 0 additions & 1 deletion src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const { title } = Astro.props;
as="style"
onload="this.onload=null; this.rel='stylesheet'; document.body.classList.add('fontLoaded')"
/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devicons/[email protected]/devicon.min.css">
<title>{title}</title>

<!-- Open Graph / Facebook -->
Expand Down
5 changes: 2 additions & 3 deletions src/layouts/ProjectLayout.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
import Icon from "astro-icon";
import BaseLayout from "./BaseLayout.astro";
import TechIcon from "../components/TechIcon.astro";
import type { CollectionEntry } from "astro:content";
import {techToIcon} from "../utils/techToIcon";
interface Props {
project: CollectionEntry<"projects">;
Expand Down Expand Up @@ -36,6 +35,6 @@ const { project } = Astro.props;
</div>
<h2 class="text-2xl font-bold mt-4 mb-2">Technologies</h2>
<p class="flex flex-row gap-2">
{project.data.technologies.map((tech) => <span>{tech}</span>)}
{project.data.technologies.map((tech) => <TechIcon name={tech} />)}
</p>
</BaseLayout>
4 changes: 1 addition & 3 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
import { Icon } from "astro-icon";
import BaseLayout from "../layouts/BaseLayout.astro";
---

Expand All @@ -12,7 +10,7 @@ import BaseLayout from "../layouts/BaseLayout.astro";
href="/"
aria-label="Go back home"
>
<Icon name="mdi:arrow-left" class="w-4 h-4" />
<span class="icon-[mdi--arrow-left]" />
<span class="text-center">Go back home</span>
</a>
</BaseLayout>
2 changes: 2 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Config } from "tailwindcss";
import { addDynamicIconSelectors } from "@iconify/tailwind";

export default {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
Expand All @@ -12,5 +13,6 @@ export default {
},
},
},
plugins: [addDynamicIconSelectors()],
darkMode: "class",
} satisfies Config;
Loading

0 comments on commit da040c8

Please sign in to comment.