Skip to content

Commit

Permalink
refactor(hiccup-css): minor updates
Browse files Browse the repository at this point in the history
- internal updates animation() & withScope()
  • Loading branch information
postspectacular committed Mar 20, 2024
1 parent 23d556f commit ac9032d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions packages/hiccup-css/src/animation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { IObjectOf } from "@thi.ng/api";
import { at_keyframes, type Keyframe } from "./keyframes.js";

export interface AnimationOpts {
Expand Down Expand Up @@ -62,7 +63,7 @@ export const animation = (
opts: Partial<AnimationOpts>,
...keyframes: Keyframe[]
) => {
opts = <any>{
const $opts: IObjectOf<any> = {
duration: "250ms",
name: id,
...opts,
Expand All @@ -71,10 +72,8 @@ export const animation = (
at_keyframes.apply(null, <any>[id, ...keyframes]),
[
`.${id}`,
Object.keys(opts).reduce(
(acc: any, k) => (
(acc[`animation-${k}`] = (<any>opts)[k]), acc
),
Object.entries($opts).reduce(
(acc: any, [k, v]) => ((acc[`animation-${k}`] = v), acc),
{}
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/hiccup-css/src/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const xfSel = comp<any, string, string>(
const withScope = (xf: Transducer<any, any>, scope: string) =>
comp(
xf,
map((x) => (isString(x) && x.indexOf(" .") == 0 ? x + scope : x))
map((x) => (isString(x) && x.startsWith(" .") ? x + scope : x))
);

/** @internal */
Expand Down

0 comments on commit ac9032d

Please sign in to comment.