feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -22,7 +22,7 @@ import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import postcss from 'postcss';
|
||||
|
||||
const css = readFileSync(new URL('../src/index.css', import.meta.url), 'utf8');
|
||||
const css = readFileSync(new URL('../src/styles/prototype.css', import.meta.url), 'utf8');
|
||||
const root = postcss.parse(css);
|
||||
|
||||
const normalizeSelector = (selector) => selector.replace(/\s+/g, ' ').trim();
|
||||
@@ -52,7 +52,7 @@ const declarations = (rule) =>
|
||||
|
||||
test('standard modal bodies only scroll vertically', () => {
|
||||
const rule = findRule(
|
||||
'.semi-modal-content:not(.semi-modal-content-fullScreen) > .semi-modal-body-wrapper > .semi-modal-body',
|
||||
'.ant-modal:not(.viewport-preview-modal) .ant-modal-body',
|
||||
);
|
||||
assert.deepEqual(
|
||||
{
|
||||
@@ -64,23 +64,13 @@ test('standard modal bodies only scroll vertically', () => {
|
||||
});
|
||||
|
||||
test('fixed-width modal shells stay inside the viewport', () => {
|
||||
assert.equal(declarations(findRule('.semi-modal'))['max-width'], '100%');
|
||||
const gutterRule = findRule(
|
||||
'.semi-modal:not(:has(> .semi-modal-content-fullScreen))',
|
||||
);
|
||||
assert.equal(declarations(gutterRule)['max-width'], 'calc(100% - 32px)');
|
||||
assert.equal(gutterRule.parent.type, 'atrule');
|
||||
assert.equal(gutterRule.parent.name, 'supports');
|
||||
assert.match(gutterRule.parent.params, /selector\(:has\(\*\)\)/);
|
||||
assert.equal(
|
||||
declarations(findRule('.viewport-preview-modal .semi-modal'))['max-width'],
|
||||
'100%',
|
||||
);
|
||||
assert.equal(declarations(findRule('.ant-modal'))['max-width'], 'calc(100vw - 32px)');
|
||||
assert.equal(declarations(findRule('.viewport-preview-modal.ant-modal'))['max-width'], '100vw');
|
||||
});
|
||||
|
||||
test('headerless viewport previews override standard body overflow', () => {
|
||||
const rule = findRule(
|
||||
'.viewport-preview-modal .semi-modal-content:not(.semi-modal-content-fullScreen) > .semi-modal-body-wrapper > .semi-modal-body',
|
||||
'.viewport-preview-modal .ant-modal-body',
|
||||
);
|
||||
assert.deepEqual(
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ test('prompt-record expand icons stay vertically centered', () => {
|
||||
cssRoot.walkRules((candidate) => {
|
||||
if (
|
||||
candidate.selector?.replace(/\s+/g, ' ').trim() ===
|
||||
'.org-prompt-records-table .semi-table-column-expand > .semi-table-expand-icon'
|
||||
'.org-prompt-records-table .ant-table-row-expand-icon-cell > .ant-table-row-expand-icon'
|
||||
) {
|
||||
rule = candidate;
|
||||
}
|
||||
|
||||
@@ -19,16 +19,12 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
import { paginationEvents } from '../src/components/ui/pagination.js';
|
||||
import test from 'node:test';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
import React from 'react';
|
||||
import { transformWithEsbuild } from 'vite';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const PaginationFoundation =
|
||||
require('@douyinfe/semi-foundation/lib/cjs/pagination/foundation.js').default;
|
||||
|
||||
async function compile(relativePath) {
|
||||
const filename = new URL(relativePath, import.meta.url);
|
||||
const { code } = await transformWithEsbuild(
|
||||
@@ -54,9 +50,8 @@ async function compile(relativePath) {
|
||||
const loadUtils = await compile('../src/helpers/utils.jsx');
|
||||
const { createCardProPagination } = loadUtils({
|
||||
react: React,
|
||||
'@douyinfe/semi-ui': { Pagination: 'semi-pagination' },
|
||||
'@/components/ui': { Pagination: 'antd-pagination' },
|
||||
'../constants': { toastConstants: {} },
|
||||
'react-toastify': {},
|
||||
i18next: {},
|
||||
'../constants/playground.constants': {},
|
||||
'../hooks/common/useIsMobile': { MOBILE_BREAKPOINT: 768 },
|
||||
@@ -68,40 +63,25 @@ const loadUsersPage = await compile('../src/components/table/users/index.jsx');
|
||||
|
||||
function paginationProps(element) {
|
||||
const pagination = React.Children.toArray(element.props.children).find(
|
||||
(child) => child.type === 'semi-pagination',
|
||||
(child) => child.type === 'antd-pagination',
|
||||
);
|
||||
assert.ok(pagination, 'The helper must render Semi Pagination');
|
||||
assert.ok(pagination, 'The helper must render Ant Design Pagination');
|
||||
return pagination.props;
|
||||
}
|
||||
|
||||
function foundationFor(props) {
|
||||
const state = {
|
||||
currentPage: props.currentPage,
|
||||
pageSize: props.pageSize,
|
||||
total: props.total,
|
||||
const events = paginationEvents(props);
|
||||
return {
|
||||
changePageSize: size => { events.onShowSizeChange(props.currentPage, size); events.onChange(props.currentPage, size); },
|
||||
goPage: page => events.onChange(page, props.pageSize),
|
||||
};
|
||||
// Keep the render snapshot during the event, as with React's batched updates.
|
||||
// Only view-state setters are stubbed; Semi's callback decisions run unchanged.
|
||||
return new PaginationFoundation({
|
||||
getProps: () => props,
|
||||
getStates: () => state,
|
||||
getState: (key) => state[key],
|
||||
updatePageSize: () => {},
|
||||
updateTotal: () => {},
|
||||
setCurrentPage: () => {},
|
||||
setDisabled: () => {},
|
||||
setPageList: () => {},
|
||||
notifyPageSizeChange: (size) => props.onPageSizeChange(size),
|
||||
notifyPageChange: (page) => props.onPageChange(page),
|
||||
notifyChange: () => {},
|
||||
});
|
||||
}
|
||||
|
||||
for (const option of [{}, { preventPageChangeOnPageSizeChange: false }]) {
|
||||
const mode = Object.hasOwn(option, 'preventPageChangeOnPageSizeChange')
|
||||
? 'explicit false'
|
||||
: 'default';
|
||||
test(`other tables retain Semi's resize page callback: ${mode}`, () => {
|
||||
test(`other tables retain existing resize page callback: ${mode}`, () => {
|
||||
const calls = [];
|
||||
const props = paginationProps(
|
||||
createCardProPagination({
|
||||
|
||||
Reference in New Issue
Block a user