podo-ui 0.1.31 → 0.1.32
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/package.json +9 -1
- package/readme.md +22 -0
- package/scss/icon/function.scss +2 -1
- package/scss/layout/bg-elevation.scss +2 -1
- package/scss/layout/border.scss +3 -1
- package/scss/layout/radius.scss +3 -1
- package/scss/layout/spacing.scss +3 -1
- package/vite-plugin.d.ts +19 -0
- package/vite-plugin.js +130 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podo-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "hada0127 <work@tarucy.net>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"url": "https://github.com/hada0127/podo-ui/issues"
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://github.com/hada0127/podo-ui#readme",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./index.html",
|
|
17
|
+
"./global.scss": "./global.scss",
|
|
18
|
+
"./mixin.scss": "./mixin.scss",
|
|
19
|
+
"./system.scss": "./system.scss",
|
|
20
|
+
"./react": "./react.ts",
|
|
21
|
+
"./vite-plugin": "./vite-plugin.js"
|
|
22
|
+
},
|
|
15
23
|
"scripts": {
|
|
16
24
|
"dev": "next dev",
|
|
17
25
|
"build": "next build",
|
package/readme.md
CHANGED
|
@@ -38,6 +38,28 @@ import 'podo-ui/global.scss';
|
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
### 3. Vite 프로젝트 설정 (필수)
|
|
42
|
+
|
|
43
|
+
⚠️ **Vite를 사용하는 경우 플러그인 설치가 필요합니다!**
|
|
44
|
+
|
|
45
|
+
Vite에서 아이콘 폰트가 올바르게 로드되도록 플러그인을 추가해야 합니다:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
// vite.config.js
|
|
49
|
+
import { defineConfig } from 'vite';
|
|
50
|
+
import react from '@vitejs/plugin-react';
|
|
51
|
+
import { podoUiVitePlugin } from 'podo-ui/vite-plugin';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
plugins: [
|
|
55
|
+
react(),
|
|
56
|
+
podoUiVitePlugin() // podo-ui 플러그인 추가
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Next.js나 CRA 등 다른 번들러는 플러그인 없이 사용 가능합니다.**
|
|
62
|
+
|
|
41
63
|
---
|
|
42
64
|
|
|
43
65
|
## 컴포넌트
|
package/scss/icon/function.scss
CHANGED
package/scss/layout/border.scss
CHANGED
package/scss/layout/radius.scss
CHANGED
package/scss/layout/spacing.scss
CHANGED
package/vite-plugin.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin for podo-ui icon fonts
|
|
5
|
+
* Resolves icon font path issues in Vite projects
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```js
|
|
9
|
+
* // vite.config.js
|
|
10
|
+
* import { podoUiVitePlugin } from 'podo-ui/vite-plugin';
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* plugins: [podoUiVitePlugin()]
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function podoUiVitePlugin(): Plugin;
|
|
18
|
+
|
|
19
|
+
export default podoUiVitePlugin;
|
package/vite-plugin.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Vite plugin for podo-ui icon fonts
|
|
10
|
+
* Resolves icon font path issues in Vite projects
|
|
11
|
+
*/
|
|
12
|
+
export function podoUiVitePlugin() {
|
|
13
|
+
let config;
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
name: 'vite-plugin-podo-ui',
|
|
17
|
+
|
|
18
|
+
configResolved(resolvedConfig) {
|
|
19
|
+
config = resolvedConfig;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// Load hook to handle the font file
|
|
23
|
+
load(id) {
|
|
24
|
+
// Check if it's requesting the icon font
|
|
25
|
+
if (id.includes('podo-ui/scss/icon/font/icon.woff')) {
|
|
26
|
+
const fontPath = join(__dirname, 'scss/icon/font/icon.woff');
|
|
27
|
+
try {
|
|
28
|
+
const buffer = readFileSync(fontPath);
|
|
29
|
+
return buffer;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.warn('[podo-ui] Failed to load icon font:', error.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// Transform hook to fix font URLs in SCSS/CSS
|
|
37
|
+
transform(code, id) {
|
|
38
|
+
// Only process SCSS/CSS files from podo-ui
|
|
39
|
+
if (!id.includes('podo-ui') || !id.match(/\.(scss|css)$/)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let transformedCode = code;
|
|
44
|
+
let hasChanges = false;
|
|
45
|
+
|
|
46
|
+
// Fix relative font paths in icon.scss
|
|
47
|
+
if (id.includes('icon/icon.scss')) {
|
|
48
|
+
const fontPath = join(__dirname, 'scss/icon/font/icon.woff');
|
|
49
|
+
transformedCode = transformedCode.replace(
|
|
50
|
+
/url\(['"]?\.\/font\/icon\.woff['"]?\)/g,
|
|
51
|
+
() => {
|
|
52
|
+
hasChanges = true;
|
|
53
|
+
return `url('${fontPath}')`;
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Fix relative font paths in font-family.scss (Pretendard fonts)
|
|
59
|
+
if (id.includes('typo/font-family.scss')) {
|
|
60
|
+
const fontFiles = [
|
|
61
|
+
'Pretendard-Black.woff2',
|
|
62
|
+
'Pretendard-ExtraBold.woff2',
|
|
63
|
+
'Pretendard-Bold.woff2',
|
|
64
|
+
'Pretendard-SemiBold.woff2',
|
|
65
|
+
'Pretendard-Medium.woff2',
|
|
66
|
+
'Pretendard-Regular.woff2',
|
|
67
|
+
'Pretendard-Light.woff2',
|
|
68
|
+
'Pretendard-ExtraLight.woff2',
|
|
69
|
+
'Pretendard-Thin.woff2'
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
fontFiles.forEach(fontFile => {
|
|
73
|
+
const fontPath = join(__dirname, `scss/typo/font/${fontFile}`);
|
|
74
|
+
const regex = new RegExp(`url\\(['"]?\\.\/font\/${fontFile}['"]?\\)`, 'g');
|
|
75
|
+
transformedCode = transformedCode.replace(regex, () => {
|
|
76
|
+
hasChanges = true;
|
|
77
|
+
return `url('${fontPath}')`;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (hasChanges) {
|
|
83
|
+
return {
|
|
84
|
+
code: transformedCode,
|
|
85
|
+
map: null
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// Serve the font files in dev mode
|
|
93
|
+
configureServer(server) {
|
|
94
|
+
server.middlewares.use((req, res, next) => {
|
|
95
|
+
// Serve icon font
|
|
96
|
+
if (req.url?.includes('/podo-ui-icon.woff')) {
|
|
97
|
+
const fontPath = join(__dirname, 'scss/icon/font/icon.woff');
|
|
98
|
+
try {
|
|
99
|
+
const buffer = readFileSync(fontPath);
|
|
100
|
+
res.setHeader('Content-Type', 'font/woff');
|
|
101
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
102
|
+
res.end(buffer);
|
|
103
|
+
return;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn('[podo-ui] Failed to serve icon font:', error.message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Serve Pretendard fonts
|
|
110
|
+
if (req.url?.includes('/Pretendard-') && req.url?.includes('.woff2')) {
|
|
111
|
+
const fontFileName = req.url.split('/').pop();
|
|
112
|
+
const fontPath = join(__dirname, 'scss/typo/font', fontFileName);
|
|
113
|
+
try {
|
|
114
|
+
const buffer = readFileSync(fontPath);
|
|
115
|
+
res.setHeader('Content-Type', 'font/woff2');
|
|
116
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
117
|
+
res.end(buffer);
|
|
118
|
+
return;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.warn('[podo-ui] Failed to serve Pretendard font:', error.message);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
next();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default podoUiVitePlugin;
|