@adam-milo/icons 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Adam Milo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @adam-milo/icons
2
+
3
+ Icon components for the Adam Milo Design System. Built on top of [Radix UI Icons](https://www.radix-ui.com/icons).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @adam-milo/icons
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { Icon } from '@adam-milo/icons';
15
+
16
+ // Decorative icon (with text label)
17
+ <Icon name="PlusIcon" decorative />
18
+
19
+ // Standalone icon (requires aria-label)
20
+ <Icon name="TrashIcon" aria-label="Delete item" size="lg" />
21
+
22
+ // Icon with color and size
23
+ <Icon name="CheckIcon" color="clickable" size="xl" aria-label="Success" />
24
+ ```
25
+
26
+ ## Props
27
+
28
+ ### `name` (required)
29
+
30
+ The name of the icon from Radix UI icons. See [available icons](https://www.radix-ui.com/icons).
31
+
32
+ ### `size`
33
+
34
+ Size variant from design system:
35
+
36
+ - `xs` - 12px
37
+ - `sm` - 14px
38
+ - `md` - 16px (default)
39
+ - `lg` - 20px
40
+ - `xl` - 24px
41
+ - `2xl` - 32px
42
+
43
+ ### `color`
44
+
45
+ Color variant from design system:
46
+
47
+ - `text` (default)
48
+ - `action`
49
+ - `clickable`
50
+ - `popup`
51
+ - `error`
52
+ - `toggle`
53
+ - `secondary`
54
+ - `system-text`
55
+ - `icon-secondary`
56
+ - `card`
57
+
58
+ ### `decorative`
59
+
60
+ If `true`, marks the icon as decorative (aria-hidden="true"). Use for icons that are purely visual or accompanied by text.
61
+
62
+ ### `aria-label`
63
+
64
+ Required for standalone/clickable icons. Omit for decorative icons.
65
+
66
+ ## Accessibility
67
+
68
+ The Icon component automatically handles ARIA attributes based on usage:
69
+
70
+ ```tsx
71
+ // Decorative icon - aria-hidden="true", role="presentation"
72
+ <Icon name="StarIcon" decorative />
73
+
74
+ // Semantic icon - role="img", requires aria-label
75
+ <Icon name="WarningIcon" aria-label="Warning" />
76
+ ```
77
+
78
+ ## Available Icons
79
+
80
+ All [Radix UI icons](https://www.radix-ui.com/icons) are available. Common ones include:
81
+
82
+ - `CheckIcon`, `Cross1Icon`, `Cross2Icon`
83
+ - `ChevronDownIcon`, `ChevronUpIcon`, `ChevronLeftIcon`, `ChevronRightIcon`
84
+ - `PlusIcon`, `MinusIcon`
85
+ - `InfoCircledIcon`, `QuestionMarkCircledIcon`
86
+ - `MagnifyingGlassIcon`, `GearIcon`
87
+ - And many more...
88
+
89
+ ## Direct Icon Import
90
+
91
+ You can also import Radix icons directly:
92
+
93
+ ```tsx
94
+ import { CheckIcon, Cross2Icon } from '@adam-milo/icons';
95
+
96
+ <CheckIcon width={16} height={16} />;
97
+ ```
98
+
99
+ ## TypeScript
100
+
101
+ Full TypeScript support with exported types:
102
+
103
+ ```typescript
104
+ import type { IconProps, IconName, IconSize, IconColor } from '@adam-milo/icons';
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT
@@ -0,0 +1,65 @@
1
+ import * as react from 'react';
2
+ import { SVGProps } from 'react';
3
+ import * as RadixIcons from '@radix-ui/react-icons';
4
+ export * from '@radix-ui/react-icons';
5
+
6
+ type IconName = keyof typeof RadixIcons;
7
+ declare const availableIcons: IconName[];
8
+ type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
9
+ type IconColor = 'text' | 'action' | 'clickable' | 'popup' | 'error' | 'toggle' | 'secondary' | 'system-text' | 'icon-secondary' | 'card';
10
+ interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'ref' | 'color'> {
11
+ /**
12
+ * The name of the icon from Radix UI icons
13
+ */
14
+ name: IconName;
15
+ /**
16
+ * Size variant from design system
17
+ * @default 'md'
18
+ */
19
+ size?: IconSize;
20
+ /**
21
+ * Color variant from design system
22
+ * @default 'text'
23
+ */
24
+ color?: IconColor;
25
+ /**
26
+ * Accessible label for the icon. Required for standalone/clickable icons.
27
+ * For decorative icons, set `decorative` to true instead.
28
+ */
29
+ 'aria-label'?: string;
30
+ /**
31
+ * If true, marks the icon as decorative (aria-hidden="true").
32
+ * Use this for icons that are purely decorative or accompanied by visible text.
33
+ * @default false
34
+ */
35
+ decorative?: boolean;
36
+ /**
37
+ * Custom data-testid for testing purposes
38
+ */
39
+ 'data-testid'?: string;
40
+ /**
41
+ * Custom data-cy attribute for Cypress testing
42
+ */
43
+ 'data-cy'?: string;
44
+ }
45
+ /**
46
+ * Icon component that provides access to all Radix UI icons with built-in accessibility support.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * // Decorative icon (with text label)
51
+ * <Icon name="PlusIcon" decorative />
52
+ *
53
+ * // Standalone icon (requires aria-label)
54
+ * <Icon name="TrashIcon" aria-label="Delete item" size="lg" />
55
+ *
56
+ * // Icon with color and size
57
+ * <Icon name="CheckIcon" color="clickable" size="xl" aria-label="Success" />
58
+ *
59
+ * // Icon with custom Cypress test ID
60
+ * <Icon name="ErrorIcon" color="error" data-cy="error-icon" decorative />
61
+ * ```
62
+ */
63
+ declare const Icon: react.ForwardRefExoticComponent<IconProps & react.RefAttributes<SVGSVGElement>>;
64
+
65
+ export { Icon, type IconColor, type IconName, type IconProps, type IconSize, availableIcons };
@@ -0,0 +1,65 @@
1
+ import * as react from 'react';
2
+ import { SVGProps } from 'react';
3
+ import * as RadixIcons from '@radix-ui/react-icons';
4
+ export * from '@radix-ui/react-icons';
5
+
6
+ type IconName = keyof typeof RadixIcons;
7
+ declare const availableIcons: IconName[];
8
+ type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
9
+ type IconColor = 'text' | 'action' | 'clickable' | 'popup' | 'error' | 'toggle' | 'secondary' | 'system-text' | 'icon-secondary' | 'card';
10
+ interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'ref' | 'color'> {
11
+ /**
12
+ * The name of the icon from Radix UI icons
13
+ */
14
+ name: IconName;
15
+ /**
16
+ * Size variant from design system
17
+ * @default 'md'
18
+ */
19
+ size?: IconSize;
20
+ /**
21
+ * Color variant from design system
22
+ * @default 'text'
23
+ */
24
+ color?: IconColor;
25
+ /**
26
+ * Accessible label for the icon. Required for standalone/clickable icons.
27
+ * For decorative icons, set `decorative` to true instead.
28
+ */
29
+ 'aria-label'?: string;
30
+ /**
31
+ * If true, marks the icon as decorative (aria-hidden="true").
32
+ * Use this for icons that are purely decorative or accompanied by visible text.
33
+ * @default false
34
+ */
35
+ decorative?: boolean;
36
+ /**
37
+ * Custom data-testid for testing purposes
38
+ */
39
+ 'data-testid'?: string;
40
+ /**
41
+ * Custom data-cy attribute for Cypress testing
42
+ */
43
+ 'data-cy'?: string;
44
+ }
45
+ /**
46
+ * Icon component that provides access to all Radix UI icons with built-in accessibility support.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * // Decorative icon (with text label)
51
+ * <Icon name="PlusIcon" decorative />
52
+ *
53
+ * // Standalone icon (requires aria-label)
54
+ * <Icon name="TrashIcon" aria-label="Delete item" size="lg" />
55
+ *
56
+ * // Icon with color and size
57
+ * <Icon name="CheckIcon" color="clickable" size="xl" aria-label="Success" />
58
+ *
59
+ * // Icon with custom Cypress test ID
60
+ * <Icon name="ErrorIcon" color="error" data-cy="error-icon" decorative />
61
+ * ```
62
+ */
63
+ declare const Icon: react.ForwardRefExoticComponent<IconProps & react.RefAttributes<SVGSVGElement>>;
64
+
65
+ export { Icon, type IconColor, type IconName, type IconProps, type IconSize, availableIcons };
package/dist/index.js ADDED
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.tsx
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ Icon: () => Icon,
35
+ availableIcons: () => availableIcons
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_react = require("react");
39
+ var RadixIcons = __toESM(require("@radix-ui/react-icons"));
40
+ __reExport(index_exports, require("@radix-ui/react-icons"), module.exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var availableIcons = Object.keys(RadixIcons);
43
+ var sizeMap = {
44
+ xs: 12,
45
+ // --font-size-10
46
+ sm: 14,
47
+ // --font-size-9
48
+ md: 16,
49
+ // --font-size-8 (default)
50
+ lg: 20,
51
+ // --spacing-5
52
+ xl: 24,
53
+ // --spacing-6
54
+ "2xl": 32
55
+ // --spacing-8
56
+ };
57
+ var colorMap = {
58
+ text: "var(--color-text)",
59
+ action: "var(--color-action)",
60
+ clickable: "var(--color-clickable)",
61
+ popup: "var(--color-popup)",
62
+ error: "var(--color-error)",
63
+ toggle: "var(--color-toggle)",
64
+ secondary: "var(--color-secondary)",
65
+ "system-text": "var(--color-system-text)",
66
+ "icon-secondary": "var(--color-icon-secondary)",
67
+ card: "var(--color-card)"
68
+ };
69
+ var Icon = (0, import_react.forwardRef)(
70
+ ({
71
+ name,
72
+ size = "md",
73
+ color = "text",
74
+ decorative = false,
75
+ "aria-label": ariaLabel,
76
+ "data-testid": dataTestId,
77
+ "data-cy": dataCy,
78
+ children: _children,
79
+ style,
80
+ ...props
81
+ }, ref) => {
82
+ const IconComponent = RadixIcons[name];
83
+ if (!IconComponent) {
84
+ console.warn(`Icon "${name}" not found in Radix Icons`);
85
+ return null;
86
+ }
87
+ const sizeValue = sizeMap[size];
88
+ const colorValue = colorMap[color];
89
+ const finalTestId = dataTestId || `icon-${name.toLowerCase().replace("icon", "")}`;
90
+ const finalCyId = dataCy || `icon-${name.toLowerCase().replace("icon", "")}`;
91
+ const isDecorative = decorative || !ariaLabel && !props["aria-labelledby"];
92
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ IconComponent,
94
+ {
95
+ ref,
96
+ width: sizeValue,
97
+ height: sizeValue,
98
+ style: {
99
+ color: colorValue,
100
+ ...style
101
+ },
102
+ "data-testid": finalTestId,
103
+ "data-cy": finalCyId,
104
+ "aria-hidden": isDecorative ? "true" : void 0,
105
+ "aria-label": isDecorative ? void 0 : ariaLabel,
106
+ role: isDecorative ? "presentation" : "img",
107
+ ...props
108
+ }
109
+ );
110
+ }
111
+ );
112
+ Icon.displayName = "Icon";
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ Icon,
116
+ availableIcons,
117
+ ...require("@radix-ui/react-icons")
118
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,80 @@
1
+ // src/index.tsx
2
+ import { forwardRef } from "react";
3
+ import * as RadixIcons from "@radix-ui/react-icons";
4
+ export * from "@radix-ui/react-icons";
5
+ import { jsx } from "react/jsx-runtime";
6
+ var availableIcons = Object.keys(RadixIcons);
7
+ var sizeMap = {
8
+ xs: 12,
9
+ // --font-size-10
10
+ sm: 14,
11
+ // --font-size-9
12
+ md: 16,
13
+ // --font-size-8 (default)
14
+ lg: 20,
15
+ // --spacing-5
16
+ xl: 24,
17
+ // --spacing-6
18
+ "2xl": 32
19
+ // --spacing-8
20
+ };
21
+ var colorMap = {
22
+ text: "var(--color-text)",
23
+ action: "var(--color-action)",
24
+ clickable: "var(--color-clickable)",
25
+ popup: "var(--color-popup)",
26
+ error: "var(--color-error)",
27
+ toggle: "var(--color-toggle)",
28
+ secondary: "var(--color-secondary)",
29
+ "system-text": "var(--color-system-text)",
30
+ "icon-secondary": "var(--color-icon-secondary)",
31
+ card: "var(--color-card)"
32
+ };
33
+ var Icon = forwardRef(
34
+ ({
35
+ name,
36
+ size = "md",
37
+ color = "text",
38
+ decorative = false,
39
+ "aria-label": ariaLabel,
40
+ "data-testid": dataTestId,
41
+ "data-cy": dataCy,
42
+ children: _children,
43
+ style,
44
+ ...props
45
+ }, ref) => {
46
+ const IconComponent = RadixIcons[name];
47
+ if (!IconComponent) {
48
+ console.warn(`Icon "${name}" not found in Radix Icons`);
49
+ return null;
50
+ }
51
+ const sizeValue = sizeMap[size];
52
+ const colorValue = colorMap[color];
53
+ const finalTestId = dataTestId || `icon-${name.toLowerCase().replace("icon", "")}`;
54
+ const finalCyId = dataCy || `icon-${name.toLowerCase().replace("icon", "")}`;
55
+ const isDecorative = decorative || !ariaLabel && !props["aria-labelledby"];
56
+ return /* @__PURE__ */ jsx(
57
+ IconComponent,
58
+ {
59
+ ref,
60
+ width: sizeValue,
61
+ height: sizeValue,
62
+ style: {
63
+ color: colorValue,
64
+ ...style
65
+ },
66
+ "data-testid": finalTestId,
67
+ "data-cy": finalCyId,
68
+ "aria-hidden": isDecorative ? "true" : void 0,
69
+ "aria-label": isDecorative ? void 0 : ariaLabel,
70
+ role: isDecorative ? "presentation" : "img",
71
+ ...props
72
+ }
73
+ );
74
+ }
75
+ );
76
+ Icon.displayName = "Icon";
77
+ export {
78
+ Icon,
79
+ availableIcons
80
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@adam-milo/icons",
3
+ "version": "1.0.0",
4
+ "description": "Icon components for the Adam Milo Design System",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.tsx --format cjs,esm --dts --external react --external react-dom",
22
+ "dev": "tsup src/index.tsx --format cjs,esm --dts --external react --external react-dom --watch",
23
+ "clean": "rm -rf dist"
24
+ },
25
+ "keywords": [
26
+ "icons",
27
+ "design-system",
28
+ "radix-ui",
29
+ "react",
30
+ "adam-milo"
31
+ ],
32
+ "author": "Adam Milo",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/adam-milo-smart/adam-milo-design-system.git",
37
+ "directory": "packages/icons"
38
+ },
39
+ "homepage": "https://github.com/adam-milo-smart/adam-milo-design-system#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/adam-milo-smart/adam-milo-design-system/issues"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^18.0.0",
48
+ "react-dom": "^18.0.0"
49
+ },
50
+ "dependencies": {
51
+ "@radix-ui/react-icons": "^1.3.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/react": "^18.2.45",
55
+ "@types/react-dom": "^18.2.18",
56
+ "react": "^18.2.0",
57
+ "react-dom": "^18.2.0",
58
+ "tsup": "^8.0.1",
59
+ "typescript": "^5.3.3"
60
+ }
61
+ }