Skip to content

Commit b39016b

Browse files
feat(ip-address): [ip-address] Adapting to the SMB theme (#2166)
1 parent d697b6a commit b39016b

File tree

10 files changed

+75
-40
lines changed

10 files changed

+75
-40
lines changed

examples/sites/demos/pc/app/ip-address/disabled.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('ipAddress 禁用', async ({ page }) => {
1313
await expect(input.nth(1)).toBeDisabled()
1414
await expect(input.nth(2)).toBeDisabled()
1515
await expect(input.nth(3)).toBeDisabled()
16-
await expect(ipAddress).toHaveCSS('background-color', 'rgb(245, 245, 246)')
17-
await expect(ipAddress).toHaveCSS('border-bottom-color', 'rgb(223, 225, 230)')
18-
await expect(ipAddress).toHaveCSS('color', 'rgb(173, 176, 184)')
16+
await expect(ipAddress).toHaveCSS('background-color', 'rgb(240, 240, 240)')
17+
await expect(ipAddress).toHaveCSS('border-bottom-color', 'rgb(219, 219, 219)')
18+
await expect(ipAddress).toHaveCSS('color', 'rgb(194, 194, 194)')
1919
})

examples/sites/demos/pc/app/ip-address/size-composition-api.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div>
33
<tiny-ip-address size="medium" v-model="value"></tiny-ip-address>
4-
<tiny-ip-address size="small" v-model="value"></tiny-ip-address>
54
<tiny-ip-address v-model="value"></tiny-ip-address>
5+
<tiny-ip-address size="small" v-model="value"></tiny-ip-address>
66
<tiny-ip-address size="mini" v-model="value"></tiny-ip-address>
77
</div>
88
</template>

examples/sites/demos/pc/app/ip-address/size.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('ipAddress 输入框大小', async ({ page }) => {
88
const ipAddress = demo.locator('.tiny-ip-address__input')
99

1010
await expect(ipAddress.first()).toHaveCSS('height', '42px')
11-
await expect(ipAddress.nth(1)).toHaveCSS('height', '36px')
11+
await expect(ipAddress.nth(1)).toHaveCSS('height', '32px')
1212
await expect(ipAddress.nth(2)).toHaveCSS('height', '28px')
1313
await expect(ipAddress.nth(3)).toHaveCSS('height', '24px')
1414
})

examples/sites/demos/pc/app/ip-address/size.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div>
33
<tiny-ip-address size="medium" v-model="value"></tiny-ip-address>
4-
<tiny-ip-address size="small" v-model="value"></tiny-ip-address>
54
<tiny-ip-address v-model="value"></tiny-ip-address>
5+
<tiny-ip-address size="small" v-model="value"></tiny-ip-address>
66
<tiny-ip-address size="mini" v-model="value"></tiny-ip-address>
77
</div>
88
</template>

packages/renderless/src/ip-address/index.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,3 @@ export const keydown =
403403
return false
404404
}
405405
}
406-
407-
export const getHeightOfSize = (size, isLineHeight = 'height') => {
408-
const sizeMap = {
409-
medium: '42px',
410-
small: '36px',
411-
mini: '24px'
412-
}
413-
414-
const sizePX = sizeMap[size]
415-
416-
return sizePX ? isLineHeight + ':' + sizePX + ';' : ''
417-
}

packages/renderless/src/ip-address/vue.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import {
2323
change,
2424
blur,
2525
keyup,
26-
keydown,
27-
getHeightOfSize
26+
keydown
2827
} from './index'
2928
import { KEY_CODE } from '../common'
3029
import type {
@@ -66,9 +65,7 @@ const initState = ({
6665

6766
formDisabled: computed(() => (parent.tinyForm || {}).disabled),
6867
disabled: computed(() => props.disabled || state.formDisabled),
69-
heightStyle: computed(() => getHeightOfSize(props.size)),
70-
lineHeightStyle: computed(() => getHeightOfSize(props.size, 'line-height')),
71-
allHeightStyle: computed(() => `${state.heightStyle}${state.lineHeightStyle}`)
68+
size: computed(() => props.size)
7269
})
7370

7471
return state as IIpAddressState

packages/theme-saas/src/ip-address/index.less

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
@apply relative;
1717
@apply p-0;
1818
@apply w-full;
19-
@apply h-7;
2019
@apply border border-solid border-color-border;
2120
@apply text-color-text-primary;
2221
@apply rounded;
@@ -77,8 +76,6 @@
7776
@apply text-color-text-primary;
7877
width: ~'calc(100% - theme(spacing.3))';
7978
@apply float-left;
80-
@apply h-7;
81-
@apply leading-7;
8279
@apply p-0;
8380
@apply text-xs;
8481

@@ -115,5 +112,37 @@
115112
}
116113
}
117114
}
115+
&.medium {
116+
height: 42px;
117+
li input {
118+
height: 42px;
119+
line-height: 42px;
120+
}
121+
}
122+
123+
&.default {
124+
@apply h-7;
125+
li input {
126+
@apply h-7;
127+
@apply leading-7;
128+
}
129+
}
130+
131+
132+
&.small {
133+
@apply h-9;
134+
li input {
135+
@apply h-9;
136+
@apply leading-9;
137+
}
138+
}
139+
140+
&.mini {
141+
@apply h-6;
142+
li input {
143+
@apply h-6;
144+
@apply leading-6;
145+
}
146+
}
118147
}
119148
}

