@aleph-alpha/config-css 0.19.0 → 0.21.0
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/.lintstagedrc.js +2 -4
- package/CHANGELOG.md +81 -1050
- package/README.md +3 -2
- package/customization.md +32 -11
- package/dist/index.js +1868 -389
- package/eslint.config.mjs +20 -0
- package/package.json +3 -3
- package/src/index.ts +2 -2
- package/tokens.json +1 -1
- package/tsconfig.json +7 -8
- package/eslint.config.js +0 -25
package/README.md
CHANGED
|
@@ -122,15 +122,16 @@ node packages/config-css-preset/src/utils/convert-fonts.js montserrat600.woff2 m
|
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
This will:
|
|
125
|
+
|
|
125
126
|
1. Read the WOFF2 font file
|
|
126
127
|
2. Convert it to base64 format
|
|
127
128
|
3. Generate a TypeScript file with an exported constant containing the base64 data
|
|
128
129
|
4. The constant name is derived from the output filename
|
|
129
130
|
|
|
130
131
|
The generated TypeScript file will look like:
|
|
132
|
+
|
|
131
133
|
```typescript
|
|
132
|
-
export const montserrat600 =
|
|
133
|
-
'data:@file/octet-stream;base64,<base64-encoded-font-data>';
|
|
134
|
+
export const montserrat600 = 'data:@file/octet-stream;base64,<base64-encoded-font-data>';
|
|
134
135
|
```
|
|
135
136
|
|
|
136
137
|
## Config CSS Preset helps in UI Customization
|
package/customization.md
CHANGED
|
@@ -12,6 +12,7 @@ The Config CSS Preset enables customization of two main visual aspects:
|
|
|
12
12
|
- **Color Themes**: Brand and core UI colors used throughout applications
|
|
13
13
|
|
|
14
14
|
These customizations are automatically applied to:
|
|
15
|
+
|
|
15
16
|
- All components from `@aleph-alpha/ds-components-vue`
|
|
16
17
|
- Any Pharia applications that consume the `@aleph-alpha/config-css` package
|
|
17
18
|
|
|
@@ -22,25 +23,31 @@ These customizations are automatically applied to:
|
|
|
22
23
|
Config CSS Preset uses a sophisticated transformation process to make fonts customizable across the entire design system:
|
|
23
24
|
|
|
24
25
|
#### 1. Token Processing
|
|
26
|
+
|
|
25
27
|
The system processes font tokens defined in [`tokens.json`](https://gitlab.aleph-alpha.de/engineering/frontend-hub/-/blob/main/packages/config-css-preset/tokens.json) using Style Dictionary, a build system for design tokens.
|
|
26
28
|
|
|
27
29
|
#### 2. Custom Transform Application
|
|
30
|
+
|
|
28
31
|
A custom Style Dictionary transform called `custom/typography/font-family` (defined in the [config file](https://gitlab.aleph-alpha.de/engineering/frontend-hub/-/blob/main/packages/config-css-preset/sd.config.js)) processes these tokens.
|
|
29
32
|
|
|
30
33
|
#### 3. Variable Substitution
|
|
34
|
+
|
|
31
35
|
The transform replaces hardcoded font family references with CSS custom properties:
|
|
32
36
|
|
|
33
37
|
**Before transformation:**
|
|
38
|
+
|
|
34
39
|
```css
|
|
35
40
|
font-family: 'Raleway';
|
|
36
41
|
```
|
|
37
42
|
|
|
38
43
|
**After transformation:**
|
|
44
|
+
|
|
39
45
|
```css
|
|
40
46
|
font-family: var(--custom-font-family, Raleway);
|
|
41
47
|
```
|
|
42
48
|
|
|
43
49
|
This approach ensures that:
|
|
50
|
+
|
|
44
51
|
- All typography classes automatically expose the customizable font family variable
|
|
45
52
|
- Applications can override fonts by simply updating the `--custom-font-family` CSS variable
|
|
46
53
|
- A fallback font (Raleway) is always available if no custom font is specified
|
|
@@ -57,13 +64,16 @@ Currently, Config CSS Preset provides built-in support for two font families thr
|
|
|
57
64
|
You have two options for extending font family support:
|
|
58
65
|
|
|
59
66
|
#### Option 1: Extend the Preset (Recommended for System-Wide Fonts)
|
|
67
|
+
|
|
60
68
|
Add new font definitions to the existing preset file by following the established code patterns. This approach makes fonts available across all applications using the preset.
|
|
61
69
|
|
|
62
70
|
#### Option 2: Application-Level Implementation (Recommended for App-Specific Fonts)
|
|
71
|
+
|
|
63
72
|
1. Define your custom `@font-face` declarations in your Pharia application
|
|
64
73
|
2. Update the `--custom-font-family` CSS variable to reference your custom font
|
|
65
74
|
|
|
66
75
|
**Example:**
|
|
76
|
+
|
|
67
77
|
```css
|
|
68
78
|
@font-face {
|
|
69
79
|
font-family: 'MyCustomFont';
|
|
@@ -80,15 +90,14 @@ Add new font definitions to the existing preset file by following the establishe
|
|
|
80
90
|
### Updating Font Variables
|
|
81
91
|
|
|
82
92
|
#### JavaScript Method
|
|
93
|
+
|
|
83
94
|
```javascript
|
|
84
95
|
// Update font family dynamically
|
|
85
|
-
document.documentElement.style.setProperty(
|
|
86
|
-
'--custom-font-family',
|
|
87
|
-
'Your-Custom-Font-Family'
|
|
88
|
-
);
|
|
96
|
+
document.documentElement.style.setProperty('--custom-font-family', 'Your-Custom-Font-Family');
|
|
89
97
|
```
|
|
90
98
|
|
|
91
99
|
#### CSS Method
|
|
100
|
+
|
|
92
101
|
```css
|
|
93
102
|
:root {
|
|
94
103
|
--custom-font-family: 'Your-Custom-Font-Family';
|
|
@@ -106,13 +115,17 @@ Config CSS Preset transforms design system color tokens into customizable CSS va
|
|
|
106
115
|
To discover all available color tokens in your system:
|
|
107
116
|
|
|
108
117
|
#### 1. Build the Token Files
|
|
118
|
+
|
|
109
119
|
Run the following command from your project root:
|
|
120
|
+
|
|
110
121
|
```bash
|
|
111
122
|
nx run config-css-preset:build
|
|
112
123
|
```
|
|
113
124
|
|
|
114
125
|
#### 2. Examine Generated Files
|
|
126
|
+
|
|
115
127
|
This command generates a structured output directory:
|
|
128
|
+
|
|
116
129
|
```
|
|
117
130
|
config-css-preset/
|
|
118
131
|
sd-output/
|
|
@@ -125,7 +138,9 @@ config-css-preset/
|
|
|
125
138
|
```
|
|
126
139
|
|
|
127
140
|
#### 3. Review Color Tokens
|
|
141
|
+
|
|
128
142
|
Open `config-css-preset/sd-output/light-mode.json` to see all available color tokens, including:
|
|
143
|
+
|
|
129
144
|
- `brand-*` tokens: Brand-specific colors
|
|
130
145
|
- `core-*` tokens: Core UI and system colors
|
|
131
146
|
|
|
@@ -136,18 +151,21 @@ The Config CSS Preset automatically transforms design tokens into CSS custom pro
|
|
|
136
151
|
#### Transformation Examples
|
|
137
152
|
|
|
138
153
|
**Brand Background Token:**
|
|
154
|
+
|
|
139
155
|
```
|
|
140
156
|
Design Token: brand-bg-brand
|
|
141
157
|
CSS Variable: --un-preset-theme-colors-brand-bg-brand
|
|
142
158
|
```
|
|
143
159
|
|
|
144
160
|
**Core Content Token:**
|
|
161
|
+
|
|
145
162
|
```
|
|
146
163
|
Design Token: core-content-secondary
|
|
147
164
|
CSS Variable: --un-preset-theme-colors-core-content-secondary
|
|
148
165
|
```
|
|
149
166
|
|
|
150
167
|
#### Naming Convention Breakdown
|
|
168
|
+
|
|
151
169
|
- **Prefix**: `--un-preset-theme-colors-`
|
|
152
170
|
- **Token Name**: The original design token name (e.g., `brand-bg-brand`)
|
|
153
171
|
- **Result**: A globally accessible CSS custom property
|
|
@@ -162,34 +180,33 @@ Color values in Config CSS Preset use a specific RGB format optimized for flexib
|
|
|
162
180
|
### Updating Color Variables
|
|
163
181
|
|
|
164
182
|
#### JavaScript Method
|
|
183
|
+
|
|
165
184
|
```javascript
|
|
166
185
|
// Update a specific color token
|
|
167
186
|
document.documentElement.style.setProperty(
|
|
168
187
|
'--un-preset-theme-colors-brand-bg-brand',
|
|
169
|
-
'255 128 0' // RGB values for orange
|
|
188
|
+
'255 128 0', // RGB values for orange
|
|
170
189
|
);
|
|
171
190
|
|
|
172
191
|
// Update multiple colors programmatically
|
|
173
192
|
const customColors = {
|
|
174
193
|
'brand-bg-brand': '255 128 0',
|
|
175
194
|
'core-content-secondary': '64 64 64',
|
|
176
|
-
'core-bg-primary': '248 250 252'
|
|
195
|
+
'core-bg-primary': '248 250 252',
|
|
177
196
|
};
|
|
178
197
|
|
|
179
198
|
Object.entries(customColors).forEach(([token, value]) => {
|
|
180
|
-
document.documentElement.style.setProperty(
|
|
181
|
-
`--un-preset-theme-colors-${token}`,
|
|
182
|
-
value
|
|
183
|
-
);
|
|
199
|
+
document.documentElement.style.setProperty(`--un-preset-theme-colors-${token}`, value);
|
|
184
200
|
});
|
|
185
201
|
```
|
|
186
202
|
|
|
187
203
|
#### CSS Method
|
|
204
|
+
|
|
188
205
|
```css
|
|
189
206
|
:root {
|
|
190
207
|
/* Brand colors */
|
|
191
208
|
--un-preset-theme-colors-brand-bg-brand: 255 128 0;
|
|
192
|
-
|
|
209
|
+
|
|
193
210
|
/* Core UI colors */
|
|
194
211
|
--un-preset-theme-colors-core-content-secondary: 64 64 64;
|
|
195
212
|
--un-preset-theme-colors-core-bg-primary: 248 250 252;
|
|
@@ -199,13 +216,17 @@ Object.entries(customColors).forEach(([token, value]) => {
|
|
|
199
216
|
## Technical Architecture
|
|
200
217
|
|
|
201
218
|
### Style Dictionary Integration
|
|
219
|
+
|
|
202
220
|
Config CSS Preset leverages Style Dictionary's token transformation capabilities to:
|
|
221
|
+
|
|
203
222
|
- Process design tokens from JSON files
|
|
204
223
|
- Apply custom transforms for font and color handling
|
|
205
224
|
- Generate CSS custom properties with consistent naming
|
|
206
225
|
|
|
207
226
|
### UnoCSS Preset Integration
|
|
227
|
+
|
|
208
228
|
The UnoCSS preset automatically:
|
|
229
|
+
|
|
209
230
|
- Generates utility classes based on design tokens
|
|
210
231
|
- Creates CSS custom properties for runtime customization
|
|
211
232
|
- Ensures consistent theming across atomic CSS classes
|