osi-cards-lib 1.5.19 → 1.5.20
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 +306 -4
- package/fesm2022/osi-cards-lib.mjs +14 -14
- package/fesm2022/osi-cards-lib.mjs.map +1 -1
- package/index.d.ts +3 -3
- package/package.json +1 -1
- package/scripts/setup-angular-styles.js +172 -0
- package/styles/components/sections/_section-animations.scss +1 -0
- package/styles/tokens/_master.scss +1 -1
package/README.md
CHANGED
|
@@ -53,12 +53,125 @@ export const appConfig: ApplicationConfig = {
|
|
|
53
53
|
|
|
54
54
|
### Step 2: Import Styles
|
|
55
55
|
|
|
56
|
+
**🎯 RECOMMENDED: Automatic Setup via angular.json**
|
|
57
|
+
|
|
58
|
+
The most reliable way to include library styles is to add them directly to `angular.json`. This ensures styles are always loaded correctly, regardless of SASS/SCSS import resolution issues.
|
|
59
|
+
|
|
60
|
+
### Quick Setup Script
|
|
61
|
+
|
|
62
|
+
We provide an automated setup script that configures `angular.json` for you:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx osi-cards-lib setup:styles
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or manually run the script from the library:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
node node_modules/osi-cards-lib/scripts/setup-angular-styles.js
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This script will:
|
|
75
|
+
- ✅ Add library styles to your `angular.json` styles array
|
|
76
|
+
- ✅ Configure `stylePreprocessorOptions` with correct `includePaths`
|
|
77
|
+
- ✅ Set up SASS deprecation silence
|
|
78
|
+
- ✅ Work with all Angular projects in your workspace
|
|
79
|
+
|
|
80
|
+
### Manual Setup (Alternative)
|
|
81
|
+
|
|
82
|
+
If you prefer to configure manually, choose one of the following options:
|
|
83
|
+
|
|
84
|
+
#### Option A: Scoped Styles (Recommended for Integration)
|
|
85
|
+
|
|
86
|
+
Use this when integrating into an existing application to prevent style conflicts. Styles are scoped to `.osi-cards-container`.
|
|
87
|
+
|
|
88
|
+
**Method 1: Import in your styles file (Recommended)**
|
|
89
|
+
|
|
90
|
+
In your `src/styles.scss` or `src/styles.sass`:
|
|
91
|
+
|
|
92
|
+
```scss
|
|
93
|
+
// Import at the TOP of your styles file (before other styles)
|
|
94
|
+
@import 'osi-cards-lib/styles/_styles-scoped';
|
|
95
|
+
|
|
96
|
+
// If that doesn't work, try with tilde prefix:
|
|
97
|
+
@import '~osi-cards-lib/styles/_styles-scoped';
|
|
98
|
+
|
|
99
|
+
// Or with explicit .scss extension:
|
|
100
|
+
@import 'osi-cards-lib/styles/_styles-scoped.scss';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Important**: Place the import at the **top** of your styles file, not at the bottom, to ensure proper CSS cascade.
|
|
104
|
+
|
|
105
|
+
**Method 2: Add to angular.json (RECOMMENDED - Most Reliable)**
|
|
106
|
+
|
|
107
|
+
This is the **most reliable method**, especially for SASS files. The styles are automatically included in every build:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"projects": {
|
|
112
|
+
"your-app": {
|
|
113
|
+
"architect": {
|
|
114
|
+
"build": {
|
|
115
|
+
"options": {
|
|
116
|
+
"styles": [
|
|
117
|
+
"src/styles.sass", // Your main styles file
|
|
118
|
+
"node_modules/osi-cards-lib/styles/_styles-scoped.scss" // Library styles
|
|
119
|
+
],
|
|
120
|
+
"stylePreprocessorOptions": {
|
|
121
|
+
"includePaths": [
|
|
122
|
+
"node_modules/osi-cards-lib/styles"
|
|
123
|
+
],
|
|
124
|
+
"sass": {
|
|
125
|
+
"silenceDeprecations": ["import"]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Note**:
|
|
137
|
+
- The `includePaths` in `stylePreprocessorOptions` helps Angular resolve relative imports within the library's SCSS files.
|
|
138
|
+
- **This is especially important when using SASS files** (`.sass` extension) as they may have different import resolution behavior.
|
|
139
|
+
- Place library styles **after** your main styles file in the array to ensure proper cascade.
|
|
140
|
+
|
|
141
|
+
**Important**:
|
|
142
|
+
- ⚠️ **Case sensitive**: Use `osi-cards-lib` (lowercase), NOT `osi-cards-Lib`
|
|
143
|
+
- ⚠️ **REQUIRED**: You must wrap your components in a container with the `osi-cards-container` class and `data-theme` attribute:
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<!-- Static theme -->
|
|
147
|
+
<div class="osi-cards-container" data-theme="day">
|
|
148
|
+
<app-ai-card-renderer [cardConfig]="card"></app-ai-card-renderer>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<!-- Dynamic theme (Angular) -->
|
|
152
|
+
<div class="osi-cards-container" [attr.data-theme]="theme" *ngIf="cardConfig">
|
|
153
|
+
<app-ai-card-renderer [cardConfig]="cardConfig"></app-ai-card-renderer>
|
|
154
|
+
</div>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**The `data-theme` attribute is REQUIRED** - without it, styles will not apply correctly. Use `"day"` for light theme or `"night"` for dark theme.
|
|
158
|
+
|
|
159
|
+
#### Option B: Global Styles (For Standalone Apps)
|
|
160
|
+
|
|
161
|
+
Use this for standalone applications or when you want styles applied globally.
|
|
162
|
+
|
|
56
163
|
In your `src/styles.scss`:
|
|
57
164
|
|
|
58
165
|
```scss
|
|
166
|
+
// Try this first
|
|
59
167
|
@import 'osi-cards-lib/styles/_styles';
|
|
168
|
+
|
|
169
|
+
// If that doesn't work, try with tilde:
|
|
170
|
+
@import '~osi-cards-lib/styles/_styles';
|
|
60
171
|
```
|
|
61
172
|
|
|
173
|
+
**Note**: This applies styles to `:root`, so no container wrapper is needed, but styles may conflict with your existing application styles.
|
|
174
|
+
|
|
62
175
|
### Step 3: Use the Component
|
|
63
176
|
|
|
64
177
|
---
|
|
@@ -104,7 +217,20 @@ export class StaticCardComponent {
|
|
|
104
217
|
}
|
|
105
218
|
```
|
|
106
219
|
|
|
107
|
-
**HTML:**
|
|
220
|
+
**HTML (with scoped styles):**
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<div class="osi-cards-container" [attr.data-theme]="cardTheme">
|
|
224
|
+
<app-ai-card-renderer
|
|
225
|
+
[cardConfig]="card"
|
|
226
|
+
[streamingStage]="'complete'"
|
|
227
|
+
[showLoadingByDefault]="false"
|
|
228
|
+
(cardInteraction)="onCardAction($event)">
|
|
229
|
+
</app-ai-card-renderer>
|
|
230
|
+
</div>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**HTML (with global styles or using OsiCardsContainerComponent):**
|
|
108
234
|
|
|
109
235
|
```html
|
|
110
236
|
<osi-cards-container [theme]="cardTheme">
|
|
@@ -209,7 +335,28 @@ export class StreamingCardComponent {
|
|
|
209
335
|
}
|
|
210
336
|
```
|
|
211
337
|
|
|
212
|
-
**HTML:**
|
|
338
|
+
**HTML (with scoped styles):**
|
|
339
|
+
|
|
340
|
+
```html
|
|
341
|
+
<button (click)="generateCard()" [disabled]="isStreaming">
|
|
342
|
+
{{ isStreaming ? 'Generating...' : 'Generate Card' }}
|
|
343
|
+
</button>
|
|
344
|
+
|
|
345
|
+
<div class="osi-cards-container" [attr.data-theme]="cardTheme">
|
|
346
|
+
<app-ai-card-renderer
|
|
347
|
+
[cardConfig]="card"
|
|
348
|
+
[isStreaming]="isStreaming"
|
|
349
|
+
[streamingStage]="streamingStage"
|
|
350
|
+
[streamingProgress]="streamingProgress"
|
|
351
|
+
[showLoadingByDefault]="true"
|
|
352
|
+
[loadingMessages]="loadingMessages"
|
|
353
|
+
[loadingTitle]="'AI Analysis'"
|
|
354
|
+
(cardInteraction)="onCardAction($event)">
|
|
355
|
+
</app-ai-card-renderer>
|
|
356
|
+
</div>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**HTML (with global styles or using OsiCardsContainerComponent):**
|
|
213
360
|
|
|
214
361
|
```html
|
|
215
362
|
<button (click)="generateCard()" [disabled]="isStreaming">
|
|
@@ -820,14 +967,155 @@ providers: [
|
|
|
820
967
|
]
|
|
821
968
|
```
|
|
822
969
|
|
|
823
|
-
### Styles not loading
|
|
970
|
+
### Styles not loading / Library looks unstyled
|
|
971
|
+
|
|
972
|
+
**If using scoped styles (`_styles-scoped`):**
|
|
973
|
+
|
|
974
|
+
**CRITICAL**: If styles are completely missing (card renders but has no styling), the SASS import is likely not resolving. Use one of these solutions:
|
|
975
|
+
|
|
976
|
+
**Solution 1: Add to angular.json (RECOMMENDED for SASS files)**
|
|
977
|
+
|
|
978
|
+
This is the most reliable method:
|
|
979
|
+
|
|
980
|
+
```json
|
|
981
|
+
{
|
|
982
|
+
"projects": {
|
|
983
|
+
"your-app": {
|
|
984
|
+
"architect": {
|
|
985
|
+
"build": {
|
|
986
|
+
"options": {
|
|
987
|
+
"styles": [
|
|
988
|
+
"src/styles.sass",
|
|
989
|
+
"node_modules/osi-cards-lib/styles/_styles-scoped.scss"
|
|
990
|
+
],
|
|
991
|
+
"stylePreprocessorOptions": {
|
|
992
|
+
"includePaths": [
|
|
993
|
+
"node_modules/osi-cards-lib/styles"
|
|
994
|
+
],
|
|
995
|
+
"sass": {
|
|
996
|
+
"silenceDeprecations": ["import"]
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
Then **remove** the `@import` from your `styles.sass` file.
|
|
1008
|
+
|
|
1009
|
+
**Solution 2: Fix the SASS import**
|
|
1010
|
+
|
|
1011
|
+
If you want to keep the import in your styles file:
|
|
1012
|
+
|
|
1013
|
+
1. **Use tilde prefix**:
|
|
1014
|
+
```sass
|
|
1015
|
+
@import '~osi-cards-lib/styles/_styles-scoped';
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
2. **Or use full path**:
|
|
1019
|
+
```sass
|
|
1020
|
+
@import 'node_modules/osi-cards-lib/styles/_styles-scoped';
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
3. **And add to angular.json**:
|
|
1024
|
+
```json
|
|
1025
|
+
"stylePreprocessorOptions": {
|
|
1026
|
+
"includePaths": ["node_modules"],
|
|
1027
|
+
"sass": {
|
|
1028
|
+
"silenceDeprecations": ["import"]
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
**Solution 3: Verify import path** - Use lowercase `osi-cards-lib` (not `osi-cards-Lib`):
|
|
1034
|
+
```scss
|
|
1035
|
+
@import 'osi-cards-lib/styles/_styles-scoped';
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
2. **Try alternative import methods** if the above doesn't work:
|
|
1039
|
+
|
|
1040
|
+
**Option A: With tilde prefix** (for older Angular versions):
|
|
1041
|
+
```scss
|
|
1042
|
+
@import '~osi-cards-lib/styles/_styles-scoped';
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
**Option B: With explicit extension**:
|
|
1046
|
+
```scss
|
|
1047
|
+
@import 'osi-cards-lib/styles/_styles-scoped.scss';
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
**Option C: Add to angular.json** (if SCSS import fails):
|
|
1051
|
+
```json
|
|
1052
|
+
{
|
|
1053
|
+
"projects": {
|
|
1054
|
+
"your-app": {
|
|
1055
|
+
"architect": {
|
|
1056
|
+
"build": {
|
|
1057
|
+
"options": {
|
|
1058
|
+
"styles": [
|
|
1059
|
+
"node_modules/osi-cards-lib/styles/_styles-scoped.scss",
|
|
1060
|
+
"src/styles.scss"
|
|
1061
|
+
],
|
|
1062
|
+
"stylePreprocessorOptions": {
|
|
1063
|
+
"includePaths": [
|
|
1064
|
+
"node_modules/osi-cards-lib/styles"
|
|
1065
|
+
],
|
|
1066
|
+
"sass": {
|
|
1067
|
+
"silenceDeprecations": ["import"]
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
```
|
|
1077
|
+
Then remove the `@import` from your `styles.scss`.
|
|
1078
|
+
|
|
1079
|
+
3. **Wrap components in container** - You MUST wrap your components:
|
|
1080
|
+
```html
|
|
1081
|
+
<div class="osi-cards-container" data-theme="day">
|
|
1082
|
+
<app-ai-card-renderer [cardConfig]="card"></app-ai-card-renderer>
|
|
1083
|
+
</div>
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
4. **Set theme attribute** - Add `data-theme="day"` or `data-theme="night"`:
|
|
1087
|
+
```html
|
|
1088
|
+
<div class="osi-cards-container" data-theme="day">
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
5. **Verify package installation**:
|
|
1092
|
+
```bash
|
|
1093
|
+
npm list osi-cards-lib
|
|
1094
|
+
```
|
|
1095
|
+
Should show version `1.5.19` or higher.
|
|
1096
|
+
|
|
1097
|
+
6. **Check browser console** - Look for 404 errors on style files. If you see errors, the import path is incorrect.
|
|
1098
|
+
|
|
1099
|
+
7. **Rebuild your app** after adding the import:
|
|
1100
|
+
```bash
|
|
1101
|
+
ng build
|
|
1102
|
+
# or
|
|
1103
|
+
npm start
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
**If using global styles (`_styles`):**
|
|
824
1107
|
|
|
825
1108
|
Import styles in your `styles.scss`:
|
|
826
|
-
|
|
827
1109
|
```scss
|
|
828
1110
|
@import 'osi-cards-lib/styles/_styles';
|
|
829
1111
|
```
|
|
830
1112
|
|
|
1113
|
+
**Common Issues:**
|
|
1114
|
+
- ❌ **Wrong import path**: `@import 'osi-cards-Lib/styles/_styles-scoped'` (wrong casing)
|
|
1115
|
+
- ❌ **Missing container**: Components not wrapped in `.osi-cards-container`
|
|
1116
|
+
- ❌ **Missing theme**: No `data-theme` attribute on container
|
|
1117
|
+
- ❌ **SCSS not compiled**: Check that your build process compiles SCSS files
|
|
1118
|
+
|
|
831
1119
|
### Icons not showing
|
|
832
1120
|
|
|
833
1121
|
Ensure `lucide-angular` is installed:
|
|
@@ -836,6 +1124,20 @@ Ensure `lucide-angular` is installed:
|
|
|
836
1124
|
npm install lucide-angular@^0.548.0
|
|
837
1125
|
```
|
|
838
1126
|
|
|
1127
|
+
### CSS Variables not working
|
|
1128
|
+
|
|
1129
|
+
If CSS variables (like `--color-brand`) aren't working:
|
|
1130
|
+
|
|
1131
|
+
1. **For scoped styles**: Ensure you're using `.osi-cards-container` wrapper
|
|
1132
|
+
2. **Check theme**: Verify `data-theme` attribute is set correctly
|
|
1133
|
+
3. **Override variables**: You can override variables in your own styles:
|
|
1134
|
+
```scss
|
|
1135
|
+
.osi-cards-container {
|
|
1136
|
+
--color-brand: #ff7900;
|
|
1137
|
+
--background: #ffffff;
|
|
1138
|
+
}
|
|
1139
|
+
```
|
|
1140
|
+
|
|
839
1141
|
---
|
|
840
1142
|
|
|
841
1143
|
## Documentation
|