@datadayrepos/icons 0.0.1-beta.20 → 0.0.1-beta.22

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.
Files changed (2) hide show
  1. package/README.md +129 -31
  2. package/package.json +14 -4
package/README.md CHANGED
@@ -1,39 +1,73 @@
1
- # Minimal icon library
1
+ # Flexible vue icon library
2
+ The primary purpose is to support both dynamic and static import syntaxes for consumers of datadayrepos - and to provide a consistent base icon library.
2
3
 
3
- ```bash
4
- pnpm i
4
+ We also encopurage use of icon imports through the vite tooling system and 'unplugins' - but those will not resolve dynamic (variable based) imports which are sometimes usefull and the original rationale for this library.
5
5
 
6
+ Especially supporting dynamic async imports turned out to be quite difficult with existing libraries.
6
7
 
7
- ```
8
+ Library is designed for vuejs apps. It requires Vite and rollup to get the build to run correctly.
8
9
 
10
+ Typed.
9
11
 
12
+ ## Import in new project
13
+ This will add the latest version of the package to your project's package.json and install it in the node_modules directory.
10
14
  ```bash
11
- # this creates vue fiels from the svg fiels. the vue dir is not commtted to git.
12
- pnpm build-icons
15
+ pnpm add @datadayrepos/icons@latest
16
+ # or
17
+ npm i @datadayrepos/icons@latest
13
18
  ```
14
- ## Ways to call
15
- ### standard
16
- import {IconCaretUp} from '@datadayrepos/icons'
17
- import IconClose from '@datadayrepos/icons/IconClose'
18
19
 
19
- ### dynamic
20
- import {iconResolver}from '../iconresolver'
21
- const Whatever=iconResolver("IconClose")
20
+ ## Usage
22
21
 
23
- ---
24
- import { defineAsyncComponent } from 'vue'
22
+ All imports are tree shakeable. The imported icon is a vue component.
23
+ Different syntaxes are supported:
25
24
 
26
- type ComponentLoader = Record<string, ReturnType<typeof defineAsyncComponent>>;
25
+ ### Standard
26
+ ```ts
27
+ // Standard - imports mapped against index file and type file.
28
+ import { IconCaretUp } from '@datadayrepos/icons'
29
+ ```
30
+
31
+ ```ts
32
+ // Standard direct - imports mapped against individual file and type - maps into long list in package.json file
33
+ import IconClose from '@datadayrepos/icons/IconClose'
34
+ ```
27
35
 
