-
Notifications
You must be signed in to change notification settings - Fork 278
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(locales): [locales] Optimize the style and demo #2475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
</template> | ||
|
||
<script lang="tsx"> | ||
import { TinyDrawer, TinyButton } from '@opentiny/vue' | ||
import { TinyDrawer, TinyButton, Notify } from '@opentiny/vue' | ||
import { iconHelp } from '@opentiny/vue-icon' | ||
|
||
export default { | ||
|
@@ -18,6 +18,9 @@ export default { | |
} | ||
}, | ||
methods: { | ||
closeDrawer() { | ||
this.drawerInstance.close() | ||
}, | ||
showDrawer() { | ||
const IconHelp = iconHelp() | ||
const config = { | ||
|
@@ -27,27 +30,35 @@ export default { | |
showFooter: true, | ||
// 通过 events 监听事件 | ||
events: { | ||
open: (instance) => console.log('open 事件', instance), | ||
close: () => console.log('close 事件') | ||
open: (instance) => | ||
Notify({ | ||
type: 'info', | ||
title: 'open 事件', | ||
message: `${instance.title}`, | ||
position: 'top-right' | ||
}), | ||
close: () => | ||
Notify({ | ||
type: 'info', | ||
title: 'close 事件', | ||
position: 'top-right' | ||
}) | ||
}, | ||
// 通过属性 customSlots 设置插槽, 插槽内容可以是 string | VNode | ({h, $drawer}) => VNode | ||
customSlots: { | ||
// 使用 h 函数 | ||
default: (h) => h('p', { class: '' }, '抽屉主体内容。'), | ||
// 返回 VNode 节点的方法, 可通过参数中 $drawer 访问到组件实例 | ||
headerRight: () => <IconHelp></IconHelp>, | ||
headerRight: () => <IconHelp style="width:20px;height:20px"></IconHelp>, | ||
// 直接赋值 VNode | ||
footer: ( | ||
<Button type="primary" onClick={this.closeDrawer}> | ||
<TinyButton type="primary" onClick={this.closeDrawer}> | ||
点击关闭 | ||
</Button> | ||
</TinyButton> | ||
Comment on lines
+52
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider moving inline styles to CSS classes While the inline styles work, consider moving them to CSS classes for better maintainability and reusability. -headerRight: () => <IconHelp style="width:20px;height:20px"></IconHelp>,
+headerRight: () => <IconHelp class="drawer-header-icon"></IconHelp>, Add to your style section: <style>
.drawer-header-icon {
width: 20px;
height: 20px;
}
</style> |
||
) | ||
} | ||
} | ||
this.drawerInstance = TinyDrawer.service(config) | ||
}, | ||
closeDrawer() { | ||
this.drawerInstance.close() | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2022 - present TinyVue Authors. | ||
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. | ||
* | ||
* Use of this source code is governed by an MIT-style license. | ||
* | ||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, | ||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR | ||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. | ||
* | ||
*/ | ||
|
||
.inject-Area-vars() { | ||
// 选中框间距 | ||
--tv-Area-select-margin-right: var(--tv-space-xl, 16px); | ||
--tv-Area-select-margin-bottom: var(--tv-space-xl, 16px); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,21 +11,41 @@ | |||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
@import '../custom.less'; | ||||||||||||||||||||||||||||||||||||||
@import './vars.less'; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
@locales-prefix-cls: ~'@{css-prefix}locales'; | ||||||||||||||||||||||||||||||||||||||
@popover-prefix-cls: ~'@{css-prefix}popover'; | ||||||||||||||||||||||||||||||||||||||
@popper-prefix-cls: ~'@{css-prefix}popper'; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
.@{locales-prefix-cls} { | ||||||||||||||||||||||||||||||||||||||
.inject-Locales-vars() ; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
cursor: pointer; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
svg { | ||||||||||||||||||||||||||||||||||||||
margin-left: 2px; | ||||||||||||||||||||||||||||||||||||||
margin-left: var(--tv-Locales-svg-margin-left); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
&__text { | ||||||||||||||||||||||||||||||||||||||
font-size: var(--tv-Locales-text-font-size); | ||||||||||||||||||||||||||||||||||||||
color: var(--tv-Locales-svg-color); | ||||||||||||||||||||||||||||||||||||||
display: inline-flex; | ||||||||||||||||||||||||||||||||||||||
align-items: center; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
&__icon { | ||||||||||||||||||||||||||||||||||||||
display: inline-flex; | ||||||||||||||||||||||||||||||||||||||
align-items: center; | ||||||||||||||||||||||||||||||||||||||
justify-content: center; | ||||||||||||||||||||||||||||||||||||||
svg { | ||||||||||||||||||||||||||||||||||||||
width: var(--tv-Locales-svg-size); | ||||||||||||||||||||||||||||||||||||||
height: var(--tv-Locales-svg-size);; | ||||||||||||||||||||||||||||||||||||||
fill: var(--tv-Locales-text-color); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+34
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix double semicolon in height property There's a syntax error in the SVG height property. - height: var(--tv-Locales-svg-size);;
+ height: var(--tv-Locales-svg-size); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
&__popper { | ||||||||||||||||||||||||||||||||||||||
.inject-Locales-vars() ; | ||||||||||||||||||||||||||||||||||||||
&.@{popover-prefix-cls}.@{popper-prefix-cls} { | ||||||||||||||||||||||||||||||||||||||
padding: 0; | ||||||||||||||||||||||||||||||||||||||
padding: var(--tv-Locales-popper-padding-h) 0; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
.poplist { | ||||||||||||||||||||||||||||||||||||||
|
@@ -34,11 +54,11 @@ | |||||||||||||||||||||||||||||||||||||
li { | ||||||||||||||||||||||||||||||||||||||
list-style: none; | ||||||||||||||||||||||||||||||||||||||
cursor: pointer; | ||||||||||||||||||||||||||||||||||||||
padding: 0 8px; | ||||||||||||||||||||||||||||||||||||||
line-height: 30px; | ||||||||||||||||||||||||||||||||||||||
padding: 0 var(--tv-Locales-popper-li-padding-h); | ||||||||||||||||||||||||||||||||||||||
line-height: var(--tv-Locales-popper-li-line-heigaht); | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in line-height variable name There's a typo in the line-height variable name that could cause styling issues. - line-height: var(--tv-Locales-popper-li-line-heigaht);
+ line-height: var(--tv-Locales-popper-li-line-height); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
&.selected { | ||||||||||||||||||||||||||||||||||||||
background: #f5f5f5; | ||||||||||||||||||||||||||||||||||||||
&:hover { | ||||||||||||||||||||||||||||||||||||||
background-color: var(--tv-Locales-popper-li-hover-color); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||
/** | ||||||
* Copyright (c) 2022 - present TinyVue Authors. | ||||||
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. | ||||||
* | ||||||
* Use of this source code is governed by an MIT-style license. | ||||||
* | ||||||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, | ||||||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR | ||||||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. | ||||||
* | ||||||
*/ | ||||||
|
||||||
.inject-Locales-vars() { | ||||||
// 图标距离文字间距 | ||||||
--tv-Locales-svg-margin-left: var(--tv-space-sm, 4px); | ||||||
// 图标尺寸 | ||||||
--tv-Locales-svg-size: var(--tv-font-size-md, 14px); | ||||||
// 图标颜色 | ||||||
--tv-Locales-svg-color: var(--tv-color-text, #191919); | ||||||
// 文字字号 | ||||||
--tv-Locales-text-font-size: var(--tv-font-size-md, 14px); | ||||||
// 文字颜色 | ||||||
--tv-Locales-text-color: var(--tv-color-text, #191919); | ||||||
// 弹框间距 | ||||||
--tv-Locales-popper-padding-h: var(--tv-space-md, 8px); | ||||||
// 弹框选项间距 | ||||||
--tv-Locales-popper-li-padding-h: var(--tv-space-xl, 16px); | ||||||
// 弹框选项行高 | ||||||
--tv-Locales-popper-li-line-heigaht: 30px; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in CSS property name. The property name contains a typo: "line-heigaht" should be "line-height". - --tv-Locales-popper-li-line-heigaht: 30px;
+ --tv-Locales-popper-li-line-height: 30px; 📝 Committable suggestion
Suggested change
|
||||||
// 弹框选项悬浮色 | ||||||
--tv-Locales-popper-li-hover-color: var(--tv-color-bg-hover, #f5f5f5); | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ | |
:append-to-body="popperAppendToBody" | ||
> | ||
<template #reference> | ||
<span | ||
<span class="tiny-locales__text" | ||
>{{ state.text && t(state.text) | ||
}}<span> | ||
}}<span class="tiny-locales__icon"> | ||
<IconChevronDown v-show="!state.visible" /> | ||
<IconChevronUp v-show="state.visible" /> </span | ||
></span> | ||
|
@@ -39,13 +39,13 @@ import { $prefix, setup, defineComponent } from '@opentiny/vue-common' | |
import { renderless, api } from '@opentiny/vue-renderless/locales/vue' | ||
import { use, enUS, zhCN } from '@opentiny/vue-locale' | ||
import TinyPopover from '@opentiny/vue-popover' | ||
import { IconChevronUp, IconChevronDown } from '@opentiny/vue-icon' | ||
import { IconUpWard, IconChevronDown } from '@opentiny/vue-icon' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the search results, I can generate the final response since I have enough information to verify the icon change impact: The icon change from IconChevronUp to IconUpWard appears to be inconsistent with the codebase patterns The search results reveal that:
This change could lead to visual inconsistency since:
🔗 Analysis chainVerify the visual impact of replacing IconChevronUp with IconUpWard. The icon change from
Let's check if these icons are used consistently across the codebase: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the usage patterns of IconChevronUp and IconUpWard
# to ensure consistent icon usage across the codebase
echo "Checking IconChevronUp usage:"
rg "IconChevronUp" -A 2
echo -e "\nChecking IconUpWard usage:"
rg "IconUpWard" -A 2
echo -e "\nChecking if these icons are paired with IconChevronDown:"
rg "IconChevronDown" -A 2
Length of output: 35861 |
||
|
||
export default defineComponent({ | ||
name: $prefix + 'Locales', | ||
components: { | ||
TinyPopover, | ||
IconChevronUp: IconChevronUp(), | ||
IconChevronUp: IconUpWard(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里修改了模板,需要确认下是否对saas主题造成影响 |
||
IconChevronDown: IconChevronDown() | ||
Comment on lines
+48
to
49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider renaming the component registration for clarity. The component is imported as Apply this diff to maintain consistency: - IconChevronUp: IconUpWard(),
+ IconUpward: IconUpWard(), Then update the template usage: - <IconChevronUp v-show="state.visible" />
+ <IconUpward v-show="state.visible" />
|
||
}, | ||
props: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider moving styles to CSS classes.
While inline styles work, moving them to CSS classes would improve maintainability and reusability.
Consider this approach:
And add to your component's style section: