|
| 1 | +/* ContentCollapse 折叠功能样式 */ |
| 2 | + |
| 3 | +/* 折叠按钮基础样式 */ |
| 4 | +:global(.collapse-toggle) { |
| 5 | + background: none; |
| 6 | + border: none; |
| 7 | + cursor: pointer; |
| 8 | + padding: 4px; |
| 9 | + margin: 0; |
| 10 | + transition: all 0.25s ease; |
| 11 | + // user-select: none; |
| 12 | + line-height: 1; |
| 13 | + display: inline-flex; |
| 14 | + align-items: center; |
| 15 | + justify-content: center; |
| 16 | + pointer-events: none; /* 按钮本身不响应点击 */ |
| 17 | +} |
| 18 | + |
| 19 | +/* 折叠图标样式 */ |
| 20 | +:global(.collapse-icon) { |
| 21 | + width: 16px; |
| 22 | + height: 16px; |
| 23 | + transition: transform 0.25s ease; |
| 24 | + transform: rotate(90deg); /* 默认向下(展开状态)*/ |
| 25 | + opacity: 0.6; |
| 26 | +} |
| 27 | + |
| 28 | +/* TOC 折叠区域 */ |
| 29 | +:global(.toc-collapse-wrapper) { |
| 30 | + position: relative; |
| 31 | + margin: 16px 0; |
| 32 | + |
| 33 | + :global(.toc-collapse-header.collapsed .toc-collapse-toggle img) { |
| 34 | + transform: rotate(0deg) !important; /* 折叠时向右 */ |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +/* TOC 折叠头部(可点击区域)*/ |
| 39 | +:global(.toc-collapse-header) { |
| 40 | + display: flex; |
| 41 | + align-items: center; |
| 42 | + justify-content: space-between; |
| 43 | + padding: 8px 12px; |
| 44 | + cursor: pointer; |
| 45 | + border-radius: 6px; |
| 46 | + transition: all 0.2s ease; |
| 47 | + // user-select: none; |
| 48 | + background: transparent; |
| 49 | + |
| 50 | + &:hover { |
| 51 | + background: var(--vp-c-bg-soft); |
| 52 | + } |
| 53 | + |
| 54 | + &:global(.collapsed) { |
| 55 | + background: var(--vp-c-bg-soft); |
| 56 | + border: 1px solid var(--vp-c-divider); |
| 57 | + |
| 58 | + &:hover { |
| 59 | + background: var(--vp-c-bg-mute); |
| 60 | + border-color: var(--vp-c-brand-1); |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +/* 折叠标签("目录"文字)*/ |
| 66 | +:global(.collapse-label) { |
| 67 | + font-weight: 600; |
| 68 | + color: var(--vp-c-text-2); |
| 69 | + font-size: 14px; |
| 70 | + display: block; /* 始终显示 */ |
| 71 | +} |
| 72 | + |
| 73 | +/* TOC 折叠按钮 */ |
| 74 | +:global(.toc-collapse-toggle) { |
| 75 | + flex-shrink: 0; |
| 76 | +} |
| 77 | + |
| 78 | +:global(.toc-collapse-header):hover :global(.collapse-icon) { |
| 79 | + opacity: 1; |
| 80 | +} |
| 81 | + |
| 82 | +/* H2 标题需要调整布局以容纳右侧按钮 */ |
| 83 | +/* 只影响带有 collapsible-h2 类的 h2 元素 */ |
| 84 | +:global(h2.collapsible-h2) { |
| 85 | + display: flex !important; |
| 86 | + align-items: center !important; |
| 87 | + justify-content: space-between !important; |
| 88 | + cursor: pointer !important; |
| 89 | + padding: 8px 12px !important; |
| 90 | + border-radius: 6px !important; |
| 91 | + transition: all 0.2s ease !important; |
| 92 | + // user-select: none !important; |
| 93 | + |
| 94 | + &:hover { |
| 95 | + background: var(--vp-c-bg-soft) !important; |
| 96 | + } |
| 97 | + |
| 98 | + &:global(.collapsed) { |
| 99 | + background: var(--vp-c-bg-soft) !important; |
| 100 | + border: 1px solid var(--vp-c-divider) !important; |
| 101 | + margin-top: 1rem !important; |
| 102 | + |
| 103 | + &:hover { |
| 104 | + background: var(--vp-c-bg-mute) !important; |
| 105 | + border-color: var(--vp-c-brand-1) !important; |
| 106 | + } |
| 107 | + |
| 108 | + :global(.collapse-icon) { |
| 109 | + transform: rotate(0deg) !important; /* 折叠时向右 */ |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + &:hover :global(.collapse-icon) { |
| 114 | + opacity: 1 !important; |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +/* H2 折叠按钮样式 */ |
| 119 | +:global(.h2-collapse-toggle) { |
| 120 | + flex-shrink: 0; |
| 121 | + margin-left: 8px; |
| 122 | +} |
| 123 | + |
| 124 | +/* 折叠内容样式 */ |
| 125 | +:global(.collapse-content) { |
| 126 | + overflow: hidden; |
| 127 | + max-height: 10000px; |
| 128 | + opacity: 1; |
| 129 | + transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease; |
| 130 | + |
| 131 | + &:global(.collapsed) { |
| 132 | + max-height: 0 !important; |
| 133 | + opacity: 0 !important; |
| 134 | + margin-top: 0 !important; |
| 135 | + margin-bottom: 0 !important; |
| 136 | + padding-top: 0 !important; |
| 137 | + padding-bottom: 0 !important; |
| 138 | + } |
| 139 | + |
| 140 | + > :first-child { |
| 141 | + margin-top: 0; |
| 142 | + } |
| 143 | + |
| 144 | + > :last-child { |
| 145 | + margin-bottom: 0; |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +/* 折叠按钮旋转动画 */ |
| 150 | +:global(.collapse-toggle) { |
| 151 | + transform-origin: center; |
| 152 | + transition: transform 0.2s ease, color 0.2s ease; |
| 153 | + |
| 154 | + &:global(.collapsed) { |
| 155 | + transform: rotate(0deg); |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +/* 修复 anchor 位置 - 只针对可折叠的 h2 */ |
| 160 | +:global(h2.collapsible-h2) :global(.header-anchor) { |
| 161 | + top: 10px !important; |
| 162 | +} |
0 commit comments