mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-03 16:59:42 +00:00
feat(@lucide/hono): add lucide package for Hono (#5069)
* feat(@lucide/hono): add lucide package for Hono Adds `@lucide/hono`, a Lucide icon package for Hono JSX, modelled on `lucide-preact` and rendering through `@lucide/shared`. - Icon, createLucideIcon, LucideProvider and types built on `hono/jsx` - Supports class names from `hono/css` by merging with Hono's `cx()` - Tests ported from lucide-preact (identical snapshots) plus Hono specific tests - CI workflow, release matrix, labeler, issue templates and PR title scope - Docs pages, sidebar, framework select, package list and logos Closes #4928 * fix(@lucide/hono): address review feedback Remove the deprecated absoluteStrokeWidth prop, follow the aria-hidden rule from #5347, add build and integration jobs to the workflow, and add an integration fixture under integrations/lucide-hono.
This commit is contained in:
@@ -18,6 +18,7 @@ body:
|
||||
- label: '@lucide/svelte'
|
||||
- label: '@lucide/angular'
|
||||
- label: '@lucide/astro'
|
||||
- label: '@lucide/hono'
|
||||
- label: lucide-react-native
|
||||
- label: lucide-preact
|
||||
- label: lucide-solid
|
||||
|
||||
@@ -18,6 +18,7 @@ body:
|
||||
- label: '@lucide/svelte'
|
||||
- label: '@lucide/angular'
|
||||
- label: '@lucide/astro'
|
||||
- label: '@lucide/hono'
|
||||
- label: lucide-react-native
|
||||
- label: lucide-preact
|
||||
- label: lucide-solid
|
||||
|
||||
@@ -91,6 +91,12 @@
|
||||
- any-glob-to-any-file:
|
||||
- 'packages/astro/*'
|
||||
|
||||
# For changes in the Lucide hono package
|
||||
🔥 hono package:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 'packages/hono/*'
|
||||
|
||||
# For changes in the @lucide/icons package
|
||||
❇️ lucide-icons:
|
||||
- changed-files:
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
name: Lucide Hono Checks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- next
|
||||
pull_request:
|
||||
paths:
|
||||
- packages/hono/**
|
||||
- packages/shared/**
|
||||
- tools/build-icons/**
|
||||
- tools/rollup-plugins/**
|
||||
- integrations/lucide-hono/**
|
||||
- package.json
|
||||
- pnpm-workspace.yaml
|
||||
- pnpm-lock.yaml
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
cache: 'pnpm'
|
||||
node-version-file: 'package.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm --filter @lucide/hono build
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
cache: 'pnpm'
|
||||
node-version-file: 'package.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Test
|
||||
run: pnpm --filter @lucide/hono test
|
||||
|
||||
typecheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
cache: 'pnpm'
|
||||
node-version-file: 'package.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Typecheck
|
||||
run: pnpm --filter @lucide/hono typecheck
|
||||
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
cache: 'pnpm'
|
||||
node-version-file: 'package.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Install Chromium
|
||||
run: pnpm --filter @lucide/integration-hono-vite exec playwright install --with-deps chromium
|
||||
|
||||
- name: Run integration checks
|
||||
run: pnpm test:integrations:hono
|
||||
@@ -52,6 +52,7 @@ jobs:
|
||||
'lucide-solid',
|
||||
'@lucide/angular',
|
||||
'@lucide/astro',
|
||||
'@lucide/hono',
|
||||
'@lucide/icons',
|
||||
'@lucide/solid',
|
||||
'@lucide/svelte',
|
||||
|
||||
@@ -41,6 +41,7 @@ Lucide is an open-source icon library that provides 1600+ vector (svg) files for
|
||||
| <img src="https://lucide.dev/framework-logos/react-native.svg" alt="React Native logo" width="48"> | **`lucide-react-native`** | [](https://www.npmjs.com/package/lucide-react-native) |  | [Docs](https://lucide.dev/guide/react-native) · [Source](./packages/lucide-react-native) |
|
||||
| <img src="https://lucide.dev/framework-logos/angular.svg" alt="Angular logo" width="48"> | **`@lucide/angular`** | [](https://www.npmjs.com/package/@lucide/angular) |  | [Docs](https://lucide.dev/guide/angular) · [Source](./packages/angular) |
|
||||
| <img src="https://lucide.dev/framework-logos/astro.svg" alt="Astro logo" width="48"> | **`@lucide/astro`** | [](https://www.npmjs.com/package/@lucide/astro) |  | [Docs](https://lucide.dev/guide/astro) · [Source](./packages/astro) |
|
||||
| <img src="https://lucide.dev/framework-logos/hono.svg" alt="Hono logo" width="48"> | **`@lucide/hono`** | [](https://www.npmjs.com/package/@lucide/hono) |  | [Docs](https://lucide.dev/guide/hono) · [Source](./packages/hono) |
|
||||
| <img src="https://lucide.dev/framework-logos/svg.svg" alt="SVG logo" width="48"> | **`lucide-static`** | [](https://www.npmjs.com/package/lucide-static) |  | [Docs](https://lucide.dev/guide/static) · [Source](./packages/lucide-static) |
|
||||
|
||||
### Figma
|
||||
|
||||
@@ -174,6 +174,24 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"@lucide/hono": {
|
||||
"docsAlias": "hono",
|
||||
"packageDirname": "hono",
|
||||
"order": 10,
|
||||
"icon": "hono",
|
||||
"shields": [
|
||||
{
|
||||
"alt": "npm",
|
||||
"src": "https://img.shields.io/npm/v/@lucide/hono",
|
||||
"href": "https://www.npmjs.com/package/@lucide/hono"
|
||||
},
|
||||
{
|
||||
"alt": "npm",
|
||||
"src": "https://img.shields.io/npm/dw/@lucide/hono",
|
||||
"href": "https://www.npmjs.com/package/@lucide/hono"
|
||||
}
|
||||
]
|
||||
},
|
||||
"lucide-static": {
|
||||
"order": 10,
|
||||
"icon": "svg",
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { DefaultTheme } from 'vitepress';
|
||||
|
||||
export const honoSidebar = [
|
||||
{
|
||||
items: [
|
||||
{
|
||||
text: 'Overview',
|
||||
link: '/guide/hono/',
|
||||
},
|
||||
{
|
||||
text: 'Getting started',
|
||||
link: '/guide/hono/getting-started',
|
||||
desc: 'Learn how to get started with Lucide for Hono.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Basics',
|
||||
items: [
|
||||
{
|
||||
text: 'Color',
|
||||
desc: 'Adjust the color of your icons',
|
||||
link: '/guide/hono/basics/color',
|
||||
},
|
||||
{
|
||||
text: 'Sizing',
|
||||
desc: 'Adjust the size of your icons',
|
||||
link: '/guide/hono/basics/sizing',
|
||||
},
|
||||
{
|
||||
text: 'Stroke width',
|
||||
desc: 'Adjust the stroke width of your icons',
|
||||
link: '/guide/hono/basics/stroke-width',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Advanced',
|
||||
items: [
|
||||
{
|
||||
text: 'Typescript',
|
||||
link: '/guide/hono/advanced/typescript',
|
||||
desc: 'All exported types and how to use them',
|
||||
},
|
||||
{
|
||||
text: 'Accessibility',
|
||||
link: '/guide/hono/advanced/accessibility',
|
||||
desc: 'Making your icons accessible',
|
||||
},
|
||||
{
|
||||
text: 'Global styling',
|
||||
link: '/guide/hono/advanced/global-styling',
|
||||
desc: 'Apply global styles to all icons',
|
||||
},
|
||||
{
|
||||
text: 'With Lucide Lab',
|
||||
link: '/guide/hono/advanced/with-lucide-lab',
|
||||
desc: 'Using lucide-lab with @lucide/hono',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Resources',
|
||||
items: [
|
||||
{
|
||||
text: 'Accessibility in depth',
|
||||
link: '/how-to/accessibility',
|
||||
desc: 'Accessibility best practices',
|
||||
},
|
||||
{
|
||||
text: 'VSCode',
|
||||
link: '/guide/vscode',
|
||||
desc: 'VSCode and Lucide',
|
||||
},
|
||||
],
|
||||
},
|
||||
] satisfies DefaultTheme.SidebarItem[] & { items: { desc?: string }[] }[];
|
||||
@@ -7,6 +7,7 @@ import { solidSidebar } from './solid.ts';
|
||||
import { preactSidebar } from './preact.ts';
|
||||
import { reactNativeSidebar } from './react-native.ts';
|
||||
import { astroSidebar } from './astro.ts';
|
||||
import { honoSidebar } from './hono.ts';
|
||||
import { resourcesSidebar } from './resources.ts';
|
||||
import { angularSidebar } from './angular.ts';
|
||||
import { lucideStaticSidebar } from './static.ts';
|
||||
@@ -32,6 +33,7 @@ const sidebar: Sidebar = {
|
||||
'/guide/svelte/': svelteSidebar,
|
||||
'/guide/solid/': solidSidebar,
|
||||
'/guide/astro/': astroSidebar,
|
||||
'/guide/hono/': honoSidebar,
|
||||
'/guide/preact/': preactSidebar,
|
||||
'/guide/react-native/': reactNativeSidebar,
|
||||
'/guide/angular/': angularSidebar,
|
||||
|
||||
@@ -35,6 +35,7 @@ const frameworks: Framework[] = [
|
||||
iconDark: '/framework-logos/astro-dark.svg',
|
||||
value: '/guide/astro/',
|
||||
},
|
||||
{ name: 'Hono', icon: '/framework-logos/hono.svg', value: '/guide/hono/' },
|
||||
{ name: 'Static', icon: '/framework-logos/svg.svg', value: '/guide/static/' },
|
||||
];
|
||||
|
||||
|
||||
@@ -51,6 +51,12 @@ const loader = {
|
||||
label: 'Lucide documentation for Astro',
|
||||
path: '/guide/astro/',
|
||||
},
|
||||
{
|
||||
name: 'lucide-hono',
|
||||
logo: '/framework-logos/hono.svg',
|
||||
label: 'Lucide documentation for Hono',
|
||||
path: '/guide/hono/',
|
||||
},
|
||||
{
|
||||
name: 'lucide-react-native',
|
||||
logo: '/framework-logos/react-native.svg',
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: Accessibility - Hono
|
||||
description: Best practices for accessible icons in your application.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import OverviewLink from '~/.vitepress/theme/components/base/OverviewLink.vue'
|
||||
</script>
|
||||
|
||||
# Accessibility
|
||||
|
||||
Lucide icons ship with `aria-hidden="true"` by default. In almost all cases this is exactly what you want.
|
||||
|
||||
## Should icons be accessible?
|
||||
|
||||
Most of the time, icons are used purely for decoration or visual reinforcement. Exposing decorative icons to assistive technologies can create unnecessary noise for screen reader users.
|
||||
|
||||
For a broader explanation of this, and other best practices on how to use icons accessibly in your application, please refer to our detailed guide on accessibility:
|
||||
|
||||
<OverviewLink href="/how-to/accessibility" title="Accessible Icons" desc="Best practices for accessible icons in your application."/>
|
||||
|
||||
Only if an icon **conveys essential meaning on its own** should it be made accessible. The sections below explain how to do that in Hono.
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```tsx
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
<House aria-label="This is my house" />
|
||||
```
|
||||
|
||||
Choose a label that clearly describes the meaning of the icon or the action it represents in the context of your application.
|
||||
|
||||
## Accessible icon buttons
|
||||
|
||||
When an icon is used inside a button, the accessible label should usually be applied to the button itself, and not the icon.
|
||||
|
||||
```tsx
|
||||
<button aria-label="Go to home">
|
||||
<House />
|
||||
</button>
|
||||
```
|
||||
|
||||
This ensures assistive technologies describe the interactive element, rather than the decorative graphic inside it.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: Global Styling - Hono
|
||||
description: Learn how to style all Lucide icons globally in your Hono application using CSS or the Lucide context provider.
|
||||
---
|
||||
|
||||
# Global Styling
|
||||
|
||||
Adjusting icons can be done by using [color](../basics/color.md), [size](../basics/sizing.md) and [stroke width](../basics/stroke-width.md).
|
||||
To style all icons globally, you can either use CSS, or use a context provider.
|
||||
|
||||
We recommend using CSS for global styling, as it is the most straightforward way to achieve this.
|
||||
But using CSS prevents you from using props like `size`, `color` and `strokeWidth` on individual icons, since CSS specificity will override these props, to be able to use the props on individual ones you need to use the Lucide context provider.
|
||||
|
||||
## Context Provider
|
||||
|
||||
For global styling using a context provider, you can use the `LucideProvider` component that is provided by the `@lucide/hono` package.
|
||||
|
||||
```tsx
|
||||
import { Hono } from 'hono';
|
||||
import { LucideProvider, House } from '@lucide/hono';
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) => {
|
||||
return c.html(
|
||||
<LucideProvider
|
||||
color="red"
|
||||
size={48}
|
||||
strokeWidth={2}
|
||||
>
|
||||
<House />
|
||||
</LucideProvider>,
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
This will apply the `color`, `size` and `strokeWidth` props to all icons that are children of the `LucideProvider`.
|
||||
|
||||
## Style by using CSS
|
||||
|
||||
Styling icons is easy to accomplish using CSS.
|
||||
|
||||
Every icon has a class attribute applied called `lucide`. This class name can be used in the CSS file to target all icons that are being used within the app.
|
||||
|
||||
- The **color** of the icons can be changed using the [`color`](https://developer.mozilla.org/en-US/docs/Web/CSS/color) CSS property.
|
||||
- The **size** of the icons can be changed using [`width`](https://developer.mozilla.org/en-US/docs/Web/CSS/width) and [`height`](https://developer.mozilla.org/en-US/docs/Web/CSS/height) CSS properties.
|
||||
- The **stroke width** of the icons can be changed using the [`stroke-width`](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width) CSS property.
|
||||
|
||||
```css
|
||||
.lucide {
|
||||
color: #ffadff;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
stroke-width: 1px;
|
||||
}
|
||||
```
|
||||
|
||||
### Non-scaling strokes
|
||||
|
||||
For global non-scaling stroke width styling the `vector-effect: non-scaling-stroke` CSS property can be applied to the children. This will keep the stroke-width the same size no matter the size of the icon. See [non-scaling strokes](../basics/stroke-width.md#non-scaling-strokes) for more info.
|
||||
|
||||
```css
|
||||
.lucide {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.lucide * {
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,111 @@
|
||||
---
|
||||
title: TypeScript - Hono
|
||||
description: Learn about the different types exported by the `@lucide/hono` package and how to use them in your Hono application.
|
||||
---
|
||||
|
||||
# TypeScript
|
||||
|
||||
List of exported types from the `@lucide/hono` package.
|
||||
These can be used to type your components when using Lucide icons in a TypeScript Hono project.
|
||||
|
||||
## `LucideProps`
|
||||
|
||||
Exports all props that can be passed to an icon component and any other SVG attributes, see: [SVG Presentation Attributes on MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation).
|
||||
|
||||
```ts
|
||||
interface LucideProps {
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number | string;
|
||||
nonScalingStroke?: boolean;
|
||||
[key: string]: any; // Any other SVG attributes
|
||||
}
|
||||
```
|
||||
|
||||
### Using `LucideProps`
|
||||
|
||||
You can use the `LucideProps` interface to type your custom icon components or when you need to work with icon props.
|
||||
|
||||
```tsx
|
||||
import { Camera, type LucideProps } from '@lucide/hono';
|
||||
|
||||
const WrapIcon = (props: LucideProps) => {
|
||||
return <Camera {...props} />;
|
||||
};
|
||||
|
||||
export default WrapIcon;
|
||||
```
|
||||
|
||||
## `LucideIcon`
|
||||
|
||||
Type for individual icon components.
|
||||
|
||||
```ts
|
||||
import type { FC } from 'hono/jsx';
|
||||
|
||||
type LucideIcon = FC<LucideProps>;
|
||||
```
|
||||
|
||||
### Using `LucideIcon`
|
||||
|
||||
You can use the `LucideIcon` type when you need to work with icon components directly.
|
||||
|
||||
```tsx
|
||||
import { House, Library, Cog, type LucideIcon } from '@lucide/hono';
|
||||
|
||||
type MenuItem = {
|
||||
name: string;
|
||||
href: string;
|
||||
icon: LucideIcon;
|
||||
};
|
||||
|
||||
const menuItems: MenuItem[] = [
|
||||
{ name: 'Home', href: '/', icon: House },
|
||||
{ name: 'Blog', href: '/blog', icon: Library },
|
||||
{ name: 'Projects', href: '/projects', icon: Cog },
|
||||
];
|
||||
|
||||
const Menu = () => (
|
||||
<nav>
|
||||
{menuItems.map((item) => (
|
||||
<a href={item.href}>
|
||||
<item.icon />
|
||||
<span>{item.name}</span>
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
```
|
||||
|
||||
## `LucideIconNode`
|
||||
|
||||
Type for the raw SVG structure of an icon. This is an array of SVG elements and their attributes to render the icon.
|
||||
Not commonly used directly in application code. But can be useful for advanced use cases, such as using custom icons or with Lucide Lab.
|
||||
|
||||
```ts
|
||||
type LucideIconNode = [elementName: string, attrs: Record<string, any>];
|
||||
```
|
||||
|
||||
### Using `LucideIconNode`
|
||||
|
||||
You can use the `LucideIconNode` type when you need to work with the raw SVG structure of an icon.
|
||||
|
||||
```tsx
|
||||
import { Icon, type LucideIconNode } from '@lucide/hono';
|
||||
|
||||
const customIcon: LucideIconNode[] = [
|
||||
['circle', { cx: 12, cy: 12, r: 10 }],
|
||||
['line', { x1: 12, y1: 8, x2: 12, y2: 12 }],
|
||||
['line', { x1: 12, y1: 16, x2: 12, y2: 16 }],
|
||||
];
|
||||
|
||||
const MyIcon = () => {
|
||||
return (
|
||||
<Icon
|
||||
iconNode={customIcon}
|
||||
size={24}
|
||||
color="blue"
|
||||
/>
|
||||
);
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: With Lucide Lab or custom icons - Hono
|
||||
description: Learn how to use Lucide Lab or custom icons in your Hono applications using the Icon component.
|
||||
---
|
||||
|
||||
# With Lucide Lab or custom icons
|
||||
|
||||
[Lucide Lab](https://github.com/lucide-icons/lucide-lab) is a collection of icons that are not part of the Lucide main library.
|
||||
|
||||
They can be used by using the `Icon` component.
|
||||
All props like regular lucide icons can be passed to adjust the icon appearance.
|
||||
|
||||
## Using the `Icon` component
|
||||
|
||||
This creates a single icon based on the iconNode passed and renders a Lucide icon component.
|
||||
|
||||
```tsx
|
||||
import { Icon } from '@lucide/hono';
|
||||
import { burger, sausage } from '@lucide/lab';
|
||||
|
||||
const App = () => (
|
||||
<>
|
||||
<Icon iconNode={burger} />
|
||||
<Icon
|
||||
iconNode={sausage}
|
||||
color="red"
|
||||
/>
|
||||
</>
|
||||
);
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: Color - Hono
|
||||
description: Learn how to customize the color of Lucide icons in your Hono applications using the color prop and CSS.
|
||||
---
|
||||
|
||||
# Color
|
||||
|
||||
By default, all icons have the color value: `currentColor`. This keyword uses the element's computed text `color` value to represent the icon color.
|
||||
|
||||
Read more about [`currentColor` on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword).
|
||||
|
||||
## Adjust the color using the `color` prop
|
||||
|
||||
The color can be adjusted by passing the color prop to the element.
|
||||
|
||||
```tsx
|
||||
import { Smile } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return <Smile color="#3e9392" />;
|
||||
};
|
||||
```
|
||||
|
||||
## Using parent elements text color value
|
||||
|
||||
Because the color of lucide icons uses `currentColor`, the color of the icon depends on the computed `color` of the element, or it inherits it from its parent.
|
||||
|
||||
For example, if a parent element's color value is `#fff` and one of the children is a lucide icon, the color of the icon will be rendered as `#fff`. This is browser native behavior.
|
||||
|
||||
```tsx
|
||||
import { ThumbsUp } from '@lucide/hono';
|
||||
|
||||
const LikeButton = () => {
|
||||
return (
|
||||
<button style={{ color: '#fff' }}>
|
||||
<ThumbsUp />
|
||||
Like
|
||||
</button>
|
||||
);
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: Sizing - Hono
|
||||
description: Learn how to adjust the size of Lucide icons in your Hono applications using the size prop and CSS.
|
||||
---
|
||||
|
||||
# Sizing
|
||||
|
||||
By default, the size of all icons is `24px` by `24px`. The size is adjustable using the `size` prop and CSS.
|
||||
|
||||
## Adjusting the icon size using the `size` prop
|
||||
|
||||
```tsx
|
||||
import { Landmark } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return <Landmark size={64} />;
|
||||
};
|
||||
```
|
||||
|
||||
## Adjusting the icon size via CSS
|
||||
|
||||
The CSS properties `width` and `height` can be used to adjust the icon size.
|
||||
|
||||
```tsx
|
||||
import { Beer } from '@lucide/hono';
|
||||
import { css, Style } from 'hono/css';
|
||||
|
||||
const beerIcon = css`
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
`;
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<Style />
|
||||
<Beer class={beerIcon} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### Dynamically change the icon size based on the font size
|
||||
|
||||
It is possible to resize icons based on font size. This can be achieved using the `em` unit. See this [MDN article](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size#ems) for more information on the `em` unit.
|
||||
|
||||
::: code-group
|
||||
|
||||
```css [icon.css]
|
||||
.my-icon {
|
||||
/* Icon size will relative to font-size of .text-wrapper */
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
.text-wrapper {
|
||||
font-size: 96px;
|
||||
|
||||
/* layout stuff */
|
||||
display: flex;
|
||||
gap: 0.25em;
|
||||
align-items: center;
|
||||
}
|
||||
```
|
||||
|
||||
```tsx [page.tsx]
|
||||
import { Star } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<div class="text-wrapper">
|
||||
<Star class="my-icon" />
|
||||
<div>Yes</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Resizing with Tailwind
|
||||
|
||||
`size-*` utilities can be used to adjust the size of the icon. See the [Tailwind documentation](https://tailwindcss.com/docs/width#setting-both-width-and-height) for more information on the `size-*` utilities.
|
||||
|
||||
```tsx
|
||||
import { PartyPopper } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return <PartyPopper class="size-24" />;
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: Stroke width - Hono
|
||||
description: Learn how to customize the stroke width of Lucide icons in your Hono applications using the strokeWidth and nonScalingStroke props.
|
||||
---
|
||||
|
||||
# Stroke width
|
||||
|
||||
All icons are designed with SVG elements using strokes.
|
||||
These have a default stroke width of `2px`.
|
||||
|
||||
The `strokeWidth` can be adjusted to create a different look of the icons.
|
||||
|
||||
## Adjusting stroke width with `strokeWidth` prop
|
||||
|
||||
```tsx
|
||||
import { FolderLock } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return <FolderLock strokeWidth={1} />;
|
||||
};
|
||||
```
|
||||
|
||||
## Non-scaling strokes
|
||||
|
||||
When adjusting the `size` prop the size of the stroke width will be relative to the size of the icon, this is the default SVG behavior. The `nonScalingStroke` prop is introduced to adjust this behavior to make the stroke width constant no matter the size of the icon.
|
||||
|
||||
This means that when `nonScalingStroke` is enabled and the `size` of the icons is set to `48px` the `strokeWidth` will still be `2px` on the screen.
|
||||
|
||||
Note `2px` is the default stroke width for a Lucide icon, this can be adjusted to all sizes.
|
||||
|
||||
<!--@include: ../../../images/non-scaling-stroke-compare.svg -->
|
||||
|
||||
### Adjusting stroke width with `nonScalingStroke` prop
|
||||
|
||||
Setting `nonScalingStroke` to `true` will make the stroke width non-scaling.
|
||||
|
||||
```tsx
|
||||
import { RollerCoaster } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<RollerCoaster
|
||||
size={96}
|
||||
nonScalingStroke
|
||||
/>
|
||||
);
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
title: Getting started - Hono
|
||||
description: This guide will help you get started with Lucide in your Hono project.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import OverviewLink from '../../.vitepress/theme/components/base/OverviewLink.vue'
|
||||
import OverviewLinkGrid from '../../.vitepress/theme/components/base/OverviewLinkGrid.vue'
|
||||
import { honoSidebar } from '../../.vitepress/sidebar/hono'
|
||||
</script>
|
||||
|
||||
# Getting started
|
||||
|
||||
This guide will help you get started with Lucide in your Hono project.
|
||||
Make sure you have a Hono project set up with [JSX enabled](https://hono.dev/docs/guides/jsx#settings). If you don't have one yet, you can create one with `npm create hono@latest`.
|
||||
|
||||
## Installation
|
||||
|
||||
::: code-group
|
||||
|
||||
```sh [pnpm]
|
||||
pnpm add @lucide/hono
|
||||
```
|
||||
|
||||
```sh [yarn]
|
||||
yarn add @lucide/hono
|
||||
```
|
||||
|
||||
```sh [npm]
|
||||
npm install @lucide/hono
|
||||
```
|
||||
|
||||
```sh [bun]
|
||||
bun add @lucide/hono
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Importing your first icon
|
||||
|
||||
Lucide is built with ES Modules, so it's completely tree-shakable.
|
||||
|
||||
Each icon can be imported as a Hono JSX component, which renders an inline SVG element. This way, only the icons that are imported into your project are included in the final bundle. The rest of the icons are tree-shaken away.
|
||||
|
||||
```tsx
|
||||
import { Hono } from 'hono';
|
||||
import { Camera } from '@lucide/hono';
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) => {
|
||||
return c.html(<Camera />);
|
||||
});
|
||||
|
||||
export default app;
|
||||
```
|
||||
|
||||
## Props
|
||||
|
||||
To customize the appearance of an icon, you can use the following props:
|
||||
|
||||
| name | type | default |
|
||||
| ------------------ | --------- | ------------ |
|
||||
| `size` | _number_ | 24 |
|
||||
| `color` | _string_ | currentColor |
|
||||
| `strokeWidth` | _number_ | 2 |
|
||||
| `nonScalingStroke` | _boolean_ | false |
|
||||
|
||||
Because icons render as SVG elements, all standard SVG attributes can also be applied as props. See the list of SVG Presentation Attributes on [MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation).
|
||||
|
||||
```tsx
|
||||
import { Camera } from '@lucide/hono';
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<Camera
|
||||
size={48}
|
||||
color="red"
|
||||
strokeWidth={1}
|
||||
/>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
More examples and details how to use props, continue the guide:
|
||||
|
||||
<OverviewLinkGrid>
|
||||
<OverviewLink v-for="item in honoSidebar[1].items" :key="item.link" :href="item.link" :title="item.text" :desc="item.desc"/>
|
||||
</OverviewLinkGrid>
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Lucide for Hono
|
||||
description: Learn how to use Lucide icons in your Hono applications with Hono JSX.
|
||||
nextPage:
|
||||
- getting-started
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import OverviewLink from '../../.vitepress/theme/components/base/OverviewLink.vue'
|
||||
import OverviewLinkGrid from '../../.vitepress/theme/components/base/OverviewLinkGrid.vue'
|
||||
import { honoSidebar } from '../../.vitepress/sidebar/hono'
|
||||
</script>
|
||||
|
||||
<!--@include: ../../../docs/images/package-logos/lucide-hono.svg -->
|
||||
|
||||
# Lucide for Hono
|
||||
|
||||
Lucide provides an icon component library for [Hono JSX](https://hono.dev/docs/guides/jsx).
|
||||
Each icon is a Hono JSX component that renders an inline SVG element, so icons are part of the HTML your Hono app sends, on any runtime Hono supports.
|
||||
|
||||
List of features:
|
||||
|
||||
- **Easy to Use**: Import icons as Hono JSX components and use them directly in `c.html()` or any Hono JSX component.
|
||||
- **Customizable**: Adjust size, color, and other properties via props.
|
||||
- **Tree-shakable**: Only the icons you use are included in your final bundle.
|
||||
- **TypeScript Support**: Fully typed components for better developer experience.
|
||||
|
||||
## Overview
|
||||
|
||||
<OverviewLinkGrid>
|
||||
<OverviewLink v-for="item in honoSidebar[0].items.slice(1)" :key="item.link" :href="item.link" :title="item.text" :desc="item.desc"/>
|
||||
</OverviewLinkGrid>
|
||||
|
||||
### Basics
|
||||
{{''}}
|
||||
|
||||
<OverviewLinkGrid>
|
||||
<OverviewLink v-for="item in honoSidebar[1].items" :key="item.link" :href="item.link" :title="item.text" :desc="item.desc"/>
|
||||
</OverviewLinkGrid>
|
||||
|
||||
### Advanced
|
||||
{{''}}
|
||||
|
||||
<OverviewLinkGrid>
|
||||
<OverviewLink v-for="item in honoSidebar[2].items" :key="item.link" :href="item.link" :title="item.text" :desc="item.desc"/>
|
||||
</OverviewLinkGrid>
|
||||
|
||||
### Resources
|
||||
{{''}}
|
||||
|
||||
<OverviewLinkGrid>
|
||||
<OverviewLink v-for="item in honoSidebar[3].items" :key="item.link" :href="item.link" :title="item.text" :desc="item.desc"/>
|
||||
</OverviewLinkGrid>
|
||||
+1
-1
@@ -29,7 +29,7 @@ However, not everyone can understand them easily. Read more about [how to use Lu
|
||||
|
||||
## Official Packages
|
||||
|
||||
Lucide's official packages are designed to work on different platforms, making it easier for users to integrate icons into their projects. The packages are available for various technologies, including [Web (Vanilla)](./lucide/index.md), [React](./react/index.md), [React Native](./react-native/index.md), [Vue](./vue/index.md), [Svelte](./svelte/index.md), [Preact](./preact/index.md), [Solid](./solid/index.md), [Angular](./angular/index.md), [Astro](./astro/index.md), and [Static](./static/index.md).
|
||||
Lucide's official packages are designed to work on different platforms, making it easier for users to integrate icons into their projects. The packages are available for various technologies, including [Web (Vanilla)](./lucide/index.md), [React](./react/index.md), [React Native](./react-native/index.md), [Vue](./vue/index.md), [Svelte](./svelte/index.md), [Preact](./preact/index.md), [Solid](./solid/index.md), [Angular](./angular/index.md), [Astro](./astro/index.md), [Hono](./hono/index.md), and [Static](./static/index.md).
|
||||
|
||||
## Community
|
||||
|
||||
|
||||
@@ -248,6 +248,36 @@ deno add @lucide/astro
|
||||
|
||||
For more details, see the [documentation](./astro/index.md).
|
||||
|
||||
## Hono
|
||||
|
||||
Implementation of the Lucide icon library for Hono applications using Hono JSX.
|
||||
|
||||
::: code-group
|
||||
|
||||
```sh [pnpm]
|
||||
pnpm add @lucide/hono
|
||||
```
|
||||
|
||||
```sh [yarn]
|
||||
yarn add @lucide/hono
|
||||
```
|
||||
|
||||
```sh [npm]
|
||||
npm install @lucide/hono
|
||||
```
|
||||
|
||||
```sh [bun]
|
||||
bun add @lucide/hono
|
||||
```
|
||||
|
||||
```sh [deno]
|
||||
deno add @lucide/hono
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
For more details, see the [documentation](./hono/index.md).
|
||||
|
||||
## Static usage
|
||||
|
||||
Implementation of the Lucide icon library for multiple usages that like to use: SVG files icons, SVG Sprite, Icon Fonts and static SVG strings export in Common JS modules (for NodeJS).
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 -1 120 26" class="package-lucide-logo">
|
||||
<path fill="currentColor"
|
||||
d="M74.202 18.17c-.875 0-1.63-.181-2.267-.545a3.694 3.694 0 0 1-1.46-1.557c-.341-.674-.512-1.468-.512-2.38 0-.898.17-1.686.512-2.364a3.867 3.867 0 0 1 1.443-1.591c.617-.383 1.342-.574 2.176-.574.538 0 1.045.087 1.523.261.48.17.905.436 1.272.796.371.36.663.818.875 1.375.212.553.319 1.212.319 1.977v.63h-7.154v-1.386h5.182a2.213 2.213 0 0 0-.256-1.05c-.166-.311-.4-.556-.699-.734a1.964 1.964 0 0 0-1.034-.267c-.42 0-.79.103-1.108.307-.318.2-.566.466-.744.796a2.289 2.289 0 0 0-.267 1.073v1.21c0 .508.093.944.278 1.307.186.36.445.637.779.83.333.19.723.284 1.17.284.3 0 .57-.042.813-.125.242-.087.452-.214.63-.38.178-.167.313-.374.404-.62l1.92.216c-.121.508-.352.95-.693 1.33a3.379 3.379 0 0 1-1.295.875c-.527.204-1.13.306-1.807.306Z" />
|
||||
<path fill="currentColor"
|
||||
d="M63.498 18.153c-.685 0-1.299-.176-1.84-.528-.542-.352-.97-.864-1.285-1.534-.314-.67-.471-1.485-.471-2.443 0-.97.159-1.788.477-2.455.322-.67.756-1.176 1.301-1.517a3.344 3.344 0 0 1 1.824-.517c.512 0 .932.087 1.262.261.329.17.59.377.784.62.193.238.342.464.448.676h.086V6.364h2.062V18h-2.023v-1.375h-.125c-.106.212-.259.438-.46.676a2.53 2.53 0 0 1-.795.602c-.33.167-.745.25-1.245.25Zm.574-1.687c.436 0 .807-.117 1.114-.352.307-.239.54-.57.699-.995.159-.424.238-.918.238-1.483 0-.564-.08-1.055-.238-1.471-.156-.417-.387-.74-.693-.972-.303-.23-.676-.346-1.12-.346-.458 0-.84.119-1.147.358-.307.238-.538.568-.694.988-.155.42-.233.902-.233 1.443 0 .546.078 1.033.233 1.46.16.425.392.76.7 1.006.31.243.69.364 1.141.364Z" />
|
||||
<path fill="currentColor"
|
||||
d="M56.088 18V9.273h2.057V18h-2.057Zm1.034-9.966a1.2 1.2 0 0 1-.84-.324 1.044 1.044 0 0 1-.353-.79c0-.31.117-.573.352-.79.235-.219.515-.329.841-.329.33 0 .61.11.841.33.235.216.352.479.352.79 0 .306-.117.57-.352.79a1.187 1.187 0 0 1-.84.323Z" />
|
||||
<path fill="currentColor"
|
||||
d="M50.66 18.17c-.87 0-1.619-.19-2.244-.573a3.831 3.831 0 0 1-1.437-1.586c-.334-.678-.5-1.458-.5-2.34 0-.887.17-1.67.511-2.347a3.817 3.817 0 0 1 1.443-1.591c.625-.383 1.364-.574 2.216-.574.709 0 1.335.13 1.88.392.55.258.988.623 1.313 1.097.326.47.512 1.019.557 1.647h-1.966c-.08-.42-.269-.77-.568-1.05-.295-.285-.691-.427-1.187-.427-.42 0-.79.114-1.108.341-.319.223-.567.545-.745.966-.174.42-.261.924-.261 1.511 0 .595.087 1.106.261 1.534.175.425.419.752.733.983.319.228.692.341 1.12.341.303 0 .574-.056.812-.17.242-.118.445-.286.608-.506a1.94 1.94 0 0 0 .335-.801H54.4a3.427 3.427 0 0 1-.545 1.642 3.23 3.23 0 0 1-1.284 1.114c-.542.265-1.178.397-1.91.397Z" />
|
||||
<path fill="currentColor"
|
||||
d="M42.682 14.33V9.272h2.057V18h-1.995v-1.551h-.09c-.198.488-.521.888-.972 1.199-.447.31-.998.466-1.654.466-.572 0-1.077-.127-1.517-.381a2.645 2.645 0 0 1-1.022-1.12c-.246-.492-.37-1.086-.37-1.784V9.273h2.057v5.238c0 .553.152.993.455 1.319.303.325.7.488 1.193.488.303 0 .596-.074.88-.221.285-.148.518-.368.7-.66.185-.295.278-.664.278-1.107Z" />
|
||||
<path fill="currentColor" d="M28.148 18V6.364h2.108v9.869h5.125V18h-7.233Z" />
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M14 12a4 4 0 0 0-8 0 8 8 0 0 0 16 0 11.97 11.97 0 0 0-4-8.944" />
|
||||
<path stroke="#F56565" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M10 12a4 4 0 0 0 8 0 8 8 0 1 0-16 0c0 3.584 1.571 6.801 4.063 9" />
|
||||
<circle cx="88" cy="12" r="2" fill="#737374" />
|
||||
<g transform="translate(98.7 0) scale(0.2449)">
|
||||
<path fill="url(#lucide-hono-gradient)" d="m11 25 7 9s9-18 22-34c17 20 36 48 36 64 0 20-19 34-37 34C17 98 0 81 0 61c0-6 3-24 11-36Z"/>
|
||||
<path fill="#F95" d="M39 21c47 51 14 66 0 66-11 0-51-11 0-66Z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="lucide-hono-gradient" x2="0%" y2="100%">
|
||||
<stop stop-color="#F84"/>
|
||||
<stop offset="100%" stop-color="#F30"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 76 98">
|
||||
<path fill="url(#a)" d="m11 25 7 9s9-18 22-34c17 20 36 48 36 64 0 20-19 34-37 34C17 98 0 81 0 61c0-6 3-24 11-36Z"/>
|
||||
<path fill="#F95" d="M39 21c47 51 14 66 0 66-11 0-51-11 0-66Z"/>
|
||||
<defs>
|
||||
<linearGradient id="a" x2="0%" y2="100%">
|
||||
<stop stop-color="#F84"/>
|
||||
<stop offset="100%" stop-color="#F30"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 418 B |
@@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 118 24">
|
||||
<path fill="#fff" d="M74.202 18.17c-.875 0-1.63-.181-2.267-.545a3.694 3.694 0 0 1-1.46-1.557c-.341-.674-.512-1.468-.512-2.38 0-.898.17-1.686.512-2.364a3.867 3.867 0 0 1 1.443-1.591c.617-.383 1.342-.574 2.176-.574.538 0 1.045.087 1.523.261.48.17.905.436 1.272.796.371.36.663.818.875 1.375.212.553.319 1.212.319 1.977v.63h-7.154v-1.386h5.182a2.213 2.213 0 0 0-.256-1.05c-.166-.311-.4-.556-.699-.734a1.964 1.964 0 0 0-1.034-.267c-.42 0-.79.103-1.108.307-.318.2-.566.466-.744.796a2.289 2.289 0 0 0-.267 1.073v1.21c0 .508.093.944.278 1.307.186.36.445.637.779.83.333.19.723.284 1.17.284.3 0 .57-.042.813-.125.242-.087.452-.214.63-.38.178-.167.313-.374.404-.62l1.92.216c-.121.508-.352.95-.693 1.33a3.379 3.379 0 0 1-1.295.875c-.527.204-1.13.306-1.807.306Z"/>
|
||||
<path fill="#fff" d="M63.498 18.153c-.685 0-1.299-.176-1.84-.528-.542-.352-.97-.864-1.285-1.534-.314-.67-.471-1.485-.471-2.443 0-.97.159-1.788.477-2.455.322-.67.756-1.176 1.301-1.517a3.344 3.344 0 0 1 1.824-.517c.512 0 .932.087 1.262.261.329.17.59.377.784.62.193.238.342.464.448.676h.086V6.364h2.062V18h-2.023v-1.375h-.125c-.106.212-.259.438-.46.676a2.53 2.53 0 0 1-.795.602c-.33.167-.745.25-1.245.25Zm.574-1.687c.436 0 .807-.117 1.114-.352.307-.239.54-.57.699-.995.159-.424.238-.918.238-1.483 0-.564-.08-1.055-.238-1.471-.156-.417-.387-.74-.693-.972-.303-.23-.676-.346-1.12-.346-.458 0-.84.119-1.147.358-.307.238-.538.568-.694.988-.155.42-.233.902-.233 1.443 0 .546.078 1.033.233 1.46.16.425.392.76.7 1.006.31.243.69.364 1.141.364Z"/>
|
||||
<path fill="#fff" d="M56.088 18V9.273h2.057V18h-2.057Zm1.034-9.966a1.2 1.2 0 0 1-.84-.324 1.044 1.044 0 0 1-.353-.79c0-.31.117-.573.352-.79.235-.219.515-.329.841-.329.33 0 .61.11.841.33.235.216.352.479.352.79 0 .306-.117.57-.352.79a1.187 1.187 0 0 1-.84.323Z"/>
|
||||
<path fill="#fff" d="M50.66 18.17c-.87 0-1.619-.19-2.244-.573a3.831 3.831 0 0 1-1.437-1.586c-.334-.678-.5-1.458-.5-2.34 0-.887.17-1.67.511-2.347a3.817 3.817 0 0 1 1.443-1.591c.625-.383 1.364-.574 2.216-.574.709 0 1.335.13 1.88.392.55.258.988.623 1.313 1.097.326.47.512 1.019.557 1.647h-1.966c-.08-.42-.269-.77-.568-1.05-.295-.285-.691-.427-1.187-.427-.42 0-.79.114-1.108.341-.319.223-.567.545-.745.966-.174.42-.261.924-.261 1.511 0 .595.087 1.106.261 1.534.175.425.419.752.733.983.319.228.692.341 1.12.341.303 0 .574-.056.812-.17.242-.118.445-.286.608-.506a1.94 1.94 0 0 0 .335-.801H54.4a3.427 3.427 0 0 1-.545 1.642 3.23 3.23 0 0 1-1.284 1.114c-.542.265-1.178.397-1.91.397Z"/>
|
||||
<path fill="#fff" d="M42.682 14.33V9.272h2.057V18h-1.995v-1.551h-.09c-.198.488-.521.888-.972 1.199-.447.31-.998.466-1.654.466-.572 0-1.077-.127-1.517-.381a2.645 2.645 0 0 1-1.022-1.12c-.246-.492-.37-1.086-.37-1.784V9.273h2.057v5.238c0 .553.152.993.455 1.319.303.325.7.488 1.193.488.303 0 .596-.074.88-.221.285-.148.518-.368.7-.66.185-.295.278-.664.278-1.107Z"/>
|
||||
<path fill="#fff" d="M28.148 18V6.364h2.108v9.869h5.125V18h-7.233Z"/>
|
||||
<path stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 12a4 4 0 0 0-8 0 8 8 0 0 0 16 0 11.97 11.97 0 0 0-4-8.944"/>
|
||||
<path stroke="#F56565" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 12a4 4 0 0 0 8 0 8 8 0 1 0-16 0c0 3.584 1.571 6.801 4.063 9"/>
|
||||
<circle cx="88" cy="12" r="2" fill="#737374"/>
|
||||
<g transform="translate(98.7 0) scale(0.2449)">
|
||||
<path fill="url(#lucide-hono-gradient)" d="m11 25 7 9s9-18 22-34c17 20 36 48 36 64 0 20-19 34-37 34C17 98 0 81 0 61c0-6 3-24 11-36Z"/>
|
||||
<path fill="#F95" d="M39 21c47 51 14 66 0 66-11 0-51-11 0-66Z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="lucide-hono-gradient" x2="0%" y2="100%">
|
||||
<stop stop-color="#F84"/>
|
||||
<stop offset="100%" stop-color="#F30"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
@@ -0,0 +1,24 @@
|
||||
<svg viewBox="0 0 160 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="128" height="32" rx="8" fill="#fff"/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 118 24" height="24" width="118" x="4" y="4">
|
||||
<path fill="#1B1B1F" d="M74.202 18.17c-.875 0-1.63-.181-2.267-.545a3.694 3.694 0 0 1-1.46-1.557c-.341-.674-.512-1.468-.512-2.38 0-.898.17-1.686.512-2.364a3.867 3.867 0 0 1 1.443-1.591c.617-.383 1.342-.574 2.176-.574.538 0 1.045.087 1.523.261.48.17.905.436 1.272.796.371.36.663.818.875 1.375.212.553.319 1.212.319 1.977v.63h-7.154v-1.386h5.182a2.213 2.213 0 0 0-.256-1.05c-.166-.311-.4-.556-.699-.734a1.964 1.964 0 0 0-1.034-.267c-.42 0-.79.103-1.108.307-.318.2-.566.466-.744.796a2.289 2.289 0 0 0-.267 1.073v1.21c0 .508.093.944.278 1.307.186.36.445.637.779.83.333.19.723.284 1.17.284.3 0 .57-.042.813-.125.242-.087.452-.214.63-.38.178-.167.313-.374.404-.62l1.92.216c-.121.508-.352.95-.693 1.33a3.379 3.379 0 0 1-1.295.875c-.527.204-1.13.306-1.807.306Z"/>
|
||||
<path fill="#1B1B1F" d="M63.498 18.153c-.685 0-1.299-.176-1.84-.528-.542-.352-.97-.864-1.285-1.534-.314-.67-.471-1.485-.471-2.443 0-.97.159-1.788.477-2.455.322-.67.756-1.176 1.301-1.517a3.344 3.344 0 0 1 1.824-.517c.512 0 .932.087 1.262.261.329.17.59.377.784.62.193.238.342.464.448.676h.086V6.364h2.062V18h-2.023v-1.375h-.125c-.106.212-.259.438-.46.676a2.53 2.53 0 0 1-.795.602c-.33.167-.745.25-1.245.25Zm.574-1.687c.436 0 .807-.117 1.114-.352.307-.239.54-.57.699-.995.159-.424.238-.918.238-1.483 0-.564-.08-1.055-.238-1.471-.156-.417-.387-.74-.693-.972-.303-.23-.676-.346-1.12-.346-.458 0-.84.119-1.147.358-.307.238-.538.568-.694.988-.155.42-.233.902-.233 1.443 0 .546.078 1.033.233 1.46.16.425.392.76.7 1.006.31.243.69.364 1.141.364Z"/>
|
||||
<path fill="#1B1B1F" d="M56.088 18V9.273h2.057V18h-2.057Zm1.034-9.966a1.2 1.2 0 0 1-.84-.324 1.044 1.044 0 0 1-.353-.79c0-.31.117-.573.352-.79.235-.219.515-.329.841-.329.33 0 .61.11.841.33.235.216.352.479.352.79 0 .306-.117.57-.352.79a1.187 1.187 0 0 1-.84.323Z"/>
|
||||
<path fill="#1B1B1F" d="M50.66 18.17c-.87 0-1.619-.19-2.244-.573a3.831 3.831 0 0 1-1.437-1.586c-.334-.678-.5-1.458-.5-2.34 0-.887.17-1.67.511-2.347a3.817 3.817 0 0 1 1.443-1.591c.625-.383 1.364-.574 2.216-.574.709 0 1.335.13 1.88.392.55.258.988.623 1.313 1.097.326.47.512 1.019.557 1.647h-1.966c-.08-.42-.269-.77-.568-1.05-.295-.285-.691-.427-1.187-.427-.42 0-.79.114-1.108.341-.319.223-.567.545-.745.966-.174.42-.261.924-.261 1.511 0 .595.087 1.106.261 1.534.175.425.419.752.733.983.319.228.692.341 1.12.341.303 0 .574-.056.812-.17.242-.118.445-.286.608-.506a1.94 1.94 0 0 0 .335-.801H54.4a3.427 3.427 0 0 1-.545 1.642 3.23 3.23 0 0 1-1.284 1.114c-.542.265-1.178.397-1.91.397Z"/>
|
||||
<path fill="#1B1B1F" d="M42.682 14.33V9.272h2.057V18h-1.995v-1.551h-.09c-.198.488-.521.888-.972 1.199-.447.31-.998.466-1.654.466-.572 0-1.077-.127-1.517-.381a2.645 2.645 0 0 1-1.022-1.12c-.246-.492-.37-1.086-.37-1.784V9.273h2.057v5.238c0 .553.152.993.455 1.319.303.325.7.488 1.193.488.303 0 .596-.074.88-.221.285-.148.518-.368.7-.66.185-.295.278-.664.278-1.107Z"/>
|
||||
<path fill="#1B1B1F" d="M28.148 18V6.364h2.108v9.869h5.125V18h-7.233Z"/>
|
||||
<path stroke="#1B1B1F" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 12a4 4 0 0 0-8 0 8 8 0 0 0 16 0 11.97 11.97 0 0 0-4-8.944"/>
|
||||
<path stroke="#F56565" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 12a4 4 0 0 0 8 0 8 8 0 1 0-16 0c0 3.584 1.571 6.801 4.063 9"/>
|
||||
<circle cx="88" cy="12" r="2" fill="#DDD"/>
|
||||
<g transform="translate(98.7 0) scale(0.2449)">
|
||||
<path fill="url(#lucide-hono-gradient)" d="m11 25 7 9s9-18 22-34c17 20 36 48 36 64 0 20-19 34-37 34C17 98 0 81 0 61c0-6 3-24 11-36Z"/>
|
||||
<path fill="#F95" d="M39 21c47 51 14 66 0 66-11 0-51-11 0-66Z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="lucide-hono-gradient" x2="0%" y2="100%">
|
||||
<stop stop-color="#F84"/>
|
||||
<stop offset="100%" stop-color="#F30"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,20 @@
|
||||
# Lucide Hono integrations
|
||||
|
||||
These fixtures exercise the built `@lucide/hono` package in a real Hono application.
|
||||
|
||||
Every fixture runs three checks:
|
||||
|
||||
- a production server build with Vite;
|
||||
- TypeScript with `noEmit`;
|
||||
- Vitest Browser Mode in Chromium, on the HTML the Hono app responds with.
|
||||
|
||||
The fixture also resolves the package entry point with Node's own resolver (`node --test`), since Hono apps usually run on a server runtime and the browser suite only sees the package through Vite.
|
||||
|
||||
From the repository root, install Chromium once and run the complete suite:
|
||||
|
||||
```sh
|
||||
pnpm --filter @lucide/integration-hono-vite exec playwright install chromium
|
||||
pnpm test:integrations:hono
|
||||
```
|
||||
|
||||
The fixtures depend on `@lucide/hono` through `workspace:*`, but import only its public package entry point. The root command builds `@lucide/hono` before running any consumer checks.
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@lucide/integration-hono-vite",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test:browser": "vitest run",
|
||||
"test:node": "node --test tests/exports.node.test.ts",
|
||||
"check": "pnpm build && pnpm typecheck && pnpm test:node && pnpm test:browser"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lucide/hono": "workspace:*",
|
||||
"hono": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "catalog:",
|
||||
"@vitest/browser-playwright": "catalog:",
|
||||
"playwright": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vite": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Camera, Circle, Droplet, Edit2, House, LucideProvider, Pen } from '@lucide/hono';
|
||||
|
||||
export default function IconShowcase() {
|
||||
return (
|
||||
<main aria-label="Lucide integration">
|
||||
<Camera data-testid="static-icon" />
|
||||
<Droplet
|
||||
data-testid="custom-icon"
|
||||
class="consumer-icon"
|
||||
color="red"
|
||||
size={48}
|
||||
strokeWidth={4}
|
||||
nonScalingStroke
|
||||
/>
|
||||
<LucideProvider
|
||||
color="purple"
|
||||
size={32}
|
||||
strokeWidth={3}
|
||||
>
|
||||
<House data-testid="provider-icon" />
|
||||
</LucideProvider>
|
||||
<Pen data-testid="alias-icon" />
|
||||
<Edit2 data-testid="canonical-icon" />
|
||||
<Circle
|
||||
aria-label="Labelled circle"
|
||||
data-testid="labelled-icon"
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Hono } from 'hono';
|
||||
import type { Child } from 'hono/jsx';
|
||||
import { Info } from '@lucide/hono';
|
||||
import IconShowcase from './IconShowcase';
|
||||
|
||||
const Layout = ({ title, children }: { title: string; children: Child }) => (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) =>
|
||||
c.html(
|
||||
<Layout title="Lucide Hono Vite integration">
|
||||
<IconShowcase />
|
||||
<a href="/about">About</a>
|
||||
</Layout>,
|
||||
),
|
||||
);
|
||||
|
||||
app.get('/about', (c) =>
|
||||
c.html(
|
||||
<Layout title="About">
|
||||
<main aria-label="About">
|
||||
<Info data-testid="route-icon" />
|
||||
</main>
|
||||
</Layout>,
|
||||
),
|
||||
);
|
||||
|
||||
export default app;
|
||||
@@ -0,0 +1,3 @@
|
||||
import app from './app';
|
||||
|
||||
export default app;
|
||||
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { test } from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { jsx } from 'hono/jsx';
|
||||
|
||||
// The browser suite resolves @lucide/hono through Vite. These checks use Node's own resolver,
|
||||
// which is what a Hono app on a server runtime sees.
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const resolved = (file: string) => {
|
||||
assert.ok(existsSync(file), `${file} does not exist`);
|
||||
return file.replaceAll('\\', '/');
|
||||
};
|
||||
|
||||
test('the root entry resolves to the ESM bundle for import and the CommonJS bundle for require', () => {
|
||||
assert.match(
|
||||
resolved(fileURLToPath(import.meta.resolve('@lucide/hono'))),
|
||||
/\/hono\/dist\/esm\/lucide-hono\.mjs$/,
|
||||
);
|
||||
assert.match(resolved(require.resolve('@lucide/hono')), /\/hono\/dist\/cjs\/lucide-hono\.js$/);
|
||||
});
|
||||
|
||||
test('the resolved entries load and render an icon', async () => {
|
||||
const esm = await import('@lucide/hono');
|
||||
const cjs = require('@lucide/hono');
|
||||
|
||||
for (const { Camera } of [esm, cjs]) {
|
||||
const html = String(jsx(Camera, { size: 32 }));
|
||||
|
||||
assert.match(html, /^<svg /);
|
||||
assert.match(html, /class="lucide lucide-camera"/);
|
||||
assert.match(html, /width="32"/);
|
||||
assert.match(html, /aria-hidden="true"/);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { page } from 'vitest/browser';
|
||||
import app from '../src/app';
|
||||
|
||||
const load = async (path: string) => {
|
||||
const response = await app.request(path);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get('content-type')).toContain('text/html');
|
||||
|
||||
const { body } = new DOMParser().parseFromString(await response.text(), 'text/html');
|
||||
|
||||
document.body.replaceChildren(...body.childNodes);
|
||||
};
|
||||
|
||||
test('renders Lucide public APIs in a real browser', async () => {
|
||||
await load('/');
|
||||
|
||||
const staticIcon = page.getByTestId('static-icon');
|
||||
await expect.element(staticIcon).toBeVisible();
|
||||
await expect.element(staticIcon).toHaveAttribute('width', '24');
|
||||
await expect.element(staticIcon).toHaveAttribute('height', '24');
|
||||
await expect.element(staticIcon).toHaveAttribute('viewBox', '0 0 24 24');
|
||||
await expect.element(staticIcon).toHaveAttribute('aria-hidden', 'true');
|
||||
|
||||
const customIcon = page.getByTestId('custom-icon');
|
||||
await expect.element(customIcon).toBeVisible();
|
||||
await expect.element(customIcon).toHaveAttribute('width', '48');
|
||||
await expect.element(customIcon).toHaveAttribute('height', '48');
|
||||
await expect.element(customIcon).toHaveAttribute('stroke', 'red');
|
||||
await expect.element(customIcon).toHaveAttribute('stroke-width', '4');
|
||||
await expect.element(customIcon).toHaveClass('consumer-icon');
|
||||
expect(customIcon.element().firstElementChild?.getAttribute('vector-effect')).toBe(
|
||||
'non-scaling-stroke',
|
||||
);
|
||||
|
||||
const providerIcon = page.getByTestId('provider-icon');
|
||||
await expect.element(providerIcon).toHaveAttribute('width', '32');
|
||||
await expect.element(providerIcon).toHaveAttribute('stroke', 'purple');
|
||||
await expect.element(providerIcon).toHaveAttribute('stroke-width', '3');
|
||||
|
||||
const aliasIcon = page.getByTestId('alias-icon');
|
||||
const canonicalIcon = page.getByTestId('canonical-icon');
|
||||
await expect.element(aliasIcon).toBeVisible();
|
||||
await expect.element(canonicalIcon).toBeVisible();
|
||||
expect(aliasIcon.element().innerHTML).toBe(canonicalIcon.element().innerHTML);
|
||||
|
||||
const labelledIcon = page.getByTestId('labelled-icon');
|
||||
await expect.element(labelledIcon).toBeVisible();
|
||||
await expect.element(labelledIcon).toHaveAttribute('aria-label', 'Labelled circle');
|
||||
await expect.element(labelledIcon).not.toHaveAttribute('aria-hidden');
|
||||
|
||||
await expect.element(page.getByRole('link', { name: 'About' })).toHaveAttribute('href', '/about');
|
||||
|
||||
await load('/about');
|
||||
await expect.element(page.getByTestId('route-icon')).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "hono/jsx",
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src", "tests", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { playwright } from '@vitest/browser-playwright';
|
||||
import { configDefaults, defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
oxc: {
|
||||
jsx: {
|
||||
runtime: 'automatic',
|
||||
importSource: 'hono/jsx',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
ssr: 'src/index.tsx',
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ['@lucide/hono'],
|
||||
},
|
||||
test: {
|
||||
exclude: [...configDefaults.exclude, 'tests/*.node.test.ts'],
|
||||
browser: {
|
||||
enabled: true,
|
||||
headless: true,
|
||||
provider: playwright(),
|
||||
instances: [{ browser: 'chromium' }],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -10,6 +10,7 @@
|
||||
"test:integrations:solid-2": "pnpm --filter @lucide/solid build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-solid-2/**' check",
|
||||
"test:integrations:vue": "pnpm --filter @lucide/vue build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-vue/**' check",
|
||||
"test:integrations:svelte": "pnpm --filter @lucide/svelte build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-svelte/**' check",
|
||||
"test:integrations:hono": "pnpm --filter @lucide/hono build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-hono/**' check",
|
||||
"test:font": "pnpm --filter build-font test",
|
||||
"test:eslint-plugin": "pnpm --filter @lucide/eslint-plugin test",
|
||||
"test:scripts": "node --test scripts/*.test.mts",
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/lucide-icons/lucide">
|
||||
<img src="https://lucide.dev/package-logos/lucide-hono.svg" alt="Lucide icon library for Hono applications." width="540">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
Lucide icon library for Hono applications.
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://www.npmjs.com/package/@lucide/hono)
|
||||

|
||||
[](https://lucide.dev/license)
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://lucide.dev/guide/">About</a>
|
||||
·
|
||||
<a href="https://lucide.dev/icons/">Icons</a>
|
||||
·
|
||||
<a href="https://lucide.dev/guide/hono">Documentation</a>
|
||||
·
|
||||
<a href="https://lucide.dev/license">License</a>
|
||||
</p>
|
||||
|
||||
# Lucide Hono
|
||||
|
||||
Implementation of the Lucide icon library for Hono applications.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
pnpm add @lucide/hono
|
||||
```
|
||||
|
||||
```sh
|
||||
npm install @lucide/hono
|
||||
```
|
||||
|
||||
```sh
|
||||
yarn add @lucide/hono
|
||||
```
|
||||
|
||||
```sh
|
||||
bun add @lucide/hono
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For full documentation, visit [lucide.dev](https://lucide.dev/guide/packages/lucide-hono)
|
||||
|
||||
## Community
|
||||
|
||||
Join the [Discord server](https://discord.gg/EH6nSts) to chat with the maintainers and other users.
|
||||
|
||||
## License
|
||||
|
||||
Lucide is licensed under the ISC license. See [LICENSE](https://lucide.dev/license).
|
||||
|
||||
[//]: <> (Sponsors)
|
||||
|
||||
## Sponsors
|
||||
|
||||
<a href="https://vercel.com?utm_source=lucide&utm_campaign=oss">
|
||||
<img src="https://lucide.dev/vercel.svg" alt="Powered by Vercel" width="200" />
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
[//]: <> (Sponsor tiers start)
|
||||
|
||||
### Hero Backer 🦸
|
||||
|
||||
<a href="https://about.sourcegraph.com"><img src="https://images.opencollective.com/sourcegraph/f67b621/logo.png" height="64" alt="Sourcegraph – Understand, fix, and automate across your codebase with Sourcegraph's code intelligence platform" /></a>
|
||||
<a href="https://opencollective.com/zephyr-cloud"><img src="https://lucide.dev/sponsors/zephyr-cloud.svg" height="64" alt="Zephyr Cloud" /></a>
|
||||
|
||||
### Awesome backers 🍺
|
||||
|
||||
<a href="https://www.paxhistoria.co"><img src="https://images.opencollective.com/pax-historia/9b4e54b/logo.png" height="64" alt="Pax Historia" /></a>
|
||||
<a href="https://pdfme.com"><img src="https://images.opencollective.com/pdfmeorg/9e0174d/logo.png" height="64" alt="pdfme – Free and Open source PDF generation library!" /></a>
|
||||
|
||||
### Backer ☕️
|
||||
|
||||
<a href="https://www.fina.money"><img src="https://lucide.dev/sponsors/fina-money.png" height="64" alt="Fina Money – Build the most flexible finance tracker" /></a>
|
||||
<a href="https://opencollective.com/rjvdw"><img src="https://images.opencollective.com/rjvdw/28bc9cd/avatar.png" height="64" alt="Ruud" /></a>
|
||||
|
||||
[//]: <> (Sponsor tiers end)
|
||||
|
||||
### Other contributors 💸
|
||||
|
||||
You can find all our past and non-recurring financial contributors at [our Open Collective page](https://opencollective.com/lucide-icons).
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "@lucide/hono",
|
||||
"description": "A Lucide icon library package for Hono applications.",
|
||||
"version": "0.0.1",
|
||||
"license": "ISC",
|
||||
"homepage": "https://lucide.dev",
|
||||
"bugs": "https://github.com/lucide-icons/lucide/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lucide-icons/lucide.git",
|
||||
"directory": "packages/hono"
|
||||
},
|
||||
"keywords": [
|
||||
"Lucide",
|
||||
"Hono",
|
||||
"Hono JSX",
|
||||
"Feather",
|
||||
"Icons",
|
||||
"Icon",
|
||||
"SVG",
|
||||
"Feather Icons",
|
||||
"Fontawesome",
|
||||
"Font Awesome"
|
||||
],
|
||||
"author": "Vedant Agarwal",
|
||||
"amdName": "lucide-hono",
|
||||
"main": "dist/cjs/lucide-hono.js",
|
||||
"module": "dist/esm/lucide-hono.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/lucide-hono.d.ts",
|
||||
"import": "./dist/esm/lucide-hono.mjs",
|
||||
"require": "./dist/cjs/lucide-hono.js"
|
||||
}
|
||||
},
|
||||
"typings": "dist/lucide-hono.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:bundles",
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.js",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mts --renderUniqueKey --withAliases --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=index.ts",
|
||||
"build:bundles": "rollup -c ./rollup.config.mjs",
|
||||
"test": "pnpm build:icons && vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"typecheck": "pnpm build:icons && tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lucide/build-icons": "workspace:*",
|
||||
"@lucide/rollup-plugins": "workspace:*",
|
||||
"@lucide/shared": "workspace:*",
|
||||
"@testing-library/jest-dom": "catalog:",
|
||||
"hono": "catalog:",
|
||||
"jest-serializer-html": "catalog:",
|
||||
"rollup": "catalog:",
|
||||
"rollup-plugin-dts": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vite": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hono": "^4.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import plugins from '@lucide/rollup-plugins';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import pkg from './package.json' with { type: 'json' };
|
||||
|
||||
const dtsOptions = {
|
||||
includeExternal: ['@lucide/shared/types'],
|
||||
tsconfig: './tsconfig.json',
|
||||
};
|
||||
|
||||
const packageName = 'LucideHono';
|
||||
const outputFileName = 'lucide-hono';
|
||||
const outputDir = 'dist';
|
||||
const inputs = [`src/lucide-hono.ts`];
|
||||
const bundles = [
|
||||
{
|
||||
format: 'cjs',
|
||||
inputs,
|
||||
outputDir,
|
||||
},
|
||||
{
|
||||
format: 'esm',
|
||||
inputs,
|
||||
outputDir,
|
||||
preserveModules: true,
|
||||
extension: 'mjs',
|
||||
},
|
||||
];
|
||||
|
||||
const configs = bundles
|
||||
.map(({ inputs, outputDir, format, preserveModules, extension = 'js' }) =>
|
||||
inputs.map((input) => ({
|
||||
input,
|
||||
plugins: plugins({
|
||||
pkg,
|
||||
esbuildOptions: { jsx: 'automatic', jsxImportSource: 'hono/jsx' },
|
||||
}),
|
||||
external: ['hono', 'hono/css', 'hono/jsx', 'hono/jsx/jsx-runtime'],
|
||||
output: {
|
||||
name: packageName,
|
||||
...(preserveModules
|
||||
? {
|
||||
dir: `${outputDir}/${format}`,
|
||||
entryFileNames: `[name].${extension}`,
|
||||
}
|
||||
: {
|
||||
file: `${outputDir}/${format}/${outputFileName}.${extension}`,
|
||||
}),
|
||||
preserveModules,
|
||||
format,
|
||||
sourcemap: true,
|
||||
preserveModulesRoot: 'src',
|
||||
globals: {
|
||||
hono: 'hono',
|
||||
'hono/css': 'hono/css',
|
||||
'hono/jsx': 'hono/jsx',
|
||||
'hono/jsx/jsx-runtime': 'hono/jsx/jsx-runtime',
|
||||
},
|
||||
},
|
||||
})),
|
||||
)
|
||||
.flat();
|
||||
|
||||
export default [
|
||||
{
|
||||
input: inputs[0],
|
||||
output: [
|
||||
{
|
||||
file: `dist/${outputFileName}.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
plugins: [dts(dtsOptions)],
|
||||
},
|
||||
{
|
||||
input: `src/${outputFileName}.suffixed.ts`,
|
||||
output: [
|
||||
{
|
||||
file: `dist/${outputFileName}.suffixed.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
plugins: [dts(dtsOptions)],
|
||||
},
|
||||
{
|
||||
input: `src/${outputFileName}.prefixed.ts`,
|
||||
output: [
|
||||
{
|
||||
file: `dist/${outputFileName}.prefixed.d.ts`,
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
plugins: [dts(dtsOptions)],
|
||||
},
|
||||
...configs,
|
||||
];
|
||||
@@ -0,0 +1,36 @@
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG';
|
||||
import defineExportTemplate from '@lucide/build-icons/utils/defineExportTemplate';
|
||||
|
||||
export default defineExportTemplate(
|
||||
async ({ componentName, iconName, iconData, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = await getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
return `
|
||||
import createLucideIcon from '../createLucideIcon';
|
||||
import type { LucideIconNode, LucideIconData } from '../types';
|
||||
|
||||
export const __iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
/**
|
||||
* @deprecated Access \`__iconData\` instead.
|
||||
*/
|
||||
export const __iconNode: LucideIconNode[] = __iconData.node;
|
||||
|
||||
/**
|
||||
* @component @name ${componentName}
|
||||
* @description Lucide SVG icon component, renders SVG Element with children.
|
||||
*
|
||||
* @preview  - https://lucide.dev/icons/${iconName}
|
||||
* @see https://lucide.dev/guide/packages/lucide-hono - Documentation
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon(__iconData);
|
||||
|
||||
export default ${componentName};
|
||||
`;
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,88 @@
|
||||
import { buildLucideIconNode, hasA11yProp, mergeClasses } from '@lucide/shared';
|
||||
import type { LucideIconData, LucideIconNode, LucideProps } from './types';
|
||||
import { useLucideContext } from './context';
|
||||
import { mergeClassNames } from './utils';
|
||||
|
||||
type IconComponentProps = LucideProps &
|
||||
(
|
||||
| {
|
||||
icon: LucideIconData;
|
||||
iconNode?: never;
|
||||
}
|
||||
| {
|
||||
iconNode: LucideIconNode[];
|
||||
icon?: never;
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Lucide icon component
|
||||
*
|
||||
* @component Icon
|
||||
* @param {object} props
|
||||
* @param {string} props.color - The color of the icon
|
||||
* @param {number} props.size - The size of the icon
|
||||
* @param {number} props.strokeWidth - The stroke width of the icon
|
||||
* @param {boolean} props.nonScalingStroke - Whether to use non scaling strokes
|
||||
* @param {string} props.class - The class name of the icon
|
||||
* @param {LucideIconNode[]} props.children - The children of the icon
|
||||
* @param {LucideIconNode[]} props.iconNode - The icon node of the icon
|
||||
*
|
||||
* @returns {JSX.Element} LucideIcon
|
||||
*/
|
||||
const Icon = ({
|
||||
color,
|
||||
size,
|
||||
width,
|
||||
height,
|
||||
strokeWidth,
|
||||
nonScalingStroke,
|
||||
children,
|
||||
iconNode = [],
|
||||
icon = {
|
||||
node: iconNode,
|
||||
aliases: [],
|
||||
size: 24,
|
||||
},
|
||||
class: classes = '',
|
||||
...rest
|
||||
}: IconComponentProps) => {
|
||||
const {
|
||||
size: contextSize = 24,
|
||||
strokeWidth: contextStrokeWidth = 2,
|
||||
nonScalingStroke: contextNonScalingStroke = false,
|
||||
color: contextColor = 'currentColor',
|
||||
class: contextClass = '',
|
||||
} = useLucideContext() ?? {};
|
||||
|
||||
const [name, svgAttributes, builtIconNode = []] = buildLucideIconNode(icon, {
|
||||
color: color ?? contextColor,
|
||||
width: width ?? size ?? contextSize,
|
||||
height: height ?? size ?? contextSize,
|
||||
strokeWidth: strokeWidth ?? contextStrokeWidth,
|
||||
nonScalingStroke: nonScalingStroke ?? contextNonScalingStroke,
|
||||
className: mergeClasses(contextClass, typeof classes === 'string' ? classes : ''),
|
||||
hasA11yProp: hasA11yProp(rest),
|
||||
attributes: rest,
|
||||
});
|
||||
|
||||
if (classes instanceof Promise) {
|
||||
svgAttributes.class = mergeClassNames(svgAttributes.class, classes);
|
||||
}
|
||||
|
||||
const Svg = name as 'svg';
|
||||
|
||||
return (
|
||||
<Svg {...svgAttributes}>
|
||||
{builtIconNode.map(([Tag, { key, ...attrs }]) => (
|
||||
<Tag
|
||||
key={key}
|
||||
{...attrs}
|
||||
/>
|
||||
))}
|
||||
{children}
|
||||
</Svg>
|
||||
);
|
||||
};
|
||||
|
||||
export default Icon;
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './aliases';
|
||||
export * from './prefixed';
|
||||
export * from './suffixed';
|
||||
@@ -0,0 +1,45 @@
|
||||
import { createContext, useContext, type Child } from 'hono/jsx';
|
||||
|
||||
const LucideContext = createContext<{
|
||||
size?: number;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
nonScalingStroke?: boolean;
|
||||
class?: string;
|
||||
}>({
|
||||
size: 24,
|
||||
color: 'currentColor',
|
||||
strokeWidth: 2,
|
||||
nonScalingStroke: false,
|
||||
class: '',
|
||||
});
|
||||
|
||||
interface LucideProviderProps {
|
||||
children: Child;
|
||||
size?: number;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
nonScalingStroke?: boolean;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
export function LucideProvider({
|
||||
children,
|
||||
size,
|
||||
color,
|
||||
strokeWidth,
|
||||
nonScalingStroke,
|
||||
class: className,
|
||||
}: LucideProviderProps) {
|
||||
const value = {
|
||||
size,
|
||||
color,
|
||||
strokeWidth,
|
||||
nonScalingStroke,
|
||||
class: className,
|
||||
};
|
||||
|
||||
return <LucideContext.Provider value={value}>{children}</LucideContext.Provider>;
|
||||
}
|
||||
|
||||
export const useLucideContext = () => useContext(LucideContext);
|
||||
@@ -0,0 +1,60 @@
|
||||
import { toLucideIconData, toPascalCase } from '@lucide/shared';
|
||||
import Icon from './Icon';
|
||||
import { mergeClassNames } from './utils';
|
||||
import type { LucideIcon, LucideIconData, LucideIconNode, LucideProps } from './types';
|
||||
|
||||
/**
|
||||
* Creates a Lucide icon component from icon data.
|
||||
*
|
||||
* @param icon Icon data object.
|
||||
* @returns Lucide icon component.
|
||||
*/
|
||||
function createLucideIcon(icon: LucideIconData): LucideIcon;
|
||||
|
||||
/**
|
||||
* Creates a Lucide icon component from the legacy icon arguments.
|
||||
*
|
||||
* @param iconName Icon name.
|
||||
* @param iconNode Icon node.
|
||||
* @param aliases Optional icon aliases.
|
||||
* @returns Lucide icon component.
|
||||
*/
|
||||
function createLucideIcon(
|
||||
iconName: string,
|
||||
iconNode: LucideIconNode[],
|
||||
aliases?: string[],
|
||||
): LucideIcon;
|
||||
|
||||
function createLucideIcon(
|
||||
iconDataOrName: LucideIconData | string,
|
||||
iconNode?: LucideIconNode[],
|
||||
aliases: string[] = [],
|
||||
): LucideIcon {
|
||||
const iconData =
|
||||
typeof iconDataOrName === 'string'
|
||||
? toLucideIconData(iconDataOrName, iconNode as LucideIconNode[], aliases)
|
||||
: iconDataOrName;
|
||||
|
||||
const Component: LucideIcon = ({
|
||||
class: classes = '',
|
||||
className = '',
|
||||
children,
|
||||
...props
|
||||
}: LucideProps) => (
|
||||
<Icon
|
||||
{...props}
|
||||
icon={iconData}
|
||||
class={mergeClassNames(classes, className)}
|
||||
>
|
||||
{children}
|
||||
</Icon>
|
||||
);
|
||||
|
||||
if (iconData.name) {
|
||||
Component.displayName = toPascalCase(iconData.name);
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
export default createLucideIcon;
|
||||
@@ -0,0 +1 @@
|
||||
export { defaultAttributes as default } from '@lucide/shared';
|
||||
@@ -0,0 +1 @@
|
||||
Folder for generated icons
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './icons';
|
||||
export * as icons from './icons';
|
||||
export * from './aliases/prefixed';
|
||||
export * from './types';
|
||||
|
||||
export { default as createLucideIcon } from './createLucideIcon';
|
||||
export { default as Icon } from './Icon';
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './icons';
|
||||
export * as icons from './icons';
|
||||
export * from './aliases/suffixed';
|
||||
export * from './types';
|
||||
|
||||
export { default as createLucideIcon } from './createLucideIcon';
|
||||
export { default as Icon } from './Icon';
|
||||
@@ -0,0 +1,8 @@
|
||||
export * from './icons';
|
||||
export * as icons from './icons';
|
||||
export * from './aliases';
|
||||
export * from './types';
|
||||
export * from './context';
|
||||
|
||||
export { default as createLucideIcon } from './createLucideIcon';
|
||||
export { default as Icon } from './Icon';
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { DOMAttributes, FC, PropsWithChildren } from 'hono/jsx';
|
||||
import type {
|
||||
LucideIconData as SharedLucideIconData,
|
||||
LucideIconNode as SharedLucideIconNode,
|
||||
} from '@lucide/shared/types';
|
||||
|
||||
export type LucideIconNode = SharedLucideIconNode;
|
||||
|
||||
export type LucideIconData = SharedLucideIconData;
|
||||
|
||||
/**
|
||||
* @deprecated Use LucideIconNode instead.
|
||||
*/
|
||||
export type IconNode = LucideIconNode[];
|
||||
|
||||
export interface LucideProps extends PropsWithChildren<Partial<Omit<DOMAttributes, 'size'>>> {
|
||||
color?: string;
|
||||
size?: string | number;
|
||||
width?: string | number;
|
||||
height?: string | number;
|
||||
strokeWidth?: string | number;
|
||||
nonScalingStroke?: boolean;
|
||||
class?: string | Promise<string>;
|
||||
className?: string | Promise<string>;
|
||||
}
|
||||
|
||||
export type LucideIcon = FC<LucideProps>;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { cx } from 'hono/css';
|
||||
import { mergeClasses } from '@lucide/shared';
|
||||
|
||||
/**
|
||||
* Class names created with `css` from `hono/css` are Promises,
|
||||
* they can't be merged as strings without losing their styles.
|
||||
*/
|
||||
const isCssClass = (value: unknown): value is Promise<string> => value instanceof Promise;
|
||||
|
||||
/**
|
||||
* Merges class names, uses `cx` from `hono/css` when any of them is a `hono/css` class name.
|
||||
*
|
||||
* @param classes Class names to merge.
|
||||
* @returns Merged class names.
|
||||
*/
|
||||
export const mergeClassNames = (
|
||||
...classes: (string | Promise<string> | undefined)[]
|
||||
): string | Promise<string> => {
|
||||
const classNames = mergeClasses(
|
||||
...classes.filter((className): className is string => typeof className === 'string'),
|
||||
);
|
||||
const cssClassNames = classes.filter(isCssClass);
|
||||
|
||||
if (!cssClassNames.length) {
|
||||
return classNames;
|
||||
}
|
||||
|
||||
return classNames ? cx(classNames, ...cssClassNames) : cx(...cssClassNames);
|
||||
};
|
||||
@@ -0,0 +1,127 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render } from './utils/render';
|
||||
|
||||
import { airVent } from './testIconNodes';
|
||||
import { Icon } from '../src/lucide-hono';
|
||||
|
||||
describe('Using Icon Component', () => {
|
||||
it('should render icon based on a iconNode', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toBeDefined();
|
||||
});
|
||||
|
||||
it('should render icon and match snapshot', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Icon Component Accessibility', () => {
|
||||
it('should have aria-hidden prop when no aria prop is present', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toHaveAttribute('aria-hidden', 'true');
|
||||
});
|
||||
|
||||
it('should not have aria-hidden prop when aria prop is present', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
aria-label="Air conditioning"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
||||
});
|
||||
|
||||
it('should not have aria-hidden prop when title prop is present', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
title="Air conditioning"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
||||
});
|
||||
|
||||
it('should render a labelled title child and not have aria-hidden prop', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
role="img"
|
||||
aria-labelledby="warn-title"
|
||||
>
|
||||
<title id="warn-title">Warning: Action cannot be undone</title>
|
||||
</Icon>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
||||
expect(container.firstChild).toHaveAttribute('role', 'img');
|
||||
expect(container.firstChild).toHaveAttribute('aria-labelledby', 'warn-title');
|
||||
expect(container.querySelector('title#warn-title')).toHaveTextContent(
|
||||
'Warning: Action cannot be undone',
|
||||
);
|
||||
});
|
||||
|
||||
it('should keep aria-hidden prop when there are only children', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
>
|
||||
<title>Some title</title>
|
||||
</Icon>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toHaveAttribute('aria-hidden', 'true');
|
||||
});
|
||||
|
||||
it('should never override aria-hidden prop', async () => {
|
||||
const { container } = render(
|
||||
<Icon
|
||||
iconNode={airVent}
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
aria-hidden={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toHaveAttribute('aria-hidden', 'false');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Using Icon Component > should render icon and match snapshot 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide"
|
||||
fill="none"
|
||||
height="48"
|
||||
stroke="red"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
width="48"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<path
|
||||
d="M6 8h12"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<path
|
||||
d="M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<path
|
||||
d="M6.6 15.6A2 2 0 1 0 10 17v-5"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
@@ -0,0 +1,24 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Using LucideProvider > should render the icon with LucideProvider 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide lucide-house lucide-home"
|
||||
fill="none"
|
||||
height="48"
|
||||
stroke="red"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
width="48"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"
|
||||
/>
|
||||
<path
|
||||
d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
@@ -0,0 +1,88 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Using createLucideIcon > should create a component from icon data 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide lucide-air-vent"
|
||||
fill="none"
|
||||
height="24"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"
|
||||
/>
|
||||
<path
|
||||
d="M6 8h12"
|
||||
/>
|
||||
<path
|
||||
d="M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12"
|
||||
/>
|
||||
<path
|
||||
d="M6.6 15.6A2 2 0 1 0 10 17v-5"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
exports[`Using createLucideIcon > should include aliases from icon data 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide lucide-circle-check lucide-check-circle"
|
||||
fill="none"
|
||||
height="24"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"
|
||||
/>
|
||||
<path
|
||||
d="M6 8h12"
|
||||
/>
|
||||
<path
|
||||
d="M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12"
|
||||
/>
|
||||
<path
|
||||
d="M6.6 15.6A2 2 0 1 0 10 17v-5"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
exports[`Using createLucideIcon > should merge className prop with icon classes 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide lucide-circle-check lucide-check-circle custom-class"
|
||||
fill="none"
|
||||
height="24"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"
|
||||
/>
|
||||
<path
|
||||
d="M6 8h12"
|
||||
/>
|
||||
<path
|
||||
d="M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12"
|
||||
/>
|
||||
<path
|
||||
d="M6.6 15.6A2 2 0 1 0 10 17v-5"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
@@ -0,0 +1,103 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Using lucide icon components > should adjust the size, stroke color and stroke width 1`] = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="48"
|
||||
height="48"
|
||||
viewbox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="red"
|
||||
stroke-width="4"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="lucide lucide-grid-3x3 lucide-grid lucide-grid-3-x-3"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<rect width="18"
|
||||
height="18"
|
||||
x="3"
|
||||
y="3"
|
||||
rx="2"
|
||||
>
|
||||
</rect>
|
||||
<path d="M3 9h18">
|
||||
</path>
|
||||
<path d="M3 15h18">
|
||||
</path>
|
||||
<path d="M9 3v18">
|
||||
</path>
|
||||
<path d="M15 3v18">
|
||||
</path>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
exports[`Using lucide icon components > should apply vector-effect when nonScalingStroke is set 1`] = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="48"
|
||||
height="48"
|
||||
viewbox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="red"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="lucide lucide-grid-3x3 lucide-grid lucide-grid-3-x-3"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<rect vector-effect="non-scaling-stroke"
|
||||
width="18"
|
||||
height="18"
|
||||
x="3"
|
||||
y="3"
|
||||
rx="2"
|
||||
>
|
||||
</rect>
|
||||
<path vector-effect="non-scaling-stroke"
|
||||
d="M3 9h18"
|
||||
>
|
||||
</path>
|
||||
<path vector-effect="non-scaling-stroke"
|
||||
d="M3 15h18"
|
||||
>
|
||||
</path>
|
||||
<path vector-effect="non-scaling-stroke"
|
||||
d="M9 3v18"
|
||||
>
|
||||
</path>
|
||||
<path vector-effect="non-scaling-stroke"
|
||||
d="M15 3v18"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
exports[`Using lucide icon components > should render an component 1`] = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewbox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="lucide lucide-grid-3x3 lucide-grid lucide-grid-3-x-3"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<rect width="18"
|
||||
height="18"
|
||||
x="3"
|
||||
y="3"
|
||||
rx="2"
|
||||
>
|
||||
</rect>
|
||||
<path d="M3 9h18">
|
||||
</path>
|
||||
<path d="M3 15h18">
|
||||
</path>
|
||||
<path d="M9 3v18">
|
||||
</path>
|
||||
<path d="M15 3v18">
|
||||
</path>
|
||||
</svg>
|
||||
`;
|
||||
@@ -0,0 +1,91 @@
|
||||
import { render } from './utils/render';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { House, LucideProvider } from '../src/lucide-hono';
|
||||
|
||||
describe('Using LucideProvider', () => {
|
||||
it('should render the icon with LucideProvider', () => {
|
||||
const { container } = render(
|
||||
<LucideProvider
|
||||
size={48}
|
||||
color="red"
|
||||
>
|
||||
<House />
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render the icon with LucideProvider and custom strokeWidth', () => {
|
||||
const { container } = render(
|
||||
<LucideProvider
|
||||
size={48}
|
||||
color="red"
|
||||
strokeWidth={4}
|
||||
>
|
||||
<House />
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
expect(IconComponent).toHaveAttribute('width', '48');
|
||||
expect(IconComponent).toHaveAttribute('height', '48');
|
||||
expect(IconComponent).toHaveAttribute('stroke', 'red');
|
||||
expect(IconComponent).toHaveAttribute('stroke-width', '4');
|
||||
});
|
||||
|
||||
it('should render the icon with LucideProvider and custom nonScalingStroke', () => {
|
||||
const { container } = render(
|
||||
<LucideProvider
|
||||
size={48}
|
||||
color="red"
|
||||
nonScalingStroke
|
||||
>
|
||||
<House />
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
expect(IconComponent?.firstElementChild).toHaveAttribute('vector-effect', 'non-scaling-stroke');
|
||||
});
|
||||
|
||||
it("should override the provider's global props when passing props to the icon", () => {
|
||||
const { container } = render(
|
||||
<LucideProvider
|
||||
size={48}
|
||||
color="red"
|
||||
strokeWidth={4}
|
||||
>
|
||||
<House
|
||||
size={24}
|
||||
color="blue"
|
||||
strokeWidth={2}
|
||||
/>
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
expect(IconComponent).toHaveAttribute('width', '24');
|
||||
expect(IconComponent).toHaveAttribute('height', '24');
|
||||
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
||||
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
||||
});
|
||||
|
||||
it('should merge class names from LucideProvider and icon props', () => {
|
||||
const { container } = render(
|
||||
<LucideProvider class="provider-class">
|
||||
<House class="icon-class" />
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
expect(IconComponent).toHaveAttribute(
|
||||
'class',
|
||||
'lucide lucide-house lucide-home provider-class icon-class',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createLucideIcon } from '../src/lucide-hono';
|
||||
import { __iconData, __iconNode } from '../src/icons/air-vent';
|
||||
import { airVent } from './testIconNodes';
|
||||
import { render } from './utils/render';
|
||||
|
||||
describe('Using createLucideIcon', () => {
|
||||
it('should export __iconData and __iconNode from icon module', () => {
|
||||
expect(__iconData).toBeDefined();
|
||||
expect(__iconData.node).toBeDefined();
|
||||
expect(__iconNode).toBeDefined();
|
||||
expect(Array.isArray(__iconNode)).toBe(true);
|
||||
expect(__iconNode.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should create a component from icon data', () => {
|
||||
const AirVent = createLucideIcon({
|
||||
name: 'air-vent',
|
||||
node: airVent,
|
||||
});
|
||||
|
||||
const { container } = render(<AirVent />);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild).toBeDefined();
|
||||
});
|
||||
|
||||
it('should include aliases from icon data', () => {
|
||||
const CircleCheck = createLucideIcon({
|
||||
name: 'circle-check',
|
||||
aliases: ['check-circle'],
|
||||
node: airVent,
|
||||
});
|
||||
|
||||
const { container } = render(<CircleCheck />);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild).toBeDefined();
|
||||
});
|
||||
|
||||
it('should merge className prop with icon classes', () => {
|
||||
const CircleCheck = createLucideIcon({
|
||||
name: 'circle-check',
|
||||
aliases: ['check-circle'],
|
||||
node: airVent,
|
||||
});
|
||||
|
||||
const { container } = render(<CircleCheck class="custom-class" />);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create a component from legacy icon arguments', () => {
|
||||
const AirVent = createLucideIcon('AirVent', airVent);
|
||||
|
||||
const { container } = render(<AirVent />);
|
||||
|
||||
expect(container.firstChild).toHaveClass('lucide-air-vent');
|
||||
});
|
||||
|
||||
it('should include aliases from legacy icon arguments', () => {
|
||||
const CircleCheck = createLucideIcon('CircleCheck', airVent, ['check-circle']);
|
||||
|
||||
const { container } = render(<CircleCheck />);
|
||||
|
||||
expect(container.firstChild).toHaveClass('lucide-circle-check');
|
||||
expect(container.firstChild).toHaveClass('lucide-check-circle');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Hono } from 'hono';
|
||||
import { css, Style } from 'hono/css';
|
||||
import type { FC } from 'hono/jsx';
|
||||
import { House, LucideProvider } from '../src/lucide-hono';
|
||||
|
||||
describe('Using lucide icons in a Hono app', () => {
|
||||
it('should render an icon with c.html()', async () => {
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) =>
|
||||
c.html(
|
||||
<div>
|
||||
<House size={32} />
|
||||
</div>,
|
||||
),
|
||||
);
|
||||
|
||||
const res = await app.request('/');
|
||||
const html = await res.text();
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get('content-type')).toContain('text/html');
|
||||
expect(html).toContain('<svg');
|
||||
expect(html).toContain('class="lucide lucide-house lucide-home"');
|
||||
expect(html).toContain('width="32"');
|
||||
});
|
||||
|
||||
it('should apply LucideProvider values through async components', async () => {
|
||||
const AsyncSection: FC = async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1));
|
||||
|
||||
return <House />;
|
||||
};
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) =>
|
||||
c.html(
|
||||
<LucideProvider
|
||||
size={48}
|
||||
color="red"
|
||||
>
|
||||
<AsyncSection />
|
||||
</LucideProvider>,
|
||||
),
|
||||
);
|
||||
|
||||
const html = await (await app.request('/')).text();
|
||||
|
||||
expect(html).toContain('width="48"');
|
||||
expect(html).toContain('stroke="red"');
|
||||
});
|
||||
|
||||
it('should escape attribute values', () => {
|
||||
const html = String(<House class={'"><script>alert(1)</script>'} />);
|
||||
|
||||
expect(html).not.toContain('<script>');
|
||||
expect(html).toContain('"><script>');
|
||||
});
|
||||
|
||||
it('should support class names from hono/css', async () => {
|
||||
const iconClass = css`
|
||||
width: 64px;
|
||||
`;
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) =>
|
||||
c.html(
|
||||
<html>
|
||||
<head>
|
||||
<Style />
|
||||
</head>
|
||||
<body>
|
||||
<House class={iconClass} />
|
||||
</body>
|
||||
</html>,
|
||||
),
|
||||
);
|
||||
|
||||
const html = await (await app.request('/')).text();
|
||||
const svgClass = html.match(/<svg[^>]* class="([^"]*)"/)?.[1] ?? '';
|
||||
const cssClass = svgClass.split(' ').find((name) => name.startsWith('css-'));
|
||||
|
||||
expect(svgClass).toContain('lucide lucide-house lucide-home');
|
||||
expect(cssClass).toBeDefined();
|
||||
expect(html).toContain(`.${cssClass}{width:64px}`);
|
||||
});
|
||||
|
||||
it('should merge string and hono/css class names', async () => {
|
||||
const iconClass = css`
|
||||
color: red;
|
||||
`;
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.get('/', (c) =>
|
||||
c.html(
|
||||
<div>
|
||||
<Style />
|
||||
<House
|
||||
class="my-icon"
|
||||
className={iconClass}
|
||||
/>
|
||||
</div>,
|
||||
),
|
||||
);
|
||||
|
||||
const html = await (await app.request('/')).text();
|
||||
const svgClass = html.match(/<svg[^>]* class="([^"]*)"/)?.[1] ?? '';
|
||||
|
||||
expect(svgClass).toContain('lucide lucide-house lucide-home');
|
||||
expect(svgClass).toContain('my-icon');
|
||||
expect(svgClass).toMatch(/css-\d+/);
|
||||
expect(html).toContain('{color:red}');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,117 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, cleanup } from './utils/render';
|
||||
import { Pen, Edit2, Grid, Droplet, LucideIconData, createLucideIcon } from '../src/lucide-hono';
|
||||
import defaultAttributes from '../src/defaultAttributes';
|
||||
|
||||
type AttributesAssertion = { attributes: Record<string, { value: string }> };
|
||||
|
||||
describe('Using lucide icon components', () => {
|
||||
it('should render an component', () => {
|
||||
const { container } = render(<Grid />);
|
||||
|
||||
expect(container.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render the icon with the default attributes', () => {
|
||||
const { container } = render(<Grid />);
|
||||
|
||||
const SVGElement = container.firstElementChild;
|
||||
|
||||
expect(SVGElement).toHaveAttribute('xmlns', defaultAttributes.xmlns);
|
||||
expect(SVGElement).toHaveAttribute('width', String(defaultAttributes.width));
|
||||
expect(SVGElement).toHaveAttribute('height', String(defaultAttributes.height));
|
||||
expect(SVGElement).toHaveAttribute('viewBox', defaultAttributes.viewBox);
|
||||
expect(SVGElement).toHaveAttribute('fill', defaultAttributes.fill);
|
||||
expect(SVGElement).toHaveAttribute('stroke', defaultAttributes.stroke);
|
||||
expect(SVGElement).toHaveAttribute('stroke-width', String(defaultAttributes['stroke-width']));
|
||||
expect(SVGElement).toHaveAttribute('stroke-linecap', defaultAttributes['stroke-linecap']);
|
||||
expect(SVGElement).toHaveAttribute('stroke-linejoin', defaultAttributes['stroke-linejoin']);
|
||||
});
|
||||
|
||||
it('should adjust the size, stroke color and stroke width', () => {
|
||||
const { container } = render(
|
||||
<Grid
|
||||
size={48}
|
||||
stroke="red"
|
||||
strokeWidth={4}
|
||||
/>,
|
||||
);
|
||||
|
||||
const SVGElement = container.firstElementChild;
|
||||
|
||||
expect(SVGElement).toHaveAttribute('stroke', 'red');
|
||||
expect(SVGElement).toHaveAttribute('width', '48');
|
||||
expect(SVGElement).toHaveAttribute('height', '48');
|
||||
expect(SVGElement).toHaveAttribute('stroke-width', '4');
|
||||
expect(container.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render the alias icon', () => {
|
||||
const { container } = render(
|
||||
<Pen
|
||||
size={48}
|
||||
stroke="red"
|
||||
strokeWidth={4}
|
||||
/>,
|
||||
);
|
||||
|
||||
const PenIconRenderedHTML = container.innerHTML;
|
||||
|
||||
cleanup();
|
||||
|
||||
const { container: Edit2Container } = render(
|
||||
<Edit2
|
||||
size={48}
|
||||
stroke="red"
|
||||
strokeWidth={4}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(PenIconRenderedHTML).toBe(Edit2Container.innerHTML);
|
||||
});
|
||||
|
||||
it('should apply vector-effect when nonScalingStroke is set', () => {
|
||||
const { container } = render(
|
||||
<Grid
|
||||
size={48}
|
||||
stroke="red"
|
||||
nonScalingStroke
|
||||
/>,
|
||||
);
|
||||
|
||||
const SVGElement = container.firstElementChild;
|
||||
|
||||
expect(SVGElement).toHaveAttribute('stroke', 'red');
|
||||
expect(SVGElement).toHaveAttribute('width', '48');
|
||||
expect(SVGElement).toHaveAttribute('height', '48');
|
||||
expect(SVGElement).toHaveAttribute('stroke-width', '2');
|
||||
expect(SVGElement?.firstElementChild).toHaveAttribute('vector-effect', 'non-scaling-stroke');
|
||||
|
||||
expect(container.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should apply all classes to the element', () => {
|
||||
const iconData: LucideIconData = {
|
||||
name: 'droplet',
|
||||
size: 24,
|
||||
node: [
|
||||
[
|
||||
'path',
|
||||
{
|
||||
d: 'M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z',
|
||||
key: 'abc123',
|
||||
},
|
||||
],
|
||||
],
|
||||
aliases: ['drop'],
|
||||
};
|
||||
const testClass = 'my-class';
|
||||
const Icon = createLucideIcon(iconData);
|
||||
const { container } = render(<Icon class={testClass} />);
|
||||
|
||||
expect(container.firstChild).toHaveClass(testClass);
|
||||
expect(container.firstChild).toHaveClass('lucide');
|
||||
expect(container.firstChild).toHaveClass('lucide-droplet');
|
||||
expect(container.firstChild).toHaveClass('lucide-drop');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { expect, afterEach } from 'vitest';
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import htmlSerializer from 'jest-serializer-html';
|
||||
import { cleanup } from './utils/render';
|
||||
|
||||
expect.addSnapshotSerializer(htmlSerializer);
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { IconNode } from '../src/types';
|
||||
|
||||
export const airVent: IconNode = [
|
||||
[
|
||||
'path',
|
||||
{
|
||||
d: 'M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2',
|
||||
key: 'larmp2',
|
||||
},
|
||||
],
|
||||
['path', { d: 'M6 8h12', key: '6g4wlu' }],
|
||||
['path', { d: 'M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12', key: '1bo8pg' }],
|
||||
['path', { d: 'M6.6 15.6A2 2 0 1 0 10 17v-5', key: 't9h90c' }],
|
||||
];
|
||||
|
||||
export const coffee: IconNode = [
|
||||
['path', { d: 'M17 8h1a4 4 0 1 1 0 8h-1', key: 'jx4kbh' }],
|
||||
['path', { d: 'M3 8h14v9a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4Z', key: '1bxrl0' }],
|
||||
['line', { x1: '6', x2: '6', y1: '2', y2: '4', key: '1cr9l3' }],
|
||||
['line', { x1: '10', x2: '10', y1: '2', y2: '4', key: '170wym' }],
|
||||
['line', { x1: '14', x2: '14', y1: '2', y2: '4', key: '1c5f70' }],
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Child } from 'hono/jsx';
|
||||
|
||||
/**
|
||||
* Renders a Hono JSX node to an HTML string, then mounts that string in a DOM container
|
||||
* so the same DOM assertions as the other Lucide packages can be used.
|
||||
*/
|
||||
export const render = (node: Child) => {
|
||||
const html = String(node);
|
||||
const container = document.createElement('div');
|
||||
|
||||
container.innerHTML = html;
|
||||
document.body.appendChild(container);
|
||||
|
||||
return { container, html };
|
||||
};
|
||||
|
||||
export const cleanup = () => {
|
||||
document.body.innerHTML = '';
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"declaration": false,
|
||||
"noEmitOnError": true,
|
||||
"noEmit": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "bundler",
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"paths": {
|
||||
"@lucide/shared": ["../shared/src/index.ts"],
|
||||
"@lucide/shared/types": ["../shared/src/build/types.ts"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"lib": ["esnext", "dom"],
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"sourceMap": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "hono/jsx",
|
||||
"types": ["@testing-library/jest-dom/vitest"]
|
||||
},
|
||||
"exclude": ["**/node_modules"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
oxc: {
|
||||
jsx: {
|
||||
runtime: 'automatic',
|
||||
importSource: 'hono/jsx',
|
||||
},
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
setupFiles: './tests/setupVitest.js',
|
||||
},
|
||||
resolve: {
|
||||
mainFields: ['module'],
|
||||
},
|
||||
});
|
||||
Generated
+89
-17
@@ -444,6 +444,9 @@ catalogs:
|
||||
h3:
|
||||
specifier: ^1.15.11
|
||||
version: 1.15.11
|
||||
hono:
|
||||
specifier: ^4.13.11
|
||||
version: 4.13.23
|
||||
husky:
|
||||
specifier: ^9.1.7
|
||||
version: 9.1.7
|
||||
@@ -989,6 +992,34 @@ importers:
|
||||
specifier: 'catalog:'
|
||||
version: 3.3.14(typescript@6.0.3)
|
||||
|
||||
integrations/lucide-hono/vite:
|
||||
dependencies:
|
||||
'@lucide/hono':
|
||||
specifier: workspace:*
|
||||
version: link:../../../packages/hono
|
||||
hono:
|
||||
specifier: 'catalog:'
|
||||
version: 4.13.23
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: 'catalog:'
|
||||
version: 26.6.11
|
||||
'@vitest/browser-playwright':
|
||||
specifier: 'catalog:'
|
||||
version: 5.0.5(playwright@1.64.1)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))(vitest@5.0.5)
|
||||
playwright:
|
||||
specifier: 'catalog:'
|
||||
version: 1.64.1
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 6.0.3
|
||||
vite:
|
||||
specifier: ^8.3.5
|
||||
version: 8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)
|
||||
vitest:
|
||||
specifier: 5.0.5
|
||||
version: 5.0.5(@types/node@26.6.11)(@vitest/browser-playwright@5.0.5)(@vitest/coverage-v8@5.0.5)(@vitest/ui@5.0.5)(jsdom@30.1.3)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
|
||||
integrations/lucide-react/nextjs:
|
||||
dependencies:
|
||||
lucide-react:
|
||||
@@ -1451,10 +1482,10 @@ importers:
|
||||
version: link:../../../packages/vue
|
||||
vike:
|
||||
specifier: 'catalog:'
|
||||
version: 0.4.266(h3@1.15.11)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
version: 0.4.266(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
vike-vue:
|
||||
specifier: 'catalog:'
|
||||
version: 0.9.13(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)(vike@0.4.266(h3@1.15.11)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)))(vue@3.5.46(typescript@6.0.3))
|
||||
version: 0.9.13(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)(vike@0.4.266(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)))(vue@3.5.46(typescript@6.0.3))
|
||||
vue:
|
||||
specifier: 'catalog:'
|
||||
version: 3.5.46(typescript@6.0.3)
|
||||
@@ -1627,6 +1658,39 @@ importers:
|
||||
specifier: 5.0.5
|
||||
version: 5.0.5(@types/node@26.6.11)(@vitest/browser-playwright@5.0.5)(@vitest/coverage-v8@5.0.5)(@vitest/ui@5.0.5)(jsdom@30.1.3)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
|
||||
packages/hono:
|
||||
devDependencies:
|
||||
'@lucide/build-icons':
|
||||
specifier: workspace:*
|
||||
version: link:../../tools/build-icons
|
||||
'@lucide/rollup-plugins':
|
||||
specifier: workspace:*
|
||||
version: link:../../tools/rollup-plugins
|
||||
'@lucide/shared':
|
||||
specifier: workspace:*
|
||||
version: link:../shared
|
||||
'@testing-library/jest-dom':
|
||||
specifier: 'catalog:'
|
||||
version: 7.0.1(@testing-library/dom@10.4.2)(vitest@5.0.5)
|
||||
hono:
|
||||
specifier: 'catalog:'
|
||||
version: 4.13.23
|
||||
jest-serializer-html:
|
||||
specifier: 'catalog:'
|
||||
version: 7.1.0
|
||||
rollup:
|
||||
specifier: 'catalog:'
|
||||
version: 4.68.9
|
||||
rollup-plugin-dts:
|
||||
specifier: 'catalog:'
|
||||
version: 6.5.1(rollup@4.68.9)(typescript@6.0.3)
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 6.0.3
|
||||
vite:
|
||||
specifier: ^8.3.5
|
||||
version: 8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)
|
||||
|
||||
packages/icons:
|
||||
devDependencies:
|
||||
'@lucide/build-icons':
|
||||
@@ -10001,6 +10065,10 @@ packages:
|
||||
hey-listen@1.0.8:
|
||||
resolution: {integrity: sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==}
|
||||
|
||||
hono@4.13.23:
|
||||
resolution: {integrity: sha512-OS90dj7dcsftEEWCOef8jRbnHE5lbrOq0hNRqjSyPsOnaGZvvfof1KS05hQNb4kUOCfDq1mG3PmHoX37DMnHQg==}
|
||||
engines: {node: '>=16.9.0'}
|
||||
|
||||
hookable@5.5.3:
|
||||
resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
|
||||
|
||||
@@ -20051,12 +20119,12 @@ snapshots:
|
||||
dependencies:
|
||||
srvx: 1.0.8
|
||||
|
||||
'@universal-deploy/vite@0.1.14(h3@1.15.11)(srvx@0.12.8)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))':
|
||||
'@universal-deploy/vite@0.1.14(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))':
|
||||
dependencies:
|
||||
'@universal-deploy/netlify': 0.2.5(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
'@universal-deploy/node': 0.1.15(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
'@universal-deploy/store': 0.2.2
|
||||
'@universal-middleware/express': 0.4.31(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-middleware/express': 0.4.31(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
magic-string: 0.30.21
|
||||
rou3: 0.8.1
|
||||
optionalDependencies:
|
||||
@@ -20072,26 +20140,28 @@ snapshots:
|
||||
- hono
|
||||
- srvx
|
||||
|
||||
'@universal-middleware/core@0.4.18(h3@1.15.11)(srvx@0.12.8)':
|
||||
'@universal-middleware/core@0.4.18(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)':
|
||||
dependencies:
|
||||
regexparam: 3.0.0
|
||||
tough-cookie: 6.1.0
|
||||
optionalDependencies:
|
||||
h3: 1.15.11
|
||||
hono: 4.13.23
|
||||
srvx: 0.12.8
|
||||
|
||||
'@universal-middleware/core@0.7.2(h3@1.15.11)(srvx@0.12.8)':
|
||||
'@universal-middleware/core@0.7.2(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)':
|
||||
dependencies:
|
||||
regexparam: 3.0.0
|
||||
tough-cookie: 6.1.0
|
||||
optionalDependencies:
|
||||
h3: 1.15.11
|
||||
hono: 4.13.23
|
||||
srvx: 0.12.8
|
||||
|
||||
'@universal-middleware/express@0.4.31(h3@1.15.11)(srvx@0.12.8)':
|
||||
'@universal-middleware/express@0.4.31(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)':
|
||||
dependencies:
|
||||
'@universal-middleware/core': 0.4.18(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-middleware/node': 0.2.9(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-middleware/core': 0.4.18(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
'@universal-middleware/node': 0.2.9(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
transitivePeerDependencies:
|
||||
- '@cloudflare/workers-types'
|
||||
- '@hattip/core'
|
||||
@@ -20103,9 +20173,9 @@ snapshots:
|
||||
- hono
|
||||
- srvx
|
||||
|
||||
'@universal-middleware/node@0.2.9(h3@1.15.11)(srvx@0.12.8)':
|
||||
'@universal-middleware/node@0.2.9(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)':
|
||||
dependencies:
|
||||
'@universal-middleware/core': 0.7.2(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-middleware/core': 0.7.2(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
transitivePeerDependencies:
|
||||
- '@cloudflare/workers-types'
|
||||
- '@hattip/core'
|
||||
@@ -22715,6 +22785,8 @@ snapshots:
|
||||
|
||||
hey-listen@1.0.8: {}
|
||||
|
||||
hono@4.13.23: {}
|
||||
|
||||
hookable@5.5.3: {}
|
||||
|
||||
hookable@6.1.2: {}
|
||||
@@ -27442,18 +27514,18 @@ snapshots:
|
||||
'@types/unist': 3.0.3
|
||||
vfile-message: 4.0.4
|
||||
|
||||
vike-vue@0.9.13(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)(vike@0.4.266(h3@1.15.11)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)))(vue@3.5.46(typescript@6.0.3)):
|
||||
vike-vue@0.9.13(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)(vike@0.4.266(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)))(vue@3.5.46(typescript@6.0.3)):
|
||||
dependencies:
|
||||
magic-string: 0.30.21
|
||||
oxc-parser: 0.104.0(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)
|
||||
oxc-walker: 0.6.0(oxc-parser@0.104.0(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2))
|
||||
vike: 0.4.266(h3@1.15.11)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
vike: 0.4.266(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
vue: 3.5.46(typescript@6.0.3)
|
||||
transitivePeerDependencies:
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
|
||||
vike@0.4.266(h3@1.15.11)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)):
|
||||
vike@0.4.266(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(supports-color@10.2.2)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1)):
|
||||
dependencies:
|
||||
'@babel/core': 7.29.16(supports-color@10.2.2)
|
||||
'@babel/types': 7.29.15
|
||||
@@ -27462,9 +27534,9 @@ snapshots:
|
||||
'@brillout/picocolors': 1.0.31
|
||||
'@brillout/vite-plugin-server-entry': 0.7.24
|
||||
'@universal-deploy/store': 0.2.2
|
||||
'@universal-deploy/vite': 0.1.14(h3@1.15.11)(srvx@0.12.8)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
'@universal-middleware/core': 0.4.18(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-middleware/node': 0.2.9(h3@1.15.11)(srvx@0.12.8)
|
||||
'@universal-deploy/vite': 0.1.14(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(less@4.9.1(supports-color@10.2.2))(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.51.4)(yaml@2.9.1))
|
||||
'@universal-middleware/core': 0.4.18(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
'@universal-middleware/node': 0.2.9(h3@1.15.11)(hono@4.13.23)(srvx@0.12.8)
|
||||
cac: 6.7.14
|
||||
convert-route: 1.1.1
|
||||
es-module-lexer: 1.7.0
|
||||
|
||||
@@ -128,6 +128,7 @@ catalog:
|
||||
fs-extra: ^11.4.0
|
||||
fuse.js: ^7.5.0
|
||||
h3: ^1.15.11
|
||||
hono: ^4.13.11
|
||||
husky: ^9.1.7
|
||||
isbot: 5.2.2
|
||||
jest-serializer-html: ^7.1.0
|
||||
|
||||
@@ -74,6 +74,7 @@ const RULES: Rule[] = [
|
||||
{ pattern: /^packages\/svelte\//, scope: '@lucide/svelte', kind: 'package' },
|
||||
{ pattern: /^packages\/solid\//, scope: '@lucide/solid', kind: 'package' },
|
||||
{ pattern: /^packages\/astro\//, scope: '@lucide/astro', kind: 'package' },
|
||||
{ pattern: /^packages\/hono\//, scope: '@lucide/hono', kind: 'package' },
|
||||
{ pattern: /^packages\/lab\//, scope: '@lucide/lab', kind: 'package' },
|
||||
{ pattern: /^packages\/shared\//, scope: '@lucide/shared', kind: 'package' },
|
||||
{ pattern: /^packages\/lucide\//, scope: 'lucide', kind: 'package' },
|
||||
|
||||
Reference in New Issue
Block a user