-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split icons to packages (#255)
* refactor: split icons to packages This will reduce the bundle size as `icons.ts` non-gzipped weights around 1.2MB and is always being imported when `frog/ui` package is used. We can improve the bundle size by splitting the icons into different packages, having just one collection imported by default – lucide. * chore: changesets * nit: unnecessary biome change * nit: lint * fix: simplify typing to let the build pass * chore: add `frog/ui/icons` proxy package with all icon sets * nit: apply suggested changes Co-authored-by: awkweb <[email protected]> * Update many-schools-reflect.md * refactor: gen icons * fix: icon type inference * chore: imports --------- Co-authored-by: awkweb <[email protected]>
- Loading branch information
Showing
14 changed files
with
163 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
"frog": minor | ||
--- | ||
|
||
**Breaking change** Frog UI `icon` property requires an icon map imported from the `'frog/ui/icons'` entrypoint. This also makes it easier for you to supply your own custom icons. | ||
|
||
```diff | ||
+ import { lucide } from 'frog/ui/icons' | ||
|
||
export const system = createSystem({ | ||
- icons: 'lucide', | ||
+ icons: lucide, | ||
}) | ||
``` | ||
|
||
In addition, the following separate entrypoints were added for resource constrained environments. | ||
|
||
- `frog/ui/icons/heroicons` | ||
- `frog/ui/icons/lucide` | ||
- `frog/ui/icons/radix-icons` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expectTypeOf, test } from 'vitest' | ||
|
||
import { createSystem } from './createSystem.js' | ||
import { heroicons, lucide } from './icons/index.js' | ||
|
||
test('defaults', () => { | ||
const { Icon } = createSystem() | ||
type IconProps = Parameters<typeof Icon>[0] | ||
expectTypeOf<IconProps['collection']>().toEqualTypeOf< | ||
Record<string, string> | undefined | ||
>() | ||
expectTypeOf<IconProps['name']>().toEqualTypeOf<keyof typeof lucide>() | ||
}) | ||
|
||
test('custom system collection', () => { | ||
const { Icon } = createSystem({ icons: heroicons }) | ||
type IconProps = Parameters<typeof Icon>[0] | ||
expectTypeOf<IconProps['collection']>().toEqualTypeOf< | ||
Record<string, string> | undefined | ||
>() | ||
expectTypeOf<IconProps['name']>().toEqualTypeOf<keyof typeof heroicons>() | ||
}) | ||
|
||
test('custom system collection', () => { | ||
const { Icon, vars } = createSystem() | ||
type IconProps = Parameters<typeof Icon<typeof vars, typeof heroicons>>[0] | ||
expectTypeOf<IconProps['collection']>().toEqualTypeOf< | ||
typeof heroicons | Record<string, string> | undefined | ||
>() | ||
expectTypeOf<IconProps['name']>().toEqualTypeOf<keyof typeof heroicons>() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expectTypeOf, test } from 'vitest' | ||
|
||
import { createSystem } from './createSystem.js' | ||
import { heroicons, lucide } from './icons/index.js' | ||
|
||
test('defaults', () => { | ||
const { vars } = createSystem() | ||
expectTypeOf(vars.icons).toEqualTypeOf<typeof lucide>() | ||
}) | ||
|
||
test('custom', () => { | ||
const { vars } = createSystem({ icons: heroicons }) | ||
expectTypeOf(vars.icons).toEqualTypeOf<typeof heroicons>() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "module", | ||
"types": "../../_lib/ui/icons/index.d.ts", | ||
"module": "../../_lib/ui/icons/index.js" | ||
} |
Oops, something went wrong.