ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.04k stars 1.29k forks source link

ProLayout 新版本欢迎试用 #4741

Closed chenshuai2144 closed 2 years ago

chenshuai2144 commented 2 years ago

查看这里直接访问 https://next-procomponents.ant.design/components/layout

基于 css in js 的方案让我们可以动态的设置布局的主题,以下是支持自定的token 列表。 ​

Token

Token 是一种设计系统的基本元素,可以使用 Token 快速的修改组件库的基础样式。Layout 中可以通过 token 属性来配置这些颜色。

默认的 token

默认的 token 部分来自于 antd,可能会有一些改动,以下是 layout 依赖的部分。

token 说明 默认值
primaryColor 主色 #1677FF
errorColor 错误色 #ff4d4f
successColor 成功色 #52c41a
infoColor 通知色 #1677FF
warningColor 警告色 #faad14
headingColor 标题色 rgba(0, 0, 0, 0.85)
textColor 正文色 rgba(0, 0, 0, 0.65)
textColorSecondary 次级色 rgba(0, 0, 0, 0.45)
borderColorBase 边框基本色 #d9d9d9
borderColorSplit 分隔边框的颜色 rgba(0, 0, 0, 0.06)
borderRadiusBase 默认圆角 4px

Layout 的 token

token 说明 默认值
layoutBgColor layout 的背景颜色 #f0f2f5
appListIconTextColor 跨站点应用的图标颜色 #666
appListIconHoverTextColor 跨站点应用的图标 hover 颜色 rgba(0, 0, 0, 0.65)
appListIconHoverTextColor 跨站点应用的图标 hover 背景颜色 rgba(0, 0, 0, 0.04)

Sider Token

Sider Token 是 侧边菜单的色值,与顶部菜单不同。

token 说明 默认值
menuBackgroundColor menu 的背景颜色 transparent
menuTitleTextColor sider 的标题字体颜色 headingColor
menuItemDividerColor menuItem 分割线的颜色 borderColorSplit
menuSubArrowColor menuItem 的箭头颜色 rgba(0, 0, 0, 0.25)
menuTextColor menuItem 的字体颜色 textColor
menuTextColorSecondary menu 的二级字体颜色,比如 footer 和 action 的 icon textColor
menuSelectedTextColor menuItem 的选中字体颜色 rgb(0,0,0)
menuItemHoverBgColor menuItem 的 hover 背景颜色 rgba(90, 75, 75, 0.03)
menuItemSelectedBgColor menuItem 的选中背景颜色 rgba(0, 0, 0, 0.04)
menuItemCollapsedHoverBgColor 收起 menuItem 的 hover 背景颜色 rgba(0, 145, 255, 0.1)
menuItemCollapsedSelectedBgColor 收起 menuItem 的选中背景颜色 rgba(0, 145, 255, 0.08)
collapsedButtonBgColor 展开收起按钮背景颜色 #fff
collapsedButtonTextColor 展开收起按钮 hover 字体颜色 menuTextColorSecondary
collapsedButtonHoverTextColor 展开收起按钮 hover 时字体颜色 menuTextColor

Header Token

token 说明 默认值
headerTitleColor sider 的标题字体颜色 headingColor
menuTextColor menuItem 的字体颜色 textColor
menuTextColorSecondary menu 的二级字体颜色,比如 footer 和 action 的 icon textColor
menuSelectedTextColor menuItem 的选中字体颜色 rgb(0,0,0)
menuItemHoverBgColor menuItem 的 hover 背景颜色 rgba(90, 75, 75, 0.03)
menuItemSelectedBgColor menuItem 的选中背景颜色 rgba(0, 0, 0, 0.04)
menuItemCollapsedHoverBgColor 收起 menuItem 的 hover 背景颜色 rgba(0, 145, 255, 0.1)
menuItemCollapsedSelectedBgColor 收起 menuItem 的选中背景颜色 rgba(0, 145, 255, 0.08)
rightActionsItemTextColor 右上角字体颜色 textColorSecondary
rightActionsItemHoverBgColor 右上角选中的 hover 颜色 rgba(0, 0, 0, 0.03)

pageContainer Token

token 说明 默认值
pageContainerContentMargin pageContainer 自带的 margin #fff
pageContainerBgColor pageContainer 的背景颜色 transparent
pageContainerFixedBgColor pageContainer 被固定时的背景颜色 #FFF

测试版本暂时包含这部分内容,未来还会增加。

