@opencompass-fe/oc-webkit-eval 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t,{useState as b,useRef as q,useEffect as g}from"react";import p from"classnames";import{langTypeEnum as X}from"../../constants/enums.js";import k from"../../assets/svg/top-nav/arena-flag.svg.js";import A from"../../assets/svg/top-nav/arrow-up.svg.js";import j from"../../assets/svg/top-nav/logo-mark.svg.js";import G from"../../assets/svg/top-nav/logo-word.svg.js";import J from"../../assets/svg/top-nav/nav-down.svg.js";import{Dropdown as P}from"antd";import n from"./top-nav.module.less.js";import{useTopNavCommon as Q,IconBox as v,renderDropdownContent as V,renderUserAvatar as ee}from"./shared.js";const ne=x=>{const{brandHref:C,locale:w,onToggleLocale:z,onArenaClick:E,navItems:h,arenaLabel:N,userInfo:D,onAvatarClick:_,userMenuItems:B,locales:m,triggerLogin:F,performLogout:H,isLoggedIn:f,hasUserMenu:R}=Q(x),T=e=>{var r,a,o,l,s,c;return w===X.en?(o=(a=(r=e.labelEn)!=null?r:e.label)!=null?a:e.labelZh)!=null?o:"":(c=(s=(l=e.labelZh)!=null?l:e.label)!=null?s:e.labelEn)!=null?c:""},M=(e,r)=>{var a,o,l,s,c;return(c=(s=(l=(o=(a=e.key)!=null?a:e.href)!=null?o:e.label)!=null?l:e.labelZh)!=null?s:e.labelEn)!=null?c:`nav-${r}`},[d,W]=b(!1),[u,Y]=b(()=>window.innerWidth>860),y=q(null),[I,$]=b(0),O=d&&u?{height:"52px",padding:"8px",backgroundColor:"var(--oc-white)",borderColor:"rgba(226, 227, 228, 1)",boxShadow:"0 4px 10px rgba(0, 0, 0, 0.15)",transform:"translateX(-50%) translateY(6px)"}:void 0,U=d&&u&&I>0?{"--oc-nav-half-width":`${I}px`}:void 0,i=d&&u,Z=i?{pointerEvents:"none",opacity:0,transform:"translateY(-8px) scale(0.96)"}:void 0,K=i?{pointerEvents:"auto",opacity:1}:void 0;g(()=>{let e=0,r=-1;const a=()=>{if(e=0,window.scrollY===r)return;r=window.scrollY;const s=window.scrollY>24;W(c=>c===s?c:s)},o=()=>{e===0&&(e=window.requestAnimationFrame(a))};a(),window.addEventListener("scroll",o,{passive:!0});const l=window.setInterval(a,120);return()=>{window.removeEventListener("scroll",o),window.clearInterval(l),e!==0&&window.cancelAnimationFrame(e)}},[]),g(()=>{const e=()=>Y(window.innerWidth>860);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),g(()=>{const e=y.current;if(!e||!u)return;const r=()=>{$(e.getBoundingClientRect().width/2)};r();const a=new ResizeObserver(r);return a.observe(e),window.addEventListener("resize",r),()=>{a.disconnect(),window.removeEventListener("resize",r)}},[u,d,w,h]);const L=e=>V({items:e,locale:w,performLogout:H,styles:n}),S=e=>ee({customDropdownRender:L,dropdownTrigger:["hover"],extra:e,hasUserMenu:R,isLoggedIn:f,onAvatarClick:_,styles:n,userInfo:D,userMenuItems:B});return t.createElement("header",{className:p(n.topbar,d&&n.scrolled),style:U},t.createElement("a",{className:n.brand,href:C,"aria-label":m.topNavBrandAria},t.createElement("img",{className:n.brandMark,src:j,alt:""}),t.createElement("img",{className:n.brandWord,src:G,alt:m.topNavBrandName})),t.createElement("nav",{ref:y,className:p(n.nav,d&&n.navScrolled),"aria-label":m.topNavNavAria,style:O},h.map((e,r)=>{const a=M(e,r),o=T(e),l=t.createElement("div",{className:p(n.navLink,e.active&&n.navLinkActive,e.withDown&&n.withDown)},t.createElement("span",null,o),e.withDown?t.createElement(v,{src:J,size:16,styles:n}):null);return!!e.dropdownItems&&e.dropdownItems.length>0?t.createElement(P,{key:a,trigger:["hover"],popupRender:()=>L(e.dropdownItems),placement:"bottom",styles:{root:{paddingTop:8}}},l):t.createElement(t.Fragment,{key:a},l)})),t.createElement("div",{className:n.actions,style:Z,"aria-hidden":i},t.createElement("button",{className:n.arenaButton,type:"button",onClick:E},t.createElement(v,{src:k,size:16,className:n.arenaIconDefault,styles:n}),t.createElement(v,{src:A,size:16,className:n.arenaIconHover,styles:n}),t.createElement("span",null,N)),t.createElement("button",{className:n.langButton,type:"button",onClick:z},m.topNavLangSwitch),f?S():t.createElement("button",{className:n.loginButton,type:"button",onClick:F},m.login)),t.createElement("div",{className:p(n.floatingArena,i&&n.visible),style:K,"aria-hidden":!i},t.createElement("button",{className:n.floatingArenaButton,type:"button",tabIndex:i?0:-1,onClick:E},t.createElement(v,{src:k,size:16,className:n.arenaIconDefault,styles:n}),t.createElement(v,{src:A,size:16,className:n.arenaIconHover,styles:n}),t.createElement("span",null,N)),f?S({className:n.floatingAvatar,tabIndex:i?0:-1}):null))};export{ne as default};
|
|
@@ -19,7 +19,7 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
19
19
|
top: 0;
|
|
20
20
|
z-index: 20;
|
|
21
21
|
display: grid;
|
|
22
|
-
grid-template-columns: 218px minmax(
|
|
22
|
+
grid-template-columns: 218px minmax(360px, 1fr) auto;
|
|
23
23
|
align-items: center;
|
|
24
24
|
width: 100%;
|
|
25
25
|
height: 64px;
|
|
@@ -64,7 +64,6 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
64
64
|
transform: translateY(-8px) scale(0.96);
|
|
65
65
|
}
|
|
66
66
|
.top-nav-module_topbar__M-9LM.top-nav-module_scrolled__0c7O- .top-nav-module_nav__CNENL.top-nav-module_navScrolled__0VNTc {
|
|
67
|
-
--oc-nav-width: 448px;
|
|
68
67
|
--oc-nav-height: 52px;
|
|
69
68
|
--oc-nav-padding: 8px;
|
|
70
69
|
--oc-nav-background: var(--oc-white);
|
|
@@ -104,7 +103,8 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
104
103
|
align-items: center;
|
|
105
104
|
justify-self: center;
|
|
106
105
|
justify-content: center;
|
|
107
|
-
width:
|
|
106
|
+
width: fit-content;
|
|
107
|
+
max-width: calc(100vw - 280px);
|
|
108
108
|
height: var(--oc-nav-height, 36px);
|
|
109
109
|
padding: var(--oc-nav-padding, 0);
|
|
110
110
|
background-color: var(--oc-nav-background, rgba(255, 255, 255, 0));
|
|
@@ -155,7 +155,7 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
155
155
|
gap: 8px;
|
|
156
156
|
align-items: center;
|
|
157
157
|
justify-self: end;
|
|
158
|
-
width:
|
|
158
|
+
width: fit-content;
|
|
159
159
|
height: 40px;
|
|
160
160
|
padding: 0;
|
|
161
161
|
background-color: rgba(255, 255, 255, 0);
|
|
@@ -167,6 +167,7 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
167
167
|
}
|
|
168
168
|
.top-nav-module_topbar__M-9LM .top-nav-module_actions__NeiZP .top-nav-module_arenaButton__uYjCi {
|
|
169
169
|
display: inline-flex;
|
|
170
|
+
flex-shrink: 0;
|
|
170
171
|
gap: 2px;
|
|
171
172
|
align-items: center;
|
|
172
173
|
justify-content: center;
|
|
@@ -202,20 +203,22 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
202
203
|
white-space: nowrap;
|
|
203
204
|
}
|
|
204
205
|
.top-nav-module_topbar__M-9LM .top-nav-module_actions__NeiZP .top-nav-module_langButton__6jlyg {
|
|
205
|
-
|
|
206
|
-
height:
|
|
206
|
+
flex-shrink: 0;
|
|
207
|
+
height: 36px;
|
|
208
|
+
padding: 8px 12px;
|
|
207
209
|
color: var(--oc-text-secondary);
|
|
208
210
|
border-radius: var(--oc-radius-md);
|
|
209
211
|
font-size: 14px;
|
|
210
212
|
font-weight: 400;
|
|
211
213
|
line-height: 20px;
|
|
212
214
|
white-space: nowrap;
|
|
213
|
-
transition:
|
|
215
|
+
transition: padding 240ms ease, opacity 180ms ease, background-color 220ms ease, transform 220ms ease;
|
|
214
216
|
}
|
|
215
217
|
.top-nav-module_topbar__M-9LM .top-nav-module_actions__NeiZP .top-nav-module_langButton__6jlyg:hover {
|
|
216
218
|
background-color: var(--oc-fill-bg-hover);
|
|
217
219
|
}
|
|
218
220
|
.top-nav-module_topbar__M-9LM .top-nav-module_actions__NeiZP .top-nav-module_loginButton__rTUW2 {
|
|
221
|
+
flex-shrink: 0;
|
|
219
222
|
height: 36px;
|
|
220
223
|
padding: 8px 20px;
|
|
221
224
|
color: var(--oc-white);
|
|
@@ -267,7 +270,7 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
267
270
|
.top-nav-module_topbar__M-9LM .top-nav-module_floatingArena__SzJGl {
|
|
268
271
|
position: fixed;
|
|
269
272
|
top: 20px;
|
|
270
|
-
left: calc(50vw +
|
|
273
|
+
left: calc(50vw + var(--oc-nav-half-width, 0px) + 8px);
|
|
271
274
|
z-index: 22;
|
|
272
275
|
display: flex;
|
|
273
276
|
gap: 8px;
|
|
@@ -345,7 +348,7 @@ import n from"../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inj
|
|
|
345
348
|
}
|
|
346
349
|
@media (max-width: 1180px) {
|
|
347
350
|
.top-nav-module_topbar__M-9LM {
|
|
348
|
-
grid-template-columns: 160px minmax(
|
|
351
|
+
grid-template-columns: 160px minmax(320px, 1fr) auto;
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
@media (max-width: 860px) {
|
|
@@ -70,10 +70,14 @@ import n from"../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-
|
|
|
70
70
|
gap: 12px;
|
|
71
71
|
}
|
|
72
72
|
.top-nav-module_topbar__0kHYG .top-nav-module_actions__b0CA9 .top-nav-module_langButton__ciwEY {
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
height: 32px;
|
|
75
|
+
padding: 0 8px;
|
|
73
76
|
color: var(--oc-text-secondary);
|
|
74
77
|
font-size: 14px;
|
|
75
78
|
font-weight: 400;
|
|
76
79
|
line-height: 20px;
|
|
80
|
+
white-space: nowrap;
|
|
77
81
|
}
|
|
78
82
|
.top-nav-module_topbar__0kHYG .top-nav-module_actions__b0CA9 .top-nav-module_loginButton__bWyfr {
|
|
79
83
|
height: 32px;
|