Skip to content

Commit

Permalink
style: Add elNamespace
Browse files Browse the repository at this point in the history
feat(component): Add namespace of class
  • Loading branch information
kailong321200875 committed Jan 23, 2022
1 parent e20fa76 commit d847ccb
Show file tree
Hide file tree
Showing 38 changed files with 508 additions and 303 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"axios": "^0.25.0",
"echarts": "^5.2.2",
"echarts-wordcloud": "^2.0.0",
"element-plus": "1.3.0-beta.5",
"element-plus": "1.3.0-beta.7",
"lodash-es": "^4.17.21",
"mockjs": "^1.1.0",
"nprogress": "^0.2.0",
Expand Down Expand Up @@ -88,7 +88,7 @@
"vite-plugin-svg-icons": "^1.1.0",
"vite-plugin-vue-setup-extend": "^0.3.0",
"vite-plugin-windicss": "^1.6.3",
"vue-tsc": "^0.30.6",
"vue-tsc": "^0.31.1",
"windicss": "^3.4.3",
"windicss-analysis": "^0.3.5"
},
Expand Down
339 changes: 164 additions & 175 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { computed } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { ConfigGlobal } from '@/components/ConfigGlobal'
import { isDark } from '@/utils/is'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('app')
const appStore = useAppStore()
Expand All @@ -20,12 +25,12 @@ initDark()

<template>
<ConfigGlobal :size="currentSize">
<RouterView :class="{ 'v-grey__mode': greyMode }" />
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
</ConfigGlobal>
</template>

