generate method
Génère les règles CSS correspondantes au token en utilisant le thème fourni.
Implementation
@override
List<JxCssRule> generate(JxClassToken token, JxThemeContract theme) {
final props = properties[token.identifier];
if (props == null) {
throw JxRuleException(
'Utility "${token.identifier}" is not handled by "$id".',
);
}
var value = resolveValue(token, theme);
if (value == null || disallowed.contains(value)) {
throw JxRuleException(
'Invalid value "${token.value}" for "${token.identifier}".'
'${describeAccepted(token, theme)}',
);
}
if (token.isNegative) value = _negate(value, token);
final targets = propertySelector?.call(value) ?? props;
final rendered = template?.replaceAll('{}', value) ?? value;
return [
JxCssRule(
selector: escapeSelector(token.raw),
declarations: [
for (final property in targets)
JxCssDeclaration(
property: property,
value: rendered,
isImportant: token.isImportant,
),
for (final entry in extra.entries)
JxCssDeclaration(
property: entry.key,
value: entry.value,
isImportant: token.isImportant,
),
],
),
];
}