@gamecrafters/base-ui-icons 0.0.1

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 Donald Lee
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.
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function classNames(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,80 @@
1
+ import React from "react";
2
+ import type { IconProps, SVGData } from "./Icon.types";
3
+ import { classNames } from "@/lib/classnames";
4
+
5
+ function createIconComponent(name: string, defaultClassName: string, getSVGData: () => SVGData) {
6
+ const svgDataByHeight = getSVGData()
7
+ const heights = Object.keys(svgDataByHeight)
8
+
9
+ const Icon = React.forwardRef<SVGSVGElement, IconProps>(
10
+ (
11
+ {
12
+ "aria-label": ariaLabel,
13
+ "aria-labelledby": arialabelledby,
14
+ tabIndex,
15
+ className = "",
16
+ fill = "currentColor",
17
+ size = 16,
18
+ id,
19
+ title,
20
+ style,
21
+ ...rest
22
+ },
23
+ ref,
24
+ ) => {
25
+ const height = size
26
+ const naturalHeight = closestNaturalHeight(heights, height)
27
+ const naturalWidth = svgDataByHeight[naturalHeight].width
28
+ const width = height * (naturalWidth / parseInt(naturalHeight, 10))
29
+ const path = svgDataByHeight[naturalHeight].path
30
+ const labelled = ariaLabel || arialabelledby
31
+ const role = labelled ? "img" : undefined
32
+ const classes = classNames(defaultClassName, className)
33
+
34
+ return (
35
+ <svg
36
+ ref={ref}
37
+ {...rest}
38
+ aria-hidden={labelled ? undefined : "true"}
39
+ tabIndex={tabIndex}
40
+ focusable={(tabIndex ?? -1) >= 0 ? "true" : "false"}
41
+ aria-label={ariaLabel}
42
+ aria-labelledby={arialabelledby}
43
+ className={classes}
44
+ role={role}
45
+ viewBox={`0 0 ${naturalWidth} ${naturalHeight}`}
46
+ width={width}
47
+ height={height}
48
+ fill={fill}
49
+ id={id}
50
+ display="inline-block"
51
+ overflow="visible"
52
+ style={style}
53
+ >
54
+ {title ? <title>{title}</title> : null}
55
+ {path}
56
+ </svg>
57
+ )
58
+ },
59
+ )
60
+
61
+ Icon.displayName = name
62
+
63
+ return Icon
64
+ }
65
+
66
+ function closestNaturalHeight(naturalHeights: string[], height: number): string {
67
+ const closestHeight = naturalHeights
68
+ .map((naturalHeight) => parseInt(naturalHeight, 10))
69
+ .reduce((acc, naturalHeight) => (naturalHeight <= height ? naturalHeight : acc), parseInt(naturalHeights[0], 10))
70
+ return closestHeight.toString()
71
+ }
72
+
73
+ export const AccessibilityRegularIcon = /*#__PURE__*/createIconComponent("AccessibilityRegularIcon", "icon icon-accessibility_regular", () => {
74
+ return {
75
+ "24": {
76
+ "width": 24,
77
+ "path": <path d="M10.5 5a1.5 1.5 0 0 0 .968 1.403c.35.085.714.085 1.063 0A1.5 1.5 0 1 0 10.5 5m-1.474.399a3 3 0 1 1 5.947 0l2.877-1.221a2.266 2.266 0 0 1 2.962 1.184 2.24 2.24 0 0 1-1.181 2.954l-3.628 1.54v3.717l1.874 5.444a2.25 2.25 0 1 1-4.255 1.465L12 15.772l-1.622 4.71a2.25 2.25 0 1 1-4.255-1.465l1.88-5.457V9.858L4.37 8.316a2.24 2.24 0 0 1-1.182-2.954A2.266 2.266 0 0 1 6.15 4.178zm1.996 2.438a4 4 0 0 1-.487-.168l-4.971-2.11a.766.766 0 0 0-1 .399.74.74 0 0 0 .392.977L8.74 8.542c.462.196.761.649.761 1.15v3.91q0 .208-.068.406l-1.892 5.497a.75.75 0 1 0 1.418.488l2.108-6.123c.306-.888 1.56-.884 1.864 0l2.108 6.123a.75.75 0 1 0 1.419-.488l-1.888-5.483a1.3 1.3 0 0 1-.069-.407V9.691c0-.502.3-.955.762-1.151l3.78-1.605a.74.74 0 0 0 .391-.977.766.766 0 0 0-.999-.4l-4.97 2.11q-.24.102-.489.17a3 3 0 0 1-1.955-.001" />
78
+ }
79
+ };
80
+ });
@@ -0,0 +1,41 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ export type SVGData = {
4
+ [height: string]: {
5
+ /**
6
+ * Width of the SVG at this height
7
+ */
8
+ width: number;
9
+ /**
10
+ * SVG path content
11
+ */
12
+ path: ReactNode;
13
+ };
14
+ };
15
+
16
+ export interface IconProps extends React.SVGAttributes<SVGSVGElement> {
17
+ /**
18
+ * Accessible label for the icon
19
+ */
20
+ "aria-label"?: string;
21
+ /**
22
+ * ID of element that labels the icon
23
+ */
24
+ "aria-labelledby"?: string;
25
+ /**
26
+ * Additional CSS class names
27
+ */
28
+ className?: string;
29
+ /**
30
+ * Fill color for the icon
31
+ */
32
+ fill?: string;
33
+ /**
34
+ * Icon size (number in pixels)
35
+ */
36
+ size?: number;
37
+ /**
38
+ * Icon title for accessibility
39
+ */
40
+ title?: string;
41
+ }
@@ -0,0 +1,7 @@
1
+ import type { ForwardRefExoticComponent, RefAttributes } from "react";
2
+ import type { IconProps } from "./Icon.types";
3
+
4
+ export type { IconProps } from "./Icon.types";
5
+ export type Icon = ForwardRefExoticComponent<IconProps & RefAttributes<SVGSVGElement>>;
6
+
7
+ export { AccessibilityRegularIcon } from "./Icon";
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@gamecrafters/base-ui-icons",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "exports": {
7
+ "./react": {
8
+ "types": "./lib/react/index.ts",
9
+ "default": "./lib/react/index.ts"
10
+ }
11
+ },
12
+ "files": [
13
+ "lib"
14
+ ],
15
+ "scripts": {
16
+ "build:optimize": "svgo icons --config svgo.config.js",
17
+ "build:data": "node scripts/build.js generate-data -i \"icons/**/*.svg\" -o build/data.json -k keywords.json",
18
+ "build:react": "node scripts/build.js generate-icons -i build/data.json -o lib/react",
19
+ "build": "npm run build:optimize && npm run build:data && npm run build:react"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/donaldturinglee/base-ui-icons.git"
27
+ },
28
+ "keywords": [],
29
+ "author": "donaldturinglee <donaldturinglee@gmail.com>",
30
+ "license": "MIT",
31
+ "type": "commonjs",
32
+ "bugs": {
33
+ "url": "https://github.com/donaldturinglee/base-ui-icons/issues"
34
+ },
35
+ "homepage": "https://github.com/donaldturinglee/base-ui-icons#readme",
36
+ "dependencies": {
37
+ "@babel/generator": "^7.28.5",
38
+ "@babel/types": "^7.28.5",
39
+ "cheerio": "^1.1.2",
40
+ "clsx": "^2.1.1",
41
+ "fs-extra": "^11.3.2",
42
+ "globby": "^15.0.0",
43
+ "lodash.merge": "^4.6.2",
44
+ "svgo": "^4.0.0",
45
+ "svgson": "^5.3.1",
46
+ "tailwind-merge": "^3.6.0",
47
+ "trim-newlines": "^5.0.0",
48
+ "yargs": "^18.0.0"
49
+ }
50
+ }