Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Menu): add menu collapse animation #3342

Merged
merged 5 commits into from
Feb 6, 2025

Conversation

hd10180
Copy link
Contributor

@hd10180 hd10180 commented Jan 22, 2025

menu collapse animation

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

此 pr 来自 #2382 ,给 menu 增加折叠动画,感谢 @xiaosansiji 的贡献
重新创建 pr 的原因是我查看了下原对话并没发现关闭的原因是什么,如有任何问题劳烦关闭本 pr

💡 需求背景和解决方案

现阶段的 menu 实现展开折叠没有动画,此 pr 增加了折叠动画,效果与Tencent/tdesign-vue-next#3140 一致

📝 更新日志

  • feat(Menu): 菜单增加折叠动画效果

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

Copy link
Contributor

github-actions bot commented Jan 23, 2025

完成

src/menu/SubMenu.tsx Outdated Show resolved Hide resolved
src/menu/SubMenu.tsx Outdated Show resolved Hide resolved
@uyarn
Copy link
Collaborator

uyarn commented Feb 6, 2025

尝试直接在ui节点上做动画
Submenu.tsx

const transitionCallbacks = {
    onEnter: () => {
      contentRef.current.style.height = `${contentRef?.current.scrollHeight}px`;
    },
    onEntered: () => {
      contentRef.current.style.height = 'auto';
    },
    onExit: () => {
      contentRef.current.style.height = `${contentRef?.current.scrollHeight}px`;
    },
    onExiting: () => {
      contentRef.current.style.height = '0px';
    },
  };

 <CSSTransition in={isOpen} appear timeout={300} nodeRef={contentRef} {...transitionCallbacks}>
          <ul
            key="normal"
            style={
              {
                ...childStyle,
                '--padding-left': `${menuPaddingLeft}px`,
                overflow: 'hidden',
              } as React.CSSProperties
            }
            className={classNames(`${classPrefix}-menu__sub`, `${classPrefix}-slide-down-enter-active`)}
            ref={contentRef}
          >
            {childrens}
          </ul>
        </CSSTransition>

global.less

.@{prefix}-slide-down-enter-active,
.@{prefix}-slide-down-leave-active {
  transition: height @anim-duration-base @anim-time-fn-easing, max-height @anim-duration-base @anim-time-fn-easing;
}

add menu collapse animation
@hd10180
Copy link
Contributor Author

hd10180 commented Feb 6, 2025

global.less

.@{prefix}-slide-down-enter-active,
.@{prefix}-slide-down-leave-active {
  transition: height @anim-duration-base @anim-time-fn-easing, max-height @anim-duration-base @anim-time-fn-easing;
}

请问这部分修改在src/_common/style/web/_global.less后如何提交

@uyarn
Copy link
Collaborator

uyarn commented Feb 6, 2025

可以直接修改 https://github.com/Tencent/tdesign-common/edit/develop/style/web/_global.less 然后提交PR,合并common PR 后触发流水线更新下当前PR的common指向就可以
image

@uyarn
Copy link
Collaborator

uyarn commented Feb 6, 2025

/update-common

@uyarn uyarn changed the title refactor(menu): menu collapse animation feat(Menu): add menu collapse animation Feb 6, 2025
src/menu/SubMenu.tsx Show resolved Hide resolved
@uyarn uyarn merged commit 6f18786 into Tencent:develop Feb 6, 2025
7 checks passed
@uyarn
Copy link
Collaborator

uyarn commented Feb 6, 2025

Thanks for your contributions 🌹

@hd10180 hd10180 deleted the refact/menu-collapse-animation branch February 6, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants