Skip to content

Commit 1a958d5

Browse files
authored
fix(address): 构建单一样式文件 (#3220)
1 parent 8b8d973 commit 1a958d5

File tree

4 files changed

+142
-119
lines changed

4 files changed

+142
-119
lines changed

scripts/build-taro.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ async function buildCSS(themeName = '') {
428428
join(`${dist}/cjs`, cssPath, `${themeDir}/css.js`),
429429
cssContent.join('\n'),
430430
)
431+
// copy harmonycss
432+
if (file.indexOf('countup') === -1) {
433+
const harmonyCss = join(__dirname, '../', file.replace('scss', 'harmony.css'))
434+
await copy(harmonyCss, join(`${dist}/cjs`, cssPath, 'style/style.harmony.css'))
435+
await copy(harmonyCss, join(`${dist}/es`, cssPath, 'style/style.harmony.css'))
436+
}
431437
}
432438
}
433439

scripts/replace-css-var.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,36 @@ components.forEach((component) => {
4242
`../src/packages/${componentName}/${componentName}.harmony.css`,
4343
)
4444
const matched = content.match(/@import.*?[;][\n\r]?/gi)
45+
const componentSplitScss = []
4546
if (matched) {
4647
matched.forEach((m) => {
4748
if (m.indexOf('styles') > -1) {
4849
content = content.replace(m, mixin)
4950
} else {
50-
content = content.replace(m, '')
51+
// 相对路径是 ../ 是组件,所以剔除
52+
if (m.indexOf("'./") === - 1) {
53+
content = content.replace(m, '')
54+
} else {
55+
// 组件内的样式拆分
56+
content = content.replace(m, '')
57+
const splitScssName = m.match(/\'\.\/([a-z]+)\.scss/)
58+
if (splitScssName && splitScssName.length == 2) {
59+
componentSplitScss.push(fs
60+
.readFileSync(
61+
path.join(
62+
__dirname,
63+
`../src/packages/${componentName}/${splitScssName[1]}.scss`,
64+
),
65+
)
66+
.toString())
67+
}
68+
69+
}
5170
}
5271
})
5372
}
5473

55-
const res = sass.compileString(theme + variables + content)
74+
const res = sass.compileString(theme + variables + componentSplitScss.join('\n') + content)
5675
postcss([
5776
cssvariables(/*options*/),
5877
])

src/packages/address/address.scss

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import './elevator.scss';
1+
@import '../elevator/elevator.scss';
22
@import '../cascader/cascader.scss';
33

44
.nut-address {
@@ -47,6 +47,120 @@
4747
}
4848
}
4949

50+
.nut-address {
51+
&-title {
52+
font-size: 14px;
53+
font-weight: 500;
54+
padding: 16px 16px 12px 16px;
55+
}
56+
&-hotlist {
57+
padding: 0 16px;
58+
display: flex;
59+
flex-wrap: wrap;
60+
align-items: flex-start;
61+
&-item {
62+
display: flex;
63+
justify-content: center;
64+
align-items: center;
65+
width: 63px;
66+
height: 28px;
67+
font-size: 12px;
68+
border-radius: 4px;
69+
margin-bottom: 7px;
70+
/* #ifdef harmony*/
71+
margin-right: 6px;
72+
/* #endif */
73+
/* #ifndef harmony*/
74+
margin-right: 7px;
75+
/* #endif */
76+
background-color: $color-background-sunken;
77+
color: $color-title;
78+
&:nth-child(5n) {
79+
margin-right: 0;
80+
}
81+
}
82+
83+
&.hotlist-more {
84+
.nut-address-hotlist-item {
85+
width: auto;
86+
padding: 0 16px;
87+
margin-right: 7px;
88+
}
89+
}
90+
}
91+
92+
&-selected {
93+
width: 100%;
94+
height: 60px;
95+
padding: 0 16px;
96+
display: flex;
97+
align-items: center;
98+
border-bottom: 1px solid $color-border;
99+
&-item {
100+
font-size: 12px;
101+
display: inline-block;
102+
height: 28px;
103+
line-height: 28px;
104+
padding: 0 12px;
105+
border-radius: 4px;
106+
background-color: $color-background-sunken;
107+
108+
&.active {
109+
border: 1px solid $color-primary;
110+
background-color: $color-primary-light-pressed;
111+
color: $color-primary;
112+
}
113+
}
114+
&-border {
115+
margin: 0 2px;
116+
color: $color-text-disabled;
117+
}
118+
}
119+
120+
&-elevator {
121+
margin-top: 0;
122+
.nut-elevator-list {
123+
&-item {
124+
position: relative;
125+
padding-left: 20px;
126+
}
127+
&-item-code {
128+
display: inline;
129+
position: absolute;
130+
left: 0;
131+
top: 0;
132+
height: 30px;
133+
line-height: 30px;
134+
border-bottom: 0;
135+
color: $color-text-help;
136+
font-weight: 500;
137+
}
138+
}
139+
.nut-elevator-bars {
140+
top: 40%;
141+
padding: 0;
142+
background: none;
143+
144+
&-inner-item {
145+
display: flex;
146+
justify-content: center;
147+
align-items: center;
148+
width: 16px;
149+
height: 16px;
150+
font-size: 10px;
151+
border-radius: 16px;
152+
margin-bottom: 2px;
153+
color: $color-text-help;
154+
&-active {
155+
background-color: $color-primary;
156+
color: $color-background-overlay;
157+
font-weight: 400;
158+
}
159+
}
160+
}
161+
}
162+
}
163+
50164
[dir='rtl'] .nut-address,
51165
.nut-rtl .nut-address {
52166
&-exist {

src/packages/address/elevator.scss

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

0 commit comments

Comments
 (0)