Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new less variable @prefix-mobile #310

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@import '../../../mixin/index.less';

:root when (@use-css-vars = 1) {
--prefix: arco;
--prefix: var(--prefix-mobile);
--prefix-mobile: arco;
--base-font-size: 50;
--arco-dark-mode-selector: .arco-theme-dark;
--background-color: #FFFFFF;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export declare function getRem(px: number, baseFontSize: number): string;
export interface ArcodesignToken extends Record<string, string> {
'prefix': string;
'prefix-mobile': string;
'base-font-size': string;
'arco-dark-mode-selector': string;
'background-color': string;
Expand Down
3 changes: 2 additions & 1 deletion packages/arcodesign/tokens/app/arcodesign/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function getRem(px, baseFontSize) {
}

var tokens = {
"prefix": "arco",
"prefix": "var(--prefix-mobile)",
"prefix-mobile": "arco",
"base-font-size": "50",
"arco-dark-mode-selector": ".arco-theme-dark",
"background-color": "#FFFFFF",
Expand Down
17 changes: 15 additions & 2 deletions packages/arcodesign/tokens/app/arcodesign/default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8049,14 +8049,27 @@
"cssKey": "prefix",
"desc": "类前缀,需配合 context-provider 中的 prefixCls 使用",
"override": "",
"value": "arco",
"jsValue": "arco",
"value": "@prefix-mobile",
"jsValue": "@global@prefixMobile",
"staticValue": "arco",
"localeDesc": {
"ch": "类前缀,需配合 context-provider 中的 prefixCls 使用",
"default": "'arco'",
"en": "Classname prefix, it needs to be used with prefixCls in context-provider"
}
},
"prefixMobile": {
"cssKey": "prefix-mobile",
"desc": "功能同 prefix,与 PC 版同用时可使用该变量修改类前缀解决冲突",
"override": "",
"value": "arco",
"jsValue": "arco",
"staticValue": "arco",
"localeDesc": {
"ch": "功能同 prefix,与 PC 版同用时可使用该变量修改类前缀解决冲突",
"en": "Same as `prefix`, it can avoid conflicts when used with arco pc"
}
},
"primaryColor": {
"cssKey": "primary-color",
"desc": "基础主题色",
Expand Down
3 changes: 2 additions & 1 deletion packages/arcodesign/tokens/app/arcodesign/default/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../../../mixin/pxtorem.less';

@prefix: arco;
@prefix: @prefix-mobile;
@prefix-mobile: arco;
@base-font-size: 50;
@arco-dark-mode-selector: .arco-theme-dark;
@background-color: #FFFFFF;
Expand Down
28 changes: 15 additions & 13 deletions packages/arcodesign/tokens/src/arcodesign/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
const extend = require('./extend');
const { theme } = require('./theme');

const getRem = px => `@getRem@${px}`;
const useGlobal = token => `@global@${token}`;
const globalTokens = getGlobalTokens();

function getGlobalTokens() {
return {
/**
* 类前缀,需配合 context-provider 中的 prefixCls 使用
* @default 'arco'
* @en Classname prefix, it needs to be used with prefixCls in context-provider
*/
prefix: 'arco',
prefix: useGlobal('prefixMobile'),
/**
* 功能同 prefix,与 PC 版同用时可使用该变量修改类前缀解决冲突
* @en Same as `prefix`, it can avoid conflicts when used with arco pc
*/
prefixMobile: 'arco',
/**
* rem 转换使用的基础字号
* @en Base font size used for rem conversion
Expand Down Expand Up @@ -127,10 +137,6 @@ function getGlobalTokens() {
};
}

const globalTokens = getGlobalTokens();
const getRem = px => `@getRem@${px}`;
const useGlobal = token => `@global@${token}`;

function getCompTokens() {
return {
/**
Expand Down Expand Up @@ -422,8 +428,7 @@ function getCompTokens() {
* 轮播图滑块文字背景色
* @en Background color of the carousel sliders
*/
carouselItemTextBackground:
'linear-gradient(180deg, rgba(0, 0, 0, 0) 5.18%, rgba(0, 0, 0, 0.15) 100%)',
carouselItemTextBackground: 'linear-gradient(180deg, rgba(0, 0, 0, 0) 5.18%, rgba(0, 0, 0, 0.15) 100%)',
/**
* 轮播图滑块文字高度
* @en Font height of the carousel sliders
Expand Down Expand Up @@ -1017,10 +1022,8 @@ function getCompTokens() {
* 文字缩略组件浮动模式下的缩略符背景色
* @en Background of floating ellipsis node
*/
ellipsisFloatEllipsisNodeBackground:
'linear-gradient(90deg, rgba(255, 255, 255, 0), #ffffff 20PX, #ffffff)',
darkEllipsisFloatEllipsisNodeBackground:
'linear-gradient(90deg, rgba(35, 35, 36, 0), #232324 20PX, #232324)',
ellipsisFloatEllipsisNodeBackground: 'linear-gradient(90deg, rgba(255, 255, 255, 0), #ffffff 20PX, #ffffff)',
darkEllipsisFloatEllipsisNodeBackground: 'linear-gradient(90deg, rgba(35, 35, 36, 0), #232324 20PX, #232324)',
/**
* 文字缩略组件浮动模式下的缩略符左边距
* @en Padding left of floating ellipsis node
Expand Down Expand Up @@ -2166,8 +2169,7 @@ function getCompTokens() {
* 图片预览指示器背景色
* @en ImagePreview indicator background color
*/
imagePreviewIndicatorBackground:
'linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.3))',
imagePreviewIndicatorBackground: 'linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.3))',
/**
* 图片预览小图放大时的动画曲线
* @en Animation curve when ImagePreview thumbnail is enlarged
Expand Down
Loading