File tree Expand file tree Collapse file tree 9 files changed +207
-0
lines changed Expand file tree Collapse file tree 9 files changed +207
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Logs
2
+ logs
3
+ * .log
4
+ npm-debug.log *
5
+ yarn-debug.log *
6
+ yarn-error.log *
7
+ lerna-debug.log *
8
+
9
+ # Diagnostic reports (https://nodejs.org/api/report.html)
10
+ report. [0-9 ]* . [0-9 ]* . [0-9 ]* . [0-9 ]* .json
11
+
12
+ # Runtime data
13
+ pids
14
+ * .pid
15
+ * .seed
16
+ * .pid.lock
17
+
18
+ # Directory for instrumented libs generated by jscoverage/JSCover
19
+ lib-cov
20
+
21
+ # Coverage directory used by tools like istanbul
22
+ coverage
23
+ * .lcov
24
+
25
+ # nyc test coverage
26
+ .nyc_output
27
+
28
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
+ .grunt
30
+
31
+ # Bower dependency directory (https://bower.io/)
32
+ bower_components
33
+
34
+ # node-waf configuration
35
+ .lock-wscript
36
+
37
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
38
+ build /Release
39
+
40
+ # Dependency directories
41
+ node_modules /
42
+ jspm_packages /
43
+
44
+ # Snowpack dependency directory (https://snowpack.dev/)
45
+ web_modules /
46
+
47
+ # TypeScript cache
48
+ * .tsbuildinfo
49
+
50
+ # Optional npm cache directory
51
+ .npm
52
+
53
+ # Optional eslint cache
54
+ .eslintcache
55
+
56
+ # Microbundle cache
57
+ .rpt2_cache /
58
+ .rts2_cache_cjs /
59
+ .rts2_cache_es /
60
+ .rts2_cache_umd /
61
+
62
+ # Optional REPL history
63
+ .node_repl_history
64
+
65
+ # Output of 'npm pack'
66
+ * .tgz
67
+
68
+ # Yarn Integrity file
69
+ .yarn-integrity
70
+
71
+ # dotenv environment variables file
72
+ .env
73
+ .env.test
74
+
75
+ # parcel-bundler cache (https://parceljs.org/)
76
+ .cache
77
+ .parcel-cache
78
+
79
+ # Next.js build output
80
+ .next
81
+ out
82
+
83
+ # Nuxt.js build / generate output
84
+ .nuxt
85
+ dist
86
+
87
+ # Gatsby files
88
+ .cache /
89
+ # Comment in the public line in if your project uses Gatsby and not Next.js
90
+ # https://nextjs.org/blog/next-9-1#public-directory-support
91
+ # public
92
+
93
+ # vuepress build output
94
+ .vuepress /dist
95
+
96
+ # Serverless directories
97
+ .serverless /
98
+
99
+ # FuseBox cache
100
+ .fusebox /
101
+
102
+ # DynamoDB Local files
103
+ .dynamodb /
104
+
105
+ # TernJS port file
106
+ .tern-port
107
+
108
+ # Stores VSCode versions used for testing VSCode extensions
109
+ .vscode-test
110
+
111
+ # yarn v2
112
+ .yarn /cache
113
+ .yarn /unplugged
114
+ .yarn /build-state.yml
115
+ .yarn /install-state.gz
116
+ .pnp. *
117
+
118
+ # Misc
119
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ ## micro ui-related utilities package.
2
+
3
+ Zero dependency, mostly use with numbers, and basic types.
4
+
5
+ > this pakcage is for performing basic and primal ui-related calculations.
Original file line number Diff line number Diff line change
1
+ interface RGB {
2
+ r : number
3
+ g : number
4
+ b : number
5
+ }
6
+
7
+ interface RGBA {
8
+ r : number
9
+ g : number
10
+ b : number
11
+ a : number
12
+ }
13
+
14
+
15
+ // from https://dev.to/alvaromontoro/building-your-own-color-contrast-checker-4j7o
16
+ export function calculateContrastRatio ( color1 : RGB , color2 : RGB ) {
17
+ const color1luminance = luminance ( color1 ) ;
18
+ const color2luminance = luminance ( color2 ) ;
19
+
20
+ const contrast =
21
+ color1luminance > color2luminance
22
+ ? ( color2luminance + 0.05 ) / ( color1luminance + 0.05 )
23
+ : ( color1luminance + 0.05 ) / ( color2luminance + 0.05 ) ;
24
+
25
+ return 1 / contrast ;
26
+ }
27
+
28
+ export function luminance ( color : RGB ) {
29
+ const a = [ color . r * 255 , color . g * 255 , color . b * 255 ] . map ( function ( v ) {
30
+ v /= 255 ;
31
+ return v <= 0.03928 ? v / 12.92 : Math . pow ( ( v + 0.055 ) / 1.055 , 2.4 ) ;
32
+ } ) ;
33
+ return a [ 0 ] * 0.2126 + a [ 1 ] * 0.7152 + a [ 2 ] * 0.0722 ;
34
+ }
Original file line number Diff line number Diff line change
1
+ export * from "./pixels"
2
+ export * from "./colors"
Original file line number Diff line number Diff line change
1
+ import { roundNumber } from "./normalize-pixel" ;
2
+
3
+ export {
4
+ roundNumber
5
+ }
Original file line number Diff line number Diff line change
1
+ // normalizing value to rounded. I.E 4.999999523162842. to 5
2
+ export function roundNumber ( num : number ) : number {
3
+ if ( num === 0 ) { return 0 }
4
+ if ( num ) {
5
+ return + num . toFixed ( 2 )
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " @reflect.bridged.xyz/uiutils" ,
3
+ "version" : " 0.0.1" ,
4
+ "scripts" : {},
5
+ "devDependencies" : {
6
+ "typescript" : " ^4.0.5"
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "target" : " es2016" ,
4
+ "module" : " commonjs" ,
5
+ "lib" : [
6
+ " es2017" ,
7
+ " es7" ,
8
+ " es6" ,
9
+ " dom"
10
+ ],
11
+ "declaration" : true ,
12
+ "outDir" : " dist" ,
13
+ "esModuleInterop" : true ,
14
+ "sourceMap" : true ,
15
+ "experimentalDecorators" : true ,
16
+ "noUnusedLocals" : false ,
17
+ "typeRoots" : [
18
+ " ./node_modules/@types" ,
19
+ ]
20
+ },
21
+ "exclude" : [
22
+ " node_modules" ,
23
+ " dist" ,
24
+ " example" ,
25
+ " docs"
26
+ ]
27
+ }
You can’t perform that action at this time.
0 commit comments