🎏 如何升级到最新版本?

我们可以使用 next 标签来安装最新版本的 ProLayout。 ​

yarn add @ant-design/pro-layout@next
npm i @ant-design/pro-layout@next --save

新版本的 ProLayout 主要是样式上的升级, API 变化不是很大的。 ​

image.png

image.png

image.png

修改的 API 列表

参数 说明 类型 默认值
avatarProps layout 的头像设置,不同的 layout 放在不同的位置 [AvatarProps](https://ant.design/components/avatar-cn/) -
actionsRender 自定义操作列表 (layoutProps)=>ReactNode[] -
appList 跨站点导航列表 { icon, title, desc:, url }[] -

另外此次的最大改变在于样式的重写,减少了 less 的导入,所以样式覆盖的功能需要重新设置。 ​

🙋‍ 反馈给我们

ProLayout 暂时还在测试模式,并且使用了 css in js 的技术,可能会有一些无法覆盖的角落,如果你在使用中碰到了问题,欢迎来给我们报告。 ​

你可以在钉钉群 和 github 中找到我们。 ​

Dunqing commented 2 years ago

Amazing😆

可以在@umijs/plugin-layout中使用吗?

chenshuai2144 commented 2 years ago

可以的, @umijs/plugin-layout 会拿用户package.json 的问题

leshalv commented 2 years ago

PageContainer 区域颜色搭配上会不会太丑了

chenshuai2144 commented 2 years ago

PageContainer 区域颜色搭配上会不会太丑了

做了 token 可以配置,设计师是想让主要内容更吸引注意力

aikin-vip commented 2 years ago

有没有一个在线预览的新版本呢

Dunqing commented 2 years ago

有没有一个在线预览的新版本呢

这里看 https://pro-components-preview-pr-4734.surge.sh/components/layout

相关pr: https://github.com/ant-design/pro-components/pull/4734#issuecomment-1053603616

XuJin186 commented 2 years ago

PageContainer 区域颜色搭配上会不会太丑了

的确是不好看

lukezzz commented 2 years ago

token headerBgColor 设置无效, header background始终为transparent

chenshuai2144 commented 2 years ago

token headerBgColor 设置无效, header background始终为transparent

升级一下最新的版本。

lukezzz commented 2 years ago

升级一下最新的版本。

升级了下到7.0.1-beta.2,设置 headerBgColor还是无效

leshalv commented 2 years ago

pro 大概什么时候换上呀? @chenshuai2144

chenshuai2144 commented 2 years ago

@leshalv 要等antd的新版本发布了

wangxin305 commented 2 years ago

菜单没有选中效果了 https://6237lu.csb.app/?layout=mix&splitMenus=true

chenshuai2144 commented 2 years ago

菜单没有选中效果了 https://6237lu.csb.app/?layout=mix&splitMenus=true

网站上看起来没问题,你有复现吗

Dunqing commented 2 years ago

https://user-images.githubusercontent.com/29533304/157648258-2601fe28-2f3e-489b-a6ba-12b74ed05ee3.mp4

看起来是一个bug

收起后打开闪了一下

wangxin305 commented 2 years ago
image

我打就是这样的,切换菜单,没有选中效果

strongyc commented 2 years ago

页面无法预览啊,加载很慢

IvenBao commented 2 years ago

能升级一下reactrouter吗?routerv6支持一下呗

chenshuai2144 commented 2 years ago

能升级一下reactrouter吗?routerv6支持一下呗

这个去看看新版本umi

IvenBao commented 2 years ago

能升级一下reactrouter吗?routerv6支持一下呗

这个去看看新版本umi

好的,谢谢

IvenBao commented 2 years ago

image 这个ProLayout中的BaseMenu中用到了这个originalTitle,但是react报了 未知props的警告

leshalv commented 2 years ago

DefaultFooter 样式啥的还没处理吧。

leshalv commented 2 years ago

新版嵌套布局的话,后期是不是可以通过pro-layout插件是不是就可以轻松实现了?

kaoding commented 2 years ago

新版本 pro-layout 要等 antd v5 和 umi 4 才能体现效果

chenshuai2144 commented 2 years ago

@leshalv 会有解决方案。

tankpanv commented 2 years ago

你好,我在移动端点击菜单之后,菜单不会自动收回去。我尝试使用menu的autoClose参数,但是不生效。不知道这个有什么解决方案。 image

image