Skip to content

Commit 0acd11c

Browse files
author
cole
committed
workflow: cssinjs
1 parent 4691896 commit 0acd11c

File tree

13 files changed

+190
-121
lines changed

13 files changed

+190
-121
lines changed

src/css/base.css

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ ul, ol, li {
2525
}
2626

2727
body {
28-
color: green;
2928
font-size: 14px;
3029
background: #fff;
3130
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
@@ -43,18 +42,9 @@ body, html {
4342
#app {
4443
width: 100%;
4544
height: 100%;
45+
overflow: hidden;
4646
}
4747

48-
/*#app a {*/
49-
/* color: #1677ff;*/
50-
/* text-decoration: none;*/
51-
/*}*/
52-
53-
/*#app a:active {*/
54-
/* color: #0958d9;*/
55-
/* text-decoration: none;*/
56-
/*}*/
57-
5848
*, *::after, *::before {
5949
box-sizing: border-box;
6050
}

src/layout/components/avatar/index.jsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import { defineComponent } from 'vue'
2-
import { Avatar, Dropdown, Menu } from 'ant-design-vue'
3-
import { CaretDownOutlined, LoginOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
1+
import { defineComponent, unref } from 'vue'
2+
import { Avatar, Dropdown, Menu, theme } from 'ant-design-vue'
3+
import { LoginOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
44
import { useAppInstance } from '@/useAppInstance'
5-
import classNames from '@/utils/classNames/bind'
6-
import styles from './style/index.module.scss'
7-
8-
const cx = classNames.bind(styles)
5+
import { useConfigInject } from '@utils/extend'
6+
import useStyle from './style'
97

108
export default defineComponent({
119
inheritAttrs: false,
12-
setup () {
10+
setup (props, { attrs }) {
11+
const { prefixCls } = useConfigInject('pro-avatar', props)
12+
const [wrapSSR, hashId] = useStyle(prefixCls)
13+
const { token } = theme.useToken()
14+
1315
const { onLogout } = useAppInstance()
1416

1517
function handleLogout () {
@@ -21,10 +23,12 @@ export default defineComponent({
2123
}
2224

2325
return () => {
26+
const { controlHeight } = unref(token)
27+
2428
const dropdownSlots = {
2529
overlay: () => {
2630
return (
27-
<Menu class={cx('avatar-menu')} selectedKeys={[]}>
31+
<Menu class={`${prefixCls.value}-menu`} selectedKeys={[]}>
2832
<Menu.Item
2933
key={'center'}
3034
v-slots={{ icon: () => <UserOutlined/> }}
@@ -50,18 +54,18 @@ export default defineComponent({
5054
}
5155
}
5256

53-
return (
54-
<div class={cx('avatar-wrap')}>
57+
return wrapSSR(
58+
<div class={[prefixCls.value, hashId.value]} {...attrs}>
5559
<Dropdown
5660
getPopupContainer={getPopupContainer}
5761
placement={'bottomRight'}
5862
v-slots={dropdownSlots}
5963
>
60-
<div class={cx('avatar-center')}>
61-
<Avatar size={28} v-slots={{ icon: () => <UserOutlined/> }}/>
62-
<div class={cx('avatar-center__icon-down')}>
63-
<CaretDownOutlined/>
64-
</div>
64+
<div class={`${prefixCls.value}-content`}>
65+
<Avatar
66+
size={controlHeight - 4}
67+
v-slots={{ icon: () => <UserOutlined/> }}
68+
/>
6569
</div>
6670
</Dropdown>
6771
</div>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { genComponentStyleHook, mergeToken } from '@utils/extend'
2+
3+
function genBaseStyle (token) {
4+
const { componentCls, avatarMenuMinWidth } = token
5+
return {
6+
[componentCls]: {
7+
position: 'relative',
8+
height: '100%',
9+
[`${componentCls}-content`]: {
10+
height: '100%',
11+
fontSize: token.fontSizeLG,
12+
color: token.colorText,
13+
lineHeight: token.lineHeightLG,
14+
paddingInline: token.fontSizeSM,
15+
cursor: 'pointer',
16+
display: 'flex',
17+
alignItems: 'center',
18+
[`&:hover`]: {
19+
color: token.colorPrimaryHover,
20+
background: token.colorFillQuaternary
21+
},
22+
[`&:active`]: {
23+
color: token.colorPrimaryActive,
24+
background: token.colorFillQuaternary
25+
}
26+
},
27+
[`${componentCls}-menu`]: {
28+
minWidth: avatarMenuMinWidth,
29+
whiteSpace: 'nowrap'
30+
}
31+
}
32+
}
33+
}
34+
35+
export default genComponentStyleHook('ProAvatar', (token) => {
36+
const avatarMenuMinWidth = token.fontSize * 8
37+
38+
const avatarToken = mergeToken(token, {
39+
avatarMenuMinWidth
40+
})
41+
return [genBaseStyle(avatarToken)]
42+
})

src/layout/components/avatar/style/index.module.scss

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/layout/components/breadcrumb/index.jsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { computed, defineComponent, unref } from 'vue'
22
import { Breadcrumb } from 'ant-design-vue'
33
import useShowTitle from '../../hooks/useShowTitle'
4-
import classNames from '@/utils/classNames/bind'
5-
import styles from './style/index.module.scss'
6-
7-
const cx = classNames.bind(styles)
4+
import { useConfigInject } from '@utils/extend'
5+
import useStyle from './style'
86

97
export default defineComponent({
108
inheritAttrs: false,
@@ -14,7 +12,10 @@ export default defineComponent({
1412
default: undefined
1513
}
1614
},
17-
setup (props) {
15+
setup (props, { attrs }) {
16+
const { prefixCls } = useConfigInject('pro-breadcrumb', props)
17+
const [wrapSSR, hashId] = useStyle(prefixCls)
18+
1819
const { showTitle } = useShowTitle()
1920

2021
const levels = computed(() => {
@@ -28,16 +29,18 @@ export default defineComponent({
2829
})
2930

3031
return () => {
31-
return (
32-
<Breadcrumb class={cx('breadcrumb')}>
33-
{unref(levels).map((item, index) => {
34-
return (
35-
<Breadcrumb.Item key={item.name || index}>
36-
{showTitle && showTitle(item)}
37-
</Breadcrumb.Item>
38-
)
39-
})}
40-
</Breadcrumb>
32+
return wrapSSR(
33+
<div class={[prefixCls.value, hashId.value]} {...attrs}>
34+
<Breadcrumb>
35+
{unref(levels).map((item, index) => {
36+
return (
37+
<Breadcrumb.Item key={item.name || index}>
38+
{showTitle && showTitle(item)}
39+
</Breadcrumb.Item>
40+
)
41+
})}
42+
</Breadcrumb>
43+
</div>
4144
)
4245
}
4346
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { genComponentStyleHook } from '@utils/extend'
2+
3+
function genBaseStyle (token) {
4+
const { componentCls, antCls } = token
5+
return {
6+
[componentCls]: {
7+
paddingInline: token.sizeMD,
8+
[`ol`]: {
9+
flexWrap: 'nowrap'
10+
},
11+
[`${antCls}-breadcrumb-link`]: {
12+
whiteSpace: 'nowrap'
13+
}
14+
}
15+
}
16+
}
17+
18+
export default genComponentStyleHook('ProBreadcrumb', (token) => {
19+
return [genBaseStyle(token)]
20+
})

src/layout/components/breadcrumb/style/index.module.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/layout/components/fullscreen/index.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { defineComponent, onBeforeUnmount, onMounted, ref, unref } from 'vue'
22
import { ExitFullscreenOutlined, FullscreenOutlined } from '@/components/icon'
33
import native from './screenfull'
44
import { off, on } from '@utils/dom'
5-
import classNames from '@/utils/classNames/bind'
6-
import styles from './style/index.module.scss'
7-
8-
const cx = classNames.bind(styles)
5+
import { useConfigInject } from '@utils/extend'
6+
import useStyle from './style'
97

108
export default defineComponent({
119
inheritAttrs: false,
12-
setup () {
10+
setup (props, { attrs }) {
11+
const { prefixCls } = useConfigInject('pro-fullscreen', props)
12+
const [wrapSSR, hashId] = useStyle(prefixCls)
13+
1314
const { fullscreenElement, exitFullscreen, requestFullscreen, fullscreenchange } = native
1415

1516
const fullest = ref(false)
@@ -40,8 +41,8 @@ export default defineComponent({
4041
})
4142

4243
return () => {
43-
return (
44-
<div class={cx('fullscreen')} onClick={handleFullscreen}>
44+
return wrapSSR(
45+
<div class={[prefixCls.value, hashId.value]} onClick={handleFullscreen} {...attrs}>
4546
{unref(fullest) ? <ExitFullscreenOutlined/> : <FullscreenOutlined/>}
4647
</div>
4748
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { genComponentStyleHook } from '@utils/extend'
2+
3+
function genBaseStyle (token) {
4+
const { componentCls } = token
5+
return {
6+
[componentCls]: {
7+
height: '100%',
8+
fontSize: token.fontSizeLG,
9+
color: token.colorText,
10+
lineHeight: token.lineHeightLG,
11+
paddingInline: token.fontSizeSM,
12+
cursor: 'pointer',
13+
display: 'flex',
14+
alignItems: 'center',
15+
[`&:hover`]: {
16+
color: token.colorPrimaryHover,
17+
background: token.colorFillQuaternary
18+
},
19+
[`&:active`]: {
20+
color: token.colorPrimaryActive,
21+
background: token.colorFillQuaternary
22+
}
23+
}
24+
}
25+
}
26+
27+
export default genComponentStyleHook('ProFullscreen', (token) => {
28+
return [genBaseStyle(token)]
29+
})

src/layout/components/fullscreen/style/index.module.scss

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/layout/components/language/index.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { GlobalOutlined } from '@ant-design/icons-vue'
44
import { useAppInstance } from '@/useAppInstance'
55
import { map } from 'lodash-es'
66
import { localCache, LOCALE__LOCAL } from '@/utils/storage'
7-
import classNames from '@/utils/classNames/bind'
8-
import styles from './style/index.module.scss'
9-
10-
const cx = classNames.bind(styles)
7+
import { useConfigInject } from '@utils/extend'
8+
import useStyle from './style'
119

1210
export default defineComponent({
1311
inheritAttrs: false,
14-
setup () {
12+
setup (props, { attrs }) {
13+
const { prefixCls } = useConfigInject('pro-language', props)
14+
const [wrapSSR, hashId] = useStyle(prefixCls)
15+
1516
const { setLocale } = useAppInstance()
1617
// 需要修改为不需要依赖 useI18n 的方式
1718
// 并且不干涉 layout 的逻辑
@@ -49,7 +50,7 @@ export default defineComponent({
4950
const dropdownSlots = {
5051
overlay: () => {
5152
return (
52-
<Menu class={cx('language-menu')} selectedKeys={[$i18n.locale]}>
53+
<Menu class={`${prefixCls.value}-menu`} selectedKeys={[$i18n.locale]}>
5354
{map(localeList, (value, key) => {
5455
return (
5556
<Menu.Item key={key} onClick={onLocaleChange.bind(null, key)}>
@@ -62,14 +63,14 @@ export default defineComponent({
6263
}
6364
}
6465

65-
return (
66-
<div class={cx('language-wrap')}>
66+
return wrapSSR(
67+
<div class={[prefixCls.value, hashId.value]} {...attrs}>
6768
<Dropdown
6869
placement={'bottom'}
6970
getPopupContainer={getPopupContainer}
7071
v-slots={dropdownSlots}
7172
>
72-
<div class={cx('language-center')}>
73+
<div class={`${prefixCls.value}-content`}>
7374
<GlobalOutlined/>
7475
</div>
7576
</Dropdown>

0 commit comments

Comments
 (0)