-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
style: Optimize style and layout #7671
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 |
---|---|---|
|
@@ -243,6 +243,6 @@ defineExpose({ | |
border: 1px solid var(--el-color-warning); | ||
background-color: transparent; | ||
padding: 8px 8px; | ||
width: 78px; | ||
max-width: 100px; | ||
} | ||
</style> | ||
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. The changes suggest that the element's width has been changed from 78px to max-width: 100px. This should not be modified without careful consideration as it might affect the layout of other elements on the page, potentially causing overflow or responsiveness problems. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<template> | ||
<el-card class="router_card"> | ||
<div class="flex w-full flex-col items-center md:justify-between md:flex-row"> | ||
<el-card class="router_card p-1 sm:p-0"> | ||
<div class="flex w-full flex-col justify-start sm:items-center items-start sm:justify-between sm:flex-row"> | ||
<el-radio-group v-model="activeName" @change="handleChange"> | ||
<el-radio-button | ||
class="router_card_button" | ||
|
@@ -15,7 +15,7 @@ | |
</el-badge> | ||
</el-radio-button> | ||
</el-radio-group> | ||
<div class="flex flex-row gap-2 md:flex-col lg:flex-row"> | ||
<div class="flex flex-col gap-2 sm:flex-row"> | ||
<slot name="route-button"></slot> | ||
</div> | ||
</div> | ||
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. After checking the code differences, I identified several irregularities and potential issues:
Here's an improved version of the code addressing these points: <template>
<el-card class="router_card">
<div class="w-full flex flex-grow flex-col items-center justify-end gap-y-4 sm:flex-row">
<!-- Radio group for displaying routes -->
<el-radio-group v-model="activeName" @change="handleChange">
<el-radio-button
class="router_card_button px-4 py-2"
:disabled="!showRouteButton"
>{route.name}
<span>{route.icon}</span></el-radio-button>
</el-radio-button>
</el-radio-group>
<!-- Slot for additional route buttons or actions -->
<div class="flex flex-gap-2 lg:hidden">
<slot name="extra-actions"></slot>
</div>
<!-- Additional div for slot content at mobile sizes -->
<div class="hidden md:block">
<slot name="extra-actions"></slot>
</div>
</div>
</el-card>
</template>
<script lang='ts'>
import { ElCard, ElRadioGroup, ElRadioButton } from 'element-plus';
export default {
components: {
ElCard,
ElRadioGroup,
ElRadioButton
},
data() {
return {
activeName: '',
showRouteButton: true // Example variable controlling visibility of the button
};
},
methods: {
handleChange(name) {
console.log('Active Name:', name);
}
}
};
</script>
<style scoped lang='scss'>
.router_card {
height:auto;
position:relative;
}
// Responsive styling examples
@media screen and (max-width:900px){
.el-card{
display:none; /* Adjust based on your requirements */
}
.btn_container {
.btn_item{
background-color:#fff5ec;
margin-right:2% !important;
&.selected , &:focus-within{
background-image:url('@/assets/images/checked.png');
border-bottom-left-radius:100%!important ;
border-bottom-right-radius:100%!important ;
border-top:1px solid black;
}
}
}
}
/* Other styles as per project design */ This revised code maintains correct HTML tag formatting, improves slot usage and logic extraction, adjusts card padding according to need, and offers basic responsiveness adjustments through media queries. Make sure to customize any other styles as appropriate for your application's design needs. 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.
Here's the optimized solution: <template>
<el-card class="router_card p-1 sm:p-0">
<div class="flex w-full flex-col justify-start sm:items-center items-start mx-auto sm:justify-between sm:flex-row">
<el-radio-group v-model="activeName" @change="handleChange">
...
</el-radio-group>
<div class="flex flex-col gap-2 sm:flex-row">
...
</div>
</div>
</el-card>
</template>
<script>
export default {
data() {
return {
activeName: ""
};
},
methods: {
handleChange(name) {
console.log(`Selected tab: ${name}`);
}
}
};
</script> These changes improve readability and adaptibility by ensuring uniform styling and enhanced user experience across different device sizes. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,19 @@ | |
<div> | ||
<el-scrollbar height="525px" class="moz-height"> | ||
<div class="h-app-card" v-for="(app, index) in apps" :key="index"> | ||
<el-row :gutter="10"> | ||
<el-col :span="5"> | ||
<div> | ||
<el-avatar shape="square" :size="55" :src="'data:image/png;base64,' + app.icon" /> | ||
<div class="flex justify-start items-center gap-2"> | ||
<div class="w-14"> | ||
<el-avatar shape="square" :size="55" :src="'data:image/png;base64,' + app.icon" /> | ||
</div> | ||
<div class="flex-1 flex flex-col h-app-content"> | ||
<span class="h-app-title">{{ app.name }}</span> | ||
<div class="h-app-desc"> | ||
<span> | ||
{{ language == 'zh' || language == 'tw' ? app.shortDescZh : app.shortDescEn }}123123 | ||
</span> | ||
</div> | ||
</el-col> | ||
<el-col :span="15"> | ||
<div class="h-app-content"> | ||
<div> | ||
<span class="h-app-title">{{ app.name }}</span> | ||
</div> | ||
<div class="h-app-desc"> | ||
<span> | ||
{{ language == 'zh' || language == 'tw' ? app.shortDescZh : app.shortDescEn }} | ||
</span> | ||
</div> | ||
</div> | ||
</el-col> | ||
<el-col :span="2"> | ||
</div> | ||
<div> | ||
<el-button | ||
class="h-app-button" | ||
type="primary" | ||
|
@@ -32,8 +26,8 @@ | |
> | ||
{{ $t('app.install') }} | ||
</el-button> | ||
</el-col> | ||
</el-row> | ||
</div> | ||
</div> | ||
<div class="h-app-divider" /> | ||
</div> | ||
</el-scrollbar> | ||
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. The updated code has several improvements that enhance readability, maintainability, and performance:
Overall, this change enhances the overall appearance and functionality while maintaining a clean development pattern. 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. There are several improvements that can be made to this code:
Here's how the improved version could look: <div class="flex justify-start">
<el-scrollbar height="525px" class="moz-height">
<div class="h-app-card w-full" v-for="(app, index) in apps" :key="index">
<div class="grid grid-cols-2 items-center space-x-2 grow">
<div>
<el-avatar shape="square" :size="55" :src="'data:image/png;base64,' + app.icon" />
</div>
<div class="grow">
<div class="flex flex-col h-app-content">
<span class="h-app-title">{{ app.name }}</span>
<div class="h-app-desc">
<span>{{ language == 'zh' || language == 'tw' ? app.shortDescZh : app.shortDescEn }}</span>
</div>
</div>
</div>
<div>
<el-button class="h-app-button" type="primary" @click="installApp(app)">Install</el-button>
</div>
</div>
<div class="h-app-divider" />
</div>
</el-scrollbar>
</div> Key Improvements:
This approach maintains similar functionality while improving overall aesthetics and maintainability of the codebase. |
||
|
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.
In the provided code snippet, there is one minor change that can be made to enhance readability:
Change from:
To:
Explanation:
width
property is set directly to78px
.max-width: 100px;
allows the element to expand up to its maximum allowable width while maintaining responsiveness and not exceeding the specified size.This suggests a preference for flexibility without setting an exact pixel limit.