-
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
pref: Optimize the button style for database connection information #7342
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 |
---|---|---|
|
@@ -89,7 +89,7 @@ | |
v-model="form.password" | ||
/> | ||
<el-button-group> | ||
<CopyButton :content="form.password" /> | ||
<CopyButton class="copy_button" :content="form.password" /> | ||
<el-button @click="random"> | ||
{{ $t('commons.button.random') }} | ||
</el-button> | ||
|
@@ -262,3 +262,14 @@ defineExpose({ | |
acceptParams, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.copy_button { | ||
border-radius: 0px; | ||
border-left-width: 0px; | ||
} | ||
:deep(.el-input__wrapper) { | ||
border-top-right-radius: 0px; | ||
border-bottom-right-radius: 0px; | ||
} | ||
</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 code changes seem mostly minor and don't introduce significant errors. Here are some points to consider:
These changes primarily focus on maintaining visual consistency with existing components while providing additional customization options using deep selectors or local classes where appropriate. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ | |
v-model="form.password" | ||
/> | ||
<el-button-group> | ||
<CopyButton :content="form.password" /> | ||
<CopyButton class="copy_button" :content="form.password" /> | ||
<el-button @click="random"> | ||
{{ $t('commons.button.random') }} | ||
</el-button> | ||
|
@@ -239,3 +239,14 @@ defineExpose({ | |
acceptParams, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.copy_button { | ||
border-radius: 0px; | ||
border-left-width: 0px; | ||
} | ||
:deep(.el-input__wrapper) { | ||
border-top-right-radius: 0px; | ||
border-bottom-right-radius: 0px; | ||
} | ||
</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 provided code seems to be related to a Vue.js component that includes an input field with a password mask and two buttons: one for copying the password to the clipboard and another for generating a random password. There are no apparent errors in the JavaScript or SASS portions of the code. Potential Issues:
Suggestions for Optimization:
Here's the revised code incorporating some of these suggestions: <template>
<!-- template code -->
</template>
<script setup lang="ts">
import CopyButton from 'path-to-copy-button-component';
const form = reactive({
// properties
});
const props = defineProps<{
// props definitions
}>();
const emit = defineEmits<{
// event emitters
}>();
watch(
() => form.someProperty,
value => {
console.log('Value changed:', value);
},
);
function random() {
// random logic here
}
// expose props and local state if necessary
if (shouldExpose) defineExpose({ acceptParams });
</script>
<style lang="scss" scoped>
.copy_button {
border-radius: 0px;
border-left-width: 0px; /* Adjust this based on layout needs */
}
.el-input__wrapper {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
</style> This script uses Vue Composition API syntax, which is modern and allows better encapsulation and flexibility compared to Option-Based API. Make sure to replace |
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.
The provided HTML/CSS code has a couple of improvements:
CSS Specificity Optimization: The
.copy_button
class is used to target the copy button while using:deep()
to target deeply nested elements. This avoids overriding styles applied by other CSS.Border Radius Removal: By removing border radius from all edges (
border-top-left-radius
,border-top-right-radius
,border-bottom-left-radius
,border-bottom-right-radius
) for the input wrapper (el-input__wrapper
), it ensures consistent styling across different platforms and browser versions.Here's the optimized version:
Key Changes Made:
.copy_button
Class: Added a rule to remove unused border properties and set it for padding on click.:el-input__wrapper
Deep Styling: Used an additional selector to apply specific radii only when not inside table columns and is not the first last child, ensuring no unwanted changes occur elsewhere.