@idds/react 1.1.86
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/README.md +429 -0
- package/dist/index.cjs.js +20 -0
- package/dist/index.css +1 -0
- package/dist/index.es.js +9682 -0
- package/dist/index.umd.js +20 -0
- package/dist/types/App.d.ts +3 -0
- package/dist/types/App.d.ts.map +1 -0
- package/dist/types/components/Accordion.d.ts +48 -0
- package/dist/types/components/Accordion.d.ts.map +1 -0
- package/dist/types/components/AccordionCard.d.ts +22 -0
- package/dist/types/components/AccordionCard.d.ts.map +1 -0
- package/dist/types/components/AccordionGroup.d.ts +45 -0
- package/dist/types/components/AccordionGroup.d.ts.map +1 -0
- package/dist/types/components/ActionDropdown.d.ts +21 -0
- package/dist/types/components/ActionDropdown.d.ts.map +1 -0
- package/dist/types/components/Alert.d.ts +55 -0
- package/dist/types/components/Alert.d.ts.map +1 -0
- package/dist/types/components/Avatar.d.ts +33 -0
- package/dist/types/components/Avatar.d.ts.map +1 -0
- package/dist/types/components/Badge.d.ts +61 -0
- package/dist/types/components/Badge.d.ts.map +1 -0
- package/dist/types/components/BottomSheet.d.ts +9 -0
- package/dist/types/components/BottomSheet.d.ts.map +1 -0
- package/dist/types/components/Breadcrumb.d.ts +25 -0
- package/dist/types/components/Breadcrumb.d.ts.map +1 -0
- package/dist/types/components/Button.d.ts +68 -0
- package/dist/types/components/Button.d.ts.map +1 -0
- package/dist/types/components/ButtonGroup.d.ts +27 -0
- package/dist/types/components/ButtonGroup.d.ts.map +1 -0
- package/dist/types/components/Card.d.ts +94 -0
- package/dist/types/components/Card.d.ts.map +1 -0
- package/dist/types/components/Checkbox.d.ts +33 -0
- package/dist/types/components/Checkbox.d.ts.map +1 -0
- package/dist/types/components/Chip.d.ts +36 -0
- package/dist/types/components/Chip.d.ts.map +1 -0
- package/dist/types/components/Collapse.d.ts +16 -0
- package/dist/types/components/Collapse.d.ts.map +1 -0
- package/dist/types/components/DatePicker.d.ts +39 -0
- package/dist/types/components/DatePicker.d.ts.map +1 -0
- package/dist/types/components/Divider.d.ts +42 -0
- package/dist/types/components/Divider.d.ts.map +1 -0
- package/dist/types/components/Drawer.d.ts +35 -0
- package/dist/types/components/Drawer.d.ts.map +1 -0
- package/dist/types/components/Dropdown.d.ts +24 -0
- package/dist/types/components/Dropdown.d.ts.map +1 -0
- package/dist/types/components/FieldInputTable.d.ts +33 -0
- package/dist/types/components/FieldInputTable.d.ts.map +1 -0
- package/dist/types/components/FileUpload.d.ts +86 -0
- package/dist/types/components/FileUpload.d.ts.map +1 -0
- package/dist/types/components/InputSearch.d.ts +14 -0
- package/dist/types/components/InputSearch.d.ts.map +1 -0
- package/dist/types/components/LinearProgressIndicator.d.ts +16 -0
- package/dist/types/components/LinearProgressIndicator.d.ts.map +1 -0
- package/dist/types/components/List/List.d.ts +17 -0
- package/dist/types/components/List/List.d.ts.map +1 -0
- package/dist/types/components/List/ListItem.d.ts +19 -0
- package/dist/types/components/List/ListItem.d.ts.map +1 -0
- package/dist/types/components/List/ListItemAvatar.d.ts +15 -0
- package/dist/types/components/List/ListItemAvatar.d.ts.map +1 -0
- package/dist/types/components/List/ListItemButton.d.ts +12 -0
- package/dist/types/components/List/ListItemButton.d.ts.map +1 -0
- package/dist/types/components/List/ListItemIcon.d.ts +12 -0
- package/dist/types/components/List/ListItemIcon.d.ts.map +1 -0
- package/dist/types/components/List/ListItemText.d.ts +14 -0
- package/dist/types/components/List/ListItemText.d.ts.map +1 -0
- package/dist/types/components/List/ListSubheader.d.ts +16 -0
- package/dist/types/components/List/ListSubheader.d.ts.map +1 -0
- package/dist/types/components/Modal.d.ts +13 -0
- package/dist/types/components/Modal.d.ts.map +1 -0
- package/dist/types/components/MonthPicker.d.ts +39 -0
- package/dist/types/components/MonthPicker.d.ts.map +1 -0
- package/dist/types/components/MultipleChoiceGrid.d.ts +32 -0
- package/dist/types/components/MultipleChoiceGrid.d.ts.map +1 -0
- package/dist/types/components/Pagination.d.ts +58 -0
- package/dist/types/components/Pagination.d.ts.map +1 -0
- package/dist/types/components/PasswordInput.d.ts +75 -0
- package/dist/types/components/PasswordInput.d.ts.map +1 -0
- package/dist/types/components/PhoneInput.d.ts +19 -0
- package/dist/types/components/PhoneInput.d.ts.map +1 -0
- package/dist/types/components/ProgressBar.d.ts +32 -0
- package/dist/types/components/ProgressBar.d.ts.map +1 -0
- package/dist/types/components/RadioInput.d.ts +27 -0
- package/dist/types/components/RadioInput.d.ts.map +1 -0
- package/dist/types/components/SelectDropdown.d.ts +81 -0
- package/dist/types/components/SelectDropdown.d.ts.map +1 -0
- package/dist/types/components/Skeleton.d.ts +20 -0
- package/dist/types/components/Skeleton.d.ts.map +1 -0
- package/dist/types/components/Spinner.d.ts +22 -0
- package/dist/types/components/Spinner.d.ts.map +1 -0
- package/dist/types/components/Stepper.d.ts +25 -0
- package/dist/types/components/Stepper.d.ts.map +1 -0
- package/dist/types/components/TabHorizontal.d.ts +34 -0
- package/dist/types/components/TabHorizontal.d.ts.map +1 -0
- package/dist/types/components/TabVertical.d.ts +34 -0
- package/dist/types/components/TabVertical.d.ts.map +1 -0
- package/dist/types/components/Table.d.ts +69 -0
- package/dist/types/components/Table.d.ts.map +1 -0
- package/dist/types/components/TableProgressBar.d.ts +20 -0
- package/dist/types/components/TableProgressBar.d.ts.map +1 -0
- package/dist/types/components/TextArea.d.ts +57 -0
- package/dist/types/components/TextArea.d.ts.map +1 -0
- package/dist/types/components/TextField.d.ts +61 -0
- package/dist/types/components/TextField.d.ts.map +1 -0
- package/dist/types/components/ThemeToggle.d.ts +7 -0
- package/dist/types/components/ThemeToggle.d.ts.map +1 -0
- package/dist/types/components/TimePicker.d.ts +56 -0
- package/dist/types/components/TimePicker.d.ts.map +1 -0
- package/dist/types/components/Toast.d.ts +15 -0
- package/dist/types/components/Toast.d.ts.map +1 -0
- package/dist/types/components/Toggle.d.ts +26 -0
- package/dist/types/components/Toggle.d.ts.map +1 -0
- package/dist/types/components/Tooltip.d.ts +85 -0
- package/dist/types/components/Tooltip.d.ts.map +1 -0
- package/dist/types/components/YearPicker.d.ts +43 -0
- package/dist/types/components/YearPicker.d.ts.map +1 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/themes/index.d.ts +41 -0
- package/dist/types/themes/index.d.ts.map +1 -0
- package/dist/types/utils/ConfirmationProvider.d.ts +16 -0
- package/dist/types/utils/ConfirmationProvider.d.ts.map +1 -0
- package/dist/types/utils/ToastProvider.d.ts +12 -0
- package/dist/types/utils/ToastProvider.d.ts.map +1 -0
- package/dist/types/utils/fileValidation.d.ts +57 -0
- package/dist/types/utils/fileValidation.d.ts.map +1 -0
- package/dist/types/utils/form.d.ts +21 -0
- package/dist/types/utils/form.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +11 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/security.d.ts +61 -0
- package/dist/types/utils/security.d.ts.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
# INA Digital Design System
|
|
2
|
+
|
|
3
|
+
**INA Digital Design System** adalah pustaka komponen UI berbasis React dan Tailwind CSS v4 yang siap di-publish ke NPM dan di‑consume oleh berbagai proyek.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Daftar Isi Cara Menggunakan Project Design System
|
|
8
|
+
|
|
9
|
+
1. [Instalasi Design System](#instalasi-design-system)
|
|
10
|
+
|
|
11
|
+
- [A. Astro Project](#a-astro-project)
|
|
12
|
+
- [B. React Project`](#b-react-project)
|
|
13
|
+
|
|
14
|
+
## Instalasi Design System
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Pasang Tailwind CSS v4 beserta plugin Vite dan @tabler/icons-react yang digunakan untuk keperluan penggunaan icons agar lebih mudah
|
|
18
|
+
npm install @idds/react tailwindcss@4.1.6 @tailwindcss/vite@4.1.6 @tabler/icons-react
|
|
19
|
+
# atau menggunakan Yarn
|
|
20
|
+
yarn add @idds/react tailwindcss@4.1.6 @tailwindcss/vite@4.1.6 @tabler/icons-react
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### A. Astro Project
|
|
24
|
+
|
|
25
|
+
1. Pastikan anda telah menginstall `@astrojs/react^4.2.7`, `react^18.0.0`, dan `react-dom^18.0.0`
|
|
26
|
+
2. Buat file **tailwind.config**, lalu import createPreset serta input nama brand yang hendak Anda pilih. Misal : BGN
|
|
27
|
+
```ts
|
|
28
|
+
import createPreset from '@idds/react/tailwind.preset.js';
|
|
29
|
+
export default {
|
|
30
|
+
darkMode: 'class',
|
|
31
|
+
presets: [createPreset({ brand: 'BGN' })],
|
|
32
|
+
theme: {
|
|
33
|
+
// anda tetap diperbolehkan untuk melakukan customization variable yang belum tercover di design-system
|
|
34
|
+
extend: {
|
|
35
|
+
spacing: {
|
|
36
|
+
'0.5': '2px',
|
|
37
|
+
'1.5': '6px',
|
|
38
|
+
'2.5': '10px',
|
|
39
|
+
'3.5': '14px',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
plugins: [],
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
3. Di file global CSS anda, misal di `src/styles/global.css`, import plugin Tailwind agar utilitas tailwind bisa di gunakan sertakan juga `@config` dari **tailwind.config** nya agar custom theme & preset design system yang telah kita definisikan bisa terpakai.
|
|
47
|
+
```ts
|
|
48
|
+
@import "tailwindcss";
|
|
49
|
+
@config '../../tailwind.config.ts';
|
|
50
|
+
```
|
|
51
|
+
4. Import file CSS dari design system pada root file `.astro` Anda (yang terdapat tag `<html></html>` nya). Misal di src/layout/BaseLayout.astro. Pastikan Anda mengimport nya sebelum global CSS
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
---
|
|
55
|
+
import { SITE_TITLE, SITE_DESCRIPTION } from '../constants';
|
|
56
|
+
import '@idds/react/style.css';
|
|
57
|
+
import '../styles/global.css';
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<!doctype html>
|
|
61
|
+
<html lang="en">
|
|
62
|
+
<head>
|
|
63
|
+
<meta charset="UTF-8" />
|
|
64
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
65
|
+
<title>{SITE_TITLE}</title>
|
|
66
|
+
|
|
67
|
+
<meta name="generator" content={Astro.generator} />
|
|
68
|
+
<meta name="description" content={SITE_DESCRIPTION} />
|
|
69
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
70
|
+
<link rel="sitemap" type="application/xml" href="/sitemap-index.xml" />
|
|
71
|
+
</head>
|
|
72
|
+
<body
|
|
73
|
+
class:list={[
|
|
74
|
+
'pb-10',
|
|
75
|
+
'bg-gray-50 dark:bg-gray-800',
|
|
76
|
+
'scrollbar scrollbar-w-3 scrollbar-thumb-rounded-[0.25rem]',
|
|
77
|
+
'scrollbar-track-slate-200 scrollbar-thumb-gray-400',
|
|
78
|
+
'dark:scrollbar-track-gray-900 dark:scrollbar-thumb-gray-700',
|
|
79
|
+
]}
|
|
80
|
+
>
|
|
81
|
+
<slot />
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
84
|
+
|
|
85
|
+
<script></script>
|
|
86
|
+
|
|
87
|
+
<style is:global>
|
|
88
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Urbanist:ital,wght@0,100..900;1,100..900&display=swap');
|
|
89
|
+
</style>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### B. React Project
|
|
93
|
+
|
|
94
|
+
1. Pastikan anda telah menginstall `react^18.0.0`, dan `react-dom^18.0.0`
|
|
95
|
+
2. Buat file **tailwind.config**, lalu import createPreset serta input nama brand yang hendak Anda pilih. Misal : BGN
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
// tailwind.config.js
|
|
99
|
+
import createPreset from '@idds/react/tailwind.preset.js';
|
|
100
|
+
|
|
101
|
+
/** @type {import('tailwindcss').Config} */
|
|
102
|
+
export default {
|
|
103
|
+
presets: [createPreset({ brand: 'BGN' })],
|
|
104
|
+
content: [
|
|
105
|
+
'./index.html',
|
|
106
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
107
|
+
'./*.{js,ts,jsx,tsx}',
|
|
108
|
+
],
|
|
109
|
+
theme: {
|
|
110
|
+
extend: {
|
|
111
|
+
backgroundImage: {},
|
|
112
|
+
colors: {},
|
|
113
|
+
fontSize: {},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
plugins: [],
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. Di file global CSS anda, misal di `src/index.css`, import plugin Tailwind agar utilitas tailwind bisa di gunakan sertakan juga `@config` dari **tailwind.config** nya agar custom theme & preset design system yang telah kita definisikan bisa terpakai.
|
|
121
|
+
```ts
|
|
122
|
+
@import "tailwindcss";
|
|
123
|
+
@config '../../tailwind.config.ts';
|
|
124
|
+
```
|
|
125
|
+
4. Import file CSS dari design system pada root file `.jsx/.tsx` dari project React Anda. Misal menggunakan vite, maka ada di `src/main.jsx` seperti contoh dibawah ini :
|
|
126
|
+
|
|
127
|
+
```jsx
|
|
128
|
+
import { StrictMode } from 'react';
|
|
129
|
+
import { createRoot } from 'react-dom/client';
|
|
130
|
+
import '@idds/react/style.css';
|
|
131
|
+
import './index.css';
|
|
132
|
+
import App from './App.jsx';
|
|
133
|
+
|
|
134
|
+
createRoot(document.getElementById('root')).render(
|
|
135
|
+
<StrictMode>
|
|
136
|
+
<App />
|
|
137
|
+
</StrictMode>
|
|
138
|
+
);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Daftar Isi Penjelasan Project Design System
|
|
144
|
+
|
|
145
|
+
**_(Just For Knowledge & Documentation Purpose, Don't Implement It In Your Project)_**
|
|
146
|
+
|
|
147
|
+
1. [Prasyarat](#prasyarat)
|
|
148
|
+
2. [Instalasi](#instalasi)
|
|
149
|
+
3. [Konfigurasi Vite & Tailwind](#konfigurasi-vite--tailwind)
|
|
150
|
+
|
|
151
|
+
- [1. Install Tailwind & Plugin](#1-install-tailwind--plugin)
|
|
152
|
+
- [2. Setup `vite.config.ts`](#2-setup-viteconfigts)
|
|
153
|
+
- [3. Prettier & VS Code Settings](#3-prettier--vs-code-settings)
|
|
154
|
+
|
|
155
|
+
4. [Struktur Tailwind Config](#struktur-tailwind-config)
|
|
156
|
+
|
|
157
|
+
- [Preset vs Config](#preset-vs-config)
|
|
158
|
+
|
|
159
|
+
5. [TypeScript Config](#typescript-config)
|
|
160
|
+
6. [Asset Font Internal](#asset-font-internal)
|
|
161
|
+
7. [Global CSS](#global-css)
|
|
162
|
+
8. [Publikasi ke NPM](#publikasi-ke-npm)
|
|
163
|
+
9. [License](#license)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Prasyarat
|
|
168
|
+
|
|
169
|
+
- Node.js ≥ 16
|
|
170
|
+
- NPM / Yarn
|
|
171
|
+
- React & ReactDOM
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Instalasi
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Pasang Tailwind CSS v4 dan plugin Vite
|
|
179
|
+
npm install tailwindcss@latest @tailwindcss/vite @tabler/icons-react
|
|
180
|
+
# atau menggunakan Yarn
|
|
181
|
+
yarn add tailwindcss@latest @tailwindcss/vite @tabler/icons-react
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Konfigurasi Vite & Tailwind
|
|
187
|
+
|
|
188
|
+
### 1. Install Tailwind & Plugin
|
|
189
|
+
|
|
190
|
+
1. Jalankan perintah instalasi di atas.
|
|
191
|
+
2. Di file `vite.config.ts`, import plugin Tailwind untuk Vite:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 2. Setup `vite.config.ts`
|
|
198
|
+
|
|
199
|
+
“Externalizing React” artinya menandai paket React (dan runtime JSX‑nya) sebagai external dalam build library-mu, sehingga tidak dibundel ke dalam output final. Sebagai gantinya, library-mu akan mengandalkan React yang diinstal oleh consumer (proyek yang menggunakan library). Ini mencegah duplikasi React di bundle, menghindari mismatched internals seperti error ReactCurrentDispatcher di Astro, dan menjaga ukuran bundle tetap kecil.
|
|
200
|
+
|
|
201
|
+
Mengapa perlu externalize React?
|
|
202
|
+
|
|
203
|
+
1. **Duplikasi React**
|
|
204
|
+
Jika library dan aplikasi utama sama‑sama membundel React, akan ada dua instance React di page yang dapat memicu hook/context breakage (mis. ReactCurrentDispatcher undefined) .
|
|
205
|
+
|
|
206
|
+
2. **Ukuran Bundle**
|
|
207
|
+
Eksternalisasi mencegah React ditambahkan ke package output, membuat library ringan dan berpindah‑pindah antar proyek tanpa membawa React.
|
|
208
|
+
|
|
209
|
+
3. **Single source of React**
|
|
210
|
+
Consumer project bertanggung jawab menginstal versi React mereka sendiri, menjaga kompatibilitas dan konsistensi.
|
|
211
|
+
|
|
212
|
+
Tambahkan konfigurasi build dan external dependency React/ReactDOM:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { defineConfig } from 'vite';
|
|
216
|
+
import react from '@vitejs/plugin-react';
|
|
217
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
218
|
+
|
|
219
|
+
export default defineConfig({
|
|
220
|
+
plugins: [react(), tailwindcss()],
|
|
221
|
+
build: {
|
|
222
|
+
lib: {
|
|
223
|
+
entry: './src/index.ts',
|
|
224
|
+
name: 'INADigitalDesignSystem',
|
|
225
|
+
formats: ['es', 'umd'],
|
|
226
|
+
fileName: (format) => `@idds/react.${format}.js`,
|
|
227
|
+
},
|
|
228
|
+
rollupOptions: {
|
|
229
|
+
external: [
|
|
230
|
+
'react',
|
|
231
|
+
'react-dom',
|
|
232
|
+
'react/jsx-runtime',
|
|
233
|
+
'react-dom/client', // untuk React 18+ jika kamu pakai createRoot
|
|
234
|
+
],
|
|
235
|
+
output: {
|
|
236
|
+
// ② Beri tahu global names untuk UMD/IIFE (jika dipakai)
|
|
237
|
+
globals: {
|
|
238
|
+
react: 'React',
|
|
239
|
+
'react-dom': 'ReactDOM',
|
|
240
|
+
'react/jsx-runtime': 'jsxRuntime',
|
|
241
|
+
'react-dom/client': 'ReactDOMClient',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 3. Prettier & VS Code Settings
|
|
250
|
+
|
|
251
|
+
- Aktifkan ekstensi **Prettier** di VS Code.
|
|
252
|
+
- (Opsional) Buat file `.vscode/settings.json` di root project untuk custom language support Tailwind:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"tailwindCSS.includeLanguages": {
|
|
257
|
+
"typescript": "javascript",
|
|
258
|
+
"typescriptreact": "javascriptreact"
|
|
259
|
+
},
|
|
260
|
+
"editor.formatOnSave": true,
|
|
261
|
+
"tailwindCSS.classAttributes": ["class", "class:list", "className"],
|
|
262
|
+
// Suruh Tailwind IntelliSense mem-parse file global.css sebagai config
|
|
263
|
+
"tailwindCSS.experimental.configFile": "src/index.css"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Struktur Tailwind Config
|
|
270
|
+
|
|
271
|
+
Kita menggunakan dua file konfigurasi:
|
|
272
|
+
|
|
273
|
+
1. **`tailwind.preset.ts`**
|
|
274
|
+
|
|
275
|
+
- Digunakan sebagai _preset_ eksternal.
|
|
276
|
+
- Definisikan brand colors, font family, spacing, dll.
|
|
277
|
+
- File ini akan di-_export_ dan dikonsumsi oleh project lain.
|
|
278
|
+
|
|
279
|
+
2. **`tailwind.config.ts`**
|
|
280
|
+
|
|
281
|
+
- Konfigurasi internal project Design System.
|
|
282
|
+
- Merujuk ke `tailwind.preset.ts` sebagai _source of truth_ agar tidak duplikasi (DRY).
|
|
283
|
+
|
|
284
|
+
Contoh `tailwind.preset.ts`:
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
import { Preset } from 'tailwindcss';
|
|
288
|
+
|
|
289
|
+
const preset: Preset = {
|
|
290
|
+
theme: {
|
|
291
|
+
colors: {
|
|
292
|
+
primary: '#1DA1F2',
|
|
293
|
+
secondary: '#14171A',
|
|
294
|
+
// … lainnya
|
|
295
|
+
},
|
|
296
|
+
fontFamily: {
|
|
297
|
+
sans: ['Inter', 'sans-serif'],
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export default preset;
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Contoh `tailwind.config.ts`:
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
import preset from './tailwind.preset';
|
|
309
|
+
|
|
310
|
+
export default {
|
|
311
|
+
presets: [preset],
|
|
312
|
+
content: ['./src/**/*.{js,ts,jsx,tsx}'],
|
|
313
|
+
};
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## TypeScript Config
|
|
319
|
+
|
|
320
|
+
Pisahkan `tsconfig` menjadi dua:
|
|
321
|
+
|
|
322
|
+
- **`tsconfig.app.json`**
|
|
323
|
+
Untuk build aplikasi React (pastikan `module` & `moduleResolution` = `nodenext`).
|
|
324
|
+
|
|
325
|
+
- **`tsconfig.node.json`**
|
|
326
|
+
Untuk keperluan _scripts_ atau _build tools_ di Node.js.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Asset Font Internal
|
|
331
|
+
|
|
332
|
+
Kami menyertakan file font `.woff2` di dalam project:
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
src/
|
|
336
|
+
└── assets/
|
|
337
|
+
└── fonts/
|
|
338
|
+
└── Inter/
|
|
339
|
+
├── Inter-Regular.woff2
|
|
340
|
+
├── Inter-Bold.woff2
|
|
341
|
+
└── … lainnya
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Global CSS
|
|
347
|
+
|
|
348
|
+
1. Buat file `src/assets/fonts.css` untuk _@font-face_:
|
|
349
|
+
|
|
350
|
+
```css
|
|
351
|
+
@font-face {
|
|
352
|
+
font-family: 'Inter';
|
|
353
|
+
src: url('../fonts/Inter/Inter-Regular.woff2') format('woff2');
|
|
354
|
+
font-weight: 400;
|
|
355
|
+
font-style: normal;
|
|
356
|
+
}
|
|
357
|
+
/* … weight lainnya */
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
2. Di `src/index.css`:
|
|
361
|
+
|
|
362
|
+
```css
|
|
363
|
+
@import 'tailwindcss/base';
|
|
364
|
+
@import 'tailwindcss/components';
|
|
365
|
+
@import 'tailwindcss/utilities';
|
|
366
|
+
|
|
367
|
+
@import './assets/fonts.css';
|
|
368
|
+
|
|
369
|
+
/* Link ke konfigurasi Tailwind */
|
|
370
|
+
@config './tailwind.config.ts';
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Publikasi ke NPM
|
|
376
|
+
|
|
377
|
+
Pastikan di `package.json` terdapat field berikut:
|
|
378
|
+
|
|
379
|
+
```jsonc
|
|
380
|
+
{
|
|
381
|
+
"name": "@idds/react",
|
|
382
|
+
"version": "0.6.21",
|
|
383
|
+
"type": "module",
|
|
384
|
+
"main": "dist/@idds/react.umd.js",
|
|
385
|
+
"module": "dist/@idds/react.es.js",
|
|
386
|
+
"types": "dist/types/index.d.ts",
|
|
387
|
+
"files": ["dist", "dist/tailwind.preset.js"],
|
|
388
|
+
"scripts": {
|
|
389
|
+
"build:css": "npx @tailwindcss/cli -i src/index.css -o dist/style.css --minify",
|
|
390
|
+
"build:preset": "tsc --project tsconfig.preset.json",
|
|
391
|
+
"build": "tsc --project tsconfig.app.json && vite build && npm run build:preset && npm run build:css"
|
|
392
|
+
},
|
|
393
|
+
"peerDependencies": {
|
|
394
|
+
"react": ">=18.0.0", // gunakan >= untuk meminimalisir error missmatch react version antara design-system and consumer project
|
|
395
|
+
"react-dom": ">=18.0.0"
|
|
396
|
+
},
|
|
397
|
+
"style": "dist/style.css", // agar saat consumer import "@idds/react/style.css" maka akan di arahkan ke file yang ada didalam folder dist/style.css
|
|
398
|
+
"exports": {
|
|
399
|
+
".": {
|
|
400
|
+
"import": "./dist/@idds/react.es.js",
|
|
401
|
+
"require": "./dist/@idds/react.umd.js",
|
|
402
|
+
"types": "./dist/types/index.d.ts"
|
|
403
|
+
},
|
|
404
|
+
"./tailwind.preset.js": {
|
|
405
|
+
"import": "./dist/tailwind.preset.js",
|
|
406
|
+
"require": "./dist/tailwind.preset.js"
|
|
407
|
+
},
|
|
408
|
+
"./style.css": {
|
|
409
|
+
"import": "./dist/style.css",
|
|
410
|
+
"require": "./dist/style.css"
|
|
411
|
+
},
|
|
412
|
+
"./*": "./dist/*"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Publikasi:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
npm run build
|
|
421
|
+
npm version patch
|
|
422
|
+
npm publish --access public
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## License
|
|
428
|
+
|
|
429
|
+
INA Digital © \[Umar Faruq]
|