<style lang="less">
@prefix-cls: ~'@{namespace}-grey';
@prefix-cls: ~'@{namespace}-app';
.size {
width: 100%;
Expand All @@ -44,7 +49,7 @@ body {
}
}
.@{prefix-cls}__mode {
.@{prefix-cls}-grey-mode {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
Expand Down
1 change: 1 addition & 0 deletions src/assets/svgs/peoples.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/components/Backtop/src/Backtop.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<script setup lang="ts">
import { ElBacktop } from 'element-plus'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls, variables } = useDesign()
const prefixCls = getPrefixCls('backtop')
</script>

<template>
<ElBacktop target=".v-content .el-scrollbar__wrap" />
<ElBacktop
:class="`${prefixCls}-backtop`"
:target="`.${variables.namespace}-layout-content-scrollbar .${variables.elNamespace}-scrollbar__wrap`"
/>
</template>
48 changes: 28 additions & 20 deletions src/components/Breadcrumb/src/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import type { RouteLocationNormalizedLoaded, RouteMeta } from 'vue-router'
import { useI18n } from '@/hooks/web/useI18n'
import { Icon } from '@/components/Icon'
import { useAppStore } from '@/store/modules/app'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('breadcrumb')
const appStore = useAppStore()
Expand Down Expand Up @@ -72,7 +77,7 @@ export default defineComponent({
)
return () => (
<ElBreadcrumb separator="/" class="flex items-center h-full ml-[10px]">
<ElBreadcrumb separator="/" class={`${prefixCls} flex items-center h-full ml-[10px]`}>
<TransitionGroup appear enter-active-class="animate__animated animate__fadeInRight">
{renderBreadcrumb()}
</TransitionGroup>
Expand All @@ -83,36 +88,39 @@ export default defineComponent({
</script>

<style lang="less" scoped>
:deep(.el-breadcrumb__item) {
display: flex;
@prefix-cls: ~'@{namespace}-breadcrumb';
.el-breadcrumb__inner {
.@{prefix-cls} {
:deep(&__item) {
display: flex;
align-items: center;
color: var(--top-header-text-color);
.@{prefix-cls}__inner {
display: flex;
align-items: center;
color: var(--top-header-text-color);
&:hover {
color: var(--el-color-primary);
&:hover {
color: var(--el-color-primary);
}
}
}
}
:deep(.el-breadcrumb__item):not(:last-child) {
.el-breadcrumb__inner {
color: var(--top-header-text-color);
:deep(&__item):not(:last-child) {
.@{prefix-cls}__inner {
color: var(--top-header-text-color);
&:hover {
color: var(--el-color-primary);
&:hover {
color: var(--el-color-primary);
}
}
}
}
:deep(.el-breadcrumb__item):last-child {
.el-breadcrumb__inner {
color: var(--el-text-color-placeholder);
&:hover {
:deep(&__item):last-child {
.@{prefix-cls}__inner {
color: var(--el-text-color-placeholder);
&:hover {
color: var(--el-text-color-placeholder);
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Collapse/src/Collapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import { computed, unref } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('collapse')
defineProps({
color: propTypes.string.def('')
Expand All @@ -18,7 +23,7 @@ const toggleCollapse = () => {
</script>

<template>
<div>
<div :class="prefixCls">
<Icon
:size="18"
:icon="collapse ? 'ant-design:menu-unfold-outlined' : 'ant-design:menu-fold-outlined'"
Expand Down
13 changes: 12 additions & 1 deletion src/components/ConfigGlobal/src/ConfigGlobal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { useLocaleStore } from '@/store/modules/locale'
import { useWindowSize } from '@vueuse/core'
import { useAppStore } from '@/store/modules/app'
import { setCssVar } from '@/utils'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls, variables } = useDesign()
const prefixCls = getPrefixCls('config-global')
const appStore = useAppStore()
Expand Down Expand Up @@ -48,7 +53,13 @@ const currentLocale = computed(() => localeStore.currentLocale)
</script>

<template>
<ElConfigProvider :locale="currentLocale.elLocale" :message="{ max: 1 }" :size="size">
<ElConfigProvider
:clss="prefixCls"
:namespace="variables.elNamespace"
:locale="currentLocale.elLocale"
:message="{ max: 1 }"
:size="size"
>
<slot></slot>
</ElConfigProvider>
</template>
12 changes: 6 additions & 6 deletions src/components/ContextMenu/src/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import { ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus'
import { PropType } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('context-menu')
const { t } = useI18n()
Expand All @@ -23,6 +28,7 @@ const command = (item: contextMenuSchema) => {

<template>
<ElDropdown
:class="prefixCls"
:trigger="trigger"
placement="bottom-start"
@command="command"
Expand All @@ -44,9 +50,3 @@ const command = (item: contextMenuSchema) => {
</template>
</ElDropdown>
</template>

<style lang="less">
.v-context-menu-popper {
min-width: 150px;
}
</style>
3 changes: 3 additions & 0 deletions src/components/CountTo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import CountTo from './src/CountTo.vue'

export { CountTo }
9 changes: 7 additions & 2 deletions src/components/CountTo/src/CountTo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
import { reactive, computed, watch, onMounted, unref, toRef, PropType } from 'vue'
import { isNumber } from '@/utils/is'
import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('count-to')
const props = defineProps({
startVal: propTypes.number.def(0),
endVal: propTypes.number.def(2021),
duration: propTypes.number.def(3000),
autoplay: propTypes.bool.def(false),
autoplay: propTypes.bool.def(true),
decimals: propTypes.number.validate((value: number) => value >= 0).def(0),
decimal: propTypes.string.def('.'),
separator: propTypes.string.def(','),
Expand Down Expand Up @@ -169,7 +174,7 @@ defineExpose({
</script>

<template>
<span>
<span :class="prefixCls">
{{ displayValue }}
</span>
</template>
7 changes: 6 additions & 1 deletion src/components/Echart/src/Echart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { propTypes } from '@/utils/propTypes'
import { computed, PropType, ref, unref, watch, onMounted, onBeforeUnmount, onActivated } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { isString } from '@/utils/is'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('echart')
const appStore = useAppStore()
Expand Down Expand Up @@ -106,5 +111,5 @@ onActivated(() => {
</script>

<template>
<div ref="elRef" :class="$attrs.class" :style="styles" />
<div ref="elRef" :class="[$attrs.class, prefixCls]" :style="styles" />
</template>
12 changes: 11 additions & 1 deletion src/components/Footer/src/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<script setup lang="ts">
import { useAppStore } from '@/store/modules/app'
import { computed } from 'vue'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('footer')
const appStore = useAppStore()
const title = computed(() => appStore.getTitle)
</script>

<template>
<div class="text-center text-[var(--el-text-color-placeholder)]">Copyright ©2021 {{ title }}</div>
<div
:class="prefixCls"
class="text-center text-[var(--el-text-color-placeholder)] bg-[var(--app-contnet-bg-color)] h-[var(--app-footer-height)] leading-[var(--app-footer-height)]"
>
Copyright ©2021 {{ title }}
</div>
</template>
7 changes: 6 additions & 1 deletion src/components/Form/src/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
import { useRenderSelect } from './components/useRenderSelect'
import { useRenderRadio } from './components/useRenderRadio'
import { useRenderChcekbox } from './components/useRenderChcekbox'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('form')
export default defineComponent({
name: 'Form',
Expand Down Expand Up @@ -194,7 +199,7 @@ export default defineComponent({
}
return () => (
<ElForm ref={elFormRef} {...getFormBindValue()} model={formModel} class="v-form">
<ElForm ref={elFormRef} {...getFormBindValue()} model={formModel} class={prefixCls}>
{{
// 如果需要自定义,就什么都不渲染,而是提供默认插槽
default: () => (isCustom ? getSlot(slots, 'default') : renderWrap())
Expand Down
7 changes: 6 additions & 1 deletion src/components/Icon/src/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { computed, unref, ref, watch, nextTick } from 'vue'
import { ElIcon } from 'element-plus'
import { propTypes } from '@/utils/propTypes'
import Iconify from '@purge-icons/generated'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('icon')
const props = defineProps({
// icon name
Expand Down Expand Up @@ -61,7 +66,7 @@ watch(
</script>

<template>
<ElIcon class="v-icon" :size="size" :color="color">
<ElIcon :class="prefixCls" :size="size" :color="color">
<svg v-if="isLocal" aria-hidden="true">
<use :xlink:href="symbolId" />
</svg>
Expand Down
14 changes: 10 additions & 4 deletions src/components/InputPassword/src/InputPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { propTypes } from '@/utils/propTypes'
import { useConfigGlobal } from '@/hooks/web/useConfigGlobal'
import { zxcvbn } from '@zxcvbn-ts/core'
import type { ZxcvbnResult } from '@zxcvbn-ts/core'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('input-password')
const props = defineProps({
// 是否显示密码强度
Expand Down Expand Up @@ -55,17 +60,18 @@ const getIconName = computed(() =>
</script>

<template>
<div :class="['v-input-password', `v-input-password--${configGlobal?.size}`]">
<div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]">
<ElInput v-bind="$attrs" v-model="valueRef" :type="textType">
<template #suffix>
<Icon class="el-input__icon cursor-pointer" :icon="getIconName" @click="changeTextType" />
</template>
</ElInput>
<div
v-if="strength"
class="v-input-password__bar relative h-6px mt-10px mb-6px mr-auto ml-auto"
:class="`${prefixCls}__bar`"
class="relative h-6px mt-10px mb-6px mr-auto ml-auto"
>
<div class="v-input-password__bar--fill" :data-score="getPasswordStrength"></div>
<div :class="`${prefixCls}__bar--fill`" :data-score="getPasswordStrength"></div>
</div>
</div>
</template>
Expand All @@ -74,7 +80,7 @@ const getIconName = computed(() =>
@prefix-cls: ~'@{namespace}-input-password';
.@{prefix-cls} {
:deep(.el-input__clear) {
:deep(.@{elNamespace}-input__clear) {
margin-left: 5px;
}
Expand Down
Loading

0 comments on commit d847ccb

Please sign in to comment.