Skip to content

Commit e739a90

Browse files
oneyouziyucongshuang
andauthored
新增几种theme-开头的样式,给ide传媒介查询参数 (#103)
* 给ide模拟器传媒介查询参数 * 新增几种灵感组件的样式配置 * 媒介参数传递遗留 * 修正格式 --------- Co-authored-by: yucongshuang <v-yucongshuang@oppo.com>
1 parent 9e17d7e commit e739a90

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

packages/hap-compiler/src/style/validator.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,24 @@ const validateTime = function (v) {
396396
}
397397
}
398398
}
399-
399+
// 灵感组件颜色值
400+
const themeColors = [
401+
'uxCardColorTheme',
402+
'uxCardColorAccent',
403+
'uxCardColorPrimary',
404+
'uxCardColorSecondary',
405+
'uxCardColorSecondaryVariant',
406+
'uxCardColorTertiary',
407+
'uxCardColorQuaternary',
408+
'uxCardColorContainer',
409+
'uxCardBackground',
410+
'uxCardColorHue',
411+
'uxCardColorHueSecondary',
412+
'uxIconColorAccent',
413+
'uxIconColorPrimary',
414+
'uxIconColorSecondary',
415+
'uxIconColorBackground'
416+
]
400417
const validator = {
401418
/**
402419
* 整数校验
@@ -2657,23 +2674,13 @@ const validatorMap = {
26572674
// font
26582675
fontSrc: validator.fontSrc,
26592676
fontFamily: validator.fontFamily,
2660-
themeColor: makeEnumValidator([
2661-
'uxCardColorTheme',
2662-
'uxCardColorAccent',
2663-
'uxCardColorPrimary',
2664-
'uxCardColorSecondary',
2665-
'uxCardColorSecondaryVariant',
2666-
'uxCardColorTertiary',
2667-
'uxCardColorQuaternary',
2668-
'uxCardColorContainer',
2669-
'uxCardBackground',
2670-
'uxCardColorHue',
2671-
'uxCardColorHueSecondary',
2672-
'uxIconColorAccent',
2673-
'uxIconColorPrimary',
2674-
'uxIconColorSecondary',
2675-
'uxIconColorBackground'
2676-
])
2677+
themeColor: makeEnumValidator(themeColors),
2678+
themeBackgroundColor: makeEnumValidator(themeColors),
2679+
themeLayerColor: makeEnumValidator(themeColors),
2680+
themeThumbColor: makeEnumValidator(themeColors),
2681+
themeTrackColor: makeEnumValidator(themeColors),
2682+
themeSelectColor: makeEnumValidator(themeColors),
2683+
themeBlockColor: makeEnumValidator(themeColors)
26772684
}
26782685

26792686
/**

packages/hap-server/src/preview/create-router.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export default async function createRouter(previewTarget) {
226226
script,
227227
scriptNotFound: !scriptExists(script),
228228
webJsUrl: genWebJsUrl(ctx.conf.options.webVersion),
229-
language: currentLanguage
229+
language: currentLanguage,
230+
mediaQueryParams: JSON.stringify(ctx.conf.options.mediaQueryParams) // 传给页面的媒介查询参数
230231
})
231232
ctx.type = 'text/html'
232233
ctx.body = html

packages/hap-server/src/preview/views/page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
var base = '/preview'
9898
var type = '{{ type }}'
9999
window.language = `{{language}}`
100+
window.mediaQueryParams = JSON.parse(`{{mediaQueryParams}}`)
100101
;(function preview() {
101102
var routeName = '{{ routeName }}'
102103
Hap.init({

0 commit comments

Comments
 (0)