aboutsummaryrefslogtreecommitdiffstats
path: root/svg.js.d.ts
diff options
context:
space:
mode:
author夜 <951540966@qq.com>2024-07-17 11:02:05 +0800
committerGitHub <noreply@github.com>2024-07-17 11:02:05 +0800
commitd5ca096619bcdcd96f40210cb1c645cd476c66ef (patch)
tree678b20c29f115492769109616cde234ede343e8a /svg.js.d.ts
parentec9d2fc952a683aaa9f0c523fbba0786babdf629 (diff)
downloadsvg.js-d5ca096619bcdcd96f40210cb1c645cd476c66ef.tar.gz
svg.js-d5ca096619bcdcd96f40210cb1c645cd476c66ef.zip
fix: shape.css({})
Diffstat (limited to 'svg.js.d.ts')
-rw-r--r--svg.js.d.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/svg.js.d.ts b/svg.js.d.ts
index 5fd0513..c731b25 100644
--- a/svg.js.d.ts
+++ b/svg.js.d.ts
@@ -10,8 +10,20 @@ declare type CSSStyleName = Exclude<
'parentRule' | 'length'
>
+// camelCase to kebab-case
+type CamelToKebab<S extends string> = S extends `${infer T}${infer U}`
+ ? U extends Uncapitalize<U>
+ ? `${Lowercase<T>}${CamelToKebab<U>}`
+ : `${Lowercase<T>}-${CamelToKebab<U>}`
+ : S;
+
+type ConvertKeysToKebab<T> = {
+ [K in keyof T as CamelToKebab<K & string>]: T[K];
+};
+
+
// create our own style declaration that includes css vars
-interface CSSStyleDeclarationWithVars extends CSSStyleDeclaration {
+interface CSSStyleDeclarationWithVars extends ConvertKeysToKebab<CSSStyleDeclaration> {
[key: `--${string}`]: string
}