summaryrefslogtreecommitdiff
path: root/src/components/shared/Modal.module.scss
blob: e4e6af526b8d071c6d7f75cea565545cfc668691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@keyframes overlayShow {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes contentShow {
  from {
    opacity: 0;
    scale: 0.96;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  background: #444;
  z-index: 1024;

  &[data-state='open'] {
    animation: overlayShow 0.2s ease;
  }
}

// Radix 的 Content 是 Overlay 的兄弟节点,需自己定位。
// 这里用独立的 translate / scale 属性而非 transform,避免与各 modal 自带的 transform 冲突。
.content {
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  z-index: 1025;
  max-height: 100vh;
  overflow: auto;
  outline: none;
  color: var(--color-text);
  background: var(--bg-modal);
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);

  &[data-state='open'] {
    animation: contentShow 0.2s ease;
  }
}