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 issues #2400

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 adding responsive width handling.

While standardizing the width is good, consider making the date picker more responsive to different screen sizes and device types. This would be particularly important when dealing with large numbers of alarms.

Consider updating the CSS to handle different viewport sizes:

 .demo-date-picker {
   width: 280px;
+  @media (min-width: 768px) {
+    width: 400px;
+  }
+  @media (min-width: 1024px) {
+    width: 480px;
+  }
 }
📝 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: 280px;
@media (min-width: 768px) {
width: 400px;
}
@media (min-width: 1024px) {
width: 480px;
}
}

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 using CSS variables for consistent sizing.

To maintain consistent widths across all date picker components, consider defining the width value as a CSS variable.

Here's how you could improve it:

+<style>
+:root {
+  --tiny-date-picker-width: 280px;
+}
+</style>
+
 <style scoped>
 .demo-date-picker {
-  width: 280px;
+  width: var(--tiny-date-picker-width);
 }

This would make it easier to maintain consistent sizing across all date picker instances and support theming.

Committable suggestion was skipped due to low confidence.

.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>
<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 making the date picker responsive.

While standardizing the width improves consistency, a fixed width of 280px might not be optimal for all screen sizes. Consider using responsive design principles.

 .demo-date-picker {
-  width: 280px;
+  width: 100%;
+  max-width: 280px;
+  min-width: 200px;
 }
📝 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: 200px;
}

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 responsive design for different screen sizes.

While standardizing the width to 280px across components is good for consistency, consider using responsive design patterns for better mobile support.

Consider using CSS media queries for responsive behavior:

 .demo-date-picker {
   width: 280px;
+  @media (max-width: 320px) {
+    width: 100%;
+    max-width: 280px;
+  }
 }
📝 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: 280px;
@media (max-width: 320px) {
width: 100%;
max-width: 280px;
}
}

.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>
2 changes: 1 addition & 1 deletion packages/renderless/src/date-panel/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const initState = ({ reactive, computed, api, i18n, designConfig }) => {
isShowTz: computed(() => state.showTimezone && state.showTime),
isShowFooter: computed(() => state.footerVisible && [DATEPICKER.Date, DATEPICKER.Year].includes(state.currentView)),
buttonType: designConfig?.state?.buttonType || 'default',
buttonSize: designConfig?.state?.buttonSize || 'default'
buttonSize: designConfig?.state?.buttonSize || ''
})

state.needChangeTimezoneData = true // 控制重新渲染时区列表
Expand Down
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 div{
background-color: var(--tv-DateTable-td-bg-color-range-selected);
}

&.week {
font-size: 80%;
Expand Down
3 changes: 2 additions & 1 deletion packages/theme/src/month-table/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@
.cell {
background-color: var(--tv-MonthTable-bg-color-disabled);
cursor: not-allowed;
color: var(--tv-MonthTable-bg-color-disabled);
color: var(--tv-MonthTable-cell-color-disabled);

&:hover {
cursor: not-allowed;
background-color: var(--tv-MonthTable-bg-color-disabled);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/theme/src/month-table/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

// 背景色(禁用)
--tv-MonthTable-bg-color-disabled: var(--tv-color-bg-disabled, #f0f0f0);
// 文字色(禁用)
--tv-MonthTable-cell-color-disabled: var(--tv-color-text-disabled, #c2c2c2);
// 背景色(悬浮)
--tv-MonthTable-bg-color-hover: var(--tv-color-bg-hover-1, #deecff);
// 背景色(高亮) 开始/结束如期高亮
Expand Down
Loading