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

feat: New Component - Resizable #2458

Merged
merged 51 commits into from
Oct 15, 2024
Merged

Conversation

Nathon2Y
Copy link
Contributor

@Nathon2Y Nathon2Y commented Aug 29, 2024

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes #

Changelog

🇨🇳 Chinese

  • Feat: 新增伸缩框组件,根据用户鼠标拖拽修改组件大小

🇺🇸 English

  • Feat: Added a resizable box component that adjusts its size based on user mouse drag actions.

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

codesandbox-ci bot commented Aug 29, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7a0a757:

Sandbox Source
pr-story Configuration

packages/semi-ui/resizable/single/resizable.tsx Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/singleConstants.ts Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/single/index.ts Outdated Show resolved Hide resolved
content/show/resizable/index.md Show resolved Hide resolved
content/show/resizable/index.md Outdated Show resolved Hide resolved
content/show/resizable/index.md Show resolved Hide resolved
content/show/resizable/index.md Show resolved Hide resolved
content/show/resizable/index.md Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeGroup.tsx Outdated Show resolved Hide resolved
packages/semi-ui/resizable/single/resizable.tsx Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeItem.tsx Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeGroup.tsx Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeGroup.tsx Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/group/index.ts Outdated Show resolved Hide resolved
content/show/resizable/index-en-US.md Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/group/resizeGroup.scss Outdated Show resolved Hide resolved
packages/semi-ui/resizable/index.tsx Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/group/resizeGroup.scss Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeGroup.tsx Outdated Show resolved Hide resolved
packages/semi-ui/resizable/group/resizeGroup.tsx Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/singleConstants.ts Outdated Show resolved Hide resolved
packages/semi-foundation/resizable/groupConstants.ts Outdated Show resolved Hide resolved
content/show/resizable/index.md Outdated Show resolved Hide resolved
content/show/resizable/index.md Show resolved Hide resolved
@pointhalo pointhalo changed the title feat:resizable feat: New Component - Resizable Sep 23, 2024

// 判断是否超出限制
let lastFlag = judgeConstraint(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset),
nextFlag = judgeConstraint(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来 resizeItem 中的 box-sizing 的设置是 border-box,那么此处还需要149,150行的 lastOffset 和 nextOffset 用于计算吗?同理 153,158行的计算

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是为了获取border和padding导致的对最大最小尺寸的误差,例如一个div border为1px,拖拽中计算会导致尺寸计算为0,设置width为0后border仍保留,因此实际width为2px;我引入这个offset就是计算了border和padding的在拖拽方向上的宽度,让宽度保证处于[min + offset, max]中消除最小时候的误差

cursor: 'nw-resize',
},
} as const;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面的 css 放在 scss 文件中。 然后这个文件命名换成 types?

left: '0',
bottom: '0',
right: '0',
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他没有改变的样式,直接放在 scss 中

content/show/resizable/index.md Show resolved Hide resolved
@YyumeiZhang
Copy link
Collaborator

一个功能性问题:resize 之后的尺寸有点误差
复现路径:
image
image
image

@YyumeiZhang YyumeiZhang merged commit e17825e into DouyinFE:release Oct 15, 2024
6 of 8 checks passed
Copy link

cypress bot commented Oct 15, 2024

semi-design    Run #2870

Run Properties:  status check passed Passed #2870  •  git commit e17825ed06: feat: New Component - Resizable (#2458)
Project semi-design
Run status status check passed Passed #2870
Run duration 07m 46s
Commit git commit e17825ed06: feat: New Component - Resizable (#2458)
Committer Nathon2Y
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 11
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 264
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants