Skip to content

Commit 38196d8

Browse files
zombieJclaude
andcommitted
refactor: use Less mixin for placement-specific styles
- Add generate-placement mixin to reduce code duplication - Support topRight, bottomRight, topLeft, bottomLeft placements - Move motion and clip-path styles into placement-specific scopes - Remove hardcoded top/right positioning from container Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 362793d commit 38196d8

1 file changed

Lines changed: 91 additions & 39 deletions

File tree

assets/geek.less

Lines changed: 91 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,66 @@
44
@notificationMotionEase: cubic-bezier(0.22, 1, 0.36, 1);
55
@notificationMotionOffset: 64px;
66

7+
.generate-placement(@placement, @vertical, @horizontal, @contentMargin, @stackClip, @motionX) {
8+
&-@{placement} {
9+
@{vertical}: 0;
10+
@{horizontal}: 0;
11+
display: flex;
12+
flex-direction: column;
13+
14+
.@{notificationPrefixCls}-list-content {
15+
@{contentMargin}: auto;
16+
}
17+
18+
.@{notificationPrefixCls}-notice {
19+
@{vertical}: var(--notification-y, 0);
20+
@{horizontal}: var(--notification-x, 0);
21+
transform-origin: center bottom;
22+
}
23+
24+
.notification-fade-appear-prepare,
25+
.notification-fade-enter-prepare {
26+
opacity: 0;
27+
transform: translateX(@motionX) scale(var(--notification-scale, 1));
28+
transition: none;
29+
}
30+
31+
.notification-fade-appear-start,
32+
.notification-fade-enter-start {
33+
opacity: 0;
34+
transform: translateX(@motionX) scale(var(--notification-scale, 1));
35+
}
36+
37+
.notification-fade-appear-active,
38+
.notification-fade-enter-active {
39+
opacity: 1;
40+
transform: translateX(0) scale(var(--notification-scale, 1));
41+
}
42+
43+
.notification-fade-leave-start {
44+
opacity: 1;
45+
transform: translateX(0) scale(var(--notification-scale, 1));
46+
}
47+
48+
.notification-fade-leave-active {
49+
opacity: 0;
50+
transform: translateX(@motionX) scale(var(--notification-scale, 1));
51+
}
52+
53+
&.@{notificationPrefixCls}-stack:not(.@{notificationPrefixCls}-stack-expanded) {
54+
.@{notificationPrefixCls}-notice {
55+
clip-path: @stackClip;
56+
}
57+
58+
.@{notificationPrefixCls}-notice[data-notification-index='0'] {
59+
clip-path: inset(-50% -50% -50% -50%);
60+
}
61+
}
62+
}
63+
}
64+
765
.@{notificationPrefixCls} {
866
position: fixed;
9-
top: 0;
10-
right: 0;
1167
z-index: 1000;
1268
width: 360px;
1369
height: 100vh;
@@ -17,6 +73,39 @@
1773
overflow: hidden;
1874
overscroll-behavior: contain;
1975

76+
.generate-placement(
77+
topRight,
78+
top,
79+
right,
80+
margin-bottom,
81+
inset(50% -50% -50% -50%),
82+
@notificationMotionOffset
83+
);
84+
.generate-placement(
85+
bottomRight,
86+
bottom,
87+
right,
88+
margin-top,
89+
inset(-50% -50% 50% -50%),
90+
@notificationMotionOffset
91+
);
92+
.generate-placement(
93+
topLeft,
94+
top,
95+
left,
96+
margin-bottom,
97+
inset(50% -50% -50% -50%),
98+
-@notificationMotionOffset
99+
);
100+
.generate-placement(
101+
bottomLeft,
102+
bottom,
103+
left,
104+
margin-top,
105+
inset(-50% -50% 50% -50%),
106+
-@notificationMotionOffset
107+
);
108+
20109
&-list {
21110
overflow-x: hidden;
22111
overflow-y: auto;
@@ -64,15 +153,12 @@
64153
box-sizing: border-box;
65154
width: 100%;
66155
// transform: translate3d(var(--notification-x, 0), var(--notification-y, 0), 0);
67-
right: var(--notification-x, 0);
68-
top: var(--notification-y, 0);
69156
transform: scale(var(--notification-scale, 1));
70157
transition:
71158
transform @notificationMotionDuration @notificationMotionEase,
72159
inset @notificationMotionDuration @notificationMotionEase,
73160
clip-path @notificationMotionDuration @notificationMotionEase,
74161
opacity @notificationMotionDuration @notificationMotionEase;
75-
transform-origin: center bottom;
76162
padding: 14px 16px;
77163
border: 2px solid #111;
78164
border-radius: 14px;
@@ -123,11 +209,6 @@
123209
&:not(.@{notificationPrefixCls}-stack-expanded) {
124210
.@{notificationPrefixCls}-notice {
125211
--notification-scale: ~'calc(1 - min(var(--notification-index, 0), 2) * 0.06)';
126-
clip-path: inset(50% -50% -50% -50%);
127-
}
128-
129-
.@{notificationPrefixCls}-notice[data-notification-index='0'] {
130-
clip-path: inset(-50% -50% -50% -50%);
131212
}
132213

133214
.@{notificationPrefixCls}-notice:not(.@{notificationPrefixCls}-notice-stack-in-threshold) {
@@ -142,32 +223,3 @@
142223
backface-visibility: hidden;
143224
will-change: transform, opacity;
144225
}
145-
146-
.notification-fade-appear-prepare,
147-
.notification-fade-enter-prepare {
148-
opacity: 0;
149-
transform: translateX(@notificationMotionOffset) scale(var(--notification-scale, 1));
150-
transition: none;
151-
}
152-
153-
.notification-fade-appear-start,
154-
.notification-fade-enter-start {
155-
opacity: 0;
156-
transform: translateX(@notificationMotionOffset) scale(var(--notification-scale, 1));
157-
}
158-
159-
.notification-fade-appear-active,
160-
.notification-fade-enter-active {
161-
opacity: 1;
162-
transform: translateX(0) scale(var(--notification-scale, 1));
163-
}
164-
165-
.notification-fade-leave-start {
166-
opacity: 1;
167-
transform: translateX(0) scale(var(--notification-scale, 1));
168-
}
169-
170-
.notification-fade-leave-active {
171-
opacity: 0;
172-
transform: translateX(@notificationMotionOffset) scale(var(--notification-scale, 1));
173-
}

0 commit comments

Comments
 (0)