packages/theme/src/ip-address/index.less

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
&__input {
3131
position: relative;
3232
width: 100%;
33-
height: var(--ti-ip-address-normal-height);
34-
line-height: var(--ti-ip-address-line-height);
3533
border: 1px solid var(--ti-ip-address-normal-border-color);
3634
color: var(--ti-ip-address-normal-text-color);
3735
border-radius: var(--ti-ip-address-border-radius);
@@ -98,8 +96,6 @@
9896
font-family: var(--ti-ip-address-normal-font-family);
9997
width: var(--ti-ip-address-input-width);
10098
float: left;
101-
height: calc(var(--ti-ip-address-normal-height) - 2px);
102-
line-height: var(--ti-ip-address-line-height);
10399
padding: 0;
104100

105101
&:focus,
@@ -144,5 +140,24 @@
144140
text-align: center;
145141
margin: 0 var(--ti-ip-address-ipv6-delimiter-margin-right);
146142
}
143+
&.medium li input {
144+
height: var(--ti--ip--address-medium-height);
145+
line-height: var(--ti--ip--address-medium-line-height);
146+
}
147+
148+
&.default li input {
149+
height: var(--ti--ip--address-default-height);
150+
line-height: var(--ti--ip--address-default-line-height);
151+
}
152+
153+
&.small li input {
154+
height: var(--ti--ip--address-small-height);
155+
line-height: var(--ti--ip--address-small-line-height);
156+
}
157+
158+
&.mini li input {
159+
height: var(--ti--ip--address-mini-height);
160+
line-height: var(--ti--ip--address-mini-line-height);
161+
}
147162
}
148163
}

packages/theme/src/ip-address/vars.less

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
--ti-ip-address-font-size: var(--ti-common-font-size-1);
3838
// IP地址输入框字族
3939
--ti-ip-address-normal-font-family: "Manrop","Manrope-Medium";
40-
// IP地址输入框行高
41-
--ti-ip-address-line-height: var(--ti-common-line-height-1);
4240
// IP地址输入框聚焦边框色
4341
--ti-ip-address-border-color-focus: var(--ti-common-color-line-active, #5e7ce0);
4442
// IP地址输入框悬浮边框色
@@ -49,4 +47,13 @@
4947
--ti-ip-address-disabled-border-color: var(--ti-common-color-line-disabled, #dfe1e6);
5048
// Ip地址输入框item宽度
5149
--ti-ip-address-input-width: var(--ti-common-size-8x);
50+
// 尺寸 高度及行高
51+
--ti--ip--address-medium-height: calc(var(--ti-common-size-height-medium));
52+
--ti--ip--address-medium-line-height: calc(var(--ti-common-line-height-5) + 2px);
53+
--ti--ip--address-default-height: calc(var(--ti-common-size-height-normal) - 2px);
54+
--ti--ip--address-default-line-height: var(--ti-common-line-height-4);
55+
--ti--ip--address-small-height: calc(var(--ti-common-size-height-minor) - 4px);
56+
--ti--ip--address-small-line-height: calc(var(--ti-common-line-height-3) - 2px);
57+
--ti--ip--address-mini-height: calc(var(--ti-common-size-height-mini) - 2px);
58+
--ti--ip--address-mini-line-height: calc(var(--ti-common-line-height-2) - 2px);
5259
}

packages/vue/src/ip-address/src/pc.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
<template>
1313
<div class="tiny-ip-address">
1414
<ul
15-
:class="{
16-
active: state.active,
17-
disabled: state.disabled,
18-
'tiny-ip-address__input': true
19-
}"
20-
:style="state.heightStyle"
15+
:class="[
16+
state.active ? 'active' : '',
17+
state.disabled ? 'disabled' : '',
18+
'tiny-ip-address__input',
19+
state.size ? `${state.size}` : 'default'
20+
]"
2121
>
22-
<li v-for="(item, index) of state.address" :key="index" :style="state.lineHeightStyle">
22+
<li v-for="(item, index) of state.address" :key="index">
2323
<input
24-
:style="state.allHeightStyle"
2524
ref="inputs"
2625
:readonly="readonly"
2726
:disabled="state.disabled"

0 commit comments

Comments
 (0)