mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
feat: zeroRuntime (#54334)
* feat: zeroRuntime * feat: generate full style * feat: add antd.css into global css * chore: revert site change * docs: add docs * chore: update scripts * chore: add test
This commit is contained in:
@@ -2,18 +2,21 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css');
|
const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css');
|
||||||
|
const antdCssPath = path.join(process.cwd(), 'components', 'style', 'antd.css');
|
||||||
const tokenStatisticPath = path.join(process.cwd(), 'components', 'version', 'token.json');
|
const tokenStatisticPath = path.join(process.cwd(), 'components', 'version', 'token.json');
|
||||||
const tokenMetaPath = path.join(process.cwd(), 'components', 'version', 'token-meta.json');
|
const tokenMetaPath = path.join(process.cwd(), 'components', 'version', 'token-meta.json');
|
||||||
|
|
||||||
function finalizeCompile() {
|
function finalizeCompile() {
|
||||||
if (fs.existsSync(path.join(__dirname, './es'))) {
|
if (fs.existsSync(path.join(__dirname, './es'))) {
|
||||||
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'es', 'style', 'reset.css'));
|
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'es', 'style', 'reset.css'));
|
||||||
|
fs.copyFileSync(antdCssPath, path.join(process.cwd(), 'es', 'style', 'antd.css'));
|
||||||
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'es', 'version', 'token.json'));
|
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'es', 'version', 'token.json'));
|
||||||
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'es', 'version', 'token-meta.json'));
|
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'es', 'version', 'token-meta.json'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(path.join(__dirname, './lib'))) {
|
if (fs.existsSync(path.join(__dirname, './lib'))) {
|
||||||
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'lib', 'style', 'reset.css'));
|
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'lib', 'style', 'reset.css'));
|
||||||
|
fs.copyFileSync(antdCssPath, path.join(process.cwd(), 'lib', 'style', 'antd.css'));
|
||||||
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'lib', 'version', 'token.json'));
|
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'lib', 'version', 'token.json'));
|
||||||
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'lib', 'version', 'token-meta.json'));
|
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'lib', 'version', 'token-meta.json'));
|
||||||
}
|
}
|
||||||
@@ -22,6 +25,7 @@ function finalizeCompile() {
|
|||||||
function finalizeDist() {
|
function finalizeDist() {
|
||||||
if (fs.existsSync(path.join(__dirname, './dist'))) {
|
if (fs.existsSync(path.join(__dirname, './dist'))) {
|
||||||
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'dist', 'reset.css'));
|
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'dist', 'reset.css'));
|
||||||
|
fs.copyFileSync(antdCssPath, path.join(process.cwd(), 'dist', 'antd.css'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -77,3 +77,6 @@ __image_snapshots__/
|
|||||||
|
|
||||||
.env
|
.env
|
||||||
examples/
|
examples/
|
||||||
|
|
||||||
|
# generated css
|
||||||
|
components/style/antd.css
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element, set relative positioning and wrapper container styles',
|
root: 'Root element, set relative positioning and wrapper container styles',
|
||||||
indicator: 'Indicator element, set absolute positioning, padding, background color, border radius and ribbon styles',
|
indicator:
|
||||||
|
'Indicator element, set absolute positioning, padding, background color, border radius and ribbon styles',
|
||||||
content: 'Content element, set text color and ribbon content display styles',
|
content: 'Content element, set text color and ribbon content display styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element containing background, border, border-radius and overall layout structure of the calendar component',
|
root: 'Root element containing background, border, border-radius and overall layout structure of the calendar component',
|
||||||
header: 'Header element with layout and style control for year selector, month selector and mode switcher',
|
header:
|
||||||
|
'Header element with layout and style control for year selector, month selector and mode switcher',
|
||||||
body: 'Body element with padding and layout control for the calendar table that contains the calendar grid',
|
body: 'Body element with padding and layout control for the calendar table that contains the calendar grid',
|
||||||
content: 'Content element with width, height and table styling control for the calendar table',
|
content: 'Content element with width, height and table styling control for the calendar table',
|
||||||
item: 'Item element with background, border, hover state, selected state and other interactive styles for calendar cells',
|
item: 'Item element with background, border, hover state, selected state and other interactive styles for calendar cells',
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with border, border-radius, background color and container styles that control the overall layout and appearance of collapse panels',
|
root: 'Root element with border, border-radius, background color and container styles that control the overall layout and appearance of collapse panels',
|
||||||
header: 'Header element with flex layout, padding, color, line-height, cursor style, transition animations and other interactive styles for panel headers',
|
header:
|
||||||
title: 'Title element with flex auto layout and margin styles for title text layout and typography',
|
'Header element with flex layout, padding, color, line-height, cursor style, transition animations and other interactive styles for panel headers',
|
||||||
|
title:
|
||||||
|
'Title element with flex auto layout and margin styles for title text layout and typography',
|
||||||
body: 'Body element with padding, color, background color and other styles for panel content area display',
|
body: 'Body element with padding, color, background color and other styles for panel content area display',
|
||||||
icon: 'Icon element with font size, transition animations, rotation transforms and other styles and animations for expand/collapse arrows',
|
icon: 'Icon element with font size, transition animations, rotation transforms and other styles and animations for expand/collapse arrows',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -142,6 +142,13 @@ export interface ThemeConfig {
|
|||||||
*/
|
*/
|
||||||
key?: string;
|
key?: string;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @descCN 是否关闭运行时样式生成
|
||||||
|
* @descEN Disable runtime style generation.
|
||||||
|
* @default false
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
zeroRuntime?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComponentStyleConfig {
|
export interface ComponentStyleConfig {
|
||||||
|
|||||||
@@ -15,20 +15,27 @@ const locales = {
|
|||||||
'popup.header': '弹出框头部元素,包含导航按钮、月份年份选择器等头部控制区域的布局和样式',
|
'popup.header': '弹出框头部元素,包含导航按钮、月份年份选择器等头部控制区域的布局和样式',
|
||||||
'popup.body': '弹出框主体元素,包含日期面板表格的容器布局和样式',
|
'popup.body': '弹出框主体元素,包含日期面板表格的容器布局和样式',
|
||||||
'popup.content': '弹出框内容元素,包含日期表格的宽度、边框、单元格等内容展示样式',
|
'popup.content': '弹出框内容元素,包含日期表格的宽度、边框、单元格等内容展示样式',
|
||||||
'popup.item': '弹出框单项元素,包含日期单元格的尺寸、背景色、边框圆角、悬停态、选中态等交互样式',
|
'popup.item':
|
||||||
|
'弹出框单项元素,包含日期单元格的尺寸、背景色、边框圆角、悬停态、选中态等交互样式',
|
||||||
'popup.footer': '弹出框底部元素,包含确认取消按钮、快捷选择等底部操作区域的布局样式',
|
'popup.footer': '弹出框底部元素,包含确认取消按钮、快捷选择等底部操作区域的布局样式',
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with relative positioning, inline-flex layout, padding, border-radius, transition animations and other basic styles for date picker container',
|
root: 'Root element with relative positioning, inline-flex layout, padding, border-radius, transition animations and other basic styles for date picker container',
|
||||||
prefix: 'Prefix element with flex layout and margin styles for prefix content layout',
|
prefix: 'Prefix element with flex layout and margin styles for prefix content layout',
|
||||||
input: 'Input element with relative positioning, width, color, font, line-height, transition animations and other core interactive styles for input field',
|
input:
|
||||||
suffix: 'Suffix element with flex layout, color, line-height, pointer events, transition animations and other styles for suffix content',
|
'Input element with relative positioning, width, color, font, line-height, transition animations and other core interactive styles for input field',
|
||||||
|
suffix:
|
||||||
|
'Suffix element with flex layout, color, line-height, pointer events, transition animations and other styles for suffix content',
|
||||||
popup: 'Popup element',
|
popup: 'Popup element',
|
||||||
'popup.header': 'Popup header element with navigation buttons, month/year selectors and other header control area layout and styles',
|
'popup.header':
|
||||||
|
'Popup header element with navigation buttons, month/year selectors and other header control area layout and styles',
|
||||||
'popup.body': 'Popup body element with container layout and styles for date panel table',
|
'popup.body': 'Popup body element with container layout and styles for date panel table',
|
||||||
'popup.content': 'Popup content element with width, border, cell and other content display styles for date table',
|
'popup.content':
|
||||||
'popup.item': 'Popup item element with size, background, border-radius, hover state, selected state and other interactive styles for date cells',
|
'Popup content element with width, border, cell and other content display styles for date table',
|
||||||
'popup.footer': 'Popup footer element with layout styles for bottom operation area including confirm/cancel buttons and shortcuts',
|
'popup.item':
|
||||||
|
'Popup item element with size, background, border-radius, hover state, selected state and other interactive styles for date cells',
|
||||||
|
'popup.footer':
|
||||||
|
'Popup footer element with layout styles for bottom operation area including confirm/cancel buttons and shortcuts',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,16 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with basic styles, reset styles, border styles, layout direction and other overall styles for description list container',
|
root: 'Root element with basic styles, reset styles, border styles, layout direction and other overall styles for description list container',
|
||||||
header: 'Header element with flex layout, alignment, bottom margin and other layout and style controls for header area',
|
header:
|
||||||
title: 'Title element with text ellipsis, flex ratio, color, font weight, font size, line height and other title text styles',
|
'Header element with flex layout, alignment, bottom margin and other layout and style controls for header area',
|
||||||
extra: 'Extra content element with left margin, color, font size and other styles for additional operation area',
|
title:
|
||||||
label: 'Label element with color, font weight, font size, line height, text align, colon styles and other label text styles',
|
'Title element with text ellipsis, flex ratio, color, font weight, font size, line height and other title text styles',
|
||||||
content: 'Content element with table cell layout, color, font size, line height, word break and other content display styles',
|
extra:
|
||||||
|
'Extra content element with left margin, color, font size and other styles for additional operation area',
|
||||||
|
label:
|
||||||
|
'Label element with color, font weight, font size, line height, text align, colon styles and other label text styles',
|
||||||
|
content:
|
||||||
|
'Content element with table cell layout, color, font size, line height, word break and other content display styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,17 @@ const locales = {
|
|||||||
en: {
|
en: {
|
||||||
root: 'Root element with fixed positioning, z-index control, pointer events, color and other basic styles and layout control for drawer container',
|
root: 'Root element with fixed positioning, z-index control, pointer events, color and other basic styles and layout control for drawer container',
|
||||||
mask: 'Mask element with absolute positioning, z-index, background color, pointer events and other mask layer styles and interaction controls',
|
mask: 'Mask element with absolute positioning, z-index, background color, pointer events and other mask layer styles and interaction controls',
|
||||||
section: 'Drawer container element with flex layout, width/height, overflow control, background color, pointer events and other drawer body styles',
|
section:
|
||||||
header: 'Header element with flex layout, alignment, padding, font size, line height, bottom border and other header area styles',
|
'Drawer container element with flex layout, width/height, overflow control, background color, pointer events and other drawer body styles',
|
||||||
|
header:
|
||||||
|
'Header element with flex layout, alignment, padding, font size, line height, bottom border and other header area styles',
|
||||||
body: 'Body element with flex ratio, minimum size, padding, overflow scroll and other content area display and layout styles',
|
body: 'Body element with flex ratio, minimum size, padding, overflow scroll and other content area display and layout styles',
|
||||||
footer: 'Footer element with flex shrink, padding, top border and other bottom operation area styles',
|
footer:
|
||||||
title: 'Title element with flex ratio, margin, font weight, font size, line height and other title text styles',
|
'Footer element with flex shrink, padding, top border and other bottom operation area styles',
|
||||||
extra: 'Extra element with flex fixed layout and other additional operation content style controls',
|
title:
|
||||||
|
'Title element with flex ratio, margin, font weight, font size, line height and other title text styles',
|
||||||
|
extra:
|
||||||
|
'Extra element with flex fixed layout and other additional operation content style controls',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,16 @@ const locales = {
|
|||||||
root: 'Root element with float button group container styles, fixed positioning, z-index, padding, gap, direction mode and other combined layout styles',
|
root: 'Root element with float button group container styles, fixed positioning, z-index, padding, gap, direction mode and other combined layout styles',
|
||||||
list: 'List element with button group list flex layout, border radius, shadow, animation transition, vertical alignment and other list container styles',
|
list: 'List element with button group list flex layout, border radius, shadow, animation transition, vertical alignment and other list container styles',
|
||||||
item: 'Item element with individual float button styles, size, shape, type, state, icon content and other button base styles',
|
item: 'Item element with individual float button styles, size, shape, type, state, icon content and other button base styles',
|
||||||
itemIcon: 'Item icon element with float button icon size, color, alignment and other icon display styles',
|
itemIcon:
|
||||||
itemContent: 'Item content element with float button text content, badge, description and other content area styles',
|
'Item icon element with float button icon size, color, alignment and other icon display styles',
|
||||||
trigger: 'Trigger element with menu mode trigger button styles, shape, icon, hover state, expand/collapse state and other interaction styles',
|
itemContent:
|
||||||
triggerIcon: 'Trigger icon element with trigger button icon styles, rotation animation, toggle state and other icon interaction styles',
|
'Item content element with float button text content, badge, description and other content area styles',
|
||||||
triggerContent: 'Trigger content element with trigger button content area text, identifier, state indicator and other content styles',
|
trigger:
|
||||||
|
'Trigger element with menu mode trigger button styles, shape, icon, hover state, expand/collapse state and other interaction styles',
|
||||||
|
triggerIcon:
|
||||||
|
'Trigger icon element with trigger button icon styles, rotation animation, toggle state and other icon interaction styles',
|
||||||
|
triggerContent:
|
||||||
|
'Trigger content element with trigger button content area text, identifier, state indicator and other content styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,18 @@ const locales = {
|
|||||||
en: {
|
en: {
|
||||||
root: 'Root element, sets relative positioning and inline-block layout styles',
|
root: 'Root element, sets relative positioning and inline-block layout styles',
|
||||||
image: 'Image element, sets width, height and vertical alignment styles',
|
image: 'Image element, sets width, height and vertical alignment styles',
|
||||||
cover: 'Image hover display prompt element, sets absolute positioning, background color, opacity and transition animation styles',
|
cover:
|
||||||
'popup.root': 'Preview root element, sets fixed positioning, z-index and background mask styles',
|
'Image hover display prompt element, sets absolute positioning, background color, opacity and transition animation styles',
|
||||||
'popup.mask': 'Preview mask element, sets absolute positioning and semi-transparent background styles',
|
'popup.root':
|
||||||
'popup.body': 'Preview body element, sets flex layout, center alignment and pointer event styles',
|
'Preview root element, sets fixed positioning, z-index and background mask styles',
|
||||||
'popup.footer': 'Preview footer element, sets absolute positioning, center layout and bottom operation area styles',
|
'popup.mask':
|
||||||
'popup.actions': 'Preview actions group element, sets flex layout, background color, border radius and action button styles',
|
'Preview mask element, sets absolute positioning and semi-transparent background styles',
|
||||||
|
'popup.body':
|
||||||
|
'Preview body element, sets flex layout, center alignment and pointer event styles',
|
||||||
|
'popup.footer':
|
||||||
|
'Preview footer element, sets absolute positioning, center layout and bottom operation area styles',
|
||||||
|
'popup.actions':
|
||||||
|
'Preview actions group element, sets flex layout, background color, border radius and action button styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ const locales = {
|
|||||||
input: 'Input element, sets font, line height, text input and interaction styles',
|
input: 'Input element, sets font, line height, text input and interaction styles',
|
||||||
prefix: 'Prefix wrapper element, sets flex layout, alignment and right margin styles',
|
prefix: 'Prefix wrapper element, sets flex layout, alignment and right margin styles',
|
||||||
suffix: 'Suffix wrapper element, sets flex layout, margin and transition animation styles',
|
suffix: 'Suffix wrapper element, sets flex layout, margin and transition animation styles',
|
||||||
actions: 'Actions element, sets absolute positioning, width, flex layout and number adjustment button styles',
|
actions:
|
||||||
|
'Actions element, sets absolute positioning, width, flex layout and number adjustment button styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with textarea wrapper styles, border, border radius, transition animation and state control',
|
root: 'Root element with textarea wrapper styles, border, border radius, transition animation and state control',
|
||||||
textarea: 'Textarea element with font, line height, padding, color, background, border, text input and multi-line text display styles',
|
textarea:
|
||||||
count: 'Count element with character count display position, font, color and numeric statistics styles',
|
'Textarea element with font, line height, padding, color, background, border, text input and multi-line text display styles',
|
||||||
|
count:
|
||||||
|
'Count element with character count display position, font, color and numeric statistics styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ const locales = {
|
|||||||
en: {
|
en: {
|
||||||
root: 'Root element, set inline flex layout, relative positioning, padding and border styles',
|
root: 'Root element, set inline flex layout, relative positioning, padding and border styles',
|
||||||
textarea: 'Textarea element, set font, line height, text input and background styles',
|
textarea: 'Textarea element, set font, line height, text input and background styles',
|
||||||
popup: 'Popup element, set absolute positioning, z-index, background color, border radius, shadow and dropdown options styles',
|
popup:
|
||||||
|
'Popup element, set absolute positioning, z-index, background color, border radius, shadow and dropdown options styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element, set flex layout, padding, background color, border, border radius and relative positioning styles',
|
root: 'Root element, set flex layout, padding, background color, border, border radius and relative positioning styles',
|
||||||
cover: 'Cover element, set absolute positioning, z-index, background color and loading state overlay styles',
|
cover:
|
||||||
|
'Cover element, set absolute positioning, z-index, background color and loading state overlay styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ const locales = {
|
|||||||
root: 'Root element with inline-block layout, padding, background, border radius, transition and container styles',
|
root: 'Root element with inline-block layout, padding, background, border radius, transition and container styles',
|
||||||
item: 'Option element with relative positioning, text alignment, cursor style, transition, selected state background and hover styles',
|
item: 'Option element with relative positioning, text alignment, cursor style, transition, selected state background and hover styles',
|
||||||
icon: 'Icon element with icon size, color and text spacing styles',
|
icon: 'Icon element with icon size, color and text spacing styles',
|
||||||
label: 'Label content element with min height, line height, padding, text ellipsis and content layout styles',
|
label:
|
||||||
|
'Label content element with min height, line height, padding, text ellipsis and content layout styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,18 @@ const locales = {
|
|||||||
track: '轨道选取条元素,设置绝对定位、背景色、圆角和过渡动画样式',
|
track: '轨道选取条元素,设置绝对定位、背景色、圆角和过渡动画样式',
|
||||||
tracks: '多段轨道容器元素,设置绝对定位和过渡动画样式',
|
tracks: '多段轨道容器元素,设置绝对定位和过渡动画样式',
|
||||||
rail: '背景轨道元素,设置绝对定位、背景色、圆角和过渡动画样式',
|
rail: '背景轨道元素,设置绝对定位、背景色、圆角和过渡动画样式',
|
||||||
handle: '滑块控制点元素,设置绝对定位、尺寸、轮廓线、用户选择、背景色、边框阴影、圆角、光标样式和过渡动画',
|
handle:
|
||||||
|
'滑块控制点元素,设置绝对定位、尺寸、轮廓线、用户选择、背景色、边框阴影、圆角、光标样式和过渡动画',
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with relative positioning, height, margin, padding, cursor style and touch action control',
|
root: 'Root element with relative positioning, height, margin, padding, cursor style and touch action control',
|
||||||
track: 'Track selection bar element with absolute positioning, background color, border radius and transition animation styles',
|
track:
|
||||||
tracks: 'Multi-segment track container element with absolute positioning and transition animation styles',
|
'Track selection bar element with absolute positioning, background color, border radius and transition animation styles',
|
||||||
|
tracks:
|
||||||
|
'Multi-segment track container element with absolute positioning and transition animation styles',
|
||||||
rail: 'Background rail element with absolute positioning, background color, border radius and transition animation styles',
|
rail: 'Background rail element with absolute positioning, background color, border radius and transition animation styles',
|
||||||
handle: 'Slider handle control element with absolute positioning, size, outline, user selection, background color, border shadow, border radius, cursor style and transition animation',
|
handle:
|
||||||
|
'Slider handle control element with absolute positioning, size, outline, user selection, background color, border shadow, border radius, cursor style and transition animation',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with absolute positioning, display control, color, font size, text alignment, vertical alignment, opacity and transition animation (effective when fullscreen is false)',
|
root: 'Root element with absolute positioning, display control, color, font size, text alignment, vertical alignment, opacity and transition animation (effective when fullscreen is false)',
|
||||||
indicator: 'Indicator element with width, height, font size, inline-block display, transition animation, transform origin, line height and color',
|
indicator:
|
||||||
|
'Indicator element with width, height, font size, inline-block display, transition animation, transform origin, line height and color',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const locales = {
|
|||||||
en: {
|
en: {
|
||||||
root: 'Root element with flex layout, width and height, alignment and stretch styles',
|
root: 'Root element with flex layout, width and height, alignment and stretch styles',
|
||||||
panel: 'Panel element with flex basis, grow ratio and panel container styles',
|
panel: 'Panel element with flex basis, grow ratio and panel container styles',
|
||||||
dragger: 'Drag control element with absolute positioning, user selection, z-index, center alignment, background color, hover and active states styles',
|
dragger:
|
||||||
|
'Drag control element with absolute positioning, user selection, z-index, center alignment, background color, hover and active states styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,12 @@ const locales = {
|
|||||||
root: 'Root element with reset styles and overall container styles for statistic component',
|
root: 'Root element with reset styles and overall container styles for statistic component',
|
||||||
header: 'Header element with bottom padding and title area layout styles',
|
header: 'Header element with bottom padding and title area layout styles',
|
||||||
title: 'Title element with text color, font size and other title text display styles',
|
title: 'Title element with text color, font size and other title text display styles',
|
||||||
content: 'Content element with text color, font size, font family and other numeric content display styles',
|
content:
|
||||||
prefix: 'Prefix element with inline-block display, right margin and other prefix content layout styles',
|
'Content element with text color, font size, font family and other numeric content display styles',
|
||||||
suffix: 'Suffix element with inline-block display, left margin and other suffix content layout styles',
|
prefix:
|
||||||
|
'Prefix element with inline-block display, right margin and other prefix content layout styles',
|
||||||
|
suffix:
|
||||||
|
'Suffix element with inline-block display, left margin and other suffix content layout styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export interface DesignTokenProviderProps {
|
|||||||
prefix?: string;
|
prefix?: string;
|
||||||
key?: string;
|
key?: string;
|
||||||
};
|
};
|
||||||
|
zeroRuntime?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DesignTokenContext = React.createContext<DesignTokenProviderProps>(defaultConfig);
|
export const DesignTokenContext = React.createContext<DesignTokenProviderProps>(defaultConfig);
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ export default function useToken(): [
|
|||||||
hashId: string,
|
hashId: string,
|
||||||
realToken: GlobalToken,
|
realToken: GlobalToken,
|
||||||
cssVar: DesignTokenProviderProps['cssVar'],
|
cssVar: DesignTokenProviderProps['cssVar'],
|
||||||
|
zeroRuntime: boolean,
|
||||||
] {
|
] {
|
||||||
const {
|
const {
|
||||||
token: rootDesignToken,
|
token: rootDesignToken,
|
||||||
@@ -124,6 +125,7 @@ export default function useToken(): [
|
|||||||
theme,
|
theme,
|
||||||
override,
|
override,
|
||||||
cssVar: ctxCssVar,
|
cssVar: ctxCssVar,
|
||||||
|
zeroRuntime,
|
||||||
} = React.useContext(DesignTokenContext);
|
} = React.useContext(DesignTokenContext);
|
||||||
|
|
||||||
const cssVar = {
|
const cssVar = {
|
||||||
@@ -151,5 +153,5 @@ export default function useToken(): [
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return [mergedTheme, realToken, hashed ? hashId : '', token, cssVar];
|
return [mergedTheme, realToken, hashed ? hashId : '', token, cssVar, !!zeroRuntime];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ export const { genStyleHooks, genComponentStyleHook, genSubStyleComponent } = ge
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
useToken: () => {
|
useToken: () => {
|
||||||
const [theme, realToken, hashId, token, cssVar] = useLocalToken();
|
const [theme, realToken, hashId, token, cssVar, zeroRuntime] = useLocalToken();
|
||||||
return { theme, realToken, hashId, token, cssVar };
|
return { theme, realToken, hashId, token, cssVar, zeroRuntime };
|
||||||
},
|
},
|
||||||
useCSP: () => {
|
useCSP: () => {
|
||||||
const { csp } = useContext(ConfigContext);
|
const { csp } = useContext(ConfigContext);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ const locales = {
|
|||||||
cn: {
|
cn: {
|
||||||
root: '根元素,设置flex布局、穿梭框容器的基础样式和布局控制',
|
root: '根元素,设置flex布局、穿梭框容器的基础样式和布局控制',
|
||||||
section: '区域元素,设置flex布局、宽度、高度、最小高度、边框、圆角等单侧穿梭框的容器样式',
|
section: '区域元素,设置flex布局、宽度、高度、最小高度、边框、圆角等单侧穿梭框的容器样式',
|
||||||
header: '头部元素,设置flex布局、对齐方式、高度、内边距、颜色、背景色、下边框、圆角等头部区域的样式',
|
header:
|
||||||
|
'头部元素,设置flex布局、对齐方式、高度、内边距、颜色、背景色、下边框、圆角等头部区域的样式',
|
||||||
title: '标题元素,设置文本省略、flex占比、文本对齐、自动左边距等标题文字的布局和样式',
|
title: '标题元素,设置文本省略、flex占比、文本对齐、自动左边距等标题文字的布局和样式',
|
||||||
body: '内容元素,设置列表主体区域的容器样式和布局控制',
|
body: '内容元素,设置列表主体区域的容器样式和布局控制',
|
||||||
list: '列表元素,设置列表内容的样式、布局和滚动控制',
|
list: '列表元素,设置列表内容的样式、布局和滚动控制',
|
||||||
@@ -20,14 +21,18 @@ const locales = {
|
|||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
root: 'Root element with flex layout, transfer container base styles and layout control',
|
root: 'Root element with flex layout, transfer container base styles and layout control',
|
||||||
section: 'Section element with flex layout, width, height, min height, border, border radius and other single-side transfer container styles',
|
section:
|
||||||
header: 'Header element with flex layout, alignment, height, padding, color, background color, bottom border, border radius and other header area styles',
|
'Section element with flex layout, width, height, min height, border, border radius and other single-side transfer container styles',
|
||||||
title: 'Title element with text ellipsis, flex ratio, text alignment, auto left margin and other title text layout and styles',
|
header:
|
||||||
|
'Header element with flex layout, alignment, height, padding, color, background color, bottom border, border radius and other header area styles',
|
||||||
|
title:
|
||||||
|
'Title element with text ellipsis, flex ratio, text alignment, auto left margin and other title text layout and styles',
|
||||||
body: 'Body element with list main area container styles and layout control',
|
body: 'Body element with list main area container styles and layout control',
|
||||||
list: 'List element with list content styles, layout and scroll control',
|
list: 'List element with list content styles, layout and scroll control',
|
||||||
item: 'List item element with relative positioning, padding, border, hover state, selected state, disabled state and other list item interaction styles',
|
item: 'List item element with relative positioning, padding, border, hover state, selected state, disabled state and other list item interaction styles',
|
||||||
itemIcon: 'List item icon element with checkbox and other icon styles and interaction states',
|
itemIcon: 'List item icon element with checkbox and other icon styles and interaction states',
|
||||||
itemContent: 'List item content element with text ellipsis, padding and other list item text content display styles',
|
itemContent:
|
||||||
|
'List item content element with text ellipsis, padding and other list item text content display styles',
|
||||||
footer: 'Footer element with bottom operation area styles and layout',
|
footer: 'Footer element with bottom operation area styles and layout',
|
||||||
actions: 'Actions element with transfer button group styles, layout and interaction states',
|
actions: 'Actions element with transfer button group styles, layout and interaction states',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ const locales = {
|
|||||||
en: {
|
en: {
|
||||||
root: 'Root element with tree selector base styles, border, border radius container styles',
|
root: 'Root element with tree selector base styles, border, border radius container styles',
|
||||||
prefix: 'Prefix element with prefix content layout and styles',
|
prefix: 'Prefix element with prefix content layout and styles',
|
||||||
input: 'Input element with text input, search, selected value display and other input core interaction styles',
|
input:
|
||||||
suffix: 'Suffix element with suffix content, clear button, dropdown arrow and other suffix area styles',
|
'Input element with text input, search, selected value display and other input core interaction styles',
|
||||||
'popup.item': 'Popup item element with tree node option styles, hover state, selected state and other interaction states',
|
suffix:
|
||||||
|
'Suffix element with suffix content, clear button, dropdown arrow and other suffix area styles',
|
||||||
|
'popup.item':
|
||||||
|
'Popup item element with tree node option styles, hover state, selected state and other interaction states',
|
||||||
'popup.itemTitle': 'Popup title element with tree node title text display styles',
|
'popup.itemTitle': 'Popup title element with tree node title text display styles',
|
||||||
'popup.root': 'Popup element with dropdown tree selection panel positioning, z-index, background, border, shadow and other popup layer styles',
|
'popup.root':
|
||||||
|
'Popup element with dropdown tree selection panel positioning, z-index, background, border, shadow and other popup layer styles',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const icon = <SmileOutlined />;
|
const icon = <SmileOutlined />;
|
||||||
|
|||||||
@@ -440,8 +440,9 @@ const theme = {
|
|||||||
| inherit | Inherit theme configured in upper ConfigProvider | boolean | true |
|
| inherit | Inherit theme configured in upper ConfigProvider | boolean | true |
|
||||||
| algorithm | Modify the algorithms of theme | `(token: SeedToken) => MapToken` \| `((token: SeedToken) => MapToken)[]` | `defaultAlgorithm` |
|
| algorithm | Modify the algorithms of theme | `(token: SeedToken) => MapToken` \| `((token: SeedToken) => MapToken)[]` | `defaultAlgorithm` |
|
||||||
| components | Modify Component Token and Alias Token applied to components | `ComponentsConfig` | - |
|
| components | Modify Component Token and Alias Token applied to components | `ComponentsConfig` | - |
|
||||||
| cssVar | Toggle CSS Variables, refer [CSS Variables](/docs/react/css-variables#api) | `boolean \| { prefix?: string; key?: string }` | false |
|
| cssVar | CSS Variables Configuration, refer [CSS Variables](/docs/react/css-variables#api) | `boolean \| { prefix?: string; key?: string }` | false |
|
||||||
| hashed | Component class Hash value, refer [CSS Variables](/docs/react/css-variables#disable-hash) | boolean | true |
|
| hashed | Component class Hash value, refer [CSS Variables](/docs/react/css-variables#disable-hash) | boolean | true |
|
||||||
|
| zeroRuntime | Enable zero-runtime mode, which will not generate style at runtime | boolean | true |
|
||||||
|
|
||||||
### ComponentsConfig
|
### ComponentsConfig
|
||||||
|
|
||||||
|
|||||||
@@ -440,8 +440,9 @@ const theme = {
|
|||||||
| inherit | 继承上层 ConfigProvider 中配置的主题。 | boolean | true |
|
| inherit | 继承上层 ConfigProvider 中配置的主题。 | boolean | true |
|
||||||
| algorithm | 用于修改 Seed Token 到 Map Token 的算法 | `(token: SeedToken) => MapToken` \| `((token: SeedToken) => MapToken)[]` | `defaultAlgorithm` |
|
| algorithm | 用于修改 Seed Token 到 Map Token 的算法 | `(token: SeedToken) => MapToken` \| `((token: SeedToken) => MapToken)[]` | `defaultAlgorithm` |
|
||||||
| components | 用于修改各个组件的 Component Token 以及覆盖该组件消费的 Alias Token | `ComponentsConfig` | - |
|
| components | 用于修改各个组件的 Component Token 以及覆盖该组件消费的 Alias Token | `ComponentsConfig` | - |
|
||||||
| cssVar | 开启 CSS 变量,参考[使用 CSS 变量](/docs/react/css-variables-cn#api) | `boolean \| { prefix?: string; key?: string }` | false |
|
| cssVar | CSS 变量配置,参考[使用 CSS 变量](/docs/react/css-variables-cn#api) | `{ prefix?: string; key?: string }` | false |
|
||||||
| hashed | 组件 class Hash 值,参考[使用 CSS 变量](/docs/react/css-variables-cn#关闭-hash) | boolean | true |
|
| hashed | 组件 class Hash 值,参考[使用 CSS 变量](/docs/react/css-variables-cn#关闭-hash) | boolean | true |
|
||||||
|
| zeroRuntime | 开启零运行时模式,不会在运行时产生样式,需要额外引入 | boolean | true |
|
||||||
|
|
||||||
### ComponentsConfig
|
### ComponentsConfig
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
"predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run test:site",
|
"predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run test:site",
|
||||||
"deploy": "gh-pages -d _site -b gh-pages -f",
|
"deploy": "gh-pages -d _site -b gh-pages -f",
|
||||||
"deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages -f",
|
"deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages -f",
|
||||||
"predist": "npm run version && npm run token:statistic && npm run token:meta",
|
"predist": "npm run version && npm run token:statistic && npm run token:meta && npm run style",
|
||||||
"dist": "antd-tools run dist",
|
"dist": "antd-tools run dist",
|
||||||
"format": "biome format --write .",
|
"format": "biome format --write .",
|
||||||
"install-react-18": "npm i --no-save --legacy-peer-deps react@18 react-dom@18 @testing-library/react@16",
|
"install-react-18": "npm i --no-save --legacy-peer-deps react@18 react-dom@18 @testing-library/react@16",
|
||||||
@@ -80,7 +80,8 @@
|
|||||||
"size-limit": "size-limit",
|
"size-limit": "size-limit",
|
||||||
"sort:api-table": "antd-tools run sort-api-table",
|
"sort:api-table": "antd-tools run sort-api-table",
|
||||||
"sort:package-json": "npx sort-package-json",
|
"sort:package-json": "npx sort-package-json",
|
||||||
"prestart": "npm run version && npm run token:statistic && npm run token:meta && npm run lint:changelog",
|
"style": "tsx scripts/build-style.tsx",
|
||||||
|
"prestart": "npm run version && npm run token:statistic && npm run token:meta && npm run lint:changelog && npm run style",
|
||||||
"start": "tsx ./scripts/set-node-options.ts cross-env PORT=8001 dumi dev",
|
"start": "tsx ./scripts/set-node-options.ts cross-env PORT=8001 dumi dev",
|
||||||
"pretest": "npm run version",
|
"pretest": "npm run version",
|
||||||
"test": "jest --config .jest.js --no-cache",
|
"test": "jest --config .jest.js --no-cache",
|
||||||
@@ -110,7 +111,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/colors": "^8.0.0",
|
"@ant-design/colors": "^8.0.0",
|
||||||
"@ant-design/cssinjs": "^2.0.0-alpha.8",
|
"@ant-design/cssinjs": "^2.0.0-alpha.8",
|
||||||
"@ant-design/cssinjs-utils": "^2.0.0-alpha.1",
|
"@ant-design/cssinjs-utils": "^2.0.0-alpha.2",
|
||||||
"@ant-design/fast-color": "^3.0.0",
|
"@ant-design/fast-color": "^3.0.0",
|
||||||
"@ant-design/icons": "^6.0.0",
|
"@ant-design/icons": "^6.0.0",
|
||||||
"@ant-design/react-slick": "~1.1.2",
|
"@ant-design/react-slick": "~1.1.2",
|
||||||
|
|||||||
113
scripts/build-style.tsx
Normal file
113
scripts/build-style.tsx
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import React from 'react';
|
||||||
|
import { createCache, extractStyle as extStyle, StyleProvider } from '@ant-design/cssinjs';
|
||||||
|
import fs from 'fs-extra';
|
||||||
|
import { renderToString } from 'react-dom/server';
|
||||||
|
|
||||||
|
import * as antd from '../components';
|
||||||
|
|
||||||
|
const output = path.join(__dirname, '../components/style/antd.css');
|
||||||
|
|
||||||
|
const blackList: string[] = ['ConfigProvider', 'Grid'];
|
||||||
|
|
||||||
|
const ComponentCustomizeRender: Record<
|
||||||
|
string,
|
||||||
|
(component: React.ComponentType<any>) => React.ReactNode
|
||||||
|
> = {
|
||||||
|
Affix: (Affix) => (
|
||||||
|
<Affix>
|
||||||
|
<div />
|
||||||
|
</Affix>
|
||||||
|
),
|
||||||
|
BackTop: () => <antd.FloatButton.BackTop />,
|
||||||
|
Dropdown: (Dropdown) => (
|
||||||
|
<Dropdown menu={{ items: [] }}>
|
||||||
|
<div />
|
||||||
|
</Dropdown>
|
||||||
|
),
|
||||||
|
Menu: (Menu) => <Menu items={[]} />,
|
||||||
|
QRCode: (QRCode) => <QRCode value="https://ant.design" />,
|
||||||
|
Tree: (Tree) => <Tree treeData={[]} />,
|
||||||
|
Tag: (Tag) => (
|
||||||
|
<>
|
||||||
|
<Tag color="blue">Tag</Tag>
|
||||||
|
<Tag color="success">Tag</Tag>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
Badge: (Badge: any) => (
|
||||||
|
<>
|
||||||
|
<Badge />
|
||||||
|
<Badge.Ribbon />
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
Space: (Space: any) => (
|
||||||
|
<>
|
||||||
|
<Space />
|
||||||
|
<Space.Compact>
|
||||||
|
<antd.Button />
|
||||||
|
</Space.Compact>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
Modal: (Modal: any) => (
|
||||||
|
<>
|
||||||
|
<Modal />
|
||||||
|
<Modal._InternalPanelDoNotUseOrYouWillBeFired />
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
message: (message: any) => {
|
||||||
|
const { _InternalPanelDoNotUseOrYouWillBeFired: PurePanel } = message;
|
||||||
|
return <PurePanel />;
|
||||||
|
},
|
||||||
|
notification: (notification: any) => {
|
||||||
|
const { _InternalPanelDoNotUseOrYouWillBeFired: PurePanel } = notification;
|
||||||
|
return <PurePanel />;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultNode = () => (
|
||||||
|
<>
|
||||||
|
{Object.keys(antd)
|
||||||
|
.filter(
|
||||||
|
(name) =>
|
||||||
|
!blackList.includes(name) &&
|
||||||
|
(name[0] === name[0].toUpperCase() || ['message', 'notification'].includes(name)),
|
||||||
|
)
|
||||||
|
.map((compName) => {
|
||||||
|
const Comp = (antd as any)[compName];
|
||||||
|
|
||||||
|
const renderFunc = ComponentCustomizeRender[compName];
|
||||||
|
|
||||||
|
if (renderFunc) {
|
||||||
|
return <React.Fragment key={compName}>{renderFunc(Comp)}</React.Fragment>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Comp key={compName} />;
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
function extractStyle(customTheme?: any): string {
|
||||||
|
const cache = createCache();
|
||||||
|
renderToString(
|
||||||
|
<StyleProvider cache={cache}>
|
||||||
|
{customTheme ? customTheme(defaultNode()) : defaultNode()}
|
||||||
|
</StyleProvider>,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Grab style from cache
|
||||||
|
const styleText = extStyle(cache, { plain: true, types: 'style' });
|
||||||
|
|
||||||
|
return styleText;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildStyle() {
|
||||||
|
if (fs.existsSync(output)) {
|
||||||
|
// Remove the old file if it exists
|
||||||
|
fs.unlinkSync(output);
|
||||||
|
}
|
||||||
|
// fs.rmSync(output);
|
||||||
|
const styleStr = extractStyle();
|
||||||
|
fs.writeFileSync(output, styleStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
buildStyle();
|
||||||
@@ -7,7 +7,7 @@ type StyleFn = (prefix?: string) => void;
|
|||||||
|
|
||||||
interface GenCssinjsOptions {
|
interface GenCssinjsOptions {
|
||||||
key: string;
|
key: string;
|
||||||
render: (Component: React.FC, filepath: string) => void;
|
render?: (Component: React.FC, filepath: string) => void;
|
||||||
beforeRender?: (componentName: string) => void;
|
beforeRender?: (componentName: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"target": "ES2015",
|
"target": "ES2015",
|
||||||
|
"jsx": "react",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"typeRoots": ["../node_modules/@types"],
|
"typeRoots": ["../node_modules/@types"],
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ $('dist')
|
|||||||
.hasFile('antd.js.map')
|
.hasFile('antd.js.map')
|
||||||
.hasFile('antd.min.js')
|
.hasFile('antd.min.js')
|
||||||
.hasFile('antd.min.js.map')
|
.hasFile('antd.min.js.map')
|
||||||
|
.hasFile('antd.css')
|
||||||
.hasFile('reset.css');
|
.hasFile('reset.css');
|
||||||
|
|
||||||
console.log(chalk.green('✨ `dist` directory is valid.'));
|
console.log(chalk.green('✨ `dist` directory is valid.'));
|
||||||
|
|||||||
Reference in New Issue
Block a user