Skip to content

Commit 6337cb4

Browse files
committed
Update rotate property, fix incorrect prefix
1 parent 4b32fc5 commit 6337cb4

4 files changed

Lines changed: 48 additions & 54 deletions

File tree

amicons/src/Amicon.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import clsx from "clsx";
44

55
interface AmiconProps {
66
icon: IAmicon;
7-
rotate?: 0 | 90 | 180 | 270 | false;
7+
rotate?: number | false;
88
flip?: true | "x" | "y" | false;
99
spin?: boolean | "pulse";
1010
beat?: boolean;
@@ -21,23 +21,27 @@ export default function AmiconIcon({
2121
fade = undefined,
2222
bounce = undefined,
2323
className,
24+
style,
2425
...props
2526
}: AmiconProps & ComponentPropsWithoutRef<"span">) {
27+
const rotateStyle =
28+
rotate !== undefined && rotate !== false
29+
? ({ "--ai-rotate": `${rotate}deg` } as React.CSSProperties)
30+
: {};
31+
2632
return (
2733
<span
28-
className={clsx(className, "vi-icon", {
29-
["vi-rotate-90"]: rotate === 90,
30-
["vi-rotate-180"]: rotate === 180,
31-
["vi-rotate-270"]: rotate === 270,
32-
["vi-flip-x"]: flip === "x",
33-
["vi-flip-y"]: flip === "y",
34-
["vi-flip"]: flip === true,
35-
["vi-spin"]: spin === true,
36-
["vi-spin vi-spin-pulse"]: spin === "pulse",
37-
["vi-beat"]: beat,
38-
["vi-fade"]: fade,
39-
["vi-bounce"]: bounce,
34+
className={clsx(className, "ai-icon", {
35+
["ai-flip-x"]: flip === "x",
36+
["ai-flip-y"]: flip === "y",
37+
["ai-flip"]: flip === true,
38+
["ai-spin"]: spin === true,
39+
["ai-spin ai-spin-pulse"]: spin === "pulse",
40+
["ai-beat"]: beat,
41+
["ai-fade"]: fade,
42+
["ai-bounce"]: bounce,
4043
})}
44+
style={{ ...rotateStyle, ...style }}
4145
dangerouslySetInnerHTML={{ __html: icon.data }}
4246
{...props}
4347
/>

amicons/src/amicons.css

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
transform: scale(1);
1414
}
1515
45% {
16-
transform: scale(var(--vi-animation-scale, 1.4));
16+
transform: scale(var(--ai-animation-scale, 1.4));
1717
}
1818
}
1919

@@ -23,7 +23,7 @@
2323
opacity: 1;
2424
}
2525
50% {
26-
opacity: var(--vi-animation-opacity, 0.4);
26+
opacity: var(--ai-animation-opacity, 0.4);
2727
}
2828
}
2929

@@ -40,7 +40,7 @@
4040
}
4141

4242
/* Base icon styling */
43-
.vi-icon {
43+
.ai-icon {
4444
height: 1em;
4545
width: 1em;
4646
min-width: 1em;
@@ -52,63 +52,49 @@
5252
vertical-align: 0;
5353
flex-shrink: 0;
5454
transition: inherit;
55+
transform: rotate(var(--ai-rotate, 0deg));
5556
}
5657

5758
/* Transform classes */
58-
.vi-rotate {
59-
transition: transform var(--vi-transition-duration, 0.2s)
60-
var(--vi-transition-timing-function, ease-in-out);
61-
}
62-
63-
.vi-rotate-90 {
64-
transform: rotate(90deg);
65-
}
66-
.vi-rotate-180 {
67-
transform: rotate(180deg);
68-
}
69-
.vi-rotate-270 {
70-
transform: rotate(270deg);
71-
}
72-
73-
.vi-flip {
59+
.ai-flip {
7460
transform: scale(-1);
7561
}
76-
.vi-flip-x {
62+
.ai-flip-x {
7763
transform: scaleX(-1);
7864
}
79-
.vi-flip-y {
65+
.ai-flip-y {
8066
transform: scaleY(-1);
8167
}
8268

8369
/* Animation classes */
84-
.vi-spin {
70+
.ai-spin {
8571
animation-name: spin-animation;
86-
animation-timing-function: var(--vi-animation-timing-function, linear);
87-
animation-duration: var(--vi-animation-duration, 2s);
88-
animation-iteration-count: var(--vi-animation-iteration-count, infinite);
72+
animation-timing-function: var(--ai-animation-timing-function, linear);
73+
animation-duration: var(--ai-animation-duration, 2s);
74+
animation-iteration-count: var(--ai-animation-iteration-count, infinite);
8975
}
9076

91-
.vi-spin-pulse {
92-
--vi-animation-timing-function: steps(var(--vi-animation-pulse-steps, 8));
93-
--vi-animation-duration: 1s;
77+
.ai-spin-pulse {
78+
--ai-animation-timing-function: steps(var(--ai-animation-pulse-steps, 8));
79+
--ai-animation-duration: 1s;
9480
}
9581

96-
.vi-beat {
82+
.ai-beat {
9783
animation-name: beat-animation;
98-
animation-timing-function: var(--vi-animation-timing-function, ease-in-out);
99-
animation-duration: var(--vi-animation-duration, 1s);
100-
animation-iteration-count: var(--vi-animation-iteration-count, infinite);
84+
animation-timing-function: var(--ai-animation-timing-function, ease-in-out);
85+
animation-duration: var(--ai-animation-duration, 1s);
86+
animation-iteration-count: var(--ai-animation-iteration-count, infinite);
10187
}
10288

103-
.vi-fade {
89+
.ai-fade {
10490
animation-name: fade-animation;
105-
animation-timing-function: var(--vi-animation-timing-function, ease-in-out);
106-
animation-duration: var(--vi-animation-duration, 1.5s);
107-
animation-iteration-count: var(--vi-animation-iteration-count, infinite);
91+
animation-timing-function: var(--ai-animation-timing-function, ease-in-out);
92+
animation-duration: var(--ai-animation-duration, 1.5s);
93+
animation-iteration-count: var(--ai-animation-iteration-count, infinite);
10894
}
10995

110-
.vi-bounce {
96+
.ai-bounce {
11197
animation-name: bounce-animation;
112-
animation-duration: var(--vi-animation-duration, 1s);
113-
animation-iteration-count: var(--vi-animation-iteration-count, infinite);
98+
animation-duration: var(--ai-animation-duration, 1s);
99+
animation-iteration-count: var(--ai-animation-iteration-count, infinite);
114100
}

docs/src/app/Docs/pages/Changelog.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ export default function Changelog() {
1212
version="1.0.0-alpha.12"
1313
date="March 2026"
1414
changed={[
15+
<>
16+
Rotate now allows you to set any numeric value rather than just <Code>0</Code>, <Code>90</Code>, <Code>180</Code>, or <Code>270</Code>.
17+
</>,
1518
<>
1619
Amicons now only has 1 dependency as we've dropper <Code>html-react-parser</Code>.
1720
</>
1821
]}
22+
fixed={[<>Fixes a bug where variables and classes used the wrong prefix.</>]}
1923
/>
2024
<Release
2125
name="Amicons 1.0 alpha 11"

docs/src/app/Docs/pages/Rotate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function PageRotate() {
1515
label: 'Rotate',
1616
type: 'chip',
1717
name: 'rotate',
18-
values: [0, 90, 180, 270, false],
18+
values: [0, 45, 90, 135, 180, 225, 270, 315, false],
1919
default: 90
2020
}
2121
],
@@ -37,7 +37,7 @@ export default function PageRotate() {
3737
<Stack gap={2}>
3838
<Typography level="h2">Rotate</Typography>
3939
<Typography>
40-
With the <Code>rotate</Code> property you can change the default rotation of your icon.
40+
With the <Code>rotate</Code> property you can change the default rotation of your icon. You can pass any numeric degree value for full flexibility.
4141
</Typography>
4242

4343
<Playground config={playgroundConfig} />

0 commit comments

Comments
 (0)