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: 为导航栏使用 nav-link style 的弹窗增加更多的对齐样式 #4365

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions registry/lib/components/style/custom-navbar/_nav-link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
border-bottom: 2px solid transparent;
font-size: 15px;
line-height: normal;

&::before {
content: "";
content: '';
position: absolute;
top: calc(100% - 4px);
left: 8px;
Expand All @@ -18,7 +19,23 @@
transition: 0.16s 0.1s ease-out;
transform: scaleX(0);
}

&:hover::before {
transform: scaleX(1);
}
}

html[data-navbar-link-popup-content-align-style='left'] &,
&.left {
justify-content: flex-start;
}

html[data-navbar-link-popup-content-align-style='center'] &,
&.center {
justify-content: center;
}

html[data-navbar-link-popup-content-align-style='right'] &,
&.right {
justify-content: flex-end;
}
}
2 changes: 2 additions & 0 deletions registry/lib/components/style/custom-navbar/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ComponentEntry } from '@/components/types'
import { addComponentListener } from '@/core/settings'
import { isIframe, isNotHtml, matchUrlPattern, mountVueComponent } from '@/core/utils'
import { setupNotifyStyle } from './notify-style'
import { setupLinkPopupContentAlignStyle } from './link-popup-content-align-style'

export const entry: ComponentEntry = async ({ metadata: { name } }) => {
// const url = document.URL.replace(location.search, '')
Expand Down Expand Up @@ -52,4 +53,5 @@ export const entry: ComponentEntry = async ({ metadata: { name } }) => {
addComponentListener(`${name}.${style}`, value => customNavbar.toggleStyle(value, style), true)
})
setupNotifyStyle()
setupLinkPopupContentAlignStyle()
}
6 changes: 6 additions & 0 deletions registry/lib/components/style/custom-navbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { urlInclude, urlExclude } from './urls'
import { entry } from './entry'
import { getNumberValidator } from '@/core/utils'
import { NavbarNotifyStyle } from './notify-style'
import { NavbarLinkPopupContentAlignStyle } from './link-popup-content-align-style'

const styleID = 'custom-navbar-style'
const options = defineOptionsMetadata({
Expand Down Expand Up @@ -91,6 +92,11 @@ const options = defineOptionsMetadata({
dropdownEnum: NavbarNotifyStyle,
displayName: '消息提醒样式',
},
linkPopupContentAlignStyle: {
defaultValue: NavbarLinkPopupContentAlignStyle.Left,
dropdownEnum: NavbarLinkPopupContentAlignStyle,
displayName: '仅包含链接的导航栏弹窗文字对齐样式',
Tinhone marked this conversation as resolved.
Show resolved Hide resolved
},
searchBarWidth: {
defaultValue: 15,
slider: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { addComponentListener } from '@/core/settings'

export enum NavbarLinkPopupContentAlignStyle {
Left = '左侧对齐',
Center = '居中对齐',
Right = '右侧对齐',
}

export const setupLinkPopupContentAlignStyle = () => {
const map = {
[NavbarLinkPopupContentAlignStyle.Left]: 'left',
[NavbarLinkPopupContentAlignStyle.Center]: 'center',
[NavbarLinkPopupContentAlignStyle.Right]: 'right',
}
addComponentListener(
'customNavbar.linkPopupContentAlignStyle',
(value: NavbarLinkPopupContentAlignStyle) => {
document.documentElement.setAttribute(
'data-navbar-link-popup-content-align-style',
map[value],
)
},
true,
)
}
Loading