@startupjs-ui/icon 0.1.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
7
+
8
+ **Note:** Version bump only for package @startupjs-ui/icon
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
20
+ * **icon:** refactor Icon component ([70237be](https://github.com/startupjs/startupjs-ui/commit/70237be3cd372154f1010def67735ef08db0c02a))
21
+ * **startupjs-ui:** move UiProvider and the main ui plugin into startupjs-ui package ([deeefaa](https://github.com/startupjs/startupjs-ui/commit/deeefaa8ca104efc835d1ff207d5450a83a5f484))
@@ -0,0 +1 @@
1
+ <svg height="512" viewBox="0 0 128 128" width="512" xmlns="http://www.w3.org/2000/svg"><path d="M86.616 36.13v76.355a9.209 9.209 0 01-9.209 9.209H35.243a9.209 9.209 0 01-9.209-9.209V36.13z" /><path d="M88.076 24.1c0-.053.008-.1.008-.157a8.515 8.515 0 00-8.293-8.721 8.071 8.071 0 00-5.953 2.657 12.3 12.3 0 00-22.818-5.6 8.342 8.342 0 00-7.863-5.964 8.515 8.515 0 00-8.293 8.721 9.281 9.281 0 00.073 1.1 7.935 7.935 0 00-1.733-.194 8.473 8.473 0 00-8.263 8.092 6.067 6.067 0 00-5.082 5.983v.051a6.07 6.07 0 006.07 6.07H48.95v29.285a3.4 3.4 0 003.4 3.4h2.184a3.4 3.4 0 003.4-3.4V53.574a3.4 3.4 0 013.4-3.4 3.4 3.4 0 003.4-3.4v-.849a3.4 3.4 0 013.4-3.4h1.275a3.4 3.4 0 013.4 3.4v5.736a3.4 3.4 0 003.4 3.4h.85a3.4 3.4 0 003.4-3.4V36.13h6.269a6.07 6.07 0 006.07-6.07v-.051a6.068 6.068 0 00-4.722-5.909z" fill="#ffde3e"/><path d="M86.616 87.483h13.418V52.517H86.616v-8.583h14.895a6.63 6.63 0 016.63 6.63v38.872a6.63 6.63 0 01-6.63 6.63H86.616z" fill="#f2e7cb"/><g fill="#422002"><path d="M26.034 90.954a1.75 1.75 0 001.75-1.75v-4.5a1.75 1.75 0 00-3.5 0v4.5a1.75 1.75 0 001.75 1.75zM36.537 106.382h24.725a1.75 1.75 0 000-3.5H36.537a1.75 1.75 0 000 3.5zM76.113 106.382a1.75 1.75 0 000-3.5h-6.639a1.75 1.75 0 100 3.5z"/><path d="M108.142 56.772a1.751 1.751 0 001.75-1.75v-4.458a8.39 8.39 0 00-8.381-8.38H88.366V37.7a7.851 7.851 0 006.175-7.693 7.769 7.769 0 00-4.765-7.2 10.222 10.222 0 00-9.985-9.343 9.639 9.639 0 00-4.736 1.236 14.079 14.079 0 00-13.5-10.144 13.93 13.93 0 00-10.216 4.4 9.9 9.9 0 00-8.185-4.4 10.237 10.237 0 00-10.011 9.627 10.2 10.2 0 00-9.787 8.442 7.85 7.85 0 00.928 15.075v38.349a1.75 1.75 0 003.5 0v-38.17H47.2v27.544a5.155 5.155 0 005.15 5.149h2.183a5.155 5.155 0 005.15-5.149V53.574a1.65 1.65 0 011.648-1.649 5.155 5.155 0 005.149-5.15v-.849a1.652 1.652 0 011.65-1.65h1.27a1.652 1.652 0 011.65 1.65v5.736a5.154 5.154 0 005.15 5.149h.85a5.154 5.154 0 005.15-5.149V37.879h2.664v74.606a7.466 7.466 0 01-7.459 7.458H35.242a7.466 7.466 0 01-7.458-7.458V97.442a1.75 1.75 0 00-3.5 0v15.043a10.971 10.971 0 0010.958 10.958h42.165a10.971 10.971 0 0010.959-10.958V97.816h13.145a8.39 8.39 0 008.381-8.38V62.7a1.75 1.75 0 00-3.5 0v26.736a4.887 4.887 0 01-4.881 4.88H88.366v-5.083h11.668a1.75 1.75 0 001.75-1.75V52.517a1.75 1.75 0 00-1.75-1.75H88.366v-5.083h13.145a4.887 4.887 0 014.881 4.88v4.458a1.75 1.75 0 001.75 1.75zm-27.69-22.393a1.75 1.75 0 00-1.75 1.75v15.533a1.651 1.651 0 01-1.649 1.649H76.2a1.651 1.651 0 01-1.649-1.649v-5.736a5.155 5.155 0 00-5.15-5.15H68.13a5.155 5.155 0 00-5.15 5.15v.849a1.651 1.651 0 01-1.649 1.65 5.154 5.154 0 00-5.148 5.149v11.849a1.651 1.651 0 01-1.65 1.649H52.35a1.651 1.651 0 01-1.65-1.649V36.129a1.75 1.75 0 00-1.75-1.75H25.929a4.344 4.344 0 01-.7-8.626 1.749 1.749 0 001.462-1.608 6.747 6.747 0 016.509-6.461 6.186 6.186 0 011.352.152 1.75 1.75 0 002.12-1.919 7.443 7.443 0 01-.061-.89 6.775 6.775 0 016.543-6.97 6.585 6.585 0 016.2 4.742 1.75 1.75 0 003.166.377 10.548 10.548 0 0119.573 4.8 1.751 1.751 0 003.034 1.081 6.3 6.3 0 014.666-2.093 6.765 6.765 0 016.541 6.936c0 .03-.007.134-.008.164a1.751 1.751 0 001.361 1.736 4.346 4.346 0 01-.966 8.577zm17.832 19.888v31.466h-9.918V54.267z"/><path d="M66.863 21.644a6.451 6.451 0 10-12.9 0 1.75 1.75 0 003.5 0 2.951 2.951 0 115.9 0 1.75 1.75 0 103.5 0zM43.343 20.159A7.048 7.048 0 0036.3 27.2a1.75 1.75 0 003.5 0 3.541 3.541 0 117.082 0 1.75 1.75 0 103.5 0 7.048 7.048 0 00-7.039-7.041zM72.137 24.513a6.339 6.339 0 00-6.331 6.332 1.75 1.75 0 003.5 0 2.832 2.832 0 115.663 0 1.75 1.75 0 003.5 0 6.34 6.34 0 00-6.332-6.332z"/></g></svg>
package/README.mdx ADDED
@@ -0,0 +1,138 @@
1
+ import { useState } from 'react'
2
+ import Icon, { _PropsJsonSchema as IconPropsJsonSchema } from './index'
3
+ import Div from '@startupjs-ui/div'
4
+ import Br from '@startupjs-ui/br'
5
+ import TextInput from '@startupjs-ui/text-input'
6
+ import {
7
+ faHouseUser,
8
+ faTable,
9
+ faShareAlt
10
+ } from '@fortawesome/free-solid-svg-icons'
11
+ import CustomIconExample from './CustomIconExample.svg'
12
+ import { Sandbox } from '@startupjs-ui/docs'
13
+ import './index.mdx.cssx.styl'
14
+
15
+ # Icon
16
+
17
+ Icons are visual symbols used to represent ideas, objects, or actions. They communicate messages at a glance, afford interactivity, and draw attention to important information.
18
+
19
+ ```jsx
20
+ import { Icon } from 'startupjs-ui'
21
+ ```
22
+
23
+ ## Simple example
24
+
25
+ Component uses `@fortawesome/react-native-fontawesome` library to implement icons.
26
+
27
+ ```jsx
28
+ import { faHouseUser } from '@fortawesome/free-solid-svg-icons'
29
+ ```
30
+
31
+ ```jsx example
32
+ return (
33
+ <Icon icon={faHouseUser} />
34
+ )
35
+ ```
36
+
37
+ ## Custom Icon
38
+
39
+ To use your custom icon you must provide a valid `svg` icon to `icon` property
40
+
41
+ ```jsx
42
+ import CustomIconExample from './CustomIconExample.svg'
43
+ ```
44
+
45
+ ```jsx example
46
+ return (
47
+ <Icon
48
+ size={50}
49
+ styleName='icon orange'
50
+ icon={CustomIconExample}
51
+ />
52
+ )
53
+ ```
54
+
55
+ ## Sizes
56
+
57
+ Size can be modified using the `size` prop. Default value is `m`. Pre defined icon size values are `xs`, `s`, `m`, `l`, `xl`, `xxl`. Size can also be arbitarily increased or decreased by providing a number to `size` prop. For a custom icon, you can set a different size of width and height using styles.
58
+
59
+ ```jsx
60
+ import {
61
+ faHouseUser,
62
+ faTable,
63
+ faShareAlt
64
+ } from '@fortawesome/free-solid-svg-icons'
65
+ import CustomIconExample from './CustomIconExample.svg'
66
+ ```
67
+
68
+ ```jsx example
69
+ const [numSize, setNumSize] = useState('80')
70
+ return (
71
+ <>
72
+ <Div row align='around'>
73
+ <Icon size='xs' icon={faShareAlt} />
74
+ <Icon size='s' icon={faHouseUser} />
75
+ <Icon icon={faTable} />
76
+ <Icon size='l' icon={faShareAlt} />
77
+ <Icon size='xl' icon={faHouseUser} />
78
+ <Icon size='xxl' icon={faTable} />
79
+ <Icon style={{ width: 40, height: 32 }} icon={CustomIconExample} />
80
+ </Div>
81
+ <Br />
82
+ <TextInput
83
+ label='Type in number to change icon size'
84
+ value={numSize}
85
+ onChangeText={value => setNumSize(value)}
86
+ />
87
+ <Br />
88
+ <Icon size={+numSize} icon={faTable} />
89
+ </>
90
+ )
91
+ ```
92
+
93
+ ## Colors
94
+
95
+ Color can be set by specifying the `color` in StyleSheet.
96
+
97
+ In `.styl` file
98
+ ```stylus
99
+ .icon
100
+ &.primary
101
+ color var(--color-text-primary)
102
+
103
+ &.success
104
+ color var(--color-text-success)
105
+
106
+ &.orange
107
+ color var(--color-text-attention)
108
+ ```
109
+
110
+ ```jsx
111
+ import {
112
+ faHouseUser,
113
+ faTable,
114
+ faShareAlt
115
+ } from '@fortawesome/free-solid-svg-icons'
116
+ ```
117
+
118
+ ```jsx example
119
+ return (
120
+ <Div row align='around'>
121
+ <Icon icon={faShareAlt} styleName='icon orange'/>
122
+ <Icon icon={faHouseUser} styleName='icon primary'/>
123
+ <Icon icon={faTable} styleName='icon success'/>
124
+ </Div>
125
+ )
126
+ ```
127
+
128
+ ## Sandbox
129
+
130
+ <Sandbox
131
+ Component={Icon}
132
+ propsJsonSchema={IconPropsJsonSchema}
133
+ extraParams={{
134
+ icon: {
135
+ showIconSelect: true
136
+ }
137
+ }}
138
+ />
@@ -0,0 +1,5 @@
1
+ export const customIcons: Record<string, any> = {}
2
+
3
+ export function setCustomIcons (newCustomIcons: Record<string, any> = {}) {
4
+ Object.assign(customIcons, newCustomIcons)
5
+ }
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /* eslint-disable */
2
+ // DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
3
+
4
+ declare const _default: import("react").ComponentType<IconProps>;
5
+ export default _default;
6
+ export declare const _PropsJsonSchema: {};
7
+ export interface IconProps {
8
+ /** Custom styles applied to the icon */
9
+ style?: any;
10
+ /** Icon definition from FontAwesome, custom component or registered name */
11
+ icon: object | string | (() => any);
12
+ /** Icon size preset or numeric value @default 'm' */
13
+ size?: 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | number;
14
+ }
@@ -0,0 +1,9 @@
1
+ .icon
2
+ &.primary
3
+ color var(--color-text-primary)
4
+
5
+ &.success
6
+ color var(--color-text-success)
7
+
8
+ &.orange
9
+ color var(--color-text-attention)
package/index.tsx ADDED
@@ -0,0 +1,82 @@
1
+ import { type ReactNode } from 'react'
2
+ import { StyleSheet, Platform } from 'react-native'
3
+ import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
4
+ import { pug, observer, u } from 'startupjs'
5
+ import { Colors, themed, useColors } from '@startupjs-ui/core'
6
+ import { customIcons } from './globalCustomIcons'
7
+
8
+ const SIZES = {
9
+ xs: u(1),
10
+ s: u(1.5),
11
+ m: u(2),
12
+ l: u(2.5),
13
+ xl: u(3),
14
+ xxl: u(3.5)
15
+ }
16
+
17
+ export default observer(themed('Icon', Icon))
18
+
19
+ export const _PropsJsonSchema = {/* IconProps */}
20
+
21
+ export interface IconProps {
22
+ /** Custom styles applied to the icon */
23
+ style?: any
24
+ /** Icon definition from FontAwesome, custom component or registered name */
25
+ icon: object | string | (() => any)
26
+ /** Icon size preset or numeric value @default 'm' */
27
+ size?: 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | number
28
+ }
29
+
30
+ function Icon ({
31
+ style,
32
+ icon,
33
+ size = 'm',
34
+ ...props
35
+ }: IconProps): ReactNode {
36
+ const getColor = useColors()
37
+ const _size = typeof size === 'string' ? SIZES[size] : size
38
+
39
+ if (!icon) return null
40
+
41
+ let CustomIcon
42
+
43
+ style = StyleSheet.flatten([{ color: getColor(Colors['text-secondary']) }, style])
44
+
45
+ if (typeof icon === 'function') {
46
+ CustomIcon = icon
47
+ } else if (typeof icon === 'string') {
48
+ CustomIcon = customIcons[icon]
49
+ }
50
+
51
+ if (CustomIcon) {
52
+ const { color: fill, width = _size, height = _size, ...iconStyle } = style
53
+ return pug`
54
+ CustomIcon(
55
+ style=iconStyle
56
+ width=width
57
+ height=height
58
+ fill=fill
59
+ )
60
+ `
61
+ }
62
+
63
+ if (Platform.OS === 'web') {
64
+ style.width ??= _size
65
+ style.height ??= _size
66
+ style.outline ??= 'none'
67
+ return pug`
68
+ FontAwesomeIcon(
69
+ style=style
70
+ icon=icon
71
+ )
72
+ `
73
+ }
74
+
75
+ return pug`
76
+ FontAwesomeIcon(
77
+ style=style
78
+ icon=icon
79
+ size=_size
80
+ )
81
+ `
82
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@startupjs-ui/icon",
3
+ "version": "0.1.3",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "index.tsx",
8
+ "types": "index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./index.tsx",
12
+ "./globalCustomIcons": "./globalCustomIcons.ts"
13
+ },
14
+ "dependencies": {
15
+ "@fortawesome/fontawesome-svg-core": "^1.2.26",
16
+ "@fortawesome/free-solid-svg-icons": "^5.12.0",
17
+ "@fortawesome/react-native-fontawesome": "^0.3.0",
18
+ "@startupjs-ui/core": "^0.1.3"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "*",
22
+ "react-native": "*",
23
+ "startupjs": "*"
24
+ },
25
+ "gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
26
+ }