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(date-picker): [date-picker]Optimize case display and fix style i… #2386

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ const value = ref('')

<style scoped>
.demo-date-picker-wrap {
width: 350px;
width: 280px;
}
</style>
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/date-picker/align.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export default {

<style scoped>
.demo-date-picker-wrap {
width: 350px;
width: 280px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const yearValue = ref('')

<style scoped lang="less">
.demo-date-picker-wrap {
width: 360px;
& > * {
margin-top: 12px;
}
Expand Down
1 change: 1 addition & 0 deletions examples/sites/demos/pc/app/date-picker/date-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default {

<style scoped lang="less">
.demo-date-picker-wrap {
width: 360px;
& > * {
margin-top: 12px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</tiny-col>
</tiny-row>
<tiny-row>
<tiny-col :span="12">
<tiny-col :span="6">
<label class="demo-date-picker-label">onPick:</label>
<tiny-date-picker v-model="valueOnPick" type="daterange" :picker-options="pickerOptions"></tiny-date-picker>
</tiny-col>
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/date-picker/events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</tiny-col>
</tiny-row>
<tiny-row>
<tiny-col :span="12">
<tiny-col :span="6">
<label class="demo-date-picker-label">onPick:</label>
<tiny-date-picker v-model="valueOnPick" type="daterange" :picker-options="pickerOptions"></tiny-date-picker>
</tiny-col>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<div style="width: 400px">
<div class="demo-date-picker">
<div class="title">插槽式:</div>
<tiny-date-picker v-model="value1" type="datetime">
<template #now>
Expand All @@ -9,7 +9,7 @@
</tiny-date-picker>
</div>

<div style="width: 400px">
<div class="demo-date-picker">
<div class="title">函数式:</div>
<tiny-date-picker v-model="value2" type="datetime" :now-click="nowClick"> </tiny-date-picker>
</div>
Expand Down Expand Up @@ -37,6 +37,9 @@ const now = () => {
</script>

<style scoped>
.demo-date-picker {
width: 280px;
}
Comment on lines +40 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making the width configurable.

While the fixed width works for the current use case, consider making it more flexible for better reusability:

 .demo-date-picker {
-  width: 280px;
+  width: var(--tiny-date-picker-width, 280px);
 }

This allows overriding the width through CSS variables when needed while maintaining the default width.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.demo-date-picker {
width: 280px;
}
.demo-date-picker {
width: var(--tiny-date-picker-width, 280px);
}

.nowclass {
display: inline-flex;
height: 28px;
Expand Down
7 changes: 5 additions & 2 deletions examples/sites/demos/pc/app/date-picker/now.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<div style="width: 400px">
<div class="demo-date-picker">
<div class="title">插槽式:</div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using i18n for text content.

The hardcoded Chinese text could be moved to translation files for better internationalization support.

- <div class="title">插槽式:</div>
+ <div class="title">{{ $t('datePicker.slotMode') }}</div>

- <div class="title">函数式:</div>
+ <div class="title">{{ $t('datePicker.functionMode') }}</div>

Also applies to: 13-13

<tiny-date-picker v-model="value1" type="datetime">
<template #now>
Expand All @@ -9,7 +9,7 @@
</tiny-date-picker>
</div>

<div style="width: 400px">
<div class="demo-date-picker">
<div class="title">函数式:</div>
<tiny-date-picker v-model="value2" type="datetime" :now-click="nowClick"> </tiny-date-picker>
</div>
Expand Down Expand Up @@ -45,6 +45,9 @@ export default {
</script>

<style scoped>
.demo-date-picker {
width: 280px;
}
Comment on lines +48 to +50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding responsive width handling.

The style implementation is clean and properly scoped. However, consider making the width responsive using min-width or max-width constraints to better handle different screen sizes and content lengths.

Here's a suggested improvement:

 .demo-date-picker {
-  width: 280px;
+  width: 100%;
+  max-width: 280px;
+  min-width: 240px;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.demo-date-picker {
width: 280px;
}
.demo-date-picker {
width: 100%;
max-width: 280px;
min-width: 240px;
}

.nowclass {
display: inline-flex;
height: 28px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ function selectChange(tz) {
Modal.message({ message: `当前值为 ${tz.tz.name}`, status: 'info' })
}
</script>

<style scoped>
.demo-date-picker-wrap {
width: 280px;
}
</style>
4 changes: 3 additions & 1 deletion packages/theme/src/date-table/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
div {
margin-left: 4px;
margin-right: 4px;
background-color: var(--tv-DateTable-td-bg-color-range-selected);
}

span {
Expand All @@ -242,6 +241,9 @@
background-color: var(--tv-DateTable-bg-color-current-select);
}
}
&.selected.in-range {
background-color: var(--tv-DateTable-td-bg-color-range-selected);
}

&.week {
font-size: 80%;
Expand Down
Loading