mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
refactor(components): [link] dynamic css vars & fix inner align (#6557)
This commit is contained in:
@@ -6,14 +6,13 @@
|
||||
</el-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Edit, View as IconView } from '@element-plus/icons-vue'
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-link {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.el-link .el-icon--right.el-icon {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@click="handleClick"
|
||||
>
|
||||
<el-icon v-if="icon"><component :is="icon" /></el-icon>
|
||||
<span v-if="$slots.default" :class="ns.m('inner')">
|
||||
<span v-if="$slots.default" :class="ns.e('inner')">
|
||||
<slot></slot>
|
||||
</span>
|
||||
|
||||
|
||||
@@ -1100,8 +1100,8 @@ $link: map.merge(
|
||||
(
|
||||
'font-size': var(--el-font-size-base),
|
||||
'font-weight': var(--el-font-weight-primary),
|
||||
'default-text-color': var(--el-text-color-regular),
|
||||
'default-active-color': var(--el-color-primary),
|
||||
'text-color': var(--el-text-color-regular),
|
||||
'hover-text-color': var(--el-color-primary),
|
||||
'disabled-text-color': var(--el-text-color-placeholder),
|
||||
),
|
||||
$link
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
@use 'mixins/mixins' as *;
|
||||
@use 'mixins/var' as *;
|
||||
@use 'mixins/utils' as *;
|
||||
@use 'common/var' as *;
|
||||
|
||||
@include b(link) {
|
||||
@@ -19,8 +20,14 @@
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-size: var(--el-link-font-size);
|
||||
font-weight: var(--el-link-font-weight);
|
||||
font-size: getCssVar('link', 'font-size');
|
||||
font-weight: getCssVar('link', 'font-weight');
|
||||
|
||||
color: getCssVar('link', 'text-color');
|
||||
|
||||
&:hover {
|
||||
color: getCssVar('link', 'hover-text-color');
|
||||
}
|
||||
|
||||
@include when(underline) {
|
||||
&:hover:after {
|
||||
@@ -30,11 +37,12 @@
|
||||
right: 0;
|
||||
height: 0;
|
||||
bottom: 0;
|
||||
border-bottom: 1px solid var(--el-link-default-active-color);
|
||||
border-bottom: 1px solid getCssVar('link', 'hover-text-color');
|
||||
}
|
||||
}
|
||||
|
||||
@include when(disabled) {
|
||||
color: getCssVar('link', 'disabled-text-color');
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
@@ -45,40 +53,36 @@
|
||||
}
|
||||
|
||||
&.#{$namespace}-link--default {
|
||||
color: var(--el-link-default-text-color);
|
||||
|
||||
&:hover {
|
||||
color: var(--el-link-default-active-color);
|
||||
}
|
||||
|
||||
&:after {
|
||||
border-color: var(--el-link-default-active-color);
|
||||
border-color: getCssVar('link', 'hover-text-color');
|
||||
}
|
||||
}
|
||||
|
||||
@include when(disabled) {
|
||||
color: var(--el-link-disabled-text-color);
|
||||
}
|
||||
@include e(inner) {
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@each $type in $types {
|
||||
&.#{$namespace}-link--#{$type} {
|
||||
--el-link-text-color: var(--el-color-#{$type});
|
||||
color: var(--el-link-text-color);
|
||||
|
||||
&:hover {
|
||||
color: mix(map.get($link-text-color, $type), $color-white, 80%);
|
||||
}
|
||||
@include css-var-from-global(('link', 'text-color'), ('color', $type));
|
||||
@include css-var-from-global(
|
||||
('link', 'hover-text-color'),
|
||||
('color', $type, 'light-3')
|
||||
);
|
||||
@include css-var-from-global(
|
||||
('link', 'disabled-text-color'),
|
||||
('color', $type, 'light-5')
|
||||
);
|
||||
|
||||
&:after {
|
||||
border-color: var(--el-link-text-color);
|
||||
border-color: getCssVar('link', 'text-color');
|
||||
}
|
||||
|
||||
@include when(disabled) {
|
||||
color: mix(map.get($link-text-color, $type), $color-white, 50%);
|
||||
}
|
||||
@include when(underline) {
|
||||
&:hover:after {
|
||||
border-color: var(--el-link-text-color);
|
||||
border-color: getCssVar('link', 'text-color');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user