Skip to content

Commit

Permalink
Merge branch 'master' into sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviortheking authored Aug 22, 2023
2 parents fbe4d7b + 2909598 commit 2f61d29
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 102 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# lucide-astro
# Simple Icons Astro

Astro library to get the Lucide.dev icons to the Astro Framework
Astro library to get the Simple Icons to the Astro Framework

_We follow the Lucide versions for our release, with the exception of the patches_
_We follow the Simple Icons versions for our release, with the exception of the patches_

## Installation

```
npm i lucide-astro
npm i simple-icons-astro
```

```
yarn add lucide-astro
yarn add simple-icons-astro
```

## Usage
Expand All @@ -20,11 +20,11 @@ You can import each icons individually like below

```astro
---
import { WifiOff } from 'lucide-astro'
import { Github } from 'simple-icons-astro'
---
<Layout>
<WifiOff />
<Github />
</Layout>
```

Expand All @@ -36,6 +36,6 @@ import { WifiOff } from 'lucide-astro'

## Attributions

Use the awesome icons from [Lucide](https://lucide.dev/)
Use the awesome icons from [Simple Icons](https://simpleicons.org/)

based on [astro-feather](https://github.com/gabrlyg/astro-feather)
based on [lucide-astro](https://github.com/dzeiocom/lucide-astro)
29 changes: 18 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "lucide-astro",
"version": "0.268.0",
"description": "Get your Lucide icons right into your Astro project",
"name": "simple-icons-astro",
"version": "9.9.0",
"description": "Get your Simple icons right into your Astro project",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"homepage": "https://lucide-astro.dzeio.com",
"bugs": "https://github.com/dzeiocom/lucide-astro/issues",
"repository": "https://github.com/dzeiocom/lucide-astro.git",
"homepage": "https://simple-icons-astro.dzeio.com",
"bugs": "https://github.com/dzeiocom/simple-icons-astro/issues",
"repository": "https://github.com/dzeiocom/simple-icons-astro.git",
"scripts": {
"prepublish": "node src/build.js",
"build": "node src/build.js"
Expand All @@ -19,14 +19,14 @@
"sideEffects": false,
"keywords": [
"astro",
"lucide",
"simple-icons",
"icons",
"astro-component"
],
"author": "Aviortheking",
"license": "MIT",
"devDependencies": {
"lucide-static": "0.268.0"
"simple-icons": "9.9.0"
},
"peerDependencies": {
"astro": "^2.7.1"
Expand Down
6 changes: 1 addition & 5 deletions src/.Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ delete Astro.props.size

<svg
xmlns="http://www.w3.org/2000/svg"
stroke-width={2}
width={size ?? 24}
height={size ?? 24}
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
fill="none"
fill="currentColor"
viewBox="0 0 24 24"
{...Astro.props}
>
Expand Down
5 changes: 4 additions & 1 deletion src/Template.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import Layout from './.Layout.astro'
export type { Props } from './index.d.ts'
---

<Layout {...Astro.props}>
<Layout
fill="<!-- color -->"
{...Astro.props}
>
<!-- icon -->
</Layout>
21 changes: 14 additions & 7 deletions src/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs/promises'
import Lucide from "lucide-static"
import * as SimpleIcons from "simple-icons"

// reset the dist folder
console.log('deleting the dist folder')
Expand All @@ -10,11 +10,11 @@ await fs.mkdir('./dist')
const template = await fs.readFile('./src/Template.astro', 'utf8')

// funciton tht fill the template with the icon SVG
function fillTemplate(icon) {
function fillTemplate(icon, color = '') {
return template.replace(
'<!-- icon -->',
icon.replace(/<svg(?:.|\n)*?>((?:.|\n)*)<\/svg>/gm, '$1').replace(/ /g, '\t').trim()
)
).replace('fill="<!-- color -->"', color ? `fill="#${color}"` : '')
}

// copy the base layout
Expand All @@ -30,18 +30,25 @@ try {

// loop through each icons
console.log('creating every icons')
for (const name in Lucide) {
for (const name in SimpleIcons) {
// get its SVG
const icon = Lucide[name]
/** @type {import('simple-icons').SimpleIcon} */
const icon = SimpleIcons[name]
const svg = icon.svg


// make the name PascalCase
const fullName = name.slice(0, 1).toUpperCase() + name.slice(1)
let fullName = name.slice(2)

if (/^\d/.test(fullName)) {
fullName = 'I' + fullName
}

// get the file path
const filePath = `./dist/${fullName}.astro`;

// compile the icon and write it out
await fs.writeFile(filePath, fillTemplate(icon), "utf-8");
await fs.writeFile(filePath, fillTemplate(svg, icon.hex), "utf-8");

// add the icon to the index
index += `export { default as ${fullName} } from './${fullName}.astro'\n`
Expand Down
5 changes: 1 addition & 4 deletions website/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ export default defineConfig({

// Customizable depending on goal
output: 'static',
site: 'https://lucide-astro.dzeio.com',
experimental: {
assets: true
}
site: 'https://simple-icons-astro.dzeio.com'
})
22 changes: 11 additions & 11 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lucide-astro-website",
"name": "simple-icons-astro-website",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -12,7 +12,7 @@
"@astrojs/tailwind": "^4",
"@dzeio/object-util": "^1",
"astro": "^2",
"lucide-astro": "*",
"simple-icons-astro": "*",
"tailwindcss": "^3"
}
}
15 changes: 0 additions & 15 deletions website/src/assets/lucide.dark.svg

This file was deleted.

15 changes: 0 additions & 15 deletions website/src/assets/lucide.light.svg

This file was deleted.

2 changes: 1 addition & 1 deletion website/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference types="astro/client-image" />
/// <reference types="astro/client" />
23 changes: 10 additions & 13 deletions website/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
import * as LucideAstro from 'lucide-astro'
import { Github } from 'lucide-astro'
import * as SimpleIcons from 'simple-icons-astro'
import { Github, Simpleicons } from 'simple-icons-astro'
import { objectMap } from '@dzeio/object-util'
import { Image } from 'astro:assets'
import LucideLight from '../assets/lucide.light.svg'
import LucideDark from '../assets/lucide.dark.svg'
---

<html lang="en">
Expand All @@ -13,23 +11,22 @@ import LucideDark from '../assets/lucide.dark.svg'
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<script defer data-domain="lucide-astro.dzeio.com" src="/js/index.js" />
<title>Lucide Icons for Astro</title>
<script defer data-domain="simple-icons-astro.dzeio.com" src="/js/index.js" />
<title>Simple Icons for Astro</title>
</head>
<body class="bg-gray-50 dark:bg-gray-950 dark:text-white">
<div class="flex w-full justify-evenly my-8 px-4">
<p class="font-bold text-xl flex gap-2 items-center">
<Image height={48} src={LucideLight} class="dark:hidden" alt="Astro Logo" />
<Image height={48} src={LucideDark} class="hidden dark:block" alt="Astro Logo" />
<span>Lucide Icons for the Astro Framework</span>
<Simpleicons size={48} class="dark:fill-white" />
<span>Simple Icons for the Astro Framework</span>
</p>
<a target="_blank" class="flex gap-2 items-center" href="https://github.com/dzeiocom/lucide-astro">
<a target="_blank" class="flex gap-2 items-center" href="https://github.com/dzeiocom/simple-icons-astro">
<span class="hidden md:block">See the Code on</span>
<Github />
<Github class="dark:fill-white" />
</a>
</div>
<div class="container flex m-auto flex-wrap gap-4">
{objectMap(LucideAstro, (Icon, key: string) => (
{objectMap(SimpleIcons, (Icon, key: string) => (
<div>
<Icon size={32} />
<p>{/^I\d/g.test(key) ? key.slice(1) : key}</p>
Expand Down

0 comments on commit 2f61d29

Please sign in to comment.