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(page-header): support rtl #1154

Merged
merged 88 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
ea64917
feat:n-input Support hidden password
doom-9 Jun 17, 2021
149d8e6
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 17, 2021
8664169
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 18, 2021
0627777
feat(form): support require-mark-placement(#171)
doom-9 Jun 18, 2021
f9729c8
Revert "feat(form): support require-mark-placement(#171)"
doom-9 Jun 18, 2021
2566db7
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 18, 2021
aa41027
Revert "feat:n-input Support hidden password"
doom-9 Jun 18, 2021
3f01195
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 18, 2021
076c432
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 21, 2021
2307ef8
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 21, 2021
d4f08f8
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 21, 2021
56f6d75
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 22, 2021
658835d
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 22, 2021
3d90083
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 22, 2021
1e860cc
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 23, 2021
c1c7942
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 23, 2021
0cb198e
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 24, 2021
71ad4cd
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 24, 2021
cd8476a
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 25, 2021
ac74273
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 26, 2021
e685823
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 28, 2021
2a450f1
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 28, 2021
b02f5f8
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 29, 2021
4f151e7
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 29, 2021
b8cf341
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 29, 2021
c7fa132
Merge branch 'TuSimple:main' into main
doom-9-zz Jun 30, 2021
d7348e6
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 1, 2021
c504c72
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 1, 2021
c14f943
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 1, 2021
23da897
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 2, 2021
eb86273
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 2, 2021
ba7fdda
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 2, 2021
51430c2
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 3, 2021
f25cbf3
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 3, 2021
bfdf90f
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 3, 2021
36939e1
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 4, 2021
244ea96
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 4, 2021
a445262
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 5, 2021
43a5740
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 5, 2021
8c53a25
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 5, 2021
bdddc47
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 6, 2021
c4b7311
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 6, 2021
3ac6a8a
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 7, 2021
9c59190
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 8, 2021
988f21f
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 8, 2021
f6a3a9c
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 9, 2021
c1e42a7
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 10, 2021
4e65da9
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 11, 2021
bd7b76c
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 12, 2021
22576d3
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 13, 2021
a3e4ecb
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 15, 2021
89b4729
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 16, 2021
c603d61
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 17, 2021
4536c5a
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 22, 2021
b9b72a4
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 24, 2021
69ef0b6
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 26, 2021
2f3f242
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 27, 2021
cde10b4
Merge branch 'TuSimple:main' into main
doom-9-zz Jul 30, 2021
3d370f7
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 2, 2021
182f166
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 3, 2021
b9ac1d9
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 8, 2021
a77df05
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 9, 2021
59de411
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 10, 2021
1d21533
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 11, 2021
ae2e706
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 12, 2021
4a93636
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 13, 2021
f5f59c5
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 16, 2021
de2aa61
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 18, 2021
e9c17d4
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 20, 2021
4b88be4
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 21, 2021
ddb72e0
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 23, 2021
2fc986b
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 25, 2021
80a016c
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 26, 2021
d2afcd9
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 30, 2021
a1ebf69
Merge branch 'TuSimple:main' into main
doom-9-zz Aug 31, 2021
98c953c
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 1, 2021
2c759c4
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 2, 2021
ede7006
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 3, 2021
d49332c
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 4, 2021
4849399
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 6, 2021
2cab16e
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 9, 2021
2a54fd7
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 10, 2021
f302028
Merge branch 'TuSimple:main' into main
doom-9-zz Sep 12, 2021
7a58c3f
feat(page-header): support rtl
doom-9 Sep 10, 2021
5b0a328
add en demo
doom-9 Sep 10, 2021
7a0beac
fix code
doom-9 Sep 12, 2021
c4f04f8
fix code
doom-9 Sep 12, 2021
72f43be
fix code
doom-9 Sep 12, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- `n-config-provider` add global config of the `Empty` component, closes [#1092](https://github.com/TuSimple/naive-ui/issues/1092).
- `n-select` add `on-update:show` prop.
- `n-auto-complete` exports `AutoCompleteOption` and `AutoCompleteGroupOption` types.
- `n-page-header` add `RTL` support.

### Fixes

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- `n-config-provider` 新增 `Empty` 组件的全局配置,关闭 [#1092](https://github.com/TuSimple/naive-ui/issues/1092)
- `n-select` 新增 `on-update:show` 属性
- `n-auto-complete` 导出 `AutoCompleteOption` 以及 `AutoCompleteGroupOption` 类型
- `n-page-header` 添加 `RTL` 支持

### Fixes

Expand Down
1 change: 1 addition & 0 deletions src/page-header/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

```demo
basic
rtl-debug
```

## Props
Expand Down
93 changes: 93 additions & 0 deletions src/page-header/demos/zhCN/rtl-debug.demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Rtl Debug

```html
<n-space vertical>
<n-space><n-switch v-model:value="rtlEnabled" />Rtl</n-space>
<n-config-provider :rtl="rtlEnabled ? rtlStyles : undefined">
<n-page-header subtitle="让你的听觉更懂视觉" @back="handleBack">
<n-grid :cols="5">
<n-gi>
<n-statistic label="正片" value="125 集" />
</n-gi>
<n-gi>
<n-statistic label="嘉宾" value="22 位" />
</n-gi>
<n-gi>
<n-statistic label="道歉" value="36 次" />
</n-gi>
<n-gi>
<n-statistic label="话题" value="83 个" />
</n-gi>
<n-gi>
<n-statistic label="参考链接" value="2,346 个" />
</n-gi>
</n-grid>
<template #title>
<a
href="https://anyway.fm/"
style="text-decoration: none; color: inherit;"
>Anyway.FM</a
>
</template>
<template #header>
<n-breadcrumb>
<n-breadcrumb-item>播客</n-breadcrumb-item>
<n-breadcrumb-item>精选</n-breadcrumb-item>
<n-breadcrumb-item>超级精选</n-breadcrumb-item>
<n-breadcrumb-item>Anyway.FM</n-breadcrumb-item>
</n-breadcrumb>
</template>
<template #avatar>
<n-avatar
src="https://cdnimg103.lizhi.fm/user/2017/02/04/2583325032200238082_160x160.jpg"
/>
</template>
<template #extra>
<n-space>
<n-button>催更</n-button>
<n-dropdown :options="options" placement="bottom-start">
<n-button :bordered="false" style="padding: 0 4px">···</n-button>
</n-dropdown>
</n-space>
</template>
<template #footer>截止到 2021 年 4 月 3 日</template>
</n-page-header>
</n-config-provider>
</n-space>
```

```js
import { EllipsisHorizontal } from '@vicons/ionicons5'
import { defineComponent, ref } from 'vue'
import { unstablePageHeaderRtl, useMessage } from 'naive-ui'

export default defineComponent({
components: {
EllipsisHorizontal
},
setup () {
const message = useMessage()
return {
rtlEnabled: ref(false),
rtlStyles: [unstablePageHeaderRtl],
handleBack () {
message.info('[onBack]')
},
options: [
{
label: '催更',
key: '1'
},
{
label: '催更',
key: '2'
},
{
label: '催更',
key: '3'
}
]
}
}
})
```
29 changes: 18 additions & 11 deletions src/page-header/src/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import style from './styles/index.cssr'
import { ArrowBackIcon } from '../../_internal/icons'
import { NBaseIcon } from '../../_internal'
import type { ExtractPublicPropTypes } from '../../_utils'
import useRtl from '../../_mixins/use-rtl'

const pageHeaderProps = {
...(useTheme.props as ThemeProps<PageHeaderTheme>),
Expand All @@ -23,7 +24,7 @@ export default defineComponent({
name: 'PageHeader',
props: pageHeaderProps,
setup (props) {
const { mergedClsPrefixRef } = useConfig(props)
const { mergedClsPrefixRef, NConfigProvider } = useConfig(props)
const themeRef = useTheme(
'PageHeader',
'PageHeader',
Expand All @@ -32,7 +33,14 @@ export default defineComponent({
props,
mergedClsPrefixRef
)
const rtlEnabledRef = useRtl(
'PageHeader',
NConfigProvider?.mergedRtlRef,
mergedClsPrefixRef
)

return {
rtlEnabled: rtlEnabledRef,
mergedClsPrefix: mergedClsPrefixRef,
cssVars: computed(() => {
const {
Expand Down Expand Up @@ -65,15 +73,8 @@ export default defineComponent({
}
},
render () {
const {
onBack,
title,
subtitle,
extra,
mergedClsPrefix,
cssVars,
$slots
} = this
const { onBack, title, subtitle, extra, mergedClsPrefix, cssVars, $slots } =
this
const {
title: titleSlot,
subtitle: subtitleSlot,
Expand All @@ -88,7 +89,13 @@ export default defineComponent({
const showSubtitle = subtitle || subtitleSlot
const showExtra = extra || extraSlot
return (
<div style={cssVars as CSSProperties}>
<div
style={cssVars as CSSProperties}
class={[
`${mergedClsPrefix}-page-header-wrapper`,
this.rtlEnabled && `${mergedClsPrefix}-page-header-wrapper--rtl`
]}
>
{headerSlot ? (
<div class={`${mergedClsPrefix}-page-header-header`} key="breadcrumn">
{headerSlot()}
Expand Down
20 changes: 20 additions & 0 deletions src/page-header/src/styles/page-header-rtl.cssr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { c, cB, cM } from '../../../_utils/cssr'

export default c([
cB('page-header-wrapper', [
cM('rtl', [
cB('page-header-header', `
direction: rtl;
`),
cB('page-header', `
direction: rtl;
`),
cB('page-header-content', `
direction: rtl;
`),
cB('page-header-footer', `
direction: rtl;
`)
])
])
])
1 change: 1 addition & 0 deletions src/page-header/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { pageHeaderLight } from './light'
export type { PageHeaderTheme, PageHeaderThemeVars } from './light'
export { pageHeaderDark } from './dark'
export { default as pageHeaderRtl } from './rtl'
6 changes: 6 additions & 0 deletions src/page-header/styles/rtl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import rtlStyle from '../src/styles/page-header-rtl.cssr'

export default {
name: 'PageHeader',
style: rtlStyle
}
1 change: 1 addition & 0 deletions src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { messageDark } from './message/styles'
export { modalDark } from './modal/styles'
export { notificationDark } from './notification/styles'
export { paginationDark } from './pagination/styles'
export { pageHeaderRtl as unstablePageHeaderRtl } from './page-header/styles'
export { popconfirmDark } from './popconfirm/styles'
export { popoverDark } from './popover/styles'
export { popselectDark } from './popselect/styles'
Expand Down