28
- const componentMap:ComponentLoader = {
36
+ ### Dynamic
37
+ This supports async imports by variable names.
38
+ Requires building a dedicated function to map a list of icon imports against variable keys.
39
+ ```ts
40
+ // iconresolver.ts
41
+ import { defineAsyncComponent } from 'vue'
42
+
43
+ type ComponentLoader = Record<string, ReturnType<typeof defineAsyncComponent>>
44
+
45
+ const componentMap: ComponentLoader = {
29
46
  IconClose: defineAsyncComponent(() => import('@datadayrepos/icons/IconClose')),
30
47
 
31
- };
48
+ }
32
49
 
33
50
  export function iconResolver(iconName: string) {
34
- return componentMap[iconName] ? componentMap[iconName] : null;
35
-
51
+ return componentMap[iconName] ? componentMap[iconName] : null
36
52
  }
53
+ ```
54
+
55
+ ```ts
56
+ // usage.ts
57
+ import { iconResolver } from '../iconresolver'
58
+
59
+ const Whatever = iconResolver('IconClose')
60
+ ```
61
+
62
+ ## Web view
63
+ There is a web html file inside "view". This can be launched in vscode directly to view all icons.
64
+ For example, right click on file, 'launch web server'
65
+
66
+ The file gives:
67
+ - visual representation of the icon
68
+ - name
69
+ - import syntax copy buttons
70
+ - copy the svg content
37
71
 
38
72
  ## Package structure
39
73
  dist/
@@ -47,21 +81,85 @@ dist/
47
81
  index.js
48
82
  index.d.ts
49
83
 
50
- ## Drafts
84
+ ## Dev and Build
85
+ There are some principles here:
86
+ - All source icons are as svg files in src/svg
87
+ - All src/vue files are autogenerated - editing is futile
88
+ - Package.json export list is autogenerated - editing is futile
89
+ - Changing an icon name is a breaking change
90
+ - Naming nomeclature:
91
+ - Descritive littral naming
92
+ - To separatefrom other components in alarge project:
93
+ - All names have first charater capitilized
94
+ - All names are CamelCase
95
+ - All names end with 'Icon'
96
+
97
+ ### Tooling helpers
98
+ There are several dev tools here.
99
+
100
+ Build:
101
+ - Dynamically creates vue files from the svg files
102
+ - Builds index.ts file
103
+ - Updates package json
104
+ - Builds dist package including types
51
105
 
52
- footnoteIcon
53
- positionIcon
54
- visibilityIcon
55
- closeIcon
56
- cancelIcon
106
+ ```bash
107
+ pnpm build
108
+ # this creates vue files from the svg files. the vue dir is not commtted to git.
109
+ pnpm build-icons
110
+ ```
57
111
 
58
- equallarger
59
- equalless
60
- multiple
61
- largerthan
62
- lessthan
112
+ Dups:
113
+ - Checks src/svg folder for duplicate svg files.
114
+ - Dups are simply console logged for manual check and delete
63
115
 
116
+ ```bash
117
+ pnpm dedupeSvg
118
+ ```
119
+
120
+ Webview:
121
+ - updates webview page based on any edits in src/svg folder
122
+
123
+ ```bash
124
+ pnpm createView
125
+ ```
126
+
127
+ Import vue files:
128
+ New named vue file in template sntax containing a svg can be imported in batch.
129
+ - Put filed in folder dev/single
130
+ - run pnpm convertVueSvg
131
+ - this fixes the syntax to a clean svg and saves file with same original filename in src/svg
132
+ - If there is a conflict with existing filename the import is ignored and console.logged
133
+ - IMPORTANT: Destructive operation. All successfully imported file are deleted from dev/single
134
+
135
+ ```bash
136
+ pnpm convertVueSvg
137
+ ```
138
+
139
+ Rename folders:
140
+ For use when adding 'named' folders.
141
+ - Checks ad changes first character to CSP
142
+ - Checks and sets last word to 'Icon'
143
+ - IMPORTANT: Will change folder names in dev/folder
144
+
145
+ ```bash
146
+ pnpm renameFolders
147
+ ```
148
+
149
+ Import folder system
150
+ Helper to import icons in folder systems.
151
+ - Takes all folders in dev/folders
152
+ - Assumes foldername is new icon name
153
+ - Finds 'index.vue' file, and creates svg file named as the folder
154
+ - IMPORTANT: Deletes successfull imports. Ignores name folders that result in a name conflict.
155
+
156
+ ```bash
157
+ pnpm folderToSvg
158
+ ```
64
159
 
160
+ ## TODOs
161
+ - small script for naming rules when importing files directly
162
+ -
65
163
 
66
164
 
67
165
 
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@datadayrepos/icons",
3
3
  "type": "module",
4
- "version": "0.0.1-beta.20",
4
+ "version": "0.0.1-beta.22",
5
5
  "private": false,
6
- "license": "Proprietary",
6
+ "packageManager": "pnpm@8.9.0",
7
+ "description": "Uix icon library",
8
+ "author": "datadayrepos",
9
+ "license": "Apache 2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/datadayrepos/dataday-icons.git"
13
+ },
7
14
  "exports": {
8
15
  ".": {
9
16
  "module": "./dist/index.js",
@@ -718,6 +725,9 @@
718
725
  "types": "./dist/ZoomInIcon/index.vue.d.ts"
719
726
  }
720
727
  },
728
+ "main": "./dist/index.js",
729
+ "module": "./dist/index.js",
730
+ "types": "./dist/index.d.ts",
721
731
  "files": [
722
732
  "dist"
723
733
  ],
@@ -732,7 +742,7 @@
732
742
  "typecheckVue": "vue-tsc --noEmit",
733
743
  "typeBuildVue": "vue-tsc --declaration --emitDeclarationOnly",
734
744
  "pub": "npm publish --access public",
735
- "convertVyeSvg": "node dev-vuetosvg.cjs",
745
+ "convertVueSvg": "node dev-vuetosvg.cjs",
736
746
  "renameFolders": "node dev-renamefolder.cjs",
737
747
  "folderToSvg": "node dev-foldertosvg.cjs",
738
748
  "createView": "node dev-createView.cjs",
@@ -771,4 +781,4 @@
771
781
  "eslint --cache --fix"
772
782
  ]
773
783
  }
774
- }
784
+ }