To access the source code of Git, visit https://github.com/codezj/exampleAppAnimation.
I recently developed a method to extract Bootstrap CSS and utilize it as CSS in Angular. However, I encountered an error while running the Angular project: Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'box-sizing')
Here are the snippets of code that may be causing the issue:
export function getStylesFromClasses(names: string | string[],
elementType: string="div") : {[key: string]: string | number}
{
let elem = document.createElement(elementType);
console.log(elem);
(typeof names == "string" ? [names]:names).forEach(c => elem.classList.add(c));
let result : any;
for (let i =0; i < document.styleSheets.length; i++){
let sheet = document.styleSheets[i] as CSSStyleSheet;
let rules = sheet.rules || sheet.cssRules;
console.log(rules,'rules rulesrulesrulesrules');
for (let j =0; j< rules.length; j++){
if(rules[j].type == CSSRule.STYLE_RULE){
let styleRule = rules[j] as unknown as CSSStyleSheet;
console.log(styleRule,'styleRules----styleRulestyleRule');
if ( styleRule instanceof CSSStyleRule){
if (elem.matches(styleRule.selectorText)){
for (let k = 0; k < styleRule.style.length; k++){
console.log(k,'k kkkkkk');
let index: any = styleRule.style[k]
console.log(styleRule.style[k],result[index],styleRule.style[index] );
// result[index] = styleRule.style[index];
}
}
}
}
}
}
return result;
}
table.animations.ts ->
import {trigger, style, state, transition, animate, group} from "@angular/animations"
import { bindCallback } from "rxjs"
import { getStylesFromClasses } from "./animationUtils"
const commonStyles = {
border: "black solid 4px",
color: "white"
}
export const HighlightTrigger = trigger("rowHightlight",[
// state("selected", style([commonStyles,{
// backgroundColor: "lightgreen",
// fontSize:"20px"
// }])),
// state("notselected", style([commonStyles,{
// backgroundColor: "lightsalmon",
// fontSize:"12px",
// color: "black"
// }])),
state("selected",style(getStylesFromClasses(["bg-success"]))),
// state("notselected",style(getStylesFromClasses(["bg-info"]))),
state("void", style({
transform: "translateX(-50%)"
})),
transition("* => notselected", animate("200ms")),
transition("* => selected", [animate("400ms 200ms ease-in",
style({
backgroudColor: "lightblue",
fontSize: "25px"
})),
animate("250ms",style({
backgroudColor: "lightcoral",
fontSize: "30px"
})),
group([
animate("250ms", style({
backgroundColor: "lightcoral",
})),
animate('450ms', style({fontSize:"30px"})),
]),
animate("200ms")
]
),
transition("void => *", animate("500ms")),
])
Despite thorough output logs, I have yet to pinpoint the exact cause of the issue.