Remove large imports
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
- **Runtime/tooling:** Bun, not Node. Use `bun install`, `bun run <script>`, `bun test`, `bunx`. Never `npm`/`npx`/`yarn`/`pnpm`.
|
- **Runtime/tooling:** Bun, not Node. Use `bun install`, `bun run <script>`, `bun test`, `bunx`. Never `npm`/`npx`/`yarn`/`pnpm`.
|
||||||
- **Build:** `tsc` emits `src/` → `dist/` (JS + `.d.ts`), then `scripts/post-compile.ts` runs. There is no Next.js, Vite, PostCSS config or `tailwind.config` in this repo - don't add them.
|
- **Build:** `tsc` emits `src/` → `dist/` (JS + `.d.ts`), then `scripts/post-compile.ts` runs. There is no Next.js, Vite, PostCSS config or `tailwind.config` in this repo - don't add them.
|
||||||
- **Styling:** Tailwind v4 via `src/base.css` (`@import "tailwindcss"`, `@source "./"`, `@theme inline` tokens). `tailwind-merge` (`twMerge`) for class composition.
|
- **Styling:** Tailwind v4 via `src/base.css` (`@import "tailwindcss"`, `@source "./"`, `@theme inline` tokens). `tailwind-merge` (`twMerge`) for class composition.
|
||||||
- **Icons:** `lucide-react` (peer dependency).
|
- **Icons:** `lucide-react` (peer dependency). Components take icons as elements. Nothing a component imports may look one up by name: `LucideIcon` (`import * as icons`) puts all of lucide in every bundle of an app that reaches it, since bundlers can't tree-shake a namespace lookup, so only an app's own pages may import it.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export default function ButtonsPage() {
|
|||||||
|
|
||||||
<DemoSection
|
<DemoSection
|
||||||
title="Icons and loading"
|
title="Icons and loading"
|
||||||
description="Icons accept a lucide name or a React element. Loading keeps the label in place and swaps in a spinner."
|
description="Icons are React elements. Loading keeps the label in place and swaps in a spinner."
|
||||||
>
|
>
|
||||||
<Row className="gap-3">
|
<Row className="gap-3">
|
||||||
<Button
|
<Button
|
||||||
@@ -91,7 +91,7 @@ export default function ButtonsPage() {
|
|||||||
<Button
|
<Button
|
||||||
title="Download button"
|
title="Download button"
|
||||||
color="success"
|
color="success"
|
||||||
after_icon_name="Download"
|
afterIcon={<Download size={16} />}
|
||||||
>
|
>
|
||||||
Download
|
Download
|
||||||
</Button>
|
</Button>
|
||||||
@@ -140,7 +140,7 @@ export default function ButtonsPage() {
|
|||||||
href="#"
|
href="#"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
before_icon_name="Download"
|
beforeIcon={<Download size={16} />}
|
||||||
>
|
>
|
||||||
Outlined link
|
Outlined link
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/twui",
|
"name": "@moduletrace/twui",
|
||||||
"version": "0.1.2",
|
"version": "0.1.4",
|
||||||
"description": "A modular skeletal React component framework for Tailwind CSS v4",
|
"description": "A modular skeletal React component framework for Tailwind CSS v4",
|
||||||
"author": "Benjamin Toby",
|
"author": "Benjamin Toby",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
+9
-33
@@ -8,8 +8,6 @@ import React, {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import Loading from "../elements/Loading";
|
import Loading from "../elements/Loading";
|
||||||
import LucideIcon, { type TWUILucideIconName } from "../elements/lucide-icon";
|
|
||||||
import type { LucideProps } from "lucide-react";
|
|
||||||
|
|
||||||
export const TWUIButtonColors = [
|
export const TWUIButtonColors = [
|
||||||
"primary",
|
"primary",
|
||||||
@@ -53,12 +51,13 @@ export type TWUIButtonProps = DetailedHTMLProps<
|
|||||||
AnchorHTMLAttributes<HTMLAnchorElement>,
|
AnchorHTMLAttributes<HTMLAnchorElement>,
|
||||||
HTMLAnchorElement
|
HTMLAnchorElement
|
||||||
>;
|
>;
|
||||||
beforeIcon?: TWUILucideIconName | React.JSX.Element;
|
/**
|
||||||
afterIcon?: TWUILucideIconName | React.JSX.Element;
|
* An icon element before the children, e.g. `<Download size={16} />`.
|
||||||
before_icon_name?: TWUILucideIconName;
|
* Icons are passed as elements, never looked up by name: a by-name
|
||||||
after_icon_name?: TWUILucideIconName;
|
* lookup puts every lucide icon in every bundle that uses `Button`.
|
||||||
before_icon_props?: LucideProps;
|
*/
|
||||||
after_icon_props?: LucideProps;
|
beforeIcon?: React.ReactNode;
|
||||||
|
afterIcon?: React.ReactNode;
|
||||||
buttonContentProps?: DetailedHTMLProps<
|
buttonContentProps?: DetailedHTMLProps<
|
||||||
HTMLAttributes<HTMLDivElement>,
|
HTMLAttributes<HTMLDivElement>,
|
||||||
HTMLDivElement
|
HTMLDivElement
|
||||||
@@ -265,10 +264,6 @@ export default function Button({
|
|||||||
loading,
|
loading,
|
||||||
loadingIconSize,
|
loadingIconSize,
|
||||||
loadingProps,
|
loadingProps,
|
||||||
before_icon_name,
|
|
||||||
after_icon_name,
|
|
||||||
before_icon_props,
|
|
||||||
after_icon_props,
|
|
||||||
...props
|
...props
|
||||||
}: TWUIButtonProps) {
|
}: TWUIButtonProps) {
|
||||||
const finalClassName =
|
const finalClassName =
|
||||||
@@ -308,28 +303,9 @@ export default function Button({
|
|||||||
buttonContentProps?.className,
|
buttonContentProps?.className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{before_icon_name ? (
|
{beforeIcon}
|
||||||
<LucideIcon
|
|
||||||
{...before_icon_props}
|
|
||||||
name={before_icon_name}
|
|
||||||
/>
|
|
||||||
) : beforeIcon ? (
|
|
||||||
typeof beforeIcon == "string" ? (
|
|
||||||
<LucideIcon name={beforeIcon as TWUILucideIconName} />
|
|
||||||
) : (
|
|
||||||
beforeIcon
|
|
||||||
)
|
|
||||||
) : null}
|
|
||||||
{props.children}
|
{props.children}
|
||||||
{after_icon_name ? (
|
{afterIcon}
|
||||||
<LucideIcon {...after_icon_props} name={after_icon_name} />
|
|
||||||
) : afterIcon ? (
|
|
||||||
typeof afterIcon == "string" ? (
|
|
||||||
<LucideIcon name={afterIcon as TWUILucideIconName} />
|
|
||||||
) : (
|
|
||||||
afterIcon
|
|
||||||
)
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading && (
|
{loading && (
|
||||||
|
|||||||
Reference in New Issue
